-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
55 lines (41 loc) · 1.58 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
PATHS = src/
PATHB = build/
PATHD = build/depends/
PATHO = build/objs/
PATHS_TEST = tests/
PATHB_TEST = $(PATHB)
PATHD_TEST = $(PATHD)
PATHO_TEST = $(PATHO)
CXX = hipcc
CXXFLAGS = -std=c++20 -MMD -MP -Wall -fopenmp -Ofast# -Wno-unused-result
CXXFLAGS_TEST = -std=c++20 -MMD -MP -Wall -fopenmp -O0
# CXXFLAGS = -std=c++20 -MMD -MP -Wall -fopenmp -O0 -g # Debug flags.
SRCS = $(addprefix $(PATHS), tools.cpp loaders.cpp hamiltonian.cpp basis.cpp basic_solver.cpp generate_indices.cpp hamiltonian_bitset_representation.cpp hamiltonian_device.cpp diagnostics.cpp hip_wrappers.cpp lanczos.cpp linear_algebra.cpp)
OBJS = $(addprefix $(PATHO), $(notdir $(SRCS:.cpp=.o)))
DEPS = $(addprefix $(PATHD), $(notdir $(SRCS:.cpp=.d)))
EXEC = $(PATHB)run.out
SRCS_TEST = $(addprefix $(PATHS_TEST), tests.cpp hash_tests.cpp lanczos_tests.cpp)
OBJS_TEST = $(addprefix $(PATHO_TEST), $(notdir $(SRCS_TEST:.cpp=.o)))
DEPS_TEST = $(addprefix $(PATHD_TEST), $(notdir $(SRCS_TEST:.cpp=.d)))
EXEC_TEST = $(PATHB)tests.out
# Build all
all: setup $(EXEC)
test: setup $(EXEC_TEST)
setup:
mkdir -p $(PATHB) $(PATHD) $(PATHO)
# Link
$(EXEC): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $^
# Link (tests)
$(EXEC_TEST): $(OBJS_TEST)
$(CXX) $(CXXFLAGS_TEST) -o $@ $^
# Rule to generate object files from cpp files
$(PATHO)%.o: $(PATHS)%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ -MF $(PATHD)$(notdir $*).d
# Rule to generate object files from cpp files (tests)
$(PATHO_TEST)%.o: $(PATHS_TEST)%.cpp
$(CXX) $(CXXFLAGS_TEST) -c $< -o $@ -MF $(PATHD_TEST)$(notdir $*).d
-include $(DEPS) $(DEPS_TEST)
clean:
rm -rf $(PATHB)
.PHONY: all clean test setup