]> rtime.felk.cvut.cz Git - omk.git/blobdiff - snippets/base
Fixed behaviour of make -k if there is an error in a subdirectory
[omk.git] / snippets / base
index 92ca687e6d84ff853f5983438dd7246e205360be..bc9622be6bd2419b8618c57da4095b8954428196 100644 (file)
@@ -171,27 +171,39 @@ export USE_LEAF_MAKEFILES
 SUBDIR_MAKEFILE=$(MAKERULES_DIR)/Makefile.rules
 SOURCESDIR_MAKEFILE=$(MAKERULES_DIR)/Makefile.rules
 else
-SUBDIR_MAKEFILE=$(SOURCES_DIR)/$(dir)/Makefile
+SUBDIR_MAKEFILE=$(SOURCES_DIR)/$(3)/Makefile
 SOURCESDIR_MAKEFILE=$(SOURCES_DIR)/Makefile
 endif
 
+# Call a pass in a subdirectory
+# Usage: $(call omk_pass_subdir_template,<pass name>,<build dir>,<subdir>)
+define omk_pass_subdir_template
+.PHONY: $(1)-$(3)-subdir
+$(1): $(1)-$(3)-subdir
+$(1)-$(3)-subdir:
+       @$(call mkdir_def,$(2)/$(3))
+       +@$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(3) $(NO_PRINT_DIRECTORY) \
+               RELATIVE_DIR=$(RELATIVE_PREFIX)$(3) -C $(2)/$(3) \
+               -f $(SUBDIR_MAKEFILE) $(1)
+endef
+
 ifdef OMK_TESTSROOT
-check-target = $$(@:%=%-check)
+check-target = $(1:%=%-check)
 endif
 
-# Syntax: $(call omk_pass_template,<pass name(s)>,<build dir>,[<local make flags>],[<local condition>])
+# Usage: $(call omk_pass_template,<pass name>,<build dir>,[<local make flags>],[<local enable condition>])
 define omk_pass_template
 .PHONY: $(1) $(addsuffix -local,$(1)) $(addsuffix -check,$(1))
+$(foreach subdir,$(SUBDIRS),$(eval $(call omk_pass_subdir_template,$(1),$(2),$(subdir))))
 $(1):
-       +@$(foreach dir,$(SUBDIRS),$(call mkdir_def,$(2)/$(dir)); \
-               $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) $(NO_PRINT_DIRECTORY) \
-               RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(2)/$(dir) \
-               -f $(SUBDIR_MAKEFILE) $$@ || exit 1 ;) true
+       @true                   # Do not emit "nothing to be done" messages
 ifneq ($(4),)
-       +@echo "make[omk]: $$@ in $(RELATIVE_DIR)"; \
-       $(call mkdir_def,$(2)); \
-       $(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \
-               -f $(SOURCESDIR_MAKEFILE) $(3) $(check-target) $$(@:%=%-local)
+$(1): $(1)-this-dir
+$(1)-this-dir: $(foreach subdir,$(SUBDIRS),$(1)-$(subdir)-subdir)
+       +@echo "make[omk]: $(strip $(1)) in $(RELATIVE_DIR)"
+       @$(call mkdir_def,$(2))
+       +@$(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \
+               -f $(SOURCESDIR_MAKEFILE) $(3) $(check-target) $(1:%=%-local)
 endif
 endef