I have a make file of, more or less, the following structure that compiles C++ source code:
.PHONY: all
all: compile_obj_files my_binary
# This rule generates the object files. It works fine afaik.
.PHONY: compile_obj_files
compile_obj_files:
$(MAKE) --file=child.makefile
# my_binary is a real binary file that I wish to build.
my_binary: $(wildcard *.o)
$(CC) $(wildcard *.o) -o my_binary
On the first run this make file generated all the object files but $(wildcard *.o)
returned an empty list. On the second run it compiled nothing, as expected, and $(wildcard *.o)
indeed returned all the object files. It looks like $(wildcard *.o)
is executed before all the object files are created, despite the fact that my_binary
rule runs always after compile_obj_files
. I sit looking helpless on this script without any idea what is wrong here (must be something silly). Can you think of anything?