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
$(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))
#=====================================================================
# 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:
#=====================================================================
# 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:
$(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)
--- /dev/null
+# 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
+
--- /dev/null
+SUBDIRS=error ok
--- /dev/null
+# 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
+
--- /dev/null
+$(error In ERROR directory)
--- /dev/null
+# 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
+
--- /dev/null
+$(info In OK directory)
--- /dev/null
+#!/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"