3 ms·
One misfeature I discovered recently and I wished got fixed is .SECONDARY vs .PRECIOUS [1]. Both are used to tell Make to keep intermediate products of chains o
by AceJohnny2 10y ago
One misfeature I discovered recently and I wished got fixed is .SECONDARY vs .PRECIOUS [1]. Both are used to tell Make to keep intermediate products of chains of rules. However, .SECONDARY does not accept wildcards (%.o patterns for example), only .PRECIOUS does. However, .PRECIOUS also adds the guard that an incomplete intermediate product is kept in case Make is interrupted, which you would only ever want for a trivial stamp file. In any other case, you risk ending up with a runt file that breaks your next build.
So if, like any significant project I know, your build specifies lots of wildcard ("implicit") rules, you're stuck using .PRECIOUS, in which case you can never interrupt the build for risk of leaving it in a broken state.
FWIW, djb's "redo" concept [2] is based centrally around atomicity to avoid such a problem.
[1] https://www.gnu.org/software/make/manual/html_node/Special-Targets.html https://www.gnu.org/software/make/manual/html_node/Special-T...
[2] https://github.com/apenwarr/redo https://github.com/apenwarr/redo
- cnvogel 10y agoYou get the same problem whenever you build up things piece by piece. So most often I work around this by atomically mv'ing a temporary file to the final product. %.foo : %.bar echo blubb >$@.tmp cat $^ >$@.tmp mv $@.tmp $@