-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (66 loc) · 1.94 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
# A makefile for building stn3d - the three-dimensional spatial Tangled
# Nature simulation.
#
# Targets:
# make: build the stn3d executable using g++ with -std=c++17
# make tests: build the stn3d_tests executable using g++ with -std=c++17
# make reset: delete all output files from ./out
# make clean: delete built executables from ./bin and object files from ./obj
# make format: format the source using Google's C++ coding standards
# make tidy: run make-tidy against the source
# make valgrind: run valgrind against the executable
CXX = g++
CXXFLAGS += -g -Wall -Wextra -pedantic -pthread -std=c++17
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
OBJECTS = $(OBJ_DIR)/main.o $(OBJ_DIR)/dynamics.o $(OBJ_DIR)/util.o \
$(OBJ_DIR)/initialise.o
CXXFLAGS += -Iinclude/
# Build system switch
ifeq ($(shell echo "windows"), "windows")
EXE = .\bin\stn3d.exe .\bin\stn3d_tests.exe
RM = del
CLEAN_OBJS = $(OBJ_DIR)\*.o
CLEAN_LIBS = $(OBJ_DIR)\*.a
CLEAN_OUT = out\*.txt
else
EXE = bin/stn3d bin/stn3d_tests
RM = rm -f
CLEAN_OBJS = $(OBJ_DIR)/*.o
CLEAN_LIBS = $(OBJ_DIR)/*.a
CLEAN_OUT = out/*.txt
endif
.PHONY: stn3d
# Link to stn3d
$(BIN_DIR)/stn3d: $(OBJECTS) | $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(BIN_DIR)/stn3d
# Build main object
$(OBJ_DIR)/main.o: $(SRC_DIR)/main.cpp | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(OBJ_DIR)/dynamics.o: $(SRC_DIR)/dynamics.cpp | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(OBJ_DIR)/util.o: $(SRC_DIR)/util.cpp | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(OBJ_DIR)/initialise.o: $(SRC_DIR)/initialise.cpp | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Creates obj and bin directories if they don't already exist
obj:
mkdir $@
bin:
mkdir $@
tests:
make
make -C ./test
reset:
$(RM) $(CLEAN_OUT)
clean:
$(RM) $(CLEAN_OBJS)
$(RM) $(CLEAN_LIBS)
$(RM) $(EXE)
format:
clang-format-10 -i src/*.cpp src/*.h
tidy:
clang-tidy-10 src/* -header-filter=.* -- -xc++ -std=c++17 -Iinclude/
valgrind:
valgrind $(BIN_DIR)/stn3d