]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added AUTOMATIC_SUBDIRS variable
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 12 Jun 2008 10:11:00 +0000 (10:11 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 12 Jun 2008 10:11:00 +0000 (10:11 +0000)
This variable enables automatic settings of SUBDIRS if it is not set in
explicitly in Makefile.omk. (inspired by Tommaso Cucinotta)

darcs-hash:20080612101137-f2ef6-18c34a9733b6ab588ec3aff5a8e84c82e93af392.gz

doc/omk-manual.texinfo
snippets/base
tests/automatic_subdirs/Makefile [new file with mode: 0644]
tests/automatic_subdirs/Makefile.omk [new file with mode: 0644]
tests/automatic_subdirs/config.target [new file with mode: 0644]
tests/automatic_subdirs/dir1/Makefile [new file with mode: 0644]
tests/automatic_subdirs/dir1/Makefile.omk [new file with mode: 0644]
tests/automatic_subdirs/dir2/Makefile [new file with mode: 0644]
tests/automatic_subdirs/dir2/Makefile.omk [new file with mode: 0644]
tests/automatic_subdirs/dir3/Makefile [new file with mode: 0644]
tests/automatic_subdirs/runtest [new file with mode: 0755]

index eef1e49f941105b3cb3ee7d34ac0cff18c8a8bd8..b0863abcfb29cfc16c19effb96081bd752d72c84 100644 (file)
@@ -516,9 +516,12 @@ You can instruct OMK to descend to a (sub)directory by setting the
 
   Compilation is invoked in these directories before it is invoked in
   the current directory.
 
   Compilation is invoked in these directories before it is invoked in
   the current directory.
+
+  See also @ref{AUTOMATIC_SUBDIRS}.
 @end defvar
 @c TODO: Write tests for this.
 
 @end defvar
 @c TODO: Write tests for this.
 
+@anchor{ALL_OMK_SUBDIRS}
 @defvar ALL_OMK_SUBDIRS
   This variable is set by OMK and can be used as the value of
   @code{SUBDIRS} variable. It contains a list of all direct
 @defvar ALL_OMK_SUBDIRS
   This variable is set by OMK and can be used as the value of
   @code{SUBDIRS} variable. It contains a list of all direct
@@ -533,6 +536,13 @@ You can instruct OMK to descend to a (sub)directory by setting the
   @end example
 @end defvar
 
   @end example
 @end defvar
 
+@anchor{AUTOMATIC_SUBDIRS}
+@defvar AUTOMATIC_SUBDIRS
+  If this variable is set to @samp{y} and @code{SUBDIRS} is not assigned
+  in @file{Makefile.omk}, then @code{SUBDIRS} is assigned a default
+  value @code{$(ALL_OMK_SUBDIRS)}.
+@end defvar
+
 @node Dependency Tracking, Configuration and Conditional Compilation, Multiple Directories, OMK User's Manual
 @section Dependency Tracking
 
 @node Dependency Tracking, Configuration and Conditional Compilation, Multiple Directories, OMK User's Manual
 @section Dependency Tracking
 
index cc843da8c6ed69f941323b7d7e6ef509a99da0b5..c89cf4bea7849f148822d6150a0e9a8e4aad14ee 100644 (file)
@@ -147,6 +147,9 @@ ALL_OMK_SUBDIRS = $(patsubst %/$(MAKEFILE_OMK),%,$(patsubst $(SOURCES_DIR)/%,%,$
 # real OCERA style Makefile.omk now
 ifndef OMK_INCLUDED
 include $(SOURCES_DIR)/$(MAKEFILE_OMK)
 # real OCERA style Makefile.omk now
 ifndef OMK_INCLUDED
 include $(SOURCES_DIR)/$(MAKEFILE_OMK)
+ifeq ($(AUTOMATIC_SUBDIRS),y)
+SUBDIRS?=$(ALL_OMK_SUBDIRS)
+endif
 OMK_INCLUDED := 1
 endif
 
 OMK_INCLUDED := 1
 endif
 
diff --git a/tests/automatic_subdirs/Makefile b/tests/automatic_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/automatic_subdirs/Makefile.omk b/tests/automatic_subdirs/Makefile.omk
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/automatic_subdirs/config.target b/tests/automatic_subdirs/config.target
new file mode 100644 (file)
index 0000000..ed32078
--- /dev/null
@@ -0,0 +1 @@
+AUTOMATIC_SUBDIRS=y
diff --git a/tests/automatic_subdirs/dir1/Makefile b/tests/automatic_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/automatic_subdirs/dir1/Makefile.omk b/tests/automatic_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/automatic_subdirs/dir2/Makefile b/tests/automatic_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/automatic_subdirs/dir2/Makefile.omk b/tests/automatic_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/automatic_subdirs/dir3/Makefile b/tests/automatic_subdirs/dir3/Makefile
new file mode 100644 (file)
index 0000000..d96b49c
--- /dev/null
@@ -0,0 +1 @@
+$(warning make-in-dir3)
diff --git a/tests/automatic_subdirs/runtest b/tests/automatic_subdirs/runtest
new file mode 100755 (executable)
index 0000000..2e0823b
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+source ../functions.sh
+
+touch config.omk-default
+
+OUTPUT=$(make 2>&1) || canttest
+echo $OUTPUT | grep make-in-dir1 || error "Make was not called in dir1" 
+echo $OUTPUT | grep make-in-dir2 || error "Make was not called in dir2"
+echo $OUTPUT | grep make-in-dir3 && error "Make shouldn't be called in dir3" 
+
+exit 0