forked from PrincetonUniversity/athena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
113 lines (89 loc) · 3.27 KB
/
Makefile.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
# Template for Athena++ Makefile
# The 'configure.py' python script uses this template to create the actual Makefile
# Files for conditional compilation
PROBLEM_FILE = @PROBLEM_FILE@
COORDINATES_FILE = @COORDINATES_FILE@
EOS_FILE = @EOS_FILE@
GENERAL_EOS_FILE = @GENERAL_EOS_FILE@
RSOLVER_FILE = @RSOLVER_FILE@
RSOLVER_DIR = @RSOLVER_DIR@
MPIFFT_FILE = @MPIFFT_FILE@
# General compiler specifications
CXX := @COMPILER_COMMAND@
CPPFLAGS := @PREPROCESSOR_FLAGS@
CXXFLAGS := @COMPILER_FLAGS@
LDFLAGS := @LINKER_FLAGS@
LDLIBS := @LIBRARY_FLAGS@
GCOV_CMD := @GCOV_COMMAND@
# Preliminary definitions
EXE_DIR := bin/
EXECUTABLE := $(EXE_DIR)athena
SRC_FILES := $(wildcard src/*.cpp) \
$(wildcard src/bvals/*.cpp) \
$(wildcard src/bvals/cc/*.cpp) \
$(wildcard src/bvals/cc/fft_grav/*.cpp) \
$(wildcard src/bvals/cc/hydro/*.cpp) \
$(wildcard src/bvals/cc/mg/*.cpp) \
$(wildcard src/bvals/fc/*.cpp) \
$(wildcard src/bvals/orbital/*.cpp) \
$(wildcard src/bvals/utils/*.cpp) \
$(wildcard src/coordinates/*.cpp) \
src/eos/general/$(GENERAL_EOS_FILE) \
src/eos/$(EOS_FILE) \
src/eos/eos_high_order.cpp \
src/eos/eos_scalars.cpp \
$(wildcard src/fft/*.cpp) \
$(wildcard src/field/*.cpp) \
$(wildcard src/field/field_diffusion/*.cpp) \
$(wildcard src/gravity/*.cpp) \
$(wildcard src/hydro/*.cpp) \
$(wildcard src/hydro/srcterms/*.cpp) \
$(wildcard src/hydro/hydro_diffusion/*.cpp) \
src/hydro/rsolvers/$(RSOLVER_DIR)$(RSOLVER_FILE) \
$(wildcard src/inputs/*.cpp) \
$(wildcard src/mesh/*.cpp) \
$(wildcard src/multigrid/*.cpp) \
$(wildcard src/orbital_advection/*.cpp) \
$(wildcard src/outputs/*.cpp) \
src/pgen/default_pgen.cpp \
src/pgen/$(PROBLEM_FILE) \
$(wildcard src/reconstruct/*.cpp) \
$(wildcard src/scalars/*.cpp) \
$(wildcard src/task_list/*.cpp) \
$(wildcard src/utils/*.cpp) \
$(MPIFFT_FILE)
OBJ_DIR := obj/
OBJ_FILES := $(addprefix $(OBJ_DIR),$(notdir $(SRC_FILES:.cpp=.o)))
GCOV_FILES := $(notdir $(addsuffix .gcov,$(SRC_FILES)))
GCDA_FILES := $(wildcard $(OBJ_DIR)/*.gcda)
SRC_PREFIX := src/
SRC_DIRS := $(dir $(SRC_FILES))
VPATH := $(SRC_DIRS)
# Generally useful targets
.PHONY : all dirs clean
all : dirs $(EXECUTABLE)
objs : dirs $(OBJ_FILES)
dirs : $(EXE_DIR) $(OBJ_DIR)
# Placing gcov target in the Makefile in order to easily collect all SRC_FILES w/ correct paths
gcov : dirs $(GCOV_FILES)
# For debugging variables in Makefile, e.g. by "make print-GCOV_FILES"
print-% : ; @echo $* = $($*)
$(EXE_DIR):
mkdir -p $(EXE_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
# Link objects into executable
$(EXECUTABLE) : $(OBJ_FILES)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $(OBJ_FILES) $(LDFLAGS) $(LDLIBS)
# Create objects from source files
$(OBJ_DIR)%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
# Process .gcno and .gcda files from obj/ into .cpp.gcov files (and .hpp.gcov, .h.gcov) in root directory
# Rerun Gcov on all files if a single .gcda changes. Other options to consider: --preserve-paths -abcu
./%.cpp.gcov : %.cpp $(OBJ_DIR)/%.gcno $(GCDA_FILES)
$(GCOV_CMD) --relative-only --source-prefix=$(SRC_PREFIX) --object-directory=$(OBJ_DIR) $<
# Cleanup
clean :
rm -rf $(OBJ_DIR)*
rm -rf $(EXECUTABLE)
rm -rf *.gcov