-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
270 lines (240 loc) · 9.6 KB
/
makefile
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
ALL: all
LOCDIR = .
DIRS = include src docs test demo
ifdef codecov
MYFLAGS += --coverage
LIBS += --coverage
endif
ifdef ugrid_debug
MYFLAGS += -DUGRID_DEBUG
endif
# These flags are supplemental to the PETSc flags
CFLAGS = ${LIBS}
FFLAGS = ${LIBS}
CPPFLAGS = ${MYFLAGS}
FPPFLAGS = ${MYFLAGS}
TDYCORE_DIR ?= $(CURDIR)
include ${TDYCORE_DIR}/lib/tdycore/conf/variables
all:
@if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \
${OMAKE} all-gmake PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; \
elif [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \
${OMAKE} all-cmake PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; else \
${OMAKE} all-legacy PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; fi;
.PHONY: all
${TDYCORE_DIR}/${PETSC_ARCH}/include:
@${MKDIR} ${TDYCORE_DIR}/${PETSC_ARCH}/include
${TDYCORE_DIR}/${PETSC_ARCH}/lib:
@${MKDIR} ${TDYCORE_DIR}/${PETSC_ARCH}/lib
${TDYCORE_DIR}/${PETSC_ARCH}/log:
@${MKDIR} ${TDYCORE_DIR}/${PETSC_ARCH}/log
arch-tree: ${TDYCORE_DIR}/${PETSC_ARCH}/include \
${TDYCORE_DIR}/${PETSC_ARCH}/lib \
${TDYCORE_DIR}/${PETSC_ARCH}/log
.PHONY: arch-tree
#
# GNU Make build
#
ifndef MAKE_IS_GNUMAKE
MAKE_IS_GNUMAKE = $(if $(findstring GNU Make,$(shell $(OMAKE) --version 2>/dev/null)),1,)
endif
ifdef OMAKE_PRINTDIR
GMAKE = ${OMAKE_PRINTDIR}
else
GMAKE = ${OMAKE}
endif
gmake-build:
@cd ${TDYCORE_DIR} && ${GMAKE} -f gmakefile -j ${MAKE_NP}
gmake-clean:
@cd ${TDYCORE_DIR} && ${GMAKE} -f gmakefile clean
all-gmake: chk_petsc_dir chk_tdycore_dir arch-tree
-@echo "=================================================="
-@echo "Building TDycore (GNU Make - ${MAKE_NP} build jobs)"
-@echo "Using TDYCORE_DIR=${TDYCORE_DIR}"
-@echo "Using PETSC_DIR=${PETSC_DIR}"
-@echo "Using PETSC_ARCH=${PETSC_ARCH}"
-@echo "=================================================="
@${GMAKE} gmake-build PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR} CFLAGS="${CFLAGS}" FFLAGS="${FFLAGS}" CPPFLAGS="${CPPFLAGS}" FPPFLAGS="${FPPFLAGS}" 2>&1 | tee ./${PETSC_ARCH}/log/make.log
-@echo "=================================================="
.PHONY: gmake-build gmake-clean all-gmake style
#
# CMake build
#
ifeq (${PETSC_LANGUAGE},CXXONLY)
cmake_cc_clang=-DPETSC_CLANGUAGE_Cxx:STRING='YES'
cmake_cc_path =-DCMAKE_CXX_COMPILER:FILEPATH=${CXX}
cmake_cc_flags=-DCMAKE_CXX_FLAGS:STRING='${PCC_FLAGS} ${CFLAGS} ${CCPPFLAGS}'
else
cmake_cc_clang=-DPETSC_CLANGUAGE_Cxx:STRING='NO'
cmake_cc_path =-DCMAKE_C_COMPILER:FILEPATH=${CC}
cmake_cc_flags=-DCMAKE_C_FLAGS:STRING='${PCC_FLAGS} ${CFLAGS} ${CCPPFLAGS}'
endif
ifneq (${FC},)
cmake_fc_path =-DCMAKE_Fortran_COMPILER:FILEPATH=${FC}
endif
ifneq (${FC_FLAGS},)
cmake_fc_flags=-DCMAKE_Fortran_FLAGS:STRING='${FC_FLAGS} ${FFLAGS} ${FCPPFLAGS}'
endif
cmake_cc=${cmake_cc_path} ${cmake_cc_flags} ${cmake_cc_clang}
cmake_fc=${cmake_fc_path} ${cmake_fc_flags}
${TDYCORE_DIR}/${PETSC_ARCH}/CMakeCache.txt: CMakeLists.txt
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/CMakeCache.txt
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/CMakeFiles
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/Makefile
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/cmake_install.cmake
@${MKDIR} ${TDYCORE_DIR}/${PETSC_ARCH}
@cd ${TDYCORE_DIR}/${PETSC_ARCH} && ${CMAKE} ${TDYCORE_DIR} ${cmake_cc} ${cmake_fc}
cmake-boot: ${TDYCORE_DIR}/${PETSC_ARCH}/CMakeCache.txt
cmake-down:
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/CMakeCache.txt
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/CMakeFiles
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/Makefile
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/cmake_install.cmake
cmake-build: cmake-boot
@cd ${TDYCORE_DIR}/${PETSC_ARCH} && ${OMAKE} -j ${MAKE_NP}
-@if [ "${DSYMUTIL}" != "true" -a -f ${INSTALL_LIB_DIR}/libtdycore.${SL_LINKER_SUFFIX} ]; then \
${DSYMUTIL} ${INSTALL_LIB_DIR}/libtdycore.${SL_LINKER_SUFFIX}; fi
cmake-install:
@cd ${TDYCORE_DIR}/${PETSC_ARCH} && ${OMAKE} install
cmake-clean:
@if [ -f ${TDYCORE_DIR}/${PETSC_ARCH}/Makefile ]; then \
cd ${TDYCORE_DIR}/${PETSC_ARCH} && ${OMAKE} clean; fi;
all-cmake: chk_petsc_dir chk_tdycore_dir arch-tree
-@echo "=================================================="
-@echo "Building TDycore (CMake - ${MAKE_NP} build jobs)"
-@echo "Using TDYCORE_DIR=${TDYCORE_DIR}"
-@echo "Using PETSC_DIR=${PETSC_DIR}"
-@echo "Using PETSC_ARCH=${PETSC_ARCH}"
-@echo "=================================================="
@${OMAKE} cmake-build PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR} CFLAGS="${CFLAGS}" FFLAGS="${FFLAGS}" CPPFLAGS="${CPPFLAGS}" FPPFLAGS="${FPPFLAGS}" 2>&1 | tee ./${PETSC_ARCH}/log/make.log
-@echo "=================================================="
.PHONY: cmake-boot cmake-down cmake-build cmake-clean all-cmake
#
# Legacy build
#
legacy-build: arch-tree deletelibs deletemods build
legacy-clean: deletemods deletelibs
-@${OMAKE} tree ACTION=clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
all-legacy: chk_petsc_dir chk_tdycore_dir arch-tree
-@echo "=================================================="
-@echo "Building TDycore (legacy build)"
-@echo "Using TDYCORE_DIR=${TDYCORE_DIR}"
-@echo "Using PETSC_DIR=${PETSC_DIR}"
-@echo "Using PETSC_ARCH=${PETSC_ARCH}"
-@echo "=================================================="
-@echo "Beginning to build TDycore library"
@${OMAKE} legacy-build PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR} 2>&1 | tee ./${PETSC_ARCH}/log/make.log
-@echo "Completed building TDycore library"
-@echo "=================================================="
.PHONY: legacy-build legacy-clean all-legacy
#
# Check if PETSC_DIR variable specified is valid
#
chk_petsc_dir:
@if [ ! -f ${PETSC_DIR}/include/petsc.h ]; then \
echo "Incorrect PETSC_DIR specified: ${PETSC_DIR}"; \
echo "Aborting build"; \
false; fi
.PHONY: chk_petsc_dir
#
# Check if TDYCORE_DIR variable specified is valid
#
chk_tdycore_dir:
@if [ ! -f ${TDYCORE_DIR}/include/tdycore.h ]; then \
echo "Incorrect TDYCORE_DIR specified: ${TDYCORE_DIR}"; \
echo "Aborting build"; \
false; fi
.PHONY: chk_tdycore_dir
#
# Build the TDycore library
#
build: compile ranlib shlibs
compile:
-@${OMAKE} tree ACTION=libfast PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
-@${MV} -f ${TDYCORE_DIR}/src/tdycore*.mod ${TDYCORE_DIR}/${PETSC_ARCH}/include
ranlib:
-@echo "building libtdycore.${AR_LIB_SUFFIX}"
-@${RANLIB} ${TDYCORE_LIB_DIR}/*.${AR_LIB_SUFFIX} > tmpf 2>&1 ; ${GREP} -v "has no symbols" tmpf; ${RM} tmpf;
shlibs:
-@${OMAKE} shared_nomesg PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR} \
| (${GREP} -vE "making shared libraries in" || true) \
| (${GREP} -vE "==========================" || true)
-@if [ "${DSYMUTIL}" != "true" ]; then \
${DSYMUTIL} ${INSTALL_LIB_DIR}/libtdycore.${SL_LINKER_SUFFIX}; fi
.PHONY: build compile ranlib shlibs
# Delete TDycore library
deletelogs:
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/log/*.log
deletemods:
-@${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/include/tdycore*.mod
deletestaticlibs:
-@${RM} -r ${TDYCORE_LIB_DIR}/libtdycore*.${AR_LIB_SUFFIX}
deletesharedlibs:
-@${RM} -r ${TDYCORE_LIB_DIR}/libtdycore*.${SL_LINKER_SUFFIX}*
deletelibs: deletestaticlibs deletesharedlibs
.PHONY: deletelogs deletemods deletestaticlibs deletesharedlibs deletelibs
# Clean up build
clean:: allclean
allclean:
@if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \
${OMAKE} gmake-clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; \
elif [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \
${OMAKE} cmake-clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; else \
${OMAKE} legacy-clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}; fi;
distclean: chk_tdycore_dir
@echo "*** Deleting all build files ***"
-${RM} -r ${TDYCORE_DIR}/${PETSC_ARCH}/
.PHONY: clean allclean distclean
# Run test examples
testexamples:
-@echo "=================================================="
-@echo "Beginning to compile and run test examples"
-@echo "=================================================="
-@${OMAKE} tree ACTION=testexamples_C PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
-@echo "Completed compiling and running test examples"
-@echo "=================================================="
.PHONY: testexamples
# Test build
#check: test
#test:
# -@${OMAKE} test-build PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR} 2>&1 | tee ./${PETSC_ARCH}/log/test.log
#test-build:
# -@echo "Running test to verify correct installation"
# -@echo "Using TDYCORE_DIR=${TDYCORE_DIR}"
# -@echo "Using PETSC_DIR=${PETSC_DIR}"
# -@echo "Using PETSC_ARCH=${PETSC_ARCH}"
# @cd test; ${OMAKE} clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
# @cd test; ${OMAKE} test-build PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
# @cd test; ${OMAKE} clean PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} TDYCORE_DIR=${TDYCORE_DIR}
# -@echo "Completed test"
.PHONY: check test test-build
#
# Code formatting (style)
#
style :
@astyle --options=.astylerc \
${TDYCORE_DIR}/src/*.[ch] ${TDYCORE_DIR}/include/*.[ch] ${TDYCORE_DIR}/demo/*.[ch]
#
# Auto-generated API documentation
#
DOXYGEN ?= doxygen
doxygen:
@$(DOXYGEN) Doxyfile
doc-html doc-latexpdf doc-epub : doc-% : doxygen
make -C doc/sphinx $*
doc: doc-html
#
# TAGS Generation
#
alletags:
-@${PYTHON} ${PETSC_DIR}/bin/maint/generateetags.py
deleteetags:
-@${RM} CTAGS TAGS
.PHONY: alletags deleteetags
#
# Compile demo codes
#
demo: all-gmake
@cd demo; make
rtest: demo
-@(cd regression_tests; make test)