-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
69 lines (45 loc) · 1.79 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
CXX = g++ -lpthread -fopenmp -O3
CXXFLAGS = -Wall -std=c++17
LDFLAGS =
SOURCE_DIR = src
INCLUDE_DIR = includes
TEST_DIR = tests
BUILD_DIR = build
BIN_DIR = bin
ALL_BUILD_DIR = $(BUILD_DIR) $(BIN_DIR)
TEST_BUILD_DIR = $(TEST_DIR)/build
TEST_BIN_DIR = $(TEST_DIR)/bin
ALL_TEST_BUILD_DIR = $(TEST_BUILD_DIR) $(TEST_BIN_DIR)
all: SPH_2D
SPH_2D: $(BIN_DIR)/SPH_2D
$(BIN_DIR)/SPH_2D: $(BUILD_DIR)/SPH_2D.o $(BUILD_DIR)/SPH_Snippet.o $(BUILD_DIR)/file_writer.o
$(CXX) -o $@ $^
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp $(INCLUDE_DIR)/*.h | directories
$(CXX) $(CPPFLAGS) -o $@ -c $< $(CXXFLAGS) -I$(INCLUDE_DIR)
clean:
rm -f $(BUILD_DIR)/* $(BIN_DIR)/* *.vtp
.PHONY: SPH_2D all clean
TESTS = test_SPH_2D test_file_writer test_output
runtests: cleantest ${TESTS}
@python3 run_tests.py
rm -f $(TEST_DIR)/test_output*.vtp
tests: ${TESTS}
test_SPH_2D: $(TEST_BIN_DIR)/test_SPH_2D
test_file_writer: $(TEST_BIN_DIR)/test_file_writer
test_output: $(TEST_BIN_DIR)/test_output
$(TEST_BIN_DIR)/test_SPH_2D: $(TEST_BUILD_DIR)/test_SPH_2D.o $(BUILD_DIR)/SPH_2D.o
$(CXX) -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
$(TEST_BIN_DIR)/test_file_writer: $(TEST_BUILD_DIR)/test_file_writer.o $(BUILD_DIR)/file_writer.o
$(CXX) -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
$(TEST_BIN_DIR)/test_output: $(TEST_BUILD_DIR)/test_output.o $(BUILD_DIR)/SPH_2D.o $(BUILD_DIR)/file_writer.o
$(CXX) -o $@ $^ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
$(TEST_BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp $(INCLUDE_DIR)/*.h | test_directories
$(CXX) -o $@ -c $< $(CXXFLAGS) $(CPPFLAGS) -I$(INCLUDE_DIR)
cleantest:
rm -f $(TEST_BUILD_DIR)/* $(TEST_BIN_DIR)/* $(TEST_DIR)/*.vtp $(TEST_DIR)/*.h5
.PHONY: tests ${TESTS} cleantests runtests
directories:
@mkdir -p $(ALL_BUILD_DIR)
test_directories:
@mkdir -p $(ALL_TEST_BUILD_DIR)
.PHONY: directories test_directories