Make does not rebuild transitive dependencies of pattern rules on change, why?
0
votes
2
answers
741
views
I have a Makefile, roughly so:
.PRECIOUS: %.a %.b %.c
%.a:
touch $@
%.b: %.a
touch $@
%.c: %.b
touch $@
If I create "test.c" with a
make test.c
, all the 3 files (test.a
, test.b
, test.c
) are created correctly. However, if I now remove test.a
, and then I try to re-create test.c
, then nothing happens.
Reason is obvious: because test.c
depends only on test.b
, and test.b
was not changed, not rebuild is needed. However, test.b
should be rebuilt because test.a
disappeared, and that should spread to test.c
as well. I find this behavior as a highly un-intuitive side effect.
Can I somehow let make to handle "transitive" dependencies on the intuitive way? (I.e. after the deletion of test.a
, all the targets must be rebuilt.)
The problem happens only with pattern rules.
(P.s. I need all the intermediate files, this is why the PRECIOUS. Default behavior of the GNU Make is that it deletes the intermediary files.)
Asked by peterh
(10459 rep)
Jan 10, 2024, 05:46 PM
Last activity: May 4, 2025, 05:41 PM
Last activity: May 4, 2025, 05:41 PM