I have a makefile which calls multiple other makefiles.
I'd like to pass the -j param along to the other makefile calls.
Something like (make -j8):
all:
make -f libpng_linux.mk -j$(J)
Where $(J) is the value 8 from -j8. I absolutely swear I've done this before but I cannot locate my example.
$(MAKEFLAGS) seems to contain --jobserver-fds=3,4 -j regardless of what -j2 or -j8
Edit: Possible Solution:
Will post this as an answer soon.
It appears one solution to not worry about it. Include -j8 when you call the main makefile. The sub calls to make should look like this:
all:
+make -f libpng_linux.mk -j$(J)
Notice the "+" in front of make. I noticed make tossing a warning when I tried parallel builds: make[1]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
-j
to a build is an "evil" thing to do. If set low it may not have a significant impact, but if set even moderately high it can create problems in a multi-user environment. Forcing developers to expressly choose a value forces them to make a choice -- hopefully based on how many people are on the machine, how it will impact currently running processes, etc. With that said, the "jobserver unavailable" warning happens under 2 circumstances: gmake cannot reliably determine that the sub-process is make, or you passed -j to a submake without+
(as you noted). – Brian Vandenberg Dec 3 '14 at 22:27