When building multiple targets per BIN with multiple jobs, for example: $ make -j6 bin-i386-efi/gpxe.efi{,drv,rom} bin-x86_64-efi/gpxe.efi{,drv,rom} we would invoke a make subprocess for each goal in parallel resulting in multiple makes running in a single BIN directory. Fix by grouping goals per BIN directory and invoking only one make per BIN. It is both safer and faster.
Signed-off-by: Piotr Jaroszyński <p.jaroszyn...@gmail.com> --- src/Makefile.housekeeping | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 1ddabb1..fe8480a 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -175,7 +175,12 @@ endif # BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS)) BIN_GOAL_BINS := $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG)))) -NUM_BINS := $(words $(sort $(BIN_GOAL_BINS))) +BIN_GOAL_UNIQUE_BINS := $(sort $(BIN_GOAL_BINS)) +# Take the first goal from each BIN directory +BIN_GOALS_REPS := $(foreach B,$(BIN_GOAL_UNIQUE_BINS),$(firstword $(filter $(B)/%,$(BIN_GOALS)))) +# Rest of the goals +BIN_GOALS_REST := $(filter-out $(BIN_GOALS_REPS),$(BIN_GOALS)) +NUM_BINS := $(words $(BIN_GOAL_UNIQUE_BINS)) ifeq ($(NUM_BINS),0) @@ -203,9 +208,19 @@ else # NUM_BINS == 1 # depends on $(BIN); such targets should be made conditional upon the # existence of $(BIN). # -$(BIN_GOALS) : % : BIN_RECURSE - $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@ -.PHONY : BIN_RECURSE + +# The recipe for each of the reps actually builds all goals from each BIN directory +$(BIN_GOALS_REPS) : + $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) \ + $(filter $(firstword $(subst /, ,$@))/%, $(BIN_GOALS)) +# Run always +.PHONY : $(BIN_GOALS_REST) + +# Do nothing for the rest of the goals as they are covered by the recipe above +$(BIN_GOALS_REST) : + $(Q)true +# Run always to avoid a "nothing to be done" messages +.PHONY : $(BIN_GOALS_REPS) endif # NUM_BINS == 1 endif # NUM_BINS == 0 -- 1.7.1 _______________________________________________ gPXE-devel mailing list gPXE-devel@etherboot.org http://etherboot.org/mailman/listinfo/gpxe-devel