Requirements That Set Order Without Changing Content

Some dependencies ensure a prerequisite operation happens first but do not make an existing output stale when their own timestamps change.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose the example carefully
  2. Distinguish actual data
  3. Use an output directory as a prerequisite for placement
  4. Verify that the prerequisite carries no content dependency

Choose the example carefully

A generated report may need its output directory to exist. Adding an unrelated file can change the directory timestamp without changing the report's inputs. GNU Make supports order-only prerequisites for such cases. Freshness explains why treating that timestamp as a data change would cause avoidable work.

Distinguish actual data

A template included in the report is a content dependency and must invalidate the artifact when changed. Use build inputs and outputs to state each role.[1]

Use an output directory as a prerequisite for placement

A rule compiling into out/app.o needs the output directory to exist. Adding an unrelated file can update the directory's modification time without changing compilation inputs. Under GNU Make's order-only prerequisite model, directory creation can precede the recipe without making that timestamp a normal rebuild trigger. See incremental freshness.

Ensure output directory exists
Source or header changed → recompile
Only directory metadata changed → keep current result under this model

Verify that the prerequisite carries no content dependency

A generated header does affect compilation output and should not be modeled only as an ordering requirement. Test by independently changing the source and the directory metadata.

References

  1. Free Software Foundation, GNU Make Manual ↩