What’s the pattern to follow when specialized Makefiles in a directory depends on the main one in a parent dir?
i have:
/
/Makefile
/src
/src/Makefile
/tests
/tests/Makefile
in /Makefile i have:
TESTING_COMMAND=something
dotest1:
make -C tests/ $@
in /tests/makefile i have
dotest1:
$(TESTING_COMMAND) $?
if i run:
me@host:/ $ Make dotest1
it works. but if i execute from the tests dir:
me@host:/tests/ $ Make dotest1
it will try to execute the test file in the shell, because $(TESTING_COMMAND) is empty, so it’s first argument became the command passed to the shell.
I don’t necessarily need that to work if executed in the /tests/ or /src/ dir, but need a way to gracefully fail.
Your design scares me, but this will do the trick in the main Makefile:
If you want
tests/Makefileto fail well, you have a couple of options. If only that one target depends onTESTING_COMMAND, you can have it print a warning and do nothing:Or if the whole Makefile depends on it, you can have Make print a warning or abort:
You can also have it abort the sub-make (the one that runs
tests/Makefile) but still continue running the Make process that invoked it, but that’s kind of a pain.