## Wednesday, April 15, 2015

### Another way to find the value of GNU make's -j parameter

The other day I wrote a blog post about finding the value of -j in GNU make and it received a lot of commentary. Daniel Frey wrote in with a different solution that goes like this. It's worth studying if you are interested in GNU make wrangling.

.PHONY: default FORCE token recursive
default: foo.out
@$(eval JOB_COUNT :=$(shell cat $<)) @echo Job count:$(JOB_COUNT)

foo.out: FORCE
@timeout 1 $(MAKE) --no-print-directory token recursive 2>/dev/null | wc -l >$@

FORCE:

token:
@echo X && sleep 2 && false

recursive: