Follow-up Comment #2, bug #20394 (project make): It's not exactly correct to say that GNU make caches directories from the 10th on, but you're on exactly the right track; thanks for the note.
What make actually does is cache EVERY directory... BUT it caches them "lazily", AND it only allows 10 directories to be open at any one time. Basically, when make wants to check a file in a directory it opens the directory for reading and looks for that file. As it reads the directory it caches the contents. Once the file is found, it leaves the directory open but stops reading. If make looks for another file in that directory and it's not in the cache, make continues reading (and caching) where it left off. If it gets to the end of the directory it closes the directory. In order to avoid too many directories being open by make at one time, if make gets to a point where more than 10 directories are open, it will completely read and cache the current (latest) directory, then close it. The issue of make's caching is well-known (see bug #443 for example). In your case it takes an odd twist but this is definitely the issue. A completely correctly-written makefile shouldn't run across cache problems, but I recognize there are situations where it's not possible to write that makefile. However, in your case I think you can do what you want. Change your makefile like this: LIBS := $(patsubst %,-l%,$(SUBDIRS)) LIBTARGETS := $(foreach L,$(LIBS),$(L)/lib$(L).a) all: $(TARGET) $(TARGET): $(LIBTARGETS) $(CC) -o $@ $(LIBDIRS) $(LIBS) $(LIBTARGETS): FORCE $(MAKE) -w -C $(@D) -f Makefile $(MAKECMDGOALS) FORCE: This has some other advantages over the method you were using (for one thing, your example does not work properly if any of the sub-makes fail). _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?20394> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make