-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
61 lines (48 loc) · 1.21 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
#########################################
# Makefile
#########################################
CXX = g++
CXXFLAGS := -std=c++17 -Wall -Wextra -Wpedantic -g -Og \
-Winit-self -Wold-style-cast -Wcast-qual -Wundef \
-Woverloaded-virtual \
-Wconversion \
-Wlogical-op \
-Wzero-as-null-pointer-constant \
-fsanitize=address \
-fsanitize=undefined \
-fsanitize=float-cast-overflow
LINK_FLAGS := -fsanitize=address \
-fsanitize=undefined \
-fsanitize=float-cast-overflow
EXEC := lindenmayer
SRCS := $(wildcard src/*.cpp)
HDRS := $(wildcard src/*.h)
OBJS := $(patsubst src/%.cpp, obj/%.o, $(SRCS))
DEPS := $(patsubst %.o, %.d, $(OBJS))
# Default target
$(EXEC) :
# Create all
all : $(EXEC)
# Include existing dependancies
-include $(DEPS)
# Create dependancy files
.SUFFIXES += .d
obj/%.d: src/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -MM -MT '$(patsubst src/%.cpp,obj/%.o,$<)' $< -MF $@
# Compilation
obj/%.o: src/%.cpp obj/%.d
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Link all object files to executable
$(EXEC) : $(OBJS)
$(CXX) $(OBJS) $(LINK_FLAGS) -lstdc++fs -o $@
# Documentation
doc : $(SRCS) $(HDRS)
doxygen
# Clean up directory
clean :
rm -f $(EXEC)
rm -rf obj
rm -rf doc
rm -rf results