-
Notifications
You must be signed in to change notification settings - Fork 95
/
make.config.in
441 lines (361 loc) · 16.1 KB
/
make.config.in
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# configuration file for BOUT++
# September 2008: Converted to use autoconf. Can be manually edited
# for the (very) rare occasions when autoconf fails
# extra compilation flags:
# -DCHECK=lvl Enables a host of additional checks on each operation
# such as uninitialised data if lvl is > 0. -DCHECK=3
# enables all tests, while -DCHECK=0 disables them.
# Helps when debugging
# -DTRACK Keeps track of variable names.
# Enables more useful error messages
# for SSE2: -msse2 -mfpmath=sse
#
# This must also specify one or more file formats
# -DPDBF PDB format (need to include pdb_format.cxx)
# -DNCDF NetCDF format (nc_format.cxx)
# PETSc config variables need to be first, else they may clobber other
# options (e.g. CXX, CXXFLAGS)
PETSC_DIR ?= @PETSC_DIR@
PETSC_ARCH ?= @PETSC_ARCH@
@PETSC_MAKE_INCLUDE@
SLEPC_DIR ?= @SLEPC_DIR@
SLEPC_ARCH ?= @SLEPC_ARCH@
@SLEPC_MAKE_INCLUDE@
# These lines can be replaced in "make install" to point to install directories
# They are used in the CXXFLAGS variable below rather than hard-coding the directories
BOUT_INCLUDE_PATH=$(BOUT_TOP)/include
BOUT_LIB_PATH=$(BOUT_TOP)/lib
BOUT_CONFIG_FILE=$(BOUT_TOP)/make.config
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
# This path to the locale (.mo) files is hard-wired into bout++.cxx at compile time
BOUT_LOCALE_PATH=@localedir@
# Created this variable so that a user won't overwrite the CXXFLAGS variable
# on the command line, just add to this one
BOUT_FLAGS = $(CXXFLAGS) @CXXFLAGS@ @OPENMP_CXXFLAGS@ @COVERAGE_FLAGS@
#Use := here to force a "static" evaluation of the current state of BOUT_FLAGS to
#avoid infinite recursion that would arise if BOUT_FLAGS appeared on both sides of =
BOUT_FLAGS := $(BOUT_FLAGS) -DBOUT_FLAGS_STRING="$(BOUT_FLAGS)"
# Specify the MPI C++ compiler in CXX
CXX = @CXX@
CC = $(CXX)
AR = ar
ARFLAGS = @ARFLAGS@
RANLIB = @RANLIB@
MKDIR = @MKDIR_P@
####################################################################
# Do not need to alter anything below
####################################################################
LD = $(CXX)
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
CPPFLAGS = @CPPFLAGS@
####################################################################
# Extra (optional) source files, includes and libs
# NOTE: EXTRA_SRC must include a solver (solver.cxx or ida_solver.cxx)
# and a file format (nc_format.cxx or pdb_format.cxx)
####################################################################
EXTRA_INCS = $(CPPFLAGS) @EXTRA_INCS@
EXTRA_LIBS = $(LIBS) @EXTRA_LIBS@ @OPENMP_CXXFLAGS@
PRECON_SOURCE = @PRECON_SOURCE@
BOUT_VERSION = @PACKAGE_VERSION@
####################################################################
# These are used for compiling physics modules using BOUT++ library
####################################################################
# Files that are needed by configure and should be dependencies for 'all'
OBJ = $(SOURCEC:%.cxx=%.o)
ifndef RELEASED
# If this is part of an packaged and installed installation, the user cannot
# write these files, so they shouldn't be changed. Thus only set this, in
# the non installed case.
LIB_A = $(BOUT_LIB_PATH)/libbout++.a
LIB_SO = $(BOUT_LIB_PATH)/libbout++.so
LIB = @LIB_TO_BUILD@
endif
MPARK_VARIANT_INCLUDE_PATH=@MPARK_VARIANT_INCLUDE_PATH@
FMT_INCLUDE_PATH=@FMT_INCLUDE_PATH@
BOUT_INCLUDE = -I$(BOUT_INCLUDE_PATH) $(CXXINCLUDE) $(EXTRA_INCS) @MPARK_INCLUDE@ -I$(FMT_INCLUDE_PATH)
BOUT_LIBS = -lm -L$(BOUT_LIB_PATH) -lbout++ $(EXTRA_LIBS)
CHANGED = $(shell find -f $(BOUT_TOP)/include $(BOUT_TOP)/src -type f \( -name \*.cxx -or -name \*.h \) -newer $(LIB) -print 2> /dev/null)
# This will set a default if no TARGET is provided
TARGET ?= $(SOURCEC:%.cxx=%)
####################################################################
# Definining stuff for recursive make
####################################################################
# Phony targets since they are directory names
.PHONY: $(DIRS) lib install libfast runtest manual sphinx doxygen
ifneq ("$(TARGET)","libfast")
all: $(BOUT_CONFIG_FILE) $(DIRS) $(TARGET)
else
all: $(BOUT_TOP)/config.status $(BOUT_CONFIG_FILE) $(DIRS)
endif
libfast: $(BOUT_CONFIG_FILE) $(DIRS)
####################################################################
# Recursively run make through subdirs
####################################################################
ifeq ("$(TARGET)" , "lib")
$(DIRS):
# make $@ slowly using the old method where parallel builds can cause
# race conditions that
@$(MAKE) -s --no-print-directory TARGET=lib -C $@ all
else
ifeq ("$(TARGET)","libfast")
$(DIRS):
# make $@ using the libfast method, where all .o files
# are only created in the end
@$(MAKE) -s --no-print-directory TARGET=$(TARGET) -C $@ $(TARGET)
else
MODULE_DIR?=$(shell pwd)
$(DIRS):
# MODULE_DIR: pass the module directory, where the libraries should be
# created.
# SUB_NAME is used for creating a library with the expected name.
# first a potential trailing slash is removed, and after that the
# directory name is extracted. This allows to e.g. specify a directory
# as fuu/bar/ and still get an archive named bar.a
@$(MAKE) -s --no-print-directory MODULE_DIR=$(MODULE_DIR) SUB_NAME=$(shell basename $@) TARGET=sub -C $@
endif
endif
# Create 'lib' and 'include' incase they don't exist
$(BOUT_TOP)/include $(BOUT_TOP)/lib:
$(MKDIR) $@
####################################################################
# Install header files and libraries
####################################################################
INSTALL = @INSTALL@
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_INCLUDE_PATH = $(DESTDIR)@includedir@/bout++/
# A list of relative paths e.g. "fr/LC_MESSAGES/libbout.mo zh_CN/LC_MESSAGES/libbout.mo"
MO_FILES = $(shell cd locale; ls */LC_MESSAGES/libbout.mo)
install: libfast
$(PRE_INSTALL) # Pre-install commands follow.
$(NORMAL_INSTALL) # Normal commands follow.
$(MKDIR) $(INSTALL_INCLUDE_PATH)/{,pvode,bout/sys,bout/invert}
$(MKDIR) $(DESTDIR)/{@libdir@,@bindir@,@datadir@/bout++/idllib}
$(MKDIR) $(DESTDIR)/@datadir@/bout++/pylib/{boutdata,boututils}
$(INSTALL_DATA) include/*.hxx $(INSTALL_INCLUDE_PATH)
ifeq ("@OWN_MPARK@", "yes")
$(MKDIR) $(INSTALL_INCLUDE_PATH)/mpark
$(INSTALL_DATA) $(MPARK_VARIANT_INCLUDE_PATH)/mpark/*.hpp $(INSTALL_INCLUDE_PATH)/mpark
endif
$(INSTALL_DATA) $(FMT_INCLUDE_PATH)/fmt/*.h $(INSTALL_INCLUDE_PATH)/fmt
$(INSTALL_DATA) include/pvode/*.h $(INSTALL_INCLUDE_PATH)/pvode/
$(INSTALL_DATA) include/bout/*.hxx $(INSTALL_INCLUDE_PATH)/bout/
$(INSTALL_DATA) include/bout/sys/*.hxx $(INSTALL_INCLUDE_PATH)/bout/sys/
$(INSTALL_DATA) include/bout/invert/*.hxx $(INSTALL_INCLUDE_PATH)/bout/invert/
$(INSTALL_DATA) lib/libbout++.a $(DESTDIR)@libdir@
$(INSTALL_DATA) lib/libpvode.a $(DESTDIR)@libdir@
$(INSTALL_DATA) lib/libpvpre.a $(DESTDIR)@libdir@
ifneq ("@SHARED_EXTRA@x", "x")
$(INSTALL_PROGRAM) lib/libbout++.so.$(SONAME) $(DESTDIR)@libdir@
$(INSTALL_PROGRAM) lib/libpvode.so.* $(DESTDIR)@libdir@
$(INSTALL_PROGRAM) lib/libpvpre.so.* $(DESTDIR)@libdir@
rm -f $(DESTDIR)@libdir@/lib{bout++,pvode,pvpre}.so
ln -s libbout++.so.$(SONAME) $(DESTDIR)@libdir@/libbout++.so
ln -s libpvode.so.1.0.0 $(DESTDIR)@libdir@/libpvode.so
ln -s libpvpre.so.1.0.0 $(DESTDIR)@libdir@/libpvpre.so
endif
$(INSTALL_PROGRAM) bin/bout-config $(DESTDIR)@bindir@
$(INSTALL_PROGRAM) bin/bout-log-color $(DESTDIR)@bindir@
$(INSTALL_DATA) tools/idllib/*.pro $(DESTDIR)@datadir@/bout++/idllib/
$(INSTALL_DATA) tools/idllib/README $(DESTDIR)@datadir@/bout++/idllib/
$(INSTALL_DATA) tools/pylib/boutdata/*.py $(DESTDIR)@datadir@/bout++/pylib/boutdata/
$(INSTALL_DATA) tools/pylib/boututils/*.py $(DESTDIR)@datadir@/bout++/pylib/boututils/
$(INSTALL_DATA) make.config $(INSTALL_INCLUDE_PATH)
for mo in $(MO_FILES); do $(MKDIR) $(DESTDIR)@localedir@/`dirname $$mo`; $(INSTALL_DATA) locale/$$mo $(DESTDIR)@localedir@/$$mo; done
$(POST_INSTALL) # Post-install commands follow.
@# Modify paths in the bout-config script
sed -i "s|^BOUT_INCLUDE_PATH=.*|BOUT_INCLUDE_PATH=@includedir@/bout++|" $(DESTDIR)@bindir@/bout-config
sed -i "s|^BOUT_LIB_PATH=.*|BOUT_LIB_PATH=@libdir@|" $(DESTDIR)@bindir@/bout-config
sed -i "s|^BOUT_CONFIG_FILE=.*|BOUT_CONFIG_FILE=@includedir@/bout++/make.config|" $(DESTDIR)@bindir@/bout-config
sed -i "s|^idlpath=.*|idlpath=@datadir@/bout++/idllib/|" $(DESTDIR)@bindir@/bout-config
sed -i "s|^pythonpath=.*|pythonpath=@datadir@/bout++/pylib/|" $(DESTDIR)@bindir@/bout-config
ifeq ("@OWN_MPARK@", "yes")
sed -i "s|^MPARK_VARIANT_INCLUDE_PATH=.*|MPARK_VARIANT_INCLUDE_PATH=@includedir@/bout++|" $(DESTDIR)@bindir@/bout-config
endif
sed -i "s|^FMT_INCLUDE_PATH=.*|FMT_INCLUDE_PATH=@includedir@/bout++|" $(DESTDIR)@bindir@/bout-config
@# Modify paths in the make.config file
sed -i "s|^BOUT_INCLUDE_PATH=.*|BOUT_INCLUDE_PATH=@includedir@/bout++|" $(INSTALL_INCLUDE_PATH)/make.config
sed -i "s|^BOUT_LIB_PATH=.*|BOUT_LIB_PATH=@libdir@|" $(INSTALL_INCLUDE_PATH)/make.config
sed -i "s|^BOUT_CONFIG_FILE=.*|BOUT_CONFIG_FILE=@includedir@/bout++/make.config|" $(INSTALL_INCLUDE_PATH)/make.config
ifeq ("@OWN_MPARK@", "yes")
sed -i "s|^MPARK_VARIANT_INCLUDE_PATH=.*|MPARK_VARIANT_INCLUDE_PATH=@includedir@/bout++|" $(INSTALL_INCLUDE_PATH)/make.config
endif
sed -i "s|^FMT_INCLUDE_PATH=.*|FMT_INCLUDE_PATH=@includedir@/bout++|" $(INSTALL_INCLUDE_PATH)/make.config
# Set the make.config as released, so the library isn't rebuild. This way the .a file doesn't need to be preserved/installed
sed -i '26 i RELEASED = yes' $(INSTALL_INCLUDE_PATH)/make.config
uninstall:
$(PRE_UNINSTALL) # Pre-uninstall commands follow.
$(NORMAL_UNINSTALL) # Normal commands follow.
$(RM) -r $(DESTDIR)@datadir@/bout++/pylib/boututils/
$(RM) -r $(DESTDIR)@datadir@/bout++/pylib/boutdata/
$(RM) -r $(DESTDIR)@datadir@/bout++/idllib/
$(RM) $(DESTDIR)@bindir@/bout-config
$(RM) $(DESTDIR)@bindir@/bout-log-color
$(RM) $(DESTDIR)@libdir@/libbout++.a
$(RM) $(DESTDIR)@libdir@/libpvode.a
$(RM) $(DESTDIR)@libdir@/libpvpre.a
$(RM) -r $(DESTDIR)@includedir@/bout++/
$(RM) $(DESTDIR)@localedir@/*/LC_MESSAGES/libbout.mo
$(POST_UNINSTALL) # Post-uninstall commands follow.
####################################################################
# Builds the library with $(OBJ) which is defined from the SOURCEC variable
####################################################################
# Rules for downloading submodules
-include $(BOUT_TOP)/makefile.submodules
ifeq ("$(TARGET)", "libfast")
libfast: makefile $(BOUT_CONFIG_FILE) $(BOUT_TOP)/include $(OBJ) $(DIRS)
endif
ifeq ("$(TARGET)", "lib")
lib: makefile $(BOUT_CONFIG_FILE) $(BOUT_TOP)/include $(BOUT_TOP)/lib $(OBJ)
ifneq ("$(OBJ)foo", "foo")
@echo " Adding $(OBJ) to libbout++.a"
@$(AR) $(ARFLAGS) $(LIB_A) $(OBJ)
@$(RANLIB) $(LIB)
endif
endif
ifeq ("$(TARGET)", "sub")
LIB=$(MODULE_DIR)/$(SUB_NAME).a
sub:$(LIB)
$(LIB): makefile $(BOUT_CONFIG_FILE) $(BOUT_TOP)/include $(BOUT_TOP)/lib $(OBJ)
ifneq ("$(OBJ)foo", "foo")
@echo " Adding $(OBJ) to $(LIB)"
@LIBT=$(LIB).$$$$.a && \
$(AR) $(ARFLAGS) $${LIBT} $(OBJ) && \
$(RANLIB) $${LIBT} && \
mv $${LIBT} $(LIB)
endif
endif
runtest:
./runtest
ifneq ("$(TARGET)", "sub")
ifneq ("$(TARGET)", "libfast")
ifneq ("$(TARGET)", "lib")
ifneq ("$(TARGET)", "runtest")
####################################################################
# Make libbout++.a if it doesn't exist with the checklib target
####################################################################
libbout++.a:
@echo "Rebuilding out-of-date bout++ library"
@$(MAKE) --no-print-directory -C $(BOUT_TOP)
####################################################################
# Make the target (e.g. gas_compress)
####################################################################
# first we remove a trailing slash, if present. Note that currently we
# dont support several trailing slashes, as in fuu/bar///
DIRS_=$(DIRS:%/=%)
# then we extract the directory name, in case it is a longer path
# We are not in a recipe, so # needs to be escaped
# $$ is an escaped $
DIRS__=$(shell for d in $(DIRS_) ; do basename $$d;done)
# now we can generate a list of libraries
SUB_LIBS=$(DIRS__:%=%.a)
$(SUB_LIBS):$(DIRS__)
$(SOURCEC): checklib
$(SOURCEC:%.cxx=%.o): $(LIB)
$(TARGET): | $(DIRS)
$(TARGET): makefile $(BOUT_CONFIG_FILE) $(OBJ) $(SUB_LIBS)
@echo " Linking" $(TARGET)
@$(LD) -o $(TARGET) $(OBJ) $(SUB_LIBS) $(BOUT_LIBS) $(LDFLAGS)
checklib:
ifneq ("$(CHANGED)foo", "foo")
@echo "Rebuilding out-of-date bout++ library"
@$(MAKE) --no-print-directory -C $(BOUT_TOP)
endif
endif
endif
endif
endif
# Ignore missing requirement files
-include .*.mk
# If it is a libfast target, track changes to rebuild library if needed
#
# Further track dependencies using gcc's -M feature:
# -MF write the generated dependency rule to a file
# -MG assume missing headers will be generated and don't stop with an error
# -MM generate dependency rule for prerequisite, skipping system headers
# -MP add phony target for each header to prevent errors when header is missing
# -MT add a target to the generated dependency
# Ignore failure, in case some compiler does not support this
%.o: $(BOUT_CONFIG_FILE) %.cxx
@echo " Compiling " $(@:.o=.cxx)
@$(CXX) $(BOUT_INCLUDE) $(BOUT_FLAGS) -c $(@:.o=.cxx) -o $@
ifeq ("$(TARGET)","libfast")
@test "$@" = "bout++-time.o" || touch $(BOUT_TOP)/lib/.last.o.file
endif
####################################################################
# Clean target. Pretty self explanatory.
# NOTE: See that double colon (::) below? That's signifies a rule that can be added to later
# See:
# http://owen.sj.ca.us/~rk/howto/slides/make/slides/makecolon.html
####################################################################
clean::
-@$(RM) -rf $(OBJ) $(DEPS) $(TARGET)
@for pp in $(DIRS) $(DIRS_CLEAN); do echo " " cleaning $$pp; $(MAKE) --no-print-directory -C $$pp clean; done
@$(RM) -f $(SUB_LIBS)
-@$(RM) .*.mk
@test -f make.config && ( find src | grep '\.o$$' && echo "WARNING: Some object files remain - which might cause issues. Clean with $(MAKE) clean-remove-object-files" ) || exit 0
clean-remove-object-files:
find src|grep '\.o$$' | xargs rm
distclean:: clean clean-tests
@echo include cleaned
# Removing the externalpackage installation. When we have more packages, need a better way
@$(RM) -rf $(BOUT_TOP)/include/pvode
@echo lib cleaned
@$(RM) -rf $(BOUT_TOP)/lib/*
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/lib/*.a
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/source/obj/*.o
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/precon/obj/*.o
-@$(RM) -rf $(BOUT_TOP)/autom4te.cache make.config
@echo externalpackages cleaned
@touch $(BOUT_TOP)/configure
@echo autom4te.cache cleaned
-@$(RM) $(BOUT_TOP)/include/bout/version.hxx
-@$(RM) $(BOUT_TOP)/include/bout/revision.hxx
-@$(RM) $(BOUT_TOP)/include/bout/build_defines.hxx
@echo generated version headers cleaned
-@$(RM) $(BOUT_TOP)/tools/pylib/boutconfig/__init__.py
@echo generated Python boutconfig module cleaned
clean-tests: clean-unit-tests clean-integrated-tests clean-mms-tests
clean-unit-tests:
@echo " tests/unit cleaned"
@$(MAKE) --no-print-directory -C tests/unit clean
clean-integrated-tests:
@echo " tests/integrated cleaned"
@$(MAKE) --no-print-directory -C tests/integrated clean
clean-mms-tests:
@echo " tests/MMS cleaned"
@$(MAKE) --no-print-directory -C tests/MMS clean
####################################################################
# Documentation
####################################################################
MANUAL_DIR=$(BOUT_TOP)/manual
doxygen:
$(MAKE) -C $(MANUAL_DIR) doxygen
breathe-autogen:
$(MAKE) -C $(MANUAL_DIR) breathe_autogen
sphinx-docs-html:
$(MAKE) -C $(MANUAL_DIR) sphinx-html
sphinx-docs-latex:
$(MAKE) -C $(MANUAL_DIR) sphinx-pdf
manual:
$(MAKE) -C $(MANUAL_DIR)
manual-html:
$(MAKE) -C $(MANUAL_DIR) html
manual-pdf:
$(MAKE) -C $(MANUAL_DIR) pdf
python: libfast
$(MAKE) -C tools/pylib python3
python2: libfast
$(MAKE) -C tools/pylib python2
python-all:python python2
######################################################################
# Code coverage
######################################################################
GCOV = @GCOV@
LCOV = @LCOV@
GENHTML = @GENHTML@
abs_builddir = @abs_builddir@
@CODE_COVERAGE_RULES@