]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added EXTRA_RULES_SUBDIRS feature
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 25 Jun 2008 12:35:00 +0000 (12:35 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 25 Jun 2008 12:35:00 +0000 (12:35 +0000)
By setting this variable in Makefile.omk, it is possible to compile some
part of the source tree using different rules. It is useful for
compilation of host tools which are needed to compile the rest of
project (e.g. IDL compilers).

darcs-hash:20080625123539-f2ef6-40ef4157c7098be9d851bae6ccf972ca90e69d23.gz

14 files changed:
snippets/base
snippets/config_h
snippets/include
snippets/linux
snippets/qt
snippets/sources-list
tests/extra_rules_subdirs/Makefile [new file with mode: 0644]
tests/extra_rules_subdirs/Makefile.omk [new file with mode: 0644]
tests/extra_rules_subdirs/runtest [new file with mode: 0755]
tests/extra_rules_subdirs/subdir/Makefile [new file with mode: 0644]
tests/extra_rules_subdirs/subdir/Makefile.omk [new file with mode: 0644]
tests/extra_rules_subdirs/tools/Makefile [new file with mode: 0644]
tests/extra_rules_subdirs/tools/Makefile.omk [new file with mode: 0644]
tests/extra_rules_subdirs/tools/test.c [new file with mode: 0644]

index c89cf4bea7849f148822d6150a0e9a8e4aad14ee..77a0d8d8dbe830556ed024a52be6ecf9ebbee098 100644 (file)
@@ -25,6 +25,13 @@ ifndef MAKERULES_DIR
 MAKERULES_DIR := $(abspath $(dir $(filter %Makefile.rules,$(MAKEFILE_LIST))))
 endif
 
 MAKERULES_DIR := $(abspath $(dir $(filter %Makefile.rules,$(MAKEFILE_LIST))))
 endif
 
+# OUTPUT_DIR is the place where _compiled, _build and possible other
+# files/directories are created. By default is the same as
+# $(MAKERULES_DIR).
+ifndef OUTPUT_DIR
+OUTPUT_DIR := $(MAKERULES_DIR)
+endif
+
 .PHONY: all default check-make-ver omkize
 
 ifdef W
 .PHONY: all default check-make-ver omkize
 
 ifdef W
@@ -48,7 +55,7 @@ endif
 ifdef OMK_TESTSROOT
 # Usage: $(call canttest,<error message>)
 define canttest
 ifdef OMK_TESTSROOT
 # Usage: $(call canttest,<error message>)
 define canttest
-       ( echo "$(1)" > $(MAKERULES_DIR)/_canttest; echo "$(1)"; exit 1 )
+       ( echo "$(1)" > $(OUTPUT_DIR)/_canttest; echo "$(1)"; exit 1 )
 endef
 else
 define canttest
 endef
 else
 define canttest
@@ -64,7 +71,7 @@ endif
 # variable related.
 ifneq ($(CONFIG_FILE_OK),y)
 ifndef CONFIG_FILE
 # variable related.
 ifneq ($(CONFIG_FILE_OK),y)
 ifndef CONFIG_FILE
-CONFIG_FILE      := $(MAKERULES_DIR)/config.omk
+CONFIG_FILE      := $(OUTPUT_DIR)/config.omk
 endif
 ifneq ($(wildcard $(CONFIG_FILE)-default),)
 -include $(CONFIG_FILE)-default
 endif
 ifneq ($(wildcard $(CONFIG_FILE)-default),)
 -include $(CONFIG_FILE)-default
@@ -74,7 +81,7 @@ $(warning Please, run "make default-config" first)
 endif
 endif
 
 endif
 endif
 
--include $(MAKERULES_DIR)/config.target
+-include $(OUTPUT_DIR)/config.target
 
 ifneq ($(wildcard $(CONFIG_FILE)),)
 -include $(CONFIG_FILE)
 
 ifneq ($(wildcard $(CONFIG_FILE)),)
 -include $(CONFIG_FILE)
@@ -83,7 +90,7 @@ endif
 endif #$(CONFIG_FILE_OK)
 
 
 endif #$(CONFIG_FILE_OK)
 
 
-CONFIG_FILES ?= $(wildcard $(CONFIG_FILE)-default) $(wildcard $(MAKERULES_DIR)/config.target) $(wildcard $(CONFIG_FILE))
+CONFIG_FILES ?= $(wildcard $(CONFIG_FILE)-default) $(wildcard $(OUTPUT_DIR)/config.target) $(wildcard $(CONFIG_FILE))
 
 
 export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR
 
 
 export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR
@@ -92,7 +99,7 @@ export CONFIG_FILE CONFIG_FILES OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
 # must to be serialized only in the toplevel make.
 
 ifndef RELATIVE_DIR
 # must to be serialized only in the toplevel make.
 
 ifndef RELATIVE_DIR
-RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%)
+RELATIVE_DIR := $(SOURCES_DIR:$(OUTPUT_DIR)%=%)
 endif
 #$(warning  === RELATIVE_DIR = "$(RELATIVE_DIR)" ===)
 override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
 endif
 #$(warning  === RELATIVE_DIR = "$(RELATIVE_DIR)" ===)
 override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
@@ -102,7 +109,7 @@ override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | sed -e 's_//_/_g' -e 's
 #$(warning  BACK2TOP_DIR = "$(BACK2TOP_DIR)")
 
 #$(warning SOURCES_DIR = "$(SOURCES_DIR)")
 #$(warning  BACK2TOP_DIR = "$(BACK2TOP_DIR)")
 
 #$(warning SOURCES_DIR = "$(SOURCES_DIR)")
-#$(warning MAKERULES_DIR = "$(MAKERULES_DIR)")
+#$(warning MAKERULES_DIR = "$(OUTPUT_DIR)")
 #$(warning RELATIVE_DIR = "$(RELATIVE_DIR)")
 
 # We have to use RELATIVE_PREFIX because of mingw
 #$(warning RELATIVE_DIR = "$(RELATIVE_DIR)")
 
 # We have to use RELATIVE_PREFIX because of mingw
@@ -162,7 +169,7 @@ check-make-ver:
 
 distclean dist-clean:
        @$(QUIET_CMD_ECHO) "  RM      $(COMPILED_DIR_NAME) $(BUILD_DIR_NAME)"
 
 distclean dist-clean:
        @$(QUIET_CMD_ECHO) "  RM      $(COMPILED_DIR_NAME) $(BUILD_DIR_NAME)"
-       @rm -fr $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)  $(MAKERULES_DIR)/$(BUILD_DIR_NAME)
+       @rm -fr $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)  $(OUTPUT_DIR)/$(BUILD_DIR_NAME)
 
 # Common OMK templates
 # ====================
 
 # Common OMK templates
 # ====================
@@ -205,6 +212,22 @@ ifdef OMK_TESTSROOT
 check-target = $(1:%=%-check)
 endif
 
 check-target = $(1:%=%-check)
 endif
 
+# Call a pass in a subdirectory
+# Usage: $(call extra_rules_subdir_template,<subdir>)
+define extra_rules_subdir_template
+extra-rules-subdirs: extra-rules-$(1)
+extra-rules-$(1):
+       +$(MAKE) OMK_SERIALIZE_INCLUDED=n MAKERULES_DIR=$(SOURCES_DIR)/$(1) OUTPUT_DIR=$(OUTPUT_DIR) \
+               SOURCES_DIR=$(SOURCES_DIR)/$(1) RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) -C $(SOURCES_DIR)/$(1)
+endef
+
+$(warning $(SOURCES_DIR))
+
+.PHONY: extra-rules-subdirs
+extra-rules-subdirs:
+
+$(foreach subdir,$(EXTRA_RULES_SUBDIRS),$(eval $(call extra_rules_subdir_template,$(subdir))))
+
 # Usage: $(call omk_pass_template,<pass name>,<build dir>,[<local make flags>],[<local enable condition>])
 define omk_pass_template
 .PHONY: $(pass) $(pass)-local $(pass)-check $(pass)-submakes
 # Usage: $(call omk_pass_template,<pass name>,<build dir>,[<local make flags>],[<local enable condition>])
 define omk_pass_template
 .PHONY: $(pass) $(pass)-local $(pass)-check $(pass)-submakes
@@ -237,9 +260,9 @@ default-config:
        @echo "# This file should not be altered manually" >> "$(CONFIG_FILE)-default"
        @echo "# Overrides should be stored in file $(notdir $(CONFIG_FILE))" >> "$(CONFIG_FILE)-default"
        @echo >> "$(CONFIG_FILE)-default"
        @echo "# This file should not be altered manually" >> "$(CONFIG_FILE)-default"
        @echo "# Overrides should be stored in file $(notdir $(CONFIG_FILE))" >> "$(CONFIG_FILE)-default"
        @echo >> "$(CONFIG_FILE)-default"
-       @$(MAKE) $(NO_PRINT_DIRECTORY) -C $(MAKERULES_DIR) \
-               RELATIVE_DIR="" SOURCES_DIR=$(MAKERULES_DIR) \
-               -f $(MAKERULES_DIR)/Makefile default-config-pass
+       @$(MAKE) $(NO_PRINT_DIRECTORY) -C $(OUTPUT_DIR) \
+               RELATIVE_DIR="" SOURCES_DIR=$(OUTPUT_DIR) \
+               -f $(OUTPUT_DIR)/Makefile default-config-pass
 
 $(eval $(call omk_pass_template,default-config-pass,$$(LOCAL_BUILD_DIR),,always))
 
 
 $(eval $(call omk_pass_template,default-config-pass,$$(LOCAL_BUILD_DIR),,always))
 
index 35cd3aa0000481d00190ff39a365954a17184013..0e25ad9e1b49deac7b02ee0d529e92ba1c3f3abc 100644 (file)
@@ -16,7 +16,7 @@ $(addprefix $(1)/,$(notdir $(addsuffix .stamp,$(2)))) : $(CONFIG_FILES)
        @if [ ! -d `dirname $(2).tmp` ] ; then \
                mkdir -p `dirname $(2).tmp` ; fi
        @echo "/* Automatically generated from */" > "$(2).tmp"
        @if [ ! -d `dirname $(2).tmp` ] ; then \
                mkdir -p `dirname $(2).tmp` ; fi
        @echo "/* Automatically generated from */" > "$(2).tmp"
-       @echo "/* config files: $$(^:$(MAKERULES_DIR)/%=%) */" >> "$(2).tmp"
+       @echo "/* config files: $$(^:$(OUTPUT_DIR)/%=%) */" >> "$(2).tmp"
        $(if $(DOXYGEN),@echo "/** @file */" >> "$(2).tmp")
        @echo "#ifndef $(4)" >> "$(2).tmp"
        @echo "#define $(4)" >> "$(2).tmp"
        $(if $(DOXYGEN),@echo "/** @file */" >> "$(2).tmp")
        @echo "#ifndef $(4)" >> "$(2).tmp"
        @echo "#define $(4)" >> "$(2).tmp"
index b30acfc5b231e44465b12bbf29e00ff31d8801a7..c2191178cf11ac755913f88f0d97bc98cfd1b29c 100644 (file)
@@ -6,11 +6,11 @@ endif
 
 ifneq ($(LN_HEADERS),y)
 define cp_cmd
 
 ifneq ($(LN_HEADERS),y)
 define cp_cmd
-( echo "  CP      $(1:$(MAKERULES_DIR)/%=%) -> $(2:$(MAKERULES_DIR)/%=%)"; cp $(CPHEADER_FLAGS) $(1) $(2) )
+( echo "  CP      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; cp $(CPHEADER_FLAGS) $(1) $(2) )
 endef
 else
 define cp_cmd
 endef
 else
 define cp_cmd
-( echo "  LN      $(1:$(MAKERULES_DIR)/%=%) -> $(2:$(MAKERULES_DIR)/%=%)"; [ -f $(1) ] && ln -sf $(LNHEADER_FLAGS) $(1) $(2) )
+( echo "  LN      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; [ -f $(1) ] && ln -sf $(LNHEADER_FLAGS) $(1) $(2) )
 endef
 endif
 
 endef
 endif
 
index 432fbc1d5a98cba506f7c978640b667f6ed08694..b077e30a0161a548e9a5f373c848facda43eec3c 100644 (file)
@@ -34,9 +34,9 @@
 #LINUX_DIR := /home/cvs/ocera/ocera-build/kernel/linux
 #RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
 #CONFIG_RTLINUX = y
 #LINUX_DIR := /home/cvs/ocera/ocera-build/kernel/linux
 #RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
 #CONFIG_RTLINUX = y
-#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+#OCERA_DIR := $(shell ( cd -L $(OUTPUT_DIR)/../../.. ; pwd -L ) )
 
 
--include $(MAKERULES_DIR)/OCERA_TOP_DIR
+-include $(OUTPUT_DIR)/OCERA_TOP_DIR
 
 BUILD_DIR_NAME = _build
 COMPILED_DIR_NAME = _compiled
 
 BUILD_DIR_NAME = _build
 COMPILED_DIR_NAME = _compiled
@@ -69,17 +69,17 @@ ifneq ($(wildcard $(CONFIG_FILE)),)
 CONFIG_FILE_OK = y
 endif
 else # OCERA_DIR
 CONFIG_FILE_OK = y
 endif
 else # OCERA_DIR
-KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
-KERN_LIB_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
-KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
-KERN_BUILD_DIR   := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
-KERN_MODPOST_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern-modpost
-USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
-USER_LIB_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
-USER_UTILS_DIR   := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
-USER_TESTS_DIR   := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-tests
-USER_BIN_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
-USER_BUILD_DIR   := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+KERN_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include-kern
+KERN_LIB_DIR     := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+KERN_MODULES_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/modules
+KERN_BUILD_DIR   := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern
+KERN_MODPOST_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/kern-modpost
+USER_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include
+USER_LIB_DIR     := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/lib
+USER_UTILS_DIR   := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+USER_TESTS_DIR   := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin-tests
+USER_BIN_DIR     := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/bin
+USER_BUILD_DIR   := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/user
 
 ifndef LINUX_VERSION
 LINUX_VERSION=$(shell uname -r)
 
 ifndef LINUX_VERSION
 LINUX_VERSION=$(shell uname -r)
@@ -375,9 +375,9 @@ endif
 
 ifdef KERN_RULE_TEMPLATES
 
 
 ifdef KERN_RULE_TEMPLATES
 
-$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(MAKERULES_DIR)/kernelcfg2mk
+$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(OUTPUT_DIR)/kernelcfg2mk
        @$(QUIET_CMD_ECHO) "  KCFG2MK $$@"
        @$(QUIET_CMD_ECHO) "  KCFG2MK $$@"
-       $(Q) $(MAKERULES_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
+       $(Q) $(OUTPUT_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
 
 ifeq ($(CONFIG_RTLINUX),y)
 include $(RTL_DIR)/rtl.mk
 
 ifeq ($(CONFIG_RTLINUX),y)
 include $(RTL_DIR)/rtl.mk
@@ -753,7 +753,7 @@ clean-local: clean-custom
            touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
        fi
 
            touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
        fi
 
-default: include-pass library-pass binary-pass
+default: extra-rules-subdirs include-pass library-pass binary-pass
 ifndef OMIT_KERNEL_PASSES
 # Also make kernel passes if not disabled
 default: kernel-lib-pass kernel-pass
 ifndef OMIT_KERNEL_PASSES
 # Also make kernel passes if not disabled
 default: kernel-lib-pass kernel-pass
index b554df47910a6b7b901421f06f51b1dc3810aa1e..c09b28afcee9bb373191081bf9696e436866418c 100644 (file)
@@ -8,7 +8,7 @@ ifneq ($(QT_SUBDIRS),)
 # Usage: $(call qt_makefile_template,<qt-subdir>)
 define qt_makefile_template
 $(SOURCES_DIR)/$(1)/Makefile: $(wildcard $(SOURCES_DIR)/$(1)/*.pro)
 # Usage: $(call qt_makefile_template,<qt-subdir>)
 define qt_makefile_template
 $(SOURCES_DIR)/$(1)/Makefile: $(wildcard $(SOURCES_DIR)/$(1)/*.pro)
-       cd $(SOURCES_DIR)/$(1); $(QTDIR:%=%/bin/)qmake TOP_DIR=$(MAKERULES_DIR) \
+       cd $(SOURCES_DIR)/$(1); $(QTDIR:%=%/bin/)qmake TOP_DIR=$(OUTPUT_DIR) \
             RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) $(QTDIR:%=QTDIR=%) CC=$(CC) \
             CXX=$(CXX) LIBS+="-L$(USER_LIB_DIR)" INCLUDEPATH+="$(USER_INCLUDE_DIR)"
 endef
             RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) $(QTDIR:%=QTDIR=%) CC=$(CC) \
             CXX=$(CXX) LIBS+="-L$(USER_LIB_DIR)" INCLUDEPATH+="$(USER_INCLUDE_DIR)"
 endef
index a9eb027a11efb9f240de5b14cd4b63bfa3b32cc8..ff5cfafda5b1dbbe9f351cc13ffff5336a751e7d 100644 (file)
@@ -6,7 +6,7 @@
 SOURCES_LIST_FN=sources.txt
 ifndef SOURCES_LIST
 SOURCES_LIST_DIR:=$(RELATIVE_DIR)
 SOURCES_LIST_FN=sources.txt
 ifndef SOURCES_LIST
 SOURCES_LIST_DIR:=$(RELATIVE_DIR)
-SOURCES_LIST:=$(MAKERULES_DIR)/$(SOURCES_LIST_DIR)/$(SOURCES_LIST_FN)
+SOURCES_LIST:=$(OUTPUT_DIR)/$(SOURCES_LIST_DIR)/$(SOURCES_LIST_FN)
 export SOURCES_LIST SOURCES_LIST_DIR
 endif
 
 export SOURCES_LIST SOURCES_LIST_DIR
 endif
 
@@ -39,7 +39,7 @@ sources-list-pass-local:
        @$(foreach h,$(include_HEADERS) $(nobase_include_HEADERS) $(kernel_HEADERS),\
          echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)" >> "$(SOURCES_LIST).tmp";)
        @$(foreach ch,$(config_include_HEADERS), \
        @$(foreach h,$(include_HEADERS) $(nobase_include_HEADERS) $(kernel_HEADERS),\
          echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)" >> "$(SOURCES_LIST).tmp";)
        @$(foreach ch,$(config_include_HEADERS), \
-         echo "$(USER_INCLUDE_DIR:$(MAKERULES_DIR)/$(addsuffix /,$(SOURCES_LIST_DIR))%=%)/$(ch)" >> "$(SOURCES_LIST).tmp";)
+         echo "$(USER_INCLUDE_DIR:$(OUTPUT_DIR)/$(addsuffix /,$(SOURCES_LIST_DIR))%=%)/$(ch)" >> "$(SOURCES_LIST).tmp";)
        @$(foreach h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
        @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(test_PROGRAMS) $(utils_PROGRAMS) \
          $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
        @$(foreach h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
        @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(test_PROGRAMS) $(utils_PROGRAMS) \
          $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
diff --git a/tests/extra_rules_subdirs/Makefile b/tests/extra_rules_subdirs/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/extra_rules_subdirs/Makefile.omk b/tests/extra_rules_subdirs/Makefile.omk
new file mode 100644 (file)
index 0000000..6f1fea0
--- /dev/null
@@ -0,0 +1,3 @@
+SUBDIRS=subdir
+EXTRA_RULES_SUBDIRS = tools
+
diff --git a/tests/extra_rules_subdirs/runtest b/tests/extra_rules_subdirs/runtest
new file mode 100755 (executable)
index 0000000..953ea3b
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+source ../functions.sh
+
+touch default-config
+
+cp Makefile.rules tools/
+make -k
+
diff --git a/tests/extra_rules_subdirs/subdir/Makefile b/tests/extra_rules_subdirs/subdir/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/extra_rules_subdirs/subdir/Makefile.omk b/tests/extra_rules_subdirs/subdir/Makefile.omk
new file mode 100644 (file)
index 0000000..cdf7e55
--- /dev/null
@@ -0,0 +1,2 @@
+
+$(info Main rules goal: $(MAKECMDGOALS))
diff --git a/tests/extra_rules_subdirs/tools/Makefile b/tests/extra_rules_subdirs/tools/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/extra_rules_subdirs/tools/Makefile.omk b/tests/extra_rules_subdirs/tools/Makefile.omk
new file mode 100644 (file)
index 0000000..0a29372
--- /dev/null
@@ -0,0 +1,5 @@
+$(warning Extra rules goal: $(MAKECMDGOALS))
+
+bin_PROGRAMS = test
+
+test_SOURCES = test.c
\ No newline at end of file
diff --git a/tests/extra_rules_subdirs/tools/test.c b/tests/extra_rules_subdirs/tools/test.c
new file mode 100644 (file)
index 0000000..f24b7bd
--- /dev/null
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int main()
+{
+#ifdef NUMBER
+        printf("NUMBER is %d\n", NUMBER);
+#endif
+        return 0;
+}