]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added support for compilation of the whole tree from any subdirectory.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 22 Jan 2007 20:43:00 +0000 (20:43 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 22 Jan 2007 20:43:00 +0000 (20:43 +0000)
darcs-hash:20070122204301-f2ef6-88b206453c326a930f9997903d56ff4e8fa2754c.gz

snippets/base
tests/whole_tree/Makefile [new file with mode: 0644]
tests/whole_tree/Makefile.omk [new file with mode: 0644]
tests/whole_tree/rules [new file with mode: 0644]
tests/whole_tree/runtest [new file with mode: 0755]
tests/whole_tree/subdir/Makefile [new file with mode: 0644]
tests/whole_tree/subdir/Makefile.omk [new file with mode: 0644]

index f64adfde2fae96804d2ff3969b12139aba906372..606c69678e171f891a8981050fbf8753533cef5b 100644 (file)
@@ -8,6 +8,7 @@
 #
 # input variables
 # V                .. if set to 1, full command text is shown else short form is used
+# 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 ...
 
@@ -18,8 +19,23 @@ endif
 
 .PHONY: all default check-make-ver
 
+ifdef W
+  ifeq ("$(origin W)", "command line")
+    OMK_WHOLE_TREE:=$(W)
+  endif
+endif
+ifndef OMK_WHOLE_TREE
+  OMK_WHOLE_TREE:=0
+endif
+
+ifneq ($(OMK_WHOLE_TREE),1)
 all: check-make-ver default
        @echo "Compilation finished"
+else
+# Run make in the top-level directory
+all:
+       @$(MAKE) -C $(MAKERULES_DIR) OMK_SERIALIZE_INCLUDED=n SOURCES_DIR=$(MAKERULES_DIR) RELATIVE_DIR="" $(MAKECMDGOALS) W=0
+endif
 
 #=========================
 # Include the config file
@@ -96,7 +112,6 @@ include $(SOURCES_DIR)/Makefile.omk
 OMK_INCLUDED := 1
 endif
 
-
 check-make-ver:
        @GOOD_MAKE_VERSION=`echo $(MAKE_VERSION) | sed -n -e 's/^[4-9]\..*\|^3\.9[0-9].*\|^3\.8[1-9].*/y/p'` ; \
        if [ x$$GOOD_MAKE_VERSION != xy ] ; then \
diff --git a/tests/whole_tree/Makefile b/tests/whole_tree/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/whole_tree/Makefile.omk b/tests/whole_tree/Makefile.omk
new file mode 100644 (file)
index 0000000..c77e8bb
--- /dev/null
@@ -0,0 +1 @@
+$(shell echo "Top-level executed" > toplevel.mark)
diff --git a/tests/whole_tree/rules b/tests/whole_tree/rules
new file mode 100644 (file)
index 0000000..9b5e7bf
--- /dev/null
@@ -0,0 +1 @@
+snip:base
diff --git a/tests/whole_tree/runtest b/tests/whole_tree/runtest
new file mode 100755 (executable)
index 0000000..7fd21c6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. $OMK_TESTSROOT/functions.sh
+
+touch config.omk-default
+make -C subdir W=1 || canttest
+
+[ -f 'toplevel.mark' ] || error "Toplevel make was not called".
diff --git a/tests/whole_tree/subdir/Makefile b/tests/whole_tree/subdir/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/whole_tree/subdir/Makefile.omk b/tests/whole_tree/subdir/Makefile.omk
new file mode 100644 (file)
index 0000000..e69de29