-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
249 lines (197 loc) · 7.77 KB
/
Makefile
File metadata and controls
249 lines (197 loc) · 7.77 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Makefile
# Bernd Bruegmann, 12/99, 5/02, Wolfgang Tichy 4/2005
# Builds the sgrid executable based on the file MyConfig
# See http://www.gnu.org/software/make/manual for the manual of GNU make
# where am I
UNAME := $(shell uname)
TOP := $(shell pwd)
## to shorten the output: about to be removed for non-standard directories
#TOP := ../../..
# name the fruit of our labor
EXEC = sgrid
EXECDIR = $(TOP)/exe
RELAPROJECTDIR = src/Projects
PROJECTDIR = $(TOP)/$(RELAPROJECTDIR)
# variables common to all setups
CC = gcc # gcc or icc
CXX = # g++ or icc
CLINKER = # will be used only in src/main/main/Makefile for linking
AR = ar # ar command we use to build library from object files
INCS = -I$(TOP)/src/main/main
LIBS = -L$(TOP)/lib
SPECIALINCS =
SPECIALLIBS =
libsys = -lm
DFLAGS =
OFLAGS =
WARN = # -Wall
# --------------------------------------------------------------------------
# different machines and environments
# Linux
OFLAGS = -O2
#CC = icc: quite different compared to Cactus: icc gives slower results!
# --------------------------------------------------------------------------
# some libraries are currently required
libpaths = src/main/MemoryMan src/utility/ParManipulator
libpaths += src/utility/Spectral
libpaths += src/utility/boundary
libpaths += src/utility/output src/utility/evolve
libpaths += src/utility/NumberChecker
libpaths += src/utility/checkpoint
# --------------------------------------------------------------------------
# the user choses the libraries and some options in the file MyConfig
projects =#
include MyConfig
# --------------------------------------------------------------------------
# set variable projectnames from git targets in projects. NOTE: there must
# be a / just before the actual projectname (e.g. mars.fau.edu:/DNSdata)
projectbasenames = $(basename $(projects))
projectnames = $(notdir $(projectbasenames))
# set projectpaths and add them to libpaths
projectpaths = $(addprefix $(RELAPROJECTDIR)/,$(projectnames))
libpaths += $(projectpaths)
# --------------------------------------------------------------------------
# some more libraries are currently required, those need to be last
libpaths += src/utility/Coordinates
#libpaths += src/utility/NumericUtils
# check if we have old NumericUtils, if not add new numerics
ifneq ($(findstring NumericUtils,$(libpaths)),NumericUtils)
libpaths += src/utility/numerics
endif
# --------------------------------------------------------------------------
# set CXX and CLINKER to CC if they are not set in MyConfig
ifeq ($(CXX),)
CXX = $(CC)
endif
ifeq ($(CLINKER),)
CLINKER = $(CC)
endif
# --------------------------------------------------------------------------
# manage how the sgrid sources are compiled
# note that the order matters, e.g.
# main has to go last since it has to be compiled last
libpaths += src/main/main
# extract the list of directory names
libdirs = $(dir $(libpaths))
# extract list of names
libnames = $(notdir $(libpaths))
# make the list of libraries
liblist := $(foreach libname,$(libnames),-l$(libname))
# remove -lmain from that list
liblist := $(subst -lmain,,$(liblist))
# make final list of libraries that is passed to the linker
# uses standard hack to resolve interdependencies by repeating the libraries
# system libraries go in the end
LIBS += $(MPIDIRL) $(liblist) $(liblist)
LIBS += $(SPECIALLIBS) $(libsys) $(MPILIBS)
# make the list of include files that will be automatically included for each
# module
libincludes := $(foreach libpath,$(libpaths),\
$(libpath)/sgrid_$(notdir $(libpath)).h)
# define the automatic configuration files
autoinclude = src/main/main/sgrid_automatic_include.h
autoinitial = src/main/main/sgrid_automatic_initialize.c
autotext = \/\* automatically generated from MyConfig \*\/
# --------------------------------------------------------------------------
# some of the above variables are meant to be global, so pass them on
# to the shell
CFLAGS = $(DFLAGS) $(OFLAGS) $(INCS) $(MPIDIRI) $(HDF5DIRI) $(SPECIALINCS) $(WARN)
export
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# default target
sgrid: $(autoinclude) $(autoinitial)
@echo CC=$(CC)
@echo CXX=$(CXX)
@echo CLINKER=$(CLINKER)
for X in $(libnames); do mkdir -p lib/obj/$$X; done
for X in $(libpaths); do $(MAKE) -C $$X; done
# --------------------------------------------------------------------------
# other targets
# if there is no MyConfig file, use the example provided in doc
MyConfig:
-if test ! -f MyConfig; then cp doc/MyConfig.example MyConfig; $(MAKE) git_clone; fi
# automatic configuration files
$(autoinclude): MyConfig
echo $(autotext) > $(autoinclude)
for X in $(libincludes); do \
echo \#include \"$(TOP)/$$X\" >> $(autoinclude); \
done
$(autoinitial): MyConfig
echo $(autotext) > $(autoinitial)
for X in $(libnames); do \
echo int sgrid\_$$X\(\)\; >> $(autoinitial); \
done
echo "/* call sgrid initialization functions: */" >> $(autoinitial); \
for X in $(libnames); do \
echo sgrid\_$$X\(\)\; >> $(autoinitial); \
done
# create tar file
tar:
cd ..; tar cf sgrid.tar --exclude lib --exclude exe --exclude .git ./sgrid
mv ../sgrid.tar ../sgrid_"$$(git rev-parse --short HEAD)".tar
# create tarfile for compiling libsgrid with DNSdata
tar_DNSlibsgrid:
mv MyConfig MyConfig.temp001
cp doc/MyConfig.DNSlibsgrid MyConfig
$(MAKE) git_clone
$(MAKE) tar
rm -f MyConfig
mv MyConfig.temp001 MyConfig
# take a fresh look at things
clean:
-rm -r lib
-rm $(autoinclude)
-rm $(autoinitial)
# remove emacs backup files
cleantilde:
find . -name "*~" -exec rm {} \;
# print some vars
printvars:
@echo projects=$(projects)
@echo PROJECTDIR=$(PROJECTDIR)
@echo projectpaths=$(projectpaths)
@echo projectnames=$(projectnames)
@echo libpaths=$(libpaths)
# targets to get git projects
git_clone:
@echo ==================== Cloning sgrid projects ====================
-for X in $(projects); do N=$$(basename $$X .git); printf "==== %s ====\n" $$N; git clone $$X $(PROJECTDIR)/$$N; done
# @$(MAKE) install_git_hooks
#git_pull: install_git_hooks
git_pull:
@echo ====================== main part of sgrid ======================
git pull
@echo ======================== sgrid projects ========================
@for X in $(projects); do N=$$(basename $$X .git); if [ -d "$(PROJECTDIR)/$$N" ]; then printf "==== %s ====\n" $$N; cd $(PROJECTDIR)/$$N; git pull; fi done
git_status:
@echo ====================== main part of sgrid ======================
git status -uno
@echo ======================== sgrid projects ========================
@for X in $(projects); do N=$$(basename $$X .git); if [ -d "$(PROJECTDIR)/$$N" ]; then printf "==== %s ====\n" $$N; cd $(PROJECTDIR)/$$N; git status -uno; fi done
# remove code that is not needed once the corresponding libs have been built
rm_MemoryMan_code:
find src/main/MemoryMan/ -name "*.c*" -print -exec rm -rf '{}' \;
find src/main/MemoryMan/ -name "*.m*" -print -exec rm -rf '{}' \;
echo -e "ls:\n\tls *.h" > donothing_Makefile
find src/main/MemoryMan/ -name "Makefile" -print -exec cp -f donothing_Makefile '{}' \;
rm -f donothing_Makefile
rm_Math_code:
rm -rf src/Math
rm_utility_code:
find src/utility/ -name "*.c*" -print -exec rm -rf '{}' \;
find src/utility/ -name "*.m*" -print -exec rm -rf '{}' \;
echo -e "ls:\n\tls *.h" > donothing_Makefile
find src/utility/ -name "Makefile" -print -exec cp -f donothing_Makefile '{}' \;
rm -f donothing_Makefile
rm_physics_code:
find src/physics/ -name "*.c*" -print -exec rm -rf '{}' \;
find src/physics/ -name "*.m*" -print -exec rm -rf '{}' \;
echo -e "ls:\n\tls *.h" > donothing_Makefile
find src/physics/ -name "Makefile" -print -exec cp -f donothing_Makefile '{}' \;
rm -f donothing_Makefile
rm_code:
make rm_MemoryMan_code
make rm_Math_code
make rm_utility_code
make rm_physics_code