Skip to content

Instantly share code, notes, and snippets.

@jgrahamc
Last active November 19, 2019 22:38
Show Gist options
  • Save jgrahamc/2cc6df7fd5cd61c4d93f to your computer and use it in GitHub Desktop.
Save jgrahamc/2cc6df7fd5cd61c4d93f to your computer and use it in GitHub Desktop.
all: | parallel ; @echo $(JOB_COUNT)
parallel: .parallel ; @$(eval JOB_COUNT := $(shell sort -n $< | tail -n 1))
.parallel: FORCE ; @$(MAKE) --no-print-directory par 2>/dev/null >$@ || true
FORCE:
to_n = $(words $2) $(if $(filter-out $1,$(words x $2)),$(call to_n,$1,x $2))
PAR_COUNT :=
par: $(addprefix par-,$(call to_n,32))
par-%: ; @$(eval PAR_COUNT += x)@echo $(words $(PAR_COUNT)) && sleep 1 && false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment