diff --git a/Makefile.lib b/Makefile.lib index d994cd1d..af1751c4 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -125,6 +125,9 @@ CLEAN += $(PROG) all-default: $(LIB_O) $(PROGS) $(MAN1) $(MAN5) +# Ensure that Makefiles in subdirs are created before we recursive into them +init-recursive: init-default + init-default: @$(foreach subdir,$(sort $(SUBDIRS)), \ $(MKINSTALLDIRS) $(subdir) >/dev/null; \ @@ -191,28 +194,24 @@ endif # Recursion: -.PHONY: all-recursive install-recursive clean-recursive cleanall-recursive init-recursive check-recursive test-recursive +RULES = all install clean cleanall init check test +RECRULES = $(addsuffix -recursive,$(RULES)) -all-recursive install-recursive clean-recursive cleanall-recursive init-recursive check-recursive test-recursive: +.PHONY: $(RECRULES) + +# The -recursive rules decend all subdirs. +$(RECRULES): ifdef SUBDIRS @$(foreach subdir,$(sort $(SUBDIRS)), \ $(call ncmd,recmake,$(subdir),$(subst -recursive,,$@)) || exit 1;) endif -all: all-recursive all-default all-local -install: install-recursive install-default install-local -check: check-recursive check-default check-local -clean: clean-recursive clean-default clean-local -test: test-recursive test-default test-local +# Setup the default sub commands dependency. First decend subdirs then do all +# the default stuff and finally do any local hooks. +$(RULES): $$@-recursive $$@-default $$@-local -cleanall: cleanall-recursive cleanall-default -init: init-default init-recursive - -all-local: -install-local: -clean-local: -check-local: -test-local: +# Dummy rules for local hooks +$(addsuffix -local,$(RULES)): # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded.