I am using GNU Make 3.81 for building a given C project. The normal behavior of GNU is to check, if the target exists and any prerequisite is newer than the target, the target commands are executed.
Is it possible to rebuild the target if the prerequisites are newer than the target AND newer than a given timestamp? Lets say, that it builds only if the files are newer than Oct 2, 2011, for example.
There's no way to do it directly with make, but you could do it with the shell in the action for the rule:
target: prereq
touch --date='Oct 2, 2011' .timestamp
if [ $< -nt .timestamp ]; then \
command to rebuild target; \
fi
Note the use of \
to make the if
command a single command. You could also use an else
to deal with the case where the target is out of date and the prereq is also old.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With