aboutsummaryrefslogtreecommitdiff
path: root/src/make.configuration.deps
blob: da0f163edd9cef6af60b5de07ef063168075ce20 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# make.configuration.deps file for thorn Formaline   -*-Makefile-*-
# $Header$



# Some configury magic

TAR = $(shell gtar > /dev/null 2> /dev/null && echo gtar || echo tar)



# Create a tarball of the source code whenever this thorn is linked
# into an executable

TARBALL_DIR = $(SCRATCH_BUILD)



#CACTUSLIBLINKLINE += $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline-cactus-source$(LIBNAME_SUFFIX)
CACTUSLIBLINKLINE += -l$(CCTK_LIBNAME_PREFIX)Formaline-cactus-source

$(EXEDIR)$(DIRSEP)$(EXE): $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline-cactus-source$(LIBNAME_SUFFIX)

$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline-cactus-source$(LIBNAME_SUFFIX): $(TARBALL_DIR)/cactus-meta-source.o $(TARBALL_DIR)/build-id.o $(TARBALL_DIR)/cactus-flesh-source.o $(patsubst %,$(TARBALL_DIR)/cactus-thorn-source-%.o,$(notdir $(THORNS)))
	$(AR) $(ARFLAGS) $@ $^
	if test "x$(USE_RANLIB)" = "xyes" ; then $(RANLIB) $(RANLIBFLAGS) $@ ; fi
	@echo $(DIVIDER)

.PRECIOUS: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline-cactus-source$(LIBNAME_SUFFIX)

## Cache optimisation:
## Build the thorns' tarballs already while the thorns are compiled
## (does not work)
#
#$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX): $(TARBALL_DIR)/cactus-thorn-source-%.o



# Unique ID for the build
$(TARBALL_DIR)/build-id.o: $(TARBALL_DIR)/build-id.c
	$(CC) $(CFLAGS) -c -o $@ $^

# (force a new ID to be created every time)
.PHONY: $(TARBALL_DIR)/build-id.c
$(TARBALL_DIR)/build-id.c:
	{ \
	echo '/* This is an auto-generated file -- do not edit */'; \
	hostname=`hostname`; \
	user="$$USER"; \
	timestamp=`date +%Y%m%d-%H%M%S`; \
	pid="$$$$"; \
	id="build-$$hostname-$$user-$$timestamp-$$pid"; \
	echo 'char const build_id[] = "'$$id'";'; \
	} > $@

.PRECIOUS: $(TARBALL_DIR)/build-id.c $(TARBALL_DIR)/build-id.o



# Meta information
$(TARBALL_DIR)/cactus-meta-source.o: $(TARBALL_DIR)/cactus-meta-source.c
	$(CC) $(CFLAGS) -c -o $@ $^

$(TARBALL_DIR)/cactus-meta-source.c: $(TARBALL_DIR)/cactus-flesh-source.c $(patsubst %,$(TARBALL_DIR)/cactus-thorn-source-%.c,$(notdir $(THORNS)))
	$(TARBALL_DIR)/makemetablob Cactus $(notdir $(THORNS)) > $@

.PRECIOUS: $(TARBALL_DIR)/cactus-meta-source.c $(TARBALL_DIR)/cactus-meta-source.o



#cleandeps:
#	rm -rf $(TOP)/scratch/cactus-flesh-source.files $(TOP)/scratch/cactus-flesh-source.ccldeps $(TOP)/scratch/cactus-thorn-source-*.files $(TOP)/scratch/cactus-thorn-source-*.ccldeps



###############################################################################
# Flesh
###############################################################################

$(TARBALL_DIR)/cactus-flesh-source.o: $(TARBALL_DIR)/cactus-flesh-source.c
	@echo "Creating tarball for the flesh"
	$(CC) $(CFLAGS) -c -o $@ $^

$(TARBALL_DIR)/cactus-flesh-source.c: $(TARBALL_DIR)/cactus-flesh-source.tar.gz $(CCTK_HOME)/arrangements/AEIThorns/Formaline/src/util/VERSION
	$(TARBALL_DIR)/makeblob '' Cactus $(@:%.c=%) < $< > $@

$(TARBALL_DIR)/cactus-flesh-source.tar.gz: $(TARBALL_DIR)/cactus-flesh-source.files
	cd $(CCTK_HOME) && \
	$(TAR) czf $@ -T $<

# This dependency means that the tarball for a thorn is only updated
# if the thorn is actually recompiled.  This does not catch changes to
# files that do not influence the executable.
$(TARBALL_DIR)/cactus-flesh-source.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)$(FLESHLIB)$(LIBNAME_SUFFIX) $(TARBALL_DIR)/cactus-flesh-source.ccldeps
	cd $(CCTK_HOME) && \
	find CONTRIBUTORS COPYRIGHT Makefile lib src \
		configs/$(notdir $(TOP))/ThornList \
		configs/$(notdir $(TOP))/config-data \
		configs/$(notdir $(TOP))/config-info \
		-name '.*' -prune -o \
		-name '*~' -prune -o \
		-not -type d \
		-print > $@

-include $(TARBALL_DIR)/cactus-flesh-source.ccldeps
# Make aborts if these dependencies vanish.  Therefore mention only files
# here that cannot go away.
$(TARBALL_DIR)/cactus-flesh-source.ccldeps:
	{ \
	        echo "$(@:%.ccldeps=%.files) \\"; \
	        echo "$@: \\"; \
	        echo " $(CCTK_HOME)/src/interface.ccl \\"; \
	        echo " $(CCTK_HOME)/src/param.ccl \\"; \
	        echo " $(CCTK_HOME)/src/schedule.ccl"; \
	} > $@

.PRECIOUS: $(TARBALL_DIR)/cactus-flesh-source.ccldeps $(TARBALL_DIR)/cactus-flesh-source.files $(TARBALL_DIR)/cactus-flesh-source.tar.gz $(TARBALL_DIR)/cactus-flesh-source.c $(TARBALL_DIR)/cactus-flesh-source.o



###############################################################################
# Thorns
###############################################################################

$(TARBALL_DIR)/cactus-thorn-source-%.o: $(TARBALL_DIR)/cactus-thorn-source-%.c
	@echo "Creating tarball for thorn $(@:$(TARBALL_DIR)/cactus-thorn-source-%.o=%)"
	$(CC) $(CFLAGS) -c -o $@ $^

$(TARBALL_DIR)/cactus-thorn-source-%.c: $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz $(CCTK_HOME)/arrangements/AEIThorns/Formaline/src/util/VERSION
	$(TARBALL_DIR)/makeblob $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%) $(@:%.c=%) < $< > $@

$(TARBALL_DIR)/cactus-thorn-source-%.tar.gz: $(TARBALL_DIR)/cactus-thorn-source-%.files
	cd $(CCTK_HOME) && \
	$(TAR) czf $@ -T $<

# This dependency means that the tarball for a thorn is only updated
# if the thorn is actually recompiled.  This does not catch changes to
# files that do not influence the executable.
$(TARBALL_DIR)/cactus-thorn-source-%.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX) $(TARBALL_DIR)/cactus-thorn-source-%.ccldeps
	cd $(CCTK_HOME) && \
	find arrangements/$(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.files=%),$(THORNS)) \
		-path 'arrangements/*/*/doc' -prune -o \
		-path 'arrangements/*/*/par' -prune -o \
		-path 'arrangements/*/*/test' -prune -o \
		-name '.*' -prune -o \
		-name '*~' -prune -o \
		-not -type d \
		-print > $@

-include $(patsubst %,$(TARBALL_DIR)/cactus-thorn-source-%.ccldeps,$(notdir $(THORNS)))
# Make aborts if these dependencies vanish.  Therefore mention only files
# here that cannot go away.
$(TARBALL_DIR)/cactus-thorn-source-%.ccldeps:
	{ \
	        echo "$(@:%.ccldeps=%.files) \\"; \
	        echo "$@: \\"; \
	        echo " $(CCTK_HOME)/arrangements/$(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.ccldeps=%),$(THORNS))/interface.ccl \\"; \
	        echo " $(CCTK_HOME)/arrangements/$(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.ccldeps=%),$(THORNS))/param.ccl \\"; \
	        echo " $(CCTK_HOME)/arrangements/$(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.ccldeps=%),$(THORNS))/schedule.ccl"; \
	} > $@

.PRECIOUS: $(TARBALL_DIR)/cactus-thorn-source-%.ccldeps $(TARBALL_DIR)/cactus-thorn-source-%.files $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz $(TARBALL_DIR)/cactus-thorn-source-%.c $(TARBALL_DIR)/cactus-thorn-source-%.o