Re:GNU make insanity: finding the value of the -j parameter
by oso2k on Saturday March 28, 2015 @05:54PM
(#9282876)
I get what you're saying but not seeing how to do that in make syntax. Mind giving an example?
[ Parent
| on HN ]
Re:GNU make insanity: finding the value of the -j parameter
by JoshTriplett on Saturday March 28, 2015 @06:43PM
(#9283050)
$ cat Makefile
test:
+env | grep MAKEFLAGS
$ make -j4 test
env | grep MAKEFLAGS
MAKEFLAGS= -j --jobserver-fds=3,4
If you want to act like a sub-make, then parse MAKEFLAGS from your environment, and if you see -j and --jobserver-fds=R,W , then parse R and W as file descriptor numbers, block waiting for a byte from R before starting an additional parallel job, and write a byte to W when done with a parallel job.