-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
55 lines (39 loc) · 1.02 KB
/
Copy pathmakefile
File metadata and controls
55 lines (39 loc) · 1.02 KB
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
CC := clang++
SRC := main.cpp Terminal.cpp AnsiParser.cpp TerminalState.cpp PTY.cpp Grid.cpp Color.cpp UTF8Decoder.cpp stb_image.cpp
EXEC := main.out
LIBS := -lX11 -lGL -lXft -lXrender -lfontconfig -lfreetype
XFT_CFLAGS := $(shell pkg-config --cflags xft 2>/dev/null)
CXXFLAGS := -std=c++17 -Wall
MODE ?= release
BUILD_DIR := build/$(MODE)
OBJ := $(SRC:%.cpp=$(BUILD_DIR)/%.o)
DEPS := $(OBJ:.o=.d)
ifeq ($(MODE),debug)
CXXFLAGS += -g -O0 -DDEBUG -Wextra -Wpedantic
else
CXXFLAGS += -DNDEBUG -O3 -flto
LDFLAGS := -flto
endif
all: $(EXEC)
$(EXEC): $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) $(LIBS) -o $@
$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR)
$(CC) $(CXXFLAGS) $(XFT_CFLAGS) -MMD -MP -c $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
debug:
$(MAKE) MODE=debug
release:
$(MAKE) MODE=release
run: $(EXEC)
./$(EXEC)
run-debug:
$(MAKE) MODE=debug run
run-release:
$(MAKE) MODE=release run
clean:
rm -rf build
clean-all: clean
rm -f $(EXEC)
-include $(DEPS)
.PHONY: all debug release run run-debug run-release clean clean-all