summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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 $@) > $@