From 9acde1c470cdf0383a42208f7e21470ec414868a Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 12 Jun 2008 10:11:00 +0000 Subject: [PATCH] Added AUTOMATIC_SUBDIRS variable 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 | 10 ++++++++++ snippets/base | 3 +++ tests/automatic_subdirs/Makefile | 14 ++++++++++++++ tests/automatic_subdirs/Makefile.omk | 0 tests/automatic_subdirs/config.target | 1 + tests/automatic_subdirs/dir1/Makefile | 14 ++++++++++++++ tests/automatic_subdirs/dir1/Makefile.omk | 1 + tests/automatic_subdirs/dir2/Makefile | 14 ++++++++++++++ tests/automatic_subdirs/dir2/Makefile.omk | 1 + tests/automatic_subdirs/dir3/Makefile | 1 + tests/automatic_subdirs/runtest | 12 ++++++++++++ 11 files changed, 71 insertions(+) create mode 100644 tests/automatic_subdirs/Makefile create mode 100644 tests/automatic_subdirs/Makefile.omk create mode 100644 tests/automatic_subdirs/config.target create mode 100644 tests/automatic_subdirs/dir1/Makefile create mode 100644 tests/automatic_subdirs/dir1/Makefile.omk create mode 100644 tests/automatic_subdirs/dir2/Makefile create mode 100644 tests/automatic_subdirs/dir2/Makefile.omk create mode 100644 tests/automatic_subdirs/dir3/Makefile create mode 100755 tests/automatic_subdirs/runtest diff --git a/doc/omk-manual.texinfo b/doc/omk-manual.texinfo index eef1e49..b0863ab 100644 --- a/doc/omk-manual.texinfo +++ b/doc/omk-manual.texinfo @@ -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. + + See also @ref{AUTOMATIC_SUBDIRS}. @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 @@ -533,6 +536,13 @@ You can instruct OMK to descend to a (sub)directory by setting the @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 diff --git a/snippets/base b/snippets/base index cc843da..c89cf4b 100644 --- a/snippets/base +++ b/snippets/base @@ -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) +ifeq ($(AUTOMATIC_SUBDIRS),y) +SUBDIRS?=$(ALL_OMK_SUBDIRS) +endif OMK_INCLUDED := 1 endif diff --git a/tests/automatic_subdirs/Makefile b/tests/automatic_subdirs/Makefile new file mode 100644 index 0000000..f595272 --- /dev/null +++ b/tests/automatic_subdirs/Makefile @@ -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 index 0000000..e69de29 diff --git a/tests/automatic_subdirs/config.target b/tests/automatic_subdirs/config.target new file mode 100644 index 0000000..ed32078 --- /dev/null +++ b/tests/automatic_subdirs/config.target @@ -0,0 +1 @@ +AUTOMATIC_SUBDIRS=y diff --git a/tests/automatic_subdirs/dir1/Makefile b/tests/automatic_subdirs/dir1/Makefile new file mode 100644 index 0000000..f595272 --- /dev/null +++ b/tests/automatic_subdirs/dir1/Makefile @@ -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 index 0000000..20ef631 --- /dev/null +++ b/tests/automatic_subdirs/dir1/Makefile.omk @@ -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 index 0000000..f595272 --- /dev/null +++ b/tests/automatic_subdirs/dir2/Makefile @@ -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 index 0000000..5976b77 --- /dev/null +++ b/tests/automatic_subdirs/dir2/Makefile.omk @@ -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 index 0000000..d96b49c --- /dev/null +++ b/tests/automatic_subdirs/dir3/Makefile @@ -0,0 +1 @@ +$(warning make-in-dir3) diff --git a/tests/automatic_subdirs/runtest b/tests/automatic_subdirs/runtest new file mode 100755 index 0000000..2e0823b --- /dev/null +++ b/tests/automatic_subdirs/runtest @@ -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 -- 2.39.2