summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--src/IO/make.code.defn4
-rw-r--r--src/IO/make.code.deps0
-rw-r--r--src/comm/make.code.defn5
-rw-r--r--src/comm/make.code.deps0
-rw-r--r--src/create_make.code.stuff13
-rw-r--r--src/main/make.code.defn18
-rw-r--r--src/main/make.code.deps0
-rw-r--r--src/make.code.defn31
-rw-r--r--src/make.code.deps56
-rw-r--r--src/util/make.code.defn8
-rw-r--r--src/util/make.code.deps0
16 files changed, 138 insertions, 104 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 $@) > $@
diff --git a/src/IO/make.code.defn b/src/IO/make.code.defn
new file mode 100644
index 00000000..ca36d274
--- /dev/null
+++ b/src/IO/make.code.defn
@@ -0,0 +1,4 @@
+SRCS=\
+CactusDefaultIO.c\
+RegisterIOFunction.c\
+
diff --git a/src/IO/make.code.deps b/src/IO/make.code.deps
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/IO/make.code.deps
diff --git a/src/comm/make.code.defn b/src/comm/make.code.defn
new file mode 100644
index 00000000..094b4e70
--- /dev/null
+++ b/src/comm/make.code.defn
@@ -0,0 +1,5 @@
+SRCS=\
+CactusDefaultComm.c\
+GHExtensions.c\
+RegisterCommFunction.c\
+
diff --git a/src/comm/make.code.deps b/src/comm/make.code.deps
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/comm/make.code.deps
diff --git a/src/create_make.code.stuff b/src/create_make.code.stuff
deleted file mode 100644
index 9d8ea5ed..00000000
--- a/src/create_make.code.stuff
+++ /dev/null
@@ -1,13 +0,0 @@
-# These are commands which can be used to automatically create make.code.defn
-# and make.code.deps stuff where there are subdirectories.
-# Hopefully the finalmake system won't need these -- Tom
-#
-
-find . -name '*.c' -o -name '*.cc' | perl -p -e 's:\./::' | grep -v datestamp.c | awk 'BEGIN {print "SRCS=\\"}; {print $0 "\\"} END {print
-""};' - > make.code.defn
-
-find . -name '*.c' | perl -p -e 's,(.*)\.(.*),\1\.o:\$(SRCDIR)/\1.\2\n\t\$(CC) \$(CFLAGS) -o \$\@ -c \$< \$(addprefix -I\,\$(INC_DIRS)),' > make.code.deps
-
-find . -name '*.cc' | perl -p -e 's,(.*)\.(.*),\1\.o:\$(SRCDIR)/\1.\2\n\t\$(CXX) \$(CXXFLAGS) -o \$\@ -c \$< \$(addprefix -I\,\$(INC_DIRS)),' >> make.code.deps
-
-
diff --git a/src/main/make.code.defn b/src/main/make.code.defn
new file mode 100644
index 00000000..499d09d8
--- /dev/null
+++ b/src/main/make.code.defn
@@ -0,0 +1,18 @@
+SRCS=\
+CactusDefaultEvolve.c\
+CactusDefaultInitialise.c\
+CallStartupFunctions.c\
+ConfigData.c\
+CreateGroup.c\
+InitialiseCactus.c\
+InitialiseDataStructures.c\
+ProcessCommandLine.c\
+ProcessParameterDatabase.c\
+RecordImplementation.c\
+RegisterMainFunction.c\
+RegisterThorn.c\
+SetParams.c\
+ShutdownCactus.c\
+StoreVariableData.c\
+flesh.cc\
+
diff --git a/src/main/make.code.deps b/src/main/make.code.deps
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/main/make.code.deps
diff --git a/src/make.code.defn b/src/make.code.defn
index e5974870..b268651e 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -1,29 +1,2 @@
-SRCS=\
-IO/CactusDefaultIO.c\
-IO/RegisterIOFunction.c\
-comm/CactusDefaultComm.c\
-comm/RegisterCommFunction.c\
-comm/GHExtensions.c\
-main/CactusDefaultInitialise.c\
-main/CallStartupFunctions.c\
-main/InitialiseCactus.c\
-main/ProcessCommandLine.c\
-main/ProcessParameterDatabase.c\
-main/RegisterMainFunction.c\
-main/ShutdownCactus.c\
-main/flesh.cc\
-main/CactusDefaultEvolve.c\
-main/SetParams.c\
-main/InitialiseDataStructures.c\
-main/RecordImplementation.c\
-main/RegisterThorn.c\
-main/CreateGroup.c\
-main/StoreVariableData.c\
-main/ConfigData.c\
-util/RegisterKeyedFunction.c\
-util/StoreKeyedData.c\
-util/StoreNamedData.c\
-util/BinaryTree.c\
-util/CactusTimers.c\
-util/ParseFile.c\
-util/ParseFile.c
+SRCS =
+SUBDIRS = IO comm rfr util main
diff --git a/src/make.code.deps b/src/make.code.deps
index 6b004a22..e69de29b 100644
--- a/src/make.code.deps
+++ b/src/make.code.deps
@@ -1,56 +0,0 @@
-./IO/CactusDefaultIO.o:$(SRCDIR)/./IO/CactusDefaultIO.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./IO/RegisterIOFunction.o:$(SRCDIR)/./IO/RegisterIOFunction.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./comm/CactusDefaultComm.o:$(SRCDIR)/./comm/CactusDefaultComm.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./comm/RegisterCommFunction.o:$(SRCDIR)/./comm/RegisterCommFunction.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./comm/GHExtensions.o:$(SRCDIR)/./comm/GHExtensions.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/CactusDefaultInitialise.o:$(SRCDIR)/./main/CactusDefaultInitialise.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/CallStartupFunctions.o:$(SRCDIR)/./main/CallStartupFunctions.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/InitialiseCactus.o:$(SRCDIR)/./main/InitialiseCactus.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/ProcessCommandLine.o:$(SRCDIR)/./main/ProcessCommandLine.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/ProcessParameterDatabase.o:$(SRCDIR)/./main/ProcessParameterDatabase.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/RegisterMainFunction.o:$(SRCDIR)/./main/RegisterMainFunction.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/ShutdownCactus.o:$(SRCDIR)/./main/ShutdownCactus.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/CactusDefaultEvolve.o:$(SRCDIR)/./main/CactusDefaultEvolve.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/SetParams.o:$(SRCDIR)/./main/SetParams.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/InitialiseDataStructures.o:$(SRCDIR)/./main/InitialiseDataStructures.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/RecordImplementation.o:$(SRCDIR)/./main/RecordImplementation.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/RegisterThorn.o:$(SRCDIR)/./main/RegisterThorn.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/CreateGroup.o:$(SRCDIR)/./main/CreateGroup.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/StoreVariableData.o:$(SRCDIR)/./main/StoreVariableData.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/ConfigData.o:$(SRCDIR)/./main/ConfigData.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/RegisterKeyedFunction.o:$(SRCDIR)/./util/RegisterKeyedFunction.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/StoreKeyedData.o:$(SRCDIR)/./util/StoreKeyedData.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/StoreNamedData.o:$(SRCDIR)/./util/StoreNamedData.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/BinaryTree.o:$(SRCDIR)/./util/BinaryTree.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/CactusTimers.o:$(SRCDIR)/./util/CactusTimers.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./util/ParseFile.o:$(SRCDIR)/./util/ParseFile.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./datestamp.o:$(SRCDIR)/./datestamp.c
- $(CC) $(CFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
-./main/flesh.o:$(SRCDIR)/./main/flesh.cc
- $(CXX) $(CXXFLAGS) -o $@ -c $< $(addprefix -I,$(INC_DIRS))
diff --git a/src/util/make.code.defn b/src/util/make.code.defn
new file mode 100644
index 00000000..3b7274fb
--- /dev/null
+++ b/src/util/make.code.defn
@@ -0,0 +1,8 @@
+SRCS=\
+BinaryTree.c\
+CactusTimers.c\
+ParseFile.c\
+RegisterKeyedFunction.c\
+StoreKeyedData.c\
+StoreNamedData.c\
+
diff --git a/src/util/make.code.deps b/src/util/make.code.deps
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/util/make.code.deps