summaryrefslogtreecommitdiff
path: root/lib/make/make.configuration
blob: 06fc172bd891341b13d5f3944c37d9e666c9972f (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
95
96
97
#/*@@
#  @file      make.configuration
#  @date      Sun Jan 17 22:15:23 1999
#  @author    Tom Goodale
#  @desc 
#  Makes the CCTK executable for a particulare configuration
#  @enddesc 
#  @version $Id$
# @@*/

# Some configuration variables
CONFIG = $(TOP)/config-data

DATESTAMP = $(CCTK_HOME)/src/datestamp.c
MAKE_DIR  = $(CCTK_HOME)/lib/make

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

# Include the definitions for this configuration
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)
	@echo Creating $(EXE) from $(THORNS)
	$(CC) -c $(DATESTAMP) -o $(TOP)/datestamp.o
	$(CC) -o $@ $(LDFLAGS) $(TOP)/datestamp.o  -L$(CCTK_LIBDIR) $(addprefix -l,$(notdir $(THORNS))) -lCCTK $(LIBDIRS:%=-L%) $(LIBS:%=-l%)
	@echo $(DIVIDER)
	@echo All done !
	@echo $(DIVIDER)

# Build a thorn library
# Libraries go into the appropriate library directory
# Each thorn's object files go into $(BUILD_DIR)/<thorn>
# This makes sure the appropriate build directories exist
# Also checks for the existance of Makefile in the thorn's
# src directory, and calls that rather than the default makefile
# used for making thorn libraries.
$(CCTK_LIBDIR)/lib%.a: update
	@echo $(DIVIDER)
	@echo Checking status of $(notdir $@)
	if [ ! -d $(BUILD_DIR) ]; then $(MKDIR) $(BUILD_DIR) ; fi
	if [ ! -d $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%) ]; then $(MKDIR) $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%) ; fi
	cd $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%); \
	if [ -e $(@:$(CCTK_LIBDIR)/lib%.a=$(TOOLKIT_DIR)/$(filter %$(@:$(CCTK_LIBDIR)/lib%.a=%),$(THORNS))/src)/Makefile ] ; \
	then $(MAKE) TOP=$(TOP) SRCDIR=$(@:$(CCTK_LIBDIR)/lib%.a=$(TOOLKIT_DIR)/$(filter %$(@:$(CCTK_LIBDIR)/lib%.a=%),$(THORNS))/src) CONFIG=$(CONFIG) NAME=$@ -f $(@:$(CCTK_LIBDIR)/lib%.a=$(TOOLKIT_DIR)/$(filter %$(@:$(CCTK_LIBDIR)/lib%.a=%),$(THORNS))/src)/Makefile ; \
	else $(MAKE) TOP=$(TOP) SRCDIR=$(@:$(CCTK_LIBDIR)/lib%.a=$(TOOLKIT_DIR)/$(filter %$(@:$(CCTK_LIBDIR)/lib%.a=%),$(THORNS))/src) CONFIG=$(CONFIG) NAME=$@ -f $(MAKE_DIR)/make.thornlib ; \
	fi
	@echo $(DIVIDER)


# Slightly modified rule for the flesh.
# Also makes sure all the subdirectories are made.
$(CCTK_LIBDIR)/libCCTK.a: update
	@echo $(DIVIDER)
	@echo Checking status of the flesh
	if [ ! -d $(BUILD_DIR) ]; then $(MKDIR) $(BUILD_DIR) ; fi
	if [ ! -d $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%) ]; then $(MKDIR) $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%) ; \
	for dir in IO comm main util rfr ; \
	do if [ ! -d $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%)/$$dir ] ; then $(MKDIR) $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%)/$$dir ; fi ; \
	done ; fi 
	cd $(@:$(CCTK_LIBDIR)/lib%.a=$(BUILD_DIR)/%); \
	$(MAKE) TOP=$(TOP) SRCDIR=$(CCTK_HOME)/src CONFIG=$(CONFIG) NAME=$@ -f $(MAKE_DIR)/make.thornlib
	@echo $(DIVIDER)


# Include any extra dependencies

include $(CONFIG)/make.config.deps

# Rule to build the make.thornlist file from the ActiveThorns file

$(CONFIG)/make.thornlist: $(TOP)/ActiveThorns
	@echo Currently $@ must be edited by hand.
	if [ ! -r $@ ] ; then touch $@ ; fi

# Rule to build ActiveThorns

$(TOP)/ActiveThorns:
	@echo Currently $@ must be created by hand and has no effect !
	if [ ! -r $@ ] ; then echo This file doesn\'t do anything yet > $@ ; fi

# Phony targets.

.PHONY:update clean
update:

clean:
	find $(TOP) -name '*.o' -o -name '*.a' -exec rm {} \;