GNU Make to create obsolete files And newer than some timestamp

I am using GNU Make 3.81 to create this project C. The normal behavior of GNU is to check if the target exists and any precondition is newer than the target, the target commands are executed.

Is it possible to restore the goal if the prerequisites are newer than the target And newer than the given time stamp? Let's say that it builds only if the files are newer than October 2, 2011, for example.

+4
source share
2 answers

There is no way to do this directly with make, but you could do it with a wrapper in 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 \ so that the if command if one command. You can also use else to consider when the target is out of date and the prereq is also old.

+2
source

make redo all targets that are newer than any of its premises, so yours and condititon will be hard to implement.

If you want to enter an era into your build directory, you can simply set the timestamps of changes to all files for the era using touch -d . Not a beautiful, but a working solution.

0
source

Source: https://habr.com/ru/post/1397860/


All Articles