forked from djbower/spider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (104 loc) · 3.92 KB
/
Copy pathMakefile
File metadata and controls
132 lines (104 loc) · 3.92 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
################################################################################
# SPIDER Makefile #
################################################################################
# Executable Name
EXNAME = spider
# Source files, each corresponding to a .o object file and .d dependency file
SRC_C = \
atmosphere.c \
bc.c \
cJSON.c \
constants.c \
ctx.c \
dimensionalisablefield.c \
energy.c \
eos.c \
eos_adamswilliamson.c \
eos_composite.c \
eos_lookup.c \
eos_output.c \
ic.c \
interp.c \
main.c \
matprop.c \
mesh.c \
monitor.c \
parameters.c \
poststep.c \
reaction.c \
rheologicalfront.c \
rhs.c \
rollback.c \
twophase.c \
util.c \
# Main Target
all :: ${EXNAME}
### SPIDER Root Directory #####################################################
# Placement of this line matters. It will only work before any "include"s
SPIDER_ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
### PETSc ######################################################################
# Include PETSc variables and rules
include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules
### Flags ######################################################################
# Extra flags
# Use -O0 to turn off optimization, to debug with LLDB/GDB
# You can specify this from the command line, e.g.
# Available sanitizer flags with OSX
# With debugging
# make clean; make -j CFLAGS_EXTRA="-O0"
# with Address Sanitizer
# make clean; make -j CFLAGS_EXTRA="-O0 -fsanitize=address"
# with UndefinedBehaviorSanitizer
# make clean; make -j CFLAGS_EXTRA="-O0 -fsanitize=undefined"
CFLAGS+=${CFLAGS_EXTRA}
# Generate dependency (.d) files as we compile
CFLAGS+=${C_DEPFLAGS}
# Provide the current directory so that absolute paths to data files can be constructed.
CFLAGS+=-DSPIDER_ROOT_DIR=${SPIDER_ROOT_DIR}
# Repo-root headers, needed when compiling the C test executables under tests/c/
CFLAGS+=-I${SPIDER_ROOT_DIR}
### Compiling/Linking #########################################################
# Objects (PETSc rules provides recipe)
SRC_O = ${SRC_C:%.c=%.o}
# Main executable
${EXNAME} : ${SRC_O}
-${CLINKER} -o $@ $^ ${PETSC_TS_LIB}
#${RM} $^
### Tests ######################################################################
# The pytest suite drives the spider binary and the C test executables.
# Tier system and writing guidance: docs/How-to/build_tests.md.
# C test executables: thin evaluators linked against the SPIDER objects.
# The pytest wrappers under tests/ own all assertions.
TEST_C_SRC = \
tests/c/test_interp.c \
tests/c/test_eos.c \
tests/c/test_eos_composite.c \
tests/c/test_dimensionalisablefield.c \
TEST_C_EXE = ${TEST_C_SRC:%.c=%}
TEST_C_O = ${TEST_C_SRC:%.c=%.o}
TEST_C_D = ${TEST_C_SRC:%.c=%.d}
# All SPIDER objects except the entry point (each test provides its own main)
SRC_O_NOMAIN = $(filter-out main.o,${SRC_O})
tests_c : ${TEST_C_EXE}
${TEST_C_EXE} : % : %.o ${SRC_O_NOMAIN}
${CLINKER} -o $@ $^ ${PETSC_TS_LIB}
test :
python3 -m pytest -m "(unit or smoke) and not skip"
test_all :
python3 -m pytest -m "not skip"
.PHONY: tests_c test test_all
### Dependencies ###############################################################
SRC_D = ${SRC_C:%.c=%.d}
# Indicate that SRC_D is up to date. Prevents the include from having quadratic complexity.
$(SRC_D) $(TEST_C_D) : ;
# Include dependency files
-include $(SRC_D)
-include $(TEST_C_D)
### Helper Targets #############################################################
clean ::
rm -f ${EXNAME} ${SRC_O} ${SRC_D} ${TEST_C_EXE} ${TEST_C_O} ${TEST_C_D}
.PHONY: clean
### Misc #######################################################################
# Remove results of partial, failed builds
.DELETE_ON_ERROR: