]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Fixed behaviour of make -k if there is an error in a subdirectory
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Apr 2008 06:25:00 +0000 (06:25 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Apr 2008 06:25:00 +0000 (06:25 +0000)
The previous implementation of recursive invocation of make in
subdirectories didn't obey the -k flag. If there was an error in some
subdirectory, the other directories were not made.

This patch creates a separate targets for each subdirectory and pass and
add them as a dependencies to the main pass target. This way the
compilation errors are handled correctly with the -k flag.

darcs-hash:20080417062508-f2ef6-d049eff642e8c33ee1822d8b321bf1365ed80869.gz

12 files changed:
snippets/base
snippets/linux
snippets/sdcc
snippets/sysless
snippets/vxworks
tests/ignore_errors/Makefile [new file with mode: 0644]
tests/ignore_errors/Makefile.omk [new file with mode: 0644]
tests/ignore_errors/error/Makefile [new file with mode: 0644]
tests/ignore_errors/error/Makefile.omk [new file with mode: 0644]
tests/ignore_errors/ok/Makefile [new file with mode: 0644]
tests/ignore_errors/ok/Makefile.omk [new file with mode: 0644]
tests/ignore_errors/runtest [new file with mode: 0755]

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
 
index 7126df52dc30e91138cb39a37ca5a0396838d460..ff67268c2ac2d09d8177aa59a76ae0d3e50db113 100644 (file)
@@ -631,8 +631,9 @@ kernel-modpost-pass:
 $(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)))
 $(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)$(test_PROGRAMS)))
 
-OTHER_PASSES = clean install include-pass
-$(eval $(call omk_pass_template,$(OTHER_PASSES),$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,clean,$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,install,$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,include-pass,$(USER_OBJS_DIR),,always))
 
 check-dir:
        @$(call mkdir_def,$(USER_BUILD_DIR))
index 0816a81872ad6f7f2262e50786db7967c61df010..af66b6f735e03e1f180d79d2c6340df055422fbb 100644 (file)
@@ -320,15 +320,14 @@ run: run-$(firstword $(link_VARIANTS))
 
 #=====================================================================
 # Generate pass rules from generic templates
-OTHER_PASSES = dep clean install
 
 $(eval $(call omk_pass_template, include-pass, $(LOCAL_BUILD_DIR),,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(lib_LDSCRIPTS)$(config_include_HEADERS)$(LOCAL_CONFIG_H)))
 $(eval $(call omk_pass_template, library-pass, $(LOCAL_BUILD_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)$(lib_obj_SOURCES)))
 $(eval $(call omk_pass_template, binary-pass,  $(LOCAL_BUILD_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(test_PROGRAMS)))
 $(eval $(call omk_pass_template, utils-pass,   $(LOCAL_BUILD_DIR),USER_RULE_TEMPLATES=y,$(utils_PROGRAMS)))
-
-
-$(eval $(call omk_pass_template,$(OTHER_PASSES),$(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, dep,    $(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, clean,  $(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, install,$(LOCAL_BUILD_DIR),,always))
 
 
 dep-local:
index eb863eaba19c00ee6b65c91f83946e14015be62d..b67cc397eb44f5d3885ebf90874eb002c7ed3832 100644 (file)
@@ -238,15 +238,14 @@ run: run-$(firstword $(link_VARIANTS))
 
 #=====================================================================
 # Generate pass rules from generic templates
-OTHER_PASSES = dep clean install
 
 $(eval $(call omk_pass_template, include-pass, $(LOCAL_BUILD_DIR),,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(lib_LDSCRIPTS)$(config_include_HEADERS)$(LOCAL_CONFIG_H)))
 $(eval $(call omk_pass_template, library-pass, $(LOCAL_BUILD_DIR),TARGET_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)$(lib_obj_SOURCES)))
 $(eval $(call omk_pass_template, binary-pass,  $(LOCAL_BUILD_DIR),TARGET_RULE_TEMPLATES=y,$(bin_PROGRAMS) $(test_PROGRAMS)))
 $(eval $(call omk_pass_template, utils-pass,   $(LOCAL_BUILD_DIR),HOST_RULE_TEMPLATES=y,$(utils_PROGRAMS)))
-
-
-$(eval $(call omk_pass_template,$(OTHER_PASSES),$(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, dep,    $(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, clean,  $(LOCAL_BUILD_DIR),,always))
+$(eval $(call omk_pass_template, install,$(LOCAL_BUILD_DIR),,always))
 
 
 dep-local:
index 16050df1863efdf68490c9352e79aaec729ee276..4570a97165ff3da51d69539bc7a5fe02fa0f0bf2 100644 (file)
@@ -176,8 +176,9 @@ $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
 
 $(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
 
-OTHER_PASSES = clean install include-pass
-$(eval $(call omk_pass_template,$(OTHER_PASSES),$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,clean,$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,install,$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,include-pass,$(USER_OBJS_DIR),,always))
 
 include-pass-local:
        $(call include-pass-template,$(USER_INCLUDE_DIR),include)
diff --git a/tests/ignore_errors/Makefile b/tests/ignore_errors/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/tests/ignore_errors/Makefile.omk b/tests/ignore_errors/Makefile.omk
new file mode 100644 (file)
index 0000000..59066de
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS=error ok
diff --git a/tests/ignore_errors/error/Makefile b/tests/ignore_errors/error/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/tests/ignore_errors/error/Makefile.omk b/tests/ignore_errors/error/Makefile.omk
new file mode 100644 (file)
index 0000000..1020cb2
--- /dev/null
@@ -0,0 +1 @@
+$(error In ERROR directory)
diff --git a/tests/ignore_errors/ok/Makefile b/tests/ignore_errors/ok/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/tests/ignore_errors/ok/Makefile.omk b/tests/ignore_errors/ok/Makefile.omk
new file mode 100644 (file)
index 0000000..a1358a9
--- /dev/null
@@ -0,0 +1 @@
+$(info In OK directory)
diff --git a/tests/ignore_errors/runtest b/tests/ignore_errors/runtest
new file mode 100755 (executable)
index 0000000..acbbcbf
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ../functions.sh
+
+touch config.omk-default
+make -k 2>&1 | tee make.log || true
+grep -q "In OK directory" make.log||error "error in subdirectory \
+blocks prevents other subdirectories from compilation with make -k"