I am new to makefile. I have a makefile with following statement:
....
all: prepare hreader $(DIRS)
echo $(DIRS)
.PHONY: prepare hreader $(DIRS)
prepare:
mkdir -p ./lib
$(MAKE) -C game_proc prepare #here, why 'prepare'?!
hreader:
make -C extra/hreader
$(DIRS):
$(MAKE) -C $@
In my makefile directory, i have a ‘game_proc’ directory. And from GNU make tutorial, i know that below lines
prepare:
mkdir -p ./lib
$(MAKE) -C game_proc
will do a recursive make on ‘game_proc’.
But why ‘prepare’ also appear in the recipe? Now how do i interpret ‘$(MAKE) -C game_proc prepare’? It does a recursive make on ‘game_proc’, and what? also a recursive make on ‘prepare’?
Thanks,
A phony target just tells make that the rule is not going to create an output file of that name.
Update after comments
Ok, it’s important to realize that there are two separate makefiles here at play:
and
The confusion results from there being a
preparetarget in bothMakefiles.I.e., there is in
game_proc/Makefilea targetprepare. Let’s for a moment rename that target toprepare2so that the situation becomes clearer:./Makefile:game_proc/Makefile: