summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-01-18 19:16:13 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-01-18 19:16:13 +0000
commit7592a0c969bb0119172e896c3b07c8bfa050903f (patch)
tree6cb7e16e9a8786cab72c3304e323467515cc1ef6 /lib
parentf2e54a409e5ac50f7ff1041773eaf6817fc3cc84 (diff)
Now make will recurse into subdirectories of a thorn.
In your make.code.defn file put lines SRCS = <sources in this directory> SUBDIRS= <all subdirectories - e.g. what find . -type d would give you> then in each subdirectory put a make.code.defn containing SRCS = <sources in this directory> (N.B. you cannot currently put a SUBDIRS line here) along with make.code.deps files in all the directories. Make will then go into the relevant subdirectory and make the object files there before updating the library file. The first time it does this you will get errors of the form cannot find <subdir-name>/make.identity you should ignore these errors, as the make system then creates the files. If I find a way to do this without the errors, I'll be happy 8-) The files are used to keep track of the subdirectory filenames. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@66 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib')
-rw-r--r--lib/make/make.configuration8
-rw-r--r--lib/make/make.post14
-rw-r--r--lib/make/make.pre13
-rw-r--r--lib/make/make.subdir36
-rw-r--r--lib/make/make.thornlib36
5 files changed, 101 insertions, 6 deletions
diff --git a/lib/make/make.configuration b/lib/make/make.configuration
index 06fc172b..9ebdf452 100644
--- a/lib/make/make.configuration
+++ b/lib/make/make.configuration
@@ -8,11 +8,14 @@
# @version $Id$
# @@*/
+# Silence all but designated output
+#.SILENT:
+
# Some configuration variables
CONFIG = $(TOP)/config-data
DATESTAMP = $(CCTK_HOME)/src/datestamp.c
-MAKE_DIR = $(CCTK_HOME)/lib/make
+export MAKE_DIR = $(CCTK_HOME)/lib/make
# Dividers to make the screen output slightly nicer
DIVEL = __________________
@@ -24,9 +27,6 @@ include $(CONFIG)/make.config.defn
# Include the list of thorns to be built
include $(CONFIG)/make.thornlist
-# Silence all but designated output
-.SILENT:
-
# Build the executable
$(EXE): $(CONFIG)/make.thornlist $(patsubst %,$(CCTK_LIBDIR)/lib%.a,$(notdir $(THORNS))) $(CCTK_LIBDIR)/libCCTK.a
@echo $(DIVIDER)
diff --git a/lib/make/make.post b/lib/make/make.post
new file mode 100644
index 00000000..32d64bed
--- /dev/null
+++ b/lib/make/make.post
@@ -0,0 +1,14 @@
+# /*@@
+# @file make.post
+# @date Mon Jan 18 19:17:14 1999
+# @author Tom Goodale
+# @desc
+# Post wrapper after including a make.code.defn file in a
+# subdirectory.
+# @enddesc
+# @@*/
+
+# This is a simply expanded variable (i.e. :=, rather than =)
+# and is used to track all source files
+
+CCTK_SRCS += $(addprefix $(CCTK_THIS_SUBDIR)/, $(SRCS))
diff --git a/lib/make/make.pre b/lib/make/make.pre
new file mode 100644
index 00000000..c1a92711
--- /dev/null
+++ b/lib/make/make.pre
@@ -0,0 +1,13 @@
+# /*@@
+# @file make.pre
+# @date Mon Jan 18 19:15:50 1999
+# @author Tom Goodale
+# @desc
+# Pre wrapper before including a make.code.defn file in a
+# subdirectory.
+# @enddesc
+# @version $Id$
+# @@*/
+
+# Reset SRCS just in case someone uses +=
+SRCS =
diff --git a/lib/make/make.subdir b/lib/make/make.subdir
new file mode 100644
index 00000000..82a72ac7
--- /dev/null
+++ b/lib/make/make.subdir
@@ -0,0 +1,36 @@
+# /*@@
+# @file make.subdir
+# @date Mon Jan 18 19:12:31 1999
+# @author Tom Goodale
+# @desc
+# Makes the object files in a subdirectory
+# @enddesc
+# @version $Id$
+# @@*/
+
+# Silence all but designated output
+.SILENT:
+
+# Include the main make definitions for this configuration
+include $(CONFIG)/make.config.defn
+
+# Add appropriate include lines
+INC_DIRS += $(SRCDIR) $(SRCDIR)/include $(CONFIG) $(CCTK_HOME)/src/include
+
+# Include the subdirectories local include data
+include $(SRCDIR)/make.code.defn
+
+# Turn source file names into object file names
+OBJS = $(patsubst %,%.o,$(basename $(SRCS)))
+
+# Build all the object files
+.PHONY:all
+
+all: $(OBJS)
+
+# Rules to make the object files
+include $(CONFIG)/make.config.rules
+
+# Extra subdir-specific dependencies
+include $(SRCDIR)/make.code.deps
+
diff --git a/lib/make/make.thornlib b/lib/make/make.thornlib
index 70dc440b..389bb0f8 100644
--- a/lib/make/make.thornlib
+++ b/lib/make/make.thornlib
@@ -17,14 +17,32 @@ include $(CONFIG)/make.config.defn
# Add appropriate include lines
INC_DIRS += $(SRCDIR) $(SRCDIR)/include $(CONFIG) $(CCTK_HOME)/src/include
+# Define some make variables
+PRE_WRAPPER = make.pre
+POST_WRAPPER = make.post
+
+CCTK_SRCS :=
+
# Include the thorn's local include data
include $(SRCDIR)/make.code.defn
+# Some extra stuff to allow make to recurse into subdirectories
+CCTK_SRCS += $(SRCS)
+
+# Include all the make.code.defn files for the subdirectories
+# These have to be wrapped to allow us to concatanate all the
+# SRCS definitions, complete with subdirectory names.
+ifneq ($(strip $(SUBDIRS)),)
+include $(foreach DIR,$(SUBDIRS), $(DIR)/make.identity $(MAKE_DIR)/$(PRE_WRAPPER) $(SRCDIR)/$(DIR)/make.code.defn $(MAKE_DIR)/$(POST_WRAPPER))
+endif
+
+SRCS = $(CCTK_SRCS)
+
# Turn source file names into object file names
OBJS = $(patsubst %,%.o,$(basename $(SRCS)))
-$(NAME): $(OBJS)
- echo Creating or updating $(NAME)
+$(NAME): $(addsuffix .check, $(SUBDIRS)) $(OBJS) $(SRCDIR)/make.code.defn $(foreach DIR,$(SUBDIRS), $(SRCDIR)/$(DIR)/make.code.defn)
+ @echo Creating or updating $(NAME)
$(AR) $(ARFLAGS) $@ $(OBJS)
# $(RANLIB) $@
@@ -33,3 +51,17 @@ include $(CONFIG)/make.config.rules
# Extra thorn-specific dependencies
include $(SRCDIR)/make.code.deps
+
+# Extra stuff for allowing make to recurse into directories
+
+# This one makes the object files in the subdirectory
+.PHONY: $(addsuffix .check, $(SUBDIRS))
+
+$(addsuffix .check, $(SUBDIRS)) :
+ if [ ! -d $(basename $@) ] ; then $(MKDIR) $(basename $@) ; fi
+ cd $(basename $@) ; $(MAKE) TOP=$(TOP) CONFIG=$(CONFIG) SRCDIR=$(SRCDIR)/$(basename $@) -f $(MAKE_DIR)/make.subdir
+
+# This one puts a file containing identity info into the build subdirectory
+$(addsuffix /make.identity, $(SUBDIRS)):
+ if [ ! -d $(dir $@) ] ; then mkdir $(dir $@) ; fi
+ echo CCTK_THIS_SUBDIR := $(dir $@) > $@