-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (48 loc) · 1.64 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
.PHONY: info clean
PROJECT_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SRC_DIR := ./src
SRC_APP := $(shell find . -name "*.cpp" ! -name "test_*cpp")
SRC_TST := $(shell find . -name "*.cpp" ! -name "app_main*cpp")
OBJ_APP := $(SRC_APP:%=%.o)
OBJ_TST := $(SRC_TST:%=%.o)
DEPENDS := $(shell find . -name "*.d")
LDFLAGS := -pthread
CPPFLAGS := -I$(SRC_DIR) -MMD -MP
CXXFLAGS := -std=c++11 -g -Wno-psabi -Wall
app_t: $(OBJ_TST)
@echo "==========> Build app_t to run unit tests"
cd $(PROJECT_ROOT)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
app_d: $(OBJ_APP)
@echo "==========> Build app_d with debug settings"
cd $(PROJECT_ROOT)
@echo "build debug version"
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
app: CXXFLAGS := -std=c++11 -O2 -Wall -fPIC
app: LDFLAGS := -shared -pthread
app: $(OBJ_APP)
@echo "==========> Build app release version"
cd $(PROJECT_ROOT)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
mv -v app touchscreen4py.so
$(SRC_DIR)/pch.hpp.gch: $(SRC_DIR)/pch.hpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++-header -c $< -o $@
$(SRC_DIR)/%.cpp.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/pch.hpp.gch
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
-include $(DEPENDS)
clean:
cd $(PROJECT_ROOT)
rm -fv $(OBJ_APP) $(OBJ_TST) ${DEPENDS} app_t app_d app $(SRC_DIR)/pch.hpp.gch
info:
cd $(PROJECT_ROOT)
@echo CXX -- $(CXX)
@echo CPPFLAGS -- $(CPPFLAGS)
@echo CXXFLAGS -- $(CXXFLAGS)
@echo LDFLAGS -- $(LDFLAGS)
@echo LDLIBS -- $(LDLIBS)
@echo PROJECT_ROOT -- $(PROJECT_ROOT)
@echo SRC_APP -- $(SRC_APP)
@echo SRC_TST -- $(SRC_TST)
@echo OBJ_APP -- $(OBJ_APP)
@echo OBJ_TST -- $(OBJ_TST)
@echo DEPENDS -- ${DEPENDS}