aboutsummaryrefslogtreecommitdiff
path: root/src/make.configuration.deps
blob: 5b694e6151db51702c947b312e5bc7c5470a0da5 (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
# make.configuration.deps file for thorn Formaline   -*-Makefile-*-
# $Header$



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

TARBALL_DIR = $(SCRATCH_BUILD)



CACTUSLIBLINKLINE += $(TARBALL_DIR)/cactus-source.a

$(EXEDIR)$(DIRSEP)$(EXE): $(TARBALL_DIR)/cactus-source.a

$(TARBALL_DIR)/cactus-source.a: $(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) $@ $^
	@echo $(DIVIDER)

## 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 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 'static char const build_id[] = "'$id'";'; \
	echo 'char const * Formaline_BuildID (void)'; \
	echo '{'; \
	echo '  return build_id;'; \
	echo '}'; \
	} > $@



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



# 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
	$(TARBALL_DIR)/makeblob '' Cactus < $< > $@

$(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, but that is okay.
$(TARBALL_DIR)/cactus-flesh-source.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Cactus$(LIBNAME_SUFFIX)
	cd $(CCTK_HOME) && \
	find CONTRIBUTORS COPYRIGHT Makefile lib src \
		configs/$(notdir $(TOP))/config-info \
		configs/$(notdir $(TOP))/ThornList \
		-name '.*' -prune -o \
		-name '*~' -prune -o \
		-not -type d \
		-print > $@



# 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
	$(TARBALL_DIR)/makeblob $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.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, but that is okay.
$(TARBALL_DIR)/cactus-thorn-source-%.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX)
	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 > $@



## 1. Create a list of files that should be in the tarball
## 2. Create the tarball
## 3. Use the makeblob utility (from this thorn; see make.code.deps)
##    to create C source code from the tarball
## 4. Compile C code and create an archive
#
#.PHONY: make-tarball
#make-tarball:
#	@echo "Creating source tarball..." && \
#	cd $(CCTK_HOME) && \
#	files="CONTRIBUTORS COPYRIGHT Makefile" && \
#	dirs="lib src" && \
#	thorns="$(THORNS:%=arrangements/%)" && \
#	filelist=$(TARBALL_DIR)/source-file-list && \
#	find $$files $$dirs $$thorns \
#		-path 'arrangements/*/*/doc' -prune \
#		-o -path 'arrangements/*/*/test' -prune \
#		-o -path 'arrangements/*/*/par' -prune \
#		-o -print > $$filelist && \
#	echo "Adding" `cat $$filelist | wc -l` "files..." && \
#	tar czf "$(TARBALL_DIR)/cactus-source.tar.gz" \
#		--no-recursion -T $$filelist && \
#	echo "Created tarball with" `cat $(TARBALL_DIR)/cactus-source.tar.gz | wc -c` "bytes..." && \
#	cd $(TARBALL_DIR) && \
#	rm -rf cactus-source && \
#	mkdir cactus-source && \
#	cd cactus-source && \
#	../makeblob < ../cactus-source.tar.gz && \
#	$(CC) $(CFLAGS) -c *.c && \
#	cd .. && \
#	$(AR) $(ARFLAGS) cactus-source.a cactus-source/*.o && \
#	echo "Added tarball to executable." && \
#	echo $(DIVIDER)