3 ms·
You may want to consider using 'stamp files'. These are just empty files created via 'touch' to serve as a timestamp that Make can use to determine if a target
by ganonm 9y ago
You may want to consider using 'stamp files'. These are just empty files created via 'touch' to serve as a timestamp that Make can use to determine if a target needs to be rebuilt if the target doesn't correspond to an actual file in the build directory. This is useful for build targets such as running docker-compose build.
See https://www.technovelty.org/tips/the-stamp-idiom-with-make.html https://www.technovelty.org/tips/the-stamp-idiom-with-make.h...
- TickleSteve 9y agoI have to disagree with this, I consider stamp files a Makefile anti-pattern. Stamp files are an often an indication that someone is trying to turn a Makefile into a shell script. Rules should be generated that generate a target from its dependencies. The intermediate steps should be encapsulated as the rule commands.
- gbuk2013 9y agoSometimes it is necessary though. I have had to use this pattern in 2 scenarios: Building a static website where the targets are wildly different from the source files. I could probably make it explicit but it will be overly verbose and brittle. Check for and remove trailing whitespace. Because the dependency is actually the target, a stamp file is necessary.
- Sean1708 9y agoSpecifically in the second case: How do you get the timestamp on these stamp files to update, or do you just do it manually? And if you are doing it manually, why not just run a shell script instead?
- gbuk2013 9y agoThe timestamp on the source files is updated by sed, when it strips the whitespace. The stamp file is then updated with touch. The advantage of using Make is that only modified files will be fed to sed and, consequently, only they will be caught by the rsync command, that I use to push the code out to the server(s).