]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added ALL_OMK_SUBDIRS variable.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 1 Mar 2007 19:21:00 +0000 (19:21 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 1 Mar 2007 19:21:00 +0000 (19:21 +0000)
darcs-hash:20070301192105-f2ef6-cb35d64e8f3af348bffcf4e1a9651c556721514f.gz

snippets/base
tests/all_omk_subdirs/Makefile [new file with mode: 0644]
tests/all_omk_subdirs/Makefile.omk [new file with mode: 0644]
tests/all_omk_subdirs/dir1/Makefile [new file with mode: 0644]
tests/all_omk_subdirs/dir1/Makefile.omk [new file with mode: 0644]
tests/all_omk_subdirs/dir2/Makefile [new file with mode: 0644]
tests/all_omk_subdirs/dir2/Makefile.omk [new file with mode: 0644]
tests/all_omk_subdirs/dir3/Makefile [new file with mode: 0644]
tests/all_omk_subdirs/runtest [new file with mode: 0755]

index 606c69678e171f891a8981050fbf8753533cef5b..fbe60555991c97e1941615e89b4c978652832b70 100644 (file)
@@ -11,6 +11,9 @@
 # W                .. whole tree - if set to 1, make is always called from the top-level directory
 # SUBDIRS          .. list of subdirectories intended for make from actual directory
 # default_CONFIG   .. list of default config assignments CONFIG_XXX=y/n ...
+#
+# output variables
+# ALL_OMK_SUBDIRS  .. Expands to all subdirectories (even linked ones) containing Makefile.omk
 
 # We need to ensure definition of sources directory first
 ifndef SOURCES_DIR
@@ -170,3 +173,10 @@ default-config-pass-local:
        @echo "# Config for $(RELATIVE_DIR)" >> "$(CONFIG_FILE)-default"
        @$(foreach x, $(default_CONFIG), echo $(x) | \
                sed -e 's/^.*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
+
+# =======================
+# Useful macros
+
+# All subdirectories (even linked ones) containing Makefile.omk
+# Usage in Makefile.omk: SUBDIRS = $(ALL_OMK_SUBDIRS)
+ALL_OMK_SUBDIRS = $(shell find -L $(SOURCES_DIR) -maxdepth 2 -mindepth 2 -name Makefile.omk|sed 's!$(SOURCES_DIR)/\(.*\)/.*!\1!')
diff --git a/tests/all_omk_subdirs/Makefile b/tests/all_omk_subdirs/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /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/all_omk_subdirs/Makefile.omk b/tests/all_omk_subdirs/Makefile.omk
new file mode 100644 (file)
index 0000000..4392cf5
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = $(ALL_OMK_SUBDIRS)
\ No newline at end of file
diff --git a/tests/all_omk_subdirs/dir1/Makefile b/tests/all_omk_subdirs/dir1/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /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/all_omk_subdirs/dir1/Makefile.omk b/tests/all_omk_subdirs/dir1/Makefile.omk
new file mode 100644 (file)
index 0000000..20ef631
--- /dev/null
@@ -0,0 +1 @@
+$(warning make-in-dir1)
diff --git a/tests/all_omk_subdirs/dir2/Makefile b/tests/all_omk_subdirs/dir2/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /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/all_omk_subdirs/dir2/Makefile.omk b/tests/all_omk_subdirs/dir2/Makefile.omk
new file mode 100644 (file)
index 0000000..5976b77
--- /dev/null
@@ -0,0 +1 @@
+$(warning make-in-dir2)
\ No newline at end of file
diff --git a/tests/all_omk_subdirs/dir3/Makefile b/tests/all_omk_subdirs/dir3/Makefile
new file mode 100644 (file)
index 0000000..d96b49c
--- /dev/null
@@ -0,0 +1 @@
+$(warning make-in-dir3)
diff --git a/tests/all_omk_subdirs/runtest b/tests/all_omk_subdirs/runtest
new file mode 100755 (executable)
index 0000000..5566591
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. $OMK_TESTSROOT/functions.sh
+
+touch config.omk-default
+make | grep make-in-dir1 || exit 1 
+make | grep make-in-dir2 || exit 1 
+make | grep make-in-dir3 && exit 1