Reputation: 3940
I am working on a boot project. In my boot root directory there is a makefile that contains among other things, the following code which confuse me:
.DEFAULT_GOAL = all
.PHONY: all
all: xboot
xboot: $(TOP_DIR)/boot
@echo "Building Boot" $(TOP_DIR)
$(MAKE) -C $(TOP_DIR)/boot/src
Now, the problem is, that any time when this makefile is executed by calling make
, the xboot
receipt is always running. It seems that this xboot
target acts like a phony target. From GNU Documentation regarding phony targets:
Phoniness is not inherited: the prerequisites of a phony target are not themselves phony, unless explicitly declared to be so.
Means that xboot
target is not a phony one, but it's receipt is always running. I could not find anywhere an explanation for that.
Project facts-
directory $(TOP_DIR)/boot
contains sources and headers under $(TOP_DIR)/boot/src
and $(TOP_DIR)/boot/include
, directory $(TOP_DIR)/boot
does not get touch
ed at the build (it is not get updated)
Trying to understand the behavior I played around-
I tried touch
ing $(TOP_DIR)/boot
, and/or tried touch
ing and creating file xboot
file anywhere in the project, but behavior remains the same.
GNU Make 4.1 Built for x86_64-pc-linux-gnu
Upvotes: 0
Views: 130
Reputation: 2176
make
is not always handling folder dependencies the way you expect.
Should use a file dependency inside $(TOP_DIR)/boot
like $(TOP_DIR)/boot/.exists
or, even better, all your source files with a $(wildcard ...)
function.
Like:
xcode: $(widcard $(TOP_DIR)/boot/src/*.c $(TOP_DIR)/boot/src/*.h)
This will cause a rebuild only on code change.
Upvotes: 0