Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile - Pass jobs param to sub makefiles

Tags:

makefile

jobs

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.

like image 598
Halsafar Avatar asked Feb 05 '12 05:02

Halsafar


1 Answers

Only certain flags go into $(MAKEFLAGS). -j isn't included because the sub-makes communicate with each other to ensure the appropriate number of jobs are occuring

Also, you should use $(MAKE) instead of make, since $(MAKE) will always evaluate to the correct executable name (which might not be make).

like image 141
m42a Avatar answered Sep 23 '22 20:09

m42a