I have a tricky issue with gmake, when I build from the parent directory, something is different and the make does not build all the .o(s) it needs and fails, but if I cd to the directory and do a make it builds them fine.
How can I get GNUmake to tell me the difference between these two runs? There must be some make variables set in the parent that break the child, but I need help figuring out how to track them down.
If running
makefrom the parent directory fails to buildfoo.o, then trymake foo.o. If that fails then try runningmake -n foo.oin 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 buildfoo.owhen run from the parent directory;make -nmay shed some light, and as a last resortmake -dwill 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:
Now you can run
make show_FOOand it will tell you the value of the variableFOO.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.