-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
119 lines (78 loc) · 2.89 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
OPTS_SQLITE3 = `pkg-config --cflags --libs sqlite3`
OPTS_YAML-CPP = -L/usr/lib/x86_64-linux-gnu -lyaml-cpp -I/usr/include/yaml-cpp/
OPTS_FMT = `pkg-config --cflags --libs fmt`
ALL_OPTS = $(OPTS_FMT) $(OPTS_SQLITE3) ${OPTS_YAML-CPP}
INCLUDE = ./include
SRC = ./src
TESTS = ./tests
TESTS_BIN = ./tests_bin
CC = g++ -std=c++2a -g
# install
BIN_PATH = /usr/local/bin
CFG_PATH = /etc/qkw-data
DATA = ./install-data
BUILD = ./build
MAN_PATH = /usr/share/man/man1
INSTALL-DATA = ./install-data
.PHONY: help
help:
@echo "\n | HELP MENU"
@echo "=================================================================="
@echo "\"make build\" : to build qkw "
@echo "\"make install\" : build, and install --qkw--"
@echo "\"make clean\" : clean after installation"
@echo "\"make run-tests\" : running all tests"
@echo " "
@echo "Defaults: after installation"
@echo "----------------------------"
@echo "binary path: /usr/local/bin/qkw"
@echo "config,database files: /etc/qkw-data/{userdata.db,qkw-config.yaml}"
@echo "Please set environment variable \"QKW_CONFIG\" to qkw-config.yaml"
@echo "=================================================================="
.PHONY: build
build : utils dir cmd _help qkw cli
@echo "--compiling--"
$(CC) -o $(BUILD)/qkw -I$(INCLUDE) $(BUILD)/*.o $(ALL_OPTS)
.PHONY: install
install:
cp $(BUILD)/qkw $(BIN_PATH)/
mkdir -p $(CFG_PATH) >> /dev/null
mkdir -p $(MAN_PATH) >> /dev/null
cp $(INSTALL-DATA)/qkw.1.gz $(MAN_PATH)/
cp $(INSTALL-DATA)/userdata.db $(CFG_PATH)/
cp $(INSTALL-DATA)/qkw-config.yaml $(CFG_PATH)/
@echo "--------------------------------------------------------"
@echo " Please set QKW_CONFIG to /etc/qkw-data/qkw-config.yaml"
@echo "--------------------------------------------------------"
.PHONY: app
app :
$(CC) -o $(TESTS_BIN)/app_header_check -I$(INCLUDE) $(ALL_OPTS) $(TESTS)/app_headers.cpp
.PHONY: test-utils
test-utils: utils
$(CC) -o $(TESTS_BIN)/$@ $(TESTS)/tests_utils.cpp $(BUILD)/*.o $(ALL_OPTS) -I$(INCLUDE)
.PHONY: test-qkw
test-qkw: utils qkw
$(CC) -o $(TESTS_BIN)/$@ $(TESTS)/tests_qkw.cpp $(BUILD)/*.o $(ALL_OPTS) -I$(INCLUDE)
.PHONY: test-dir
test-dir: utils qkw dir
$(CC) -o $(TESTS_BIN)/$@ $(TESTS)/tests_dir.cpp $(BUILD)/*.o $(ALL_OPTS) -I$(INCLUDE)
.PHONY: test-cmd
test-cmd: utils qkw cmd
$(CC) -o $(TESTS_BIN)/$@ $(TESTS)/tests_cmd.cpp $(BUILD)/*.o $(ALL_OPTS) -I$(INCLUDE)
.PHONY: run-tests
run-tests: test-qkw test-cmd test-dir test-utils
.PHONY: clean
clean:
rm $(BUILD)/*.o
cmd :
$(CC) -o $(BUILD)/$@.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/$@.cpp
utils :
$(CC) -o $(BUILD)/$@.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/$@.cpp
qkw :
$(CC) -o $(BUILD)/$@.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/$@.cpp
dir :
$(CC) -o $(BUILD)/$@.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/$@.cpp
cli :
$(CC) -o $(BUILD)/$@.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/$@.cpp
_help :
$(CC) -o $(BUILD)/help.o -I$(INCLUDE) $(ALL_OPTS) -c $(SRC)/help.cpp