summaryrefslogtreecommitdiff
path: root/lib/make/make.thornlib
blob: 80dbf04666b191b4740490f6f349416a3d82dc83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# /*@@
#   @file      make.thornlib
#   @date      Sun Jan 17 22:20:45 1999
#   @author    Tom Goodale
#   @desc 
#   Creates the library for a particular thorn
#   @enddesc 
#   @version $Id$
# @@*/

# Silence all but designated output
#.SILENT:

# Dividers to make the screen output slightly nicer
DIVEL   =  __________________
DIVIDER =  $(DIVEL)$(DIVEL)$(DIVEL)$(DIVEL)

# Include the main make definitions for this configuration
include $(CONFIG)/make.config.defn

# Add appropriate include lines
INC_DIRS = $(SYS_INC_DIRS) $(SRCDIR) $(SRCDIR)/include $(CONFIG) $(TOP)/bindings/include $(CCTK_HOME)/src/include $(CCTK_HOME)/arrangements

# Allow subdirectories to inherit these include directories
export INC_DIRS

EXTRA_DEFINES += THORN_IS_$(THORN) 

# 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)

# Protect the value of SRCS and SUBDIRS of this directory
LOCAL_SRCS := $(SRCS)
LOCAL_SUBDIRS := $(SUBDIRS)

# 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.
# Using -include to prevent warnings the first time the make.identity files 
# need to be made.
ifneq ($(strip $(LOCAL_SUBDIRS)),)
-include $(foreach DIR,$(LOCAL_SUBDIRS), $(DIR)/make.identity $(MAKE_DIR)/$(PRE_WRAPPER) $(SRCDIR)/$(DIR)/make.code.defn $(MAKE_DIR)/$(POST_WRAPPER))
endif

# Restore the value of SRCS and SUBDIRS of this directory
SRCS = $(CCTK_SRCS)
SUBDIRS = $(LOCAL_SUBDIRS)

# Turn source file names into object file names
OBJS = $(patsubst %,%.o,$(basename $(SRCS)))

$(NAME): $(addsuffix .check, $(SUBDIRS)) $(OBJS) $(SRCDIR)/make.code.defn $(foreach DIR,$(SUBDIRS), $(SRCDIR)/$(DIR)/make.code.defn)
	@echo $(DIVIDER)
	if [ -r $(NAME) ] ; then echo Updating $(NAME) ; else echo Creating $(NAME) ; fi
	if [ -r $@ ] ; then rm $@ ; fi
	$(AR) $(ARFLAGS) $@ $(OBJS)
#	$(RANLIB) $@

# Rules to make the object files
include $(CONFIG)/make.config.rules

# Extra thorn-specific dependencies
# This file isn't strictly necessary, so use -include to prevent 
# warnings if it is missing.
-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 $@) THORN=$(THORN) -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 $@) > $@

# Dependency stuff

ifneq ($(strip $(LOCAL_SRCS)),)
-include $(patsubst %,%.d,$(basename $(LOCAL_SRCS)))
endif