Replace pre-make rule with before-actions rules

For all standard build ACTIONS, a rule before-<action> is
run just before running that action in the subdirectories
given by the DIRS variable. Only works in Makefiles that
include RULES_DIRS or RULES_TOP.
This commit is contained in:
Andrew Johnson
2020-04-21 01:14:03 -05:00
parent b655662131
commit 582a9dbef5
2 changed files with 15 additions and 9 deletions
+10 -4
View File
@@ -54,7 +54,7 @@ $(foreach dir, $(DIRS), \
define DEP_template2
$(1)$$(DIVIDER)$(2) : $$(foreach ddir, $$($(1)_DEPEND_DIRS), \
$$(addsuffix $$(DIVIDER)$(2),$$(ddir)))
$$(addsuffix $$(DIVIDER)$(2),$$(ddir))) | before-$(2)
endef
$(foreach action, $(ACTIONS), \
$(foreach dir, $(DIRS), \
@@ -81,14 +81,20 @@ dirPart = $(join $(dir $@), $(word 1, $(subst $(DIVIDER), ,$(notdir $@))))
actionArchPart = $(join $(word 2, $(subst $(DIVIDER), ,$(notdir $@))), \
$(addprefix $(DIVIDER),$(word 3, $(subst $(DIVIDER), ,$(notdir $@)))))
$(DIRS) $(dirActionTargets) $(dirArchTargets) $(dirActionArchTargets): pre-make
$(DIRS) $(dirActionTargets) $(dirArchTargets) $(dirActionArchTargets):
$(MAKE) -C $(dirPart) $(actionArchPart)
# before-action rules are run once prior to recursing through the
# list of subdirectories and running the action rule in each one.
# See DEP_template2 above for how that rule ordering is achieved.
beforeActions = $(addprefix before-,$(ACTIONS))
$(beforeActions):
$(ARCHS) $(ACTIONS) $(actionArchTargets) :%: \
$(foreach dir, $(DIRS), $(dir)$(DIVIDER)%)
.PHONY : $(DIRS) all host rebuild pre-make
.PHONY : $(ARCHS) $(ACTIONS)
.PHONY : $(DIRS) all host rebuild
.PHONY : $(ARCHS) $(ACTIONS) $(beforeActions)
.PHONY : $(dirActionTargets) $(dirArchTargets)
.PHONY : $(dirActionArchTargets)
.PHONY : $(actionArchTargets)
+5 -5
View File
@@ -35,10 +35,10 @@ uninstall$(DIVIDER)%:
$(RMDIR) $(addsuffix /$(subst uninstall$(DIVIDER),,$@), \
$(INSTALL_LOCATION_BIN) $(INSTALL_LOCATION_LIB))
pre-make:
@$(if $(filter test-results, $(MAKECMDGOALS)), \
$(RM) $(TEST_FAILURE_FILE))
test-results:
before-runtests before-test-results: rm-failure-file
rm-failure-file:
@$(RM) $(TEST_FAILURE_FILE)
runtests test-results:
$(PERL) $(TOOLS)/testFailures.pl $(TEST_FAILURE_FILE)
help:
@@ -74,7 +74,7 @@ help:
@echo " xxxRecord.o"
.PHONY: distclean cvsclean realuninstall archuninstall uninstallDirs
.PHONY: uninstall help
.PHONY: uninstall rm-failure-file help
# Include <top>/cfg/TOP_RULES* files from tops defined in RELEASE* files
#