-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.22 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
SRC_ROOT := src
HEADER_ROOT := include
SRC := $(shell fd -e cpp . $(SRC_ROOT))
HEADERS := $(shell fd -e hpp . $(HEADER_ROOT))
OBJ := $(SRC:%.cpp=%.o)
WARNINGS := -Wall -Wextra -Wpedantic -Walloca -Wfloat-equal -Wlarger-than=4KiB -Wpointer-arith
OUT ?= mite
CXXFLAGS += -std=c++20 -pipe
INCLUDE := -Iinclude
LIB :=
all: $(OUT) compile_flags.txt
.DEFAULT_GOAL = debug
debug: CXX = g++
debug: CXXFLAGS += -Og -ggdb3 -DDEBUG -ltree-sitter -ltree-sitter-cpp
debug: all
analyze: CXX = g++
analyze: CXXFLAGS += -fanalyzer
analyze: debug
release: CXX = clang++
release: CXXFLAGS += -O2 -flto=thin -DNO_TS
release: clean
release: all
minimal: CXXFLAGS += -DNO_LSP -DNO_TS
minimal: release
tree-sitter: CXX = clang++
tree-sitter: CXXFLAGS += -O2 -flto=thin -ltree-sitter -ltree-sitter-cpp
tree-sitter: clean
tree-sitter: all
format: $(SRC) $(HEADERS)
clang-format -i $(SRC) $(HEADERS)
debugger: debug
gdb $(OUT)
$(OUT): $(OBJ)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIB)
%.o: %.cpp $(HEADERS)
$(CXX) -c -o $@ $(INCLUDE) $(WARNINGS) $(CXXFLAGS) $<
compile_flags.txt: Makefile
rm -f compile_flags.txt
for flag in $(INCLUDE) $(WARNINGS) $(CXXFLAGS); do \
echo $$flag >> $@; \
done
clean:
rm -rf $(OUT)
rm -rf compile_flags.txt
rm -rf src/*.o