-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
51 lines (37 loc) · 1.42 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
SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin
TEST_SRC_DIR := test
VERSION := $(shell grep -m1 -oP '## \[\K[^]]+' CHANGELOG.md)
EXE := $(BIN_DIR)/overlay
SRC := $(filter-out $(SRC_DIR)/overlay.cpp, $(wildcard $(SRC_DIR)/*.cpp))
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
TEST_EXE := $(BIN_DIR)/run_tests
TEST_SRC := $(filter-out $(TEST_SRC_DIR)/test.cpp, $(wildcard $(TEST_SRC_DIR)/*.cpp))
TEST_OBJ := $(TEST_SRC:$(TEST_SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
CPPFLAGS := -Iinclude -MMD -MP -D VERSION="\"$(VERSION)\""
CFLAGS := -Wall `pkg-config --cflags freetype2`
LDFLAGS :=
LDLIBS := -lX11 -lXext -lXfixes -lXrandr -lXft -lfreetype
.PHONY: all clean
all: overlay test
overlay: $(EXE)
test: $(TEST_EXE)
debug: CPPFLAGS += -DDEBUG -g
debug: $(EXE)
$(EXE): $(OBJ_DIR)/overlay.o $(OBJ) | $(BIN_DIR)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(TEST_EXE): $(OBJ_DIR)/test.o ${TEST_OBJ} ${OBJ} | $(BIN_DIR)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(TEST_SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) -fno-access-control -I3rdparty/acutest/include -DTEST_NO_MAIN $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/test.o: $(TEST_SRC_DIR)/test.cpp | $(OBJ_DIR)
$(CXX) -fno-access-control -I3rdparty/acutest/include $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BIN_DIR) $(OBJ_DIR):
@mkdir -p $@
clean:
@$(RM) -r $(BIN_DIR) $(OBJ_DIR)
@echo "clean... OK"
-include $(OBJ:.o=.d)