If running make
from the parent directory fails to build foo.o
, then try make foo.o
. If that fails then try running make -n foo.o
in both directories (to print the commands instead of executing them) to see what it's doing differently. If it succeeds, then it's not even trying to build foo.o
when run from the parent directory; make -n
may shed some light, and as a last resort make -d
will give you a torrent of information about the decision process, why it's doing what it's doing.
Here's a handy trick to see the value of variables. Put this rule in your makefile:
show_%:
@echo $@ is $($*)
Now you can run make show_FOO
and it will tell you the value of the variable FOO
.
Finally, are you sure you know where you build your .o files? Make is very good at using things there to build files here, but not the other way around, so it can lose track of intermediate files if you're not careful.