Reputation: 108
I have an issue with Make failing to rebuild a target because it doesn't believe that anything has changed. I've distilled the issue down to the following two Makefiles:
1) Makefile
.DEFAULT_GOAL := all
%:
@echo "Catch all for $@"
@make -sf common.mk $@
2) common.mk
.PHONY: all clean
all:
@make -s package
@echo "Nothing to do for all"
package: ${shell find ./src -type f}
@echo "The following files have changed... $?"
@echo "Making 'package'"
@touch package
clean:
@echo "Cleaning 'package'"
@rm -f package
With the above, you can reproduce the issue by:
$mkdir src
$touch src/test.c
$make
At this point, if you try and make again, it correctly determines that nothing has changed...
$make
But then, if you simulate a change and try to rebuild, it doesn't think anything has changed...
$touch src/test.c
$make
If I move the 'package' target from common.mk to Makefile, it works fine, so there is something it really doesn't like, but I'm really not sure what is going on.
Any ideas?
Upvotes: 0
Views: 120
Reputation: 99094
Here:
all:
@make -s package
In that call to Make, you don't specify which makefile to use, so Make looks for the defaults and finds a file named "Makefile". The new instance of Make attempts to rebuild package
using the makefile Makefile
, and finds this rule:
%:
@echo "Catch all for $@"
@make -sf common.mk $@
Note that this rule has no prerequisites, package
has not been declared PHONY
, and a file named "package" already exists. So Make[1] sees no reason to rebuild the file, and terminates, passing control back to its parent Make.
Upvotes: 1