-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (125 loc) · 4.69 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
################################################################################
# Makefile for building an implementation of the ASW method (someday this might#
# actually be a "full" DFT code) #
################################################################################
################################################################################
# Author: Johan Jönsson #
# Email: [email protected] #
# Created: 2018-01-31 #
# Last updated: 2019-07-08 #
################################################################################
CXXCHECK = clang-tidy
# List of all executables in this project
LIB = GSLpp
# Source files directory
SRC_DIR = src
TEST_DIR = tests
# Build directory
BUILD_DIR = build
# Library directory
LIB_DIR = lib
# include directory
INC_DIR = include
# Flags for the above defined compilers
WFLAGS = -Werror -Wall -Wextra -pedantic -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Weffc++ -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast
#CXXFLAGS = -std=c++11 $(WFLAGS) -I $(INC_DIR) -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF -fPIC -g -pg -O3 -flto
CXXFLAGS = -std=c++11 $(WFLAGS) -I$(INC_DIR) -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF -fPIC -O0 -flto -DDEBUG -g
CXXCHECKS =clang-analyzer-*,-clang-analyzer-cplusplus*,cppcoreguidelines-*,bugprone-*
CXXCHECKFLAGS = -checks=$(CXXCHECKS) -header-filter=.* -- -std=c++11
# Libraries to link against
LDFLAGS = -lgsl -lopenblas -fPIC -Ofast -fuse-ld=gold -flto
LIB_OBJ = complex_impl.o\
matrix_impl.o\
vector_impl.o\
divided_difference.o\
permutation.o\
eigen.o\
linalg.o\
basic_math.o\
special_functions_bessel.o\
special_functions_legendre.o\
special_functions_laguerre.o\
special_functions_hermite.o\
special_functions_coupling.o\
special_functions_exp.o\
special_functions_log.o\
special_functions_trig.o\
special_functions_erf.o\
special_functions_gamma_beta.o\
special_functions_results.o\
interp.o\
ode.o\
error.o
TEST_OBJ = main_tests.o\
complex_test.o\
complex_base_math_test.o\
complex_ld_test.o\
complex_ld_base_math_test.o\
complex_f_test.o\
complex_f_base_math_test.o\
vector_test.o\
vector_c_test.o\
vector_uc_test.o\
vector_f_test.o\
vector_ld_test.o\
vector_i_test.o\
vector_ui_test.o\
vector_l_test.o\
vector_ul_test.o\
vector_s_test.o\
vector_us_test.o\
vector_cx_test.o\
vector_cxf_test.o\
vector_cxld_test.o\
matrix_test.o\
matrix_f_test.o\
matrix_ld_test.o\
matrix_c_test.o\
matrix_uc_test.o\
matrix_s_test.o\
matrix_us_test.o\
matrix_i_test.o\
matrix_ui_test.o\
matrix_cx_test.o\
matrix_cxf_test.o\
matrix_cxld_test.o\
interp_test.o\
ode_test.o\
OBJS = $(addprefix $(BUILD_DIR)/, $(LIB_OBJ))
TEST_OBJS = $(addprefix $(BUILD_DIR)/, $(TEST_OBJ))
# Targets to always execute, even if new files with the same names exists
.PHONY: clean cleanall $(LIB_DIR) $(INC_DIR)
# Build all executables
all: $(LIB_DIR) $(BUILD_DIR) lib$(LIB).so $(TEST)
# Create object files from c++ sources
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $? -o $@
$(BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $? -o $@
lib$(LIB).so: $(OBJS)
$(CXX) $^ -o $(LIB_DIR)/$(LIB)/$@ $(LDFLAGS) -shared -Wl,-soname,$@
cp $(SRC_DIR)/$(LIB)/*.h $(INC_DIR)/$(LIB)
lib$(LIB)cov.so: $(OBJS)
$(CXX) $^ -o $(LIB_DIR)/$(LIB)/$@ $(LDFLAGS) -shared -Wl,-soname,$@
checkall: $(addprefix $(SRC_DIR)/, $(LIB_OBJ:o=cpp))
$(CXXCHECK) $^ $(CXXCHECKFLAGS)
test: CXXFLAGS += --coverage
test: LDFLAGS += --coverage -lgtest
test: lib$(LIB)cov.so
test: $(BUILD_DIR) $(LIB_DIR) $(TEST_OBJS)
$(CXX) $(TEST_OBJS) -o $@ -L $(LIB_DIR)/$(LIB) -I$(INC_DIR) -Wl,-rpath=$(LIB_DIR)/$(LIB) -l$(LIB)cov $(LDFLAGS)
travis : -std=c++11 -I $(INC_DIR) -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF -Ofast -flto -fPIC
travis: $(BUILD_DIR) $(LIB_DIR) lib$(LIB).so
$(BUILD_DIR) :
mkdir -p $(BUILD_DIR)
$(LIB_DIR) :
mkdir -p $(LIB_DIR)/$(LIB)
#$(INC_DIR) :
# mkdir -p $(INC_DIR)/$(LIB)
# cp $(SRC_DIR)/$(LIB)/*.h $(INC_DIR)/$(LIB)
# Remove object files
clean:
rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/*.gcda $(BUILD_DIR)/*.gcno
# Remove executables and object files
cleanall: clean
rm -f $(LIB_DIR)/$(LIB)/lib$(LIB).so* $(LIB_DIR)/$(LIB)/lib$(LIB)cov.so* test tester