On Sat, Apr 9, 2011 at 2:32 PM, Philip Prindeville <phil...@redfish-solutions.com> wrote: > [philipp@builder ~/openwrt2]$ make -j5 -f /tmp/Makefile > MAKEFLAGS= > MFLAGS= > MAKE=make > PBUILD= > MAKEFLAGS=w > MFLAGS=-w > MAKE=make > make[1]: Entering directory `/home/philipp/openwrt2' > make[1]: Nothing to be done for `stop'. > make[1]: Leaving directory `/home/philipp/openwrt2' > [philipp@builder ~/openwrt2]$ > > Not sure what I'm missing...
Unfortunately it appears that MAKEFLAGS is composed on the fly when forking a command (aka job). See the following makefile: % cat /tmp/Makefile $(info MAKEFLAGS='$(MAKEFLAGS)') .PHONY: all all: @echo "MAKEFLAGS='$(MAKEFLAGS)' (recipe)" % make -f /tmp/Makefile -j2 MAKEFLAGS='' MAKEFLAGS=' --jobserver-fds=3,4 -j' (recipe) So it's not available to $(info) and other functions outside of a recipe. There's probably a way to trick make into doing a simple recursion to harvest the data. Or if you're dealing with an automated/nightly build you could set MAKEFLAGS yourself to turn on parallelism: MAKEFLAGS=-j8 make ... but at that point you might as well just take control yourself PARALLEL=YES make -j8 ... Here's a hack which will work by calling make recursively once, but note that it will only work when no explicit target is mentioned: % cat Makefile .PHONY: all all: ifndef PARALLEL .PHONY: _is_parallel .DEFAULT_GOAL := _is_parallel _is_parallel: +@PARALLEL=`PARALLEL=tbd $(MAKE) -s -f $(MAKEFILE_LIST) _is_parallel2` &&\ PARALLEL=$$PARALLEL $(MAKE) --no-print-directory -f $(MAKEFILE_LIST) $(MAKECMDGOALS) else .PHONY: _is_parallel2 _is_parallel2: ; @echo "$(if $(findstring -j,$(MAKEFLAGS)),YES,NO)" endif all: @echo "We $(if $(findstring YES,$(PARALLEL)),ARE,ARE NOT) building in parallel" David Boyce _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make