Specifically, this idiom:
all:
for dir in $(MODULES); do \
(cd $$dir; ${MAKE} all); \
done
should be banished from everyone's Makefiles. make isn't a just way of cobbling together some collection arbitrary collection of scripts. Each of those modules should be a target with dependencies. The rule to make that module is the recursive make. But the order is determined by the explicit dependencies, not whatever random order glob gives you. ie, what you should have is: module1:
(cd $module1_dir; make)
module2: module1
(cd $module2_dir; make)
etc etc etcEvery single time in my career that I've had someone complain about a flaw in make, what I discover is a significant flaw in their description of the make rules. If it is not behaving correctly, you did not fully describe the DAG.