-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
264 lines (224 loc) · 7.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
CXX := g++
CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror -Wno-error=unused-function -Wfatal-errors -std=c++20 -O3 -g
LDFLAGS := -L /usr/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
GEN_DIR := $(BUILD)/generated
APP_DIR := $(BUILD)/apps
BASE_NAME := libghoti.io-wave.so
MAJOR_VERSION := 0
MINOR_VERSION := 0.0
SO_NAME := $(BASE_NAME).$(MAJOR_VERSION)
TARGET := $(SO_NAME).$(MINOR_VERSION)
INCLUDE := -I include/ -I include/wave
LIBOBJECTS := $(OBJ_DIR)/blob.o \
$(OBJ_DIR)/client.o \
$(OBJ_DIR)/clientSession.o \
$(OBJ_DIR)/parser.o \
$(OBJ_DIR)/parsing.o \
$(OBJ_DIR)/response.o \
$(OBJ_DIR)/message.o \
$(OBJ_DIR)/server.o \
$(OBJ_DIR)/serverSession.o
TESTFLAGS := `pkg-config --libs --cflags gtest`
WAVELIBRARY := -L $(APP_DIR) -lghoti.io-wave `pkg-config --libs --cflags ghoti.io-util ghoti.io-pool`
all: $(APP_DIR)/$(TARGET) ## Build the shared library
####################################################################
# Dependency Variables
####################################################################
DEP_MACROS = \
include/wave/macros.hpp
DEP_PARSING = \
include/wave/parsing.hpp
DEP_BLOB = \
include/wave/blob.hpp
DEP_HASCLIENTPARAMETERS = \
include/wave/hasClientParameters.hpp
DEP_HASSERVERPARAMETERS = \
include/wave/hasServerParameters.hpp
DEP_MESSAGE = \
$(DEP_BLOB) \
$(DEP_PARSING) \
include/wave/message.hpp
DEP_PARSER = \
$(DEP_HASCLIENTPARAMETERS) \
$(DEP_HASSERVERPARAMETERS) \
$(DEP_BLOB) \
$(DEP_PARSING) \
$(DEP_MESSAGE) \
include/wave/parser.hpp
DEP_RESPONSE = \
include/wave/response.hpp
DEP_CLIENTSESSION = \
$(DEP_HASCLIENTPARAMETERS) \
$(DEP_PARSER) \
$(DEP_MESSAGE) \
include/wave/clientSession.hpp
DEP_SERVERSESSION = \
$(DEP_HASSERVERPARAMETERS) \
$(DEP_PARSER) \
$(DEP_MESSAGE) \
include/wave/serverSession.hpp
DEP_CLIENT = \
$(DEP_HASCLIENTPARAMETERS) \
$(DEP_CLIENTSESSION) \
include/wave/client.hpp
DEP_SERVER = \
$(DEP_HASSERVERPARAMETERS) \
$(DEP_SERVERSESSION) \
include/wave/server.hpp
DEP_WAVE = \
$(DEP_HASCLIENTPARAMETERS) \
$(DEP_HASSERVERPARAMETERS) \
$(DEP_CLIENT) \
$(DEP_CLIENTSESSION) \
$(DEP_MACROS) \
$(DEP_RESPONSE) \
$(DEP_MESSAGE) \
$(DEP_SERVER) \
$(DEP_SERVERSESSION) \
include/wave.hpp
####################################################################
# Object Files
####################################################################
$(LIBOBJECTS) :
@echo "\n### Compiling $@ ###"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@ -fPIC
$(OBJ_DIR)/blob.o: \
src/blob.cpp \
$(DEP_BLOB)
$(OBJ_DIR)/client.o: \
src/client.cpp \
$(DEP_CLIENT)
$(OBJ_DIR)/clientSession.o: \
src/clientSession.cpp \
$(DEP_CLIENTSESSION)
$(OBJ_DIR)/parser.o: \
src/parser.cpp \
$(DEP_PARSER)
$(OBJ_DIR)/parsing.o: \
src/parsing.cpp \
$(DEP_PARSING)
$(OBJ_DIR)/response.o: \
src/response.cpp \
$(DEP_RESPONSE)
$(OBJ_DIR)/message.o: \
src/message.cpp \
$(DEP_MESSAGE)
$(OBJ_DIR)/server.o: \
src/server.cpp \
$(DEP_SERVER)
$(OBJ_DIR)/serverSession.o: \
src/serverSession.cpp \
$(DEP_SERVERSESSION)
$(OBJ_DIR)/wave.o: \
src/wave.cpp \
$(DEP_WAVE)
####################################################################
# Shared Library
####################################################################
$(APP_DIR)/$(TARGET): \
$(LIBOBJECTS)
@echo "\n### Compiling Ghoti.io Wave Shared Library ###"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) `pkg-config --libs --cflags ghoti.io-pool ghoti.io-util` -Wl,-soname,$(SO_NAME)
@ln -f -s $(TARGET) $(APP_DIR)/$(SO_NAME)
@ln -f -s $(SO_NAME) $(APP_DIR)/$(BASE_NAME)
####################################################################
# Unit Tests
####################################################################
OBJDEP_BLOB = \
$(OBJ_DIR)/blob.o
$(APP_DIR)/test-blob: \
test/test-blob.cpp \
$(DEP_BLOB) \
$(OBJDEP_BLOB)
@echo "\n### Compiling Wave Blob Test ###"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ $< $(LDFLAGS) $(TESTFLAGS) `pkg-config --libs --cflags ghoti.io-util` $(OBJDEP_BLOB)
OBJDEP_MESSAGE = \
$(OBJDEP_BLOB) \
$(OBJ_DIR)/parsing.o \
$(OBJ_DIR)/message.o
$(APP_DIR)/test-message: \
test/test-message.cpp \
$(DEP_MESSAGE) \
$(OBJDEP_MESSAGE)
@echo "\n### Compiling Wave Message Test ###"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ $< $(LDFLAGS) $(TESTFLAGS) `pkg-config --libs --cflags ghoti.io-util` $(OBJDEP_MESSAGE)
$(APP_DIR)/test: \
test/test.cpp \
$(DEP_WAVE) \
$(APP_DIR)/$(TARGET)
@echo "\n### Compiling Wave Test ###"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ $< $(LDFLAGS) $(TESTFLAGS) $(WAVELIBRARY)
####################################################################
# Commands
####################################################################
.PHONY: all clean cloc docs docs-pdf install test test-watch watch
watch: ## Watch the file directory for changes and compile the target
@while true; do \
make all; \
echo "\033[0;32m"; \
echo "#########################"; \
echo "# Waiting for changes.. #"; \
echo "#########################"; \
echo "\033[0m"; \
inotifywait -qr -e modify -e create -e delete -e move src include test Makefile --exclude '/\.'; \
done
test-watch: ## Watch the file directory for changes and run the unit tests
@while true; do \
make test; \
echo "\033[0;32m"; \
echo "#########################"; \
echo "# Waiting for changes.. #"; \
echo "#########################"; \
echo "\033[0m"; \
inotifywait -qr -e modify -e create -e delete -e move src include test Makefile --exclude '/\.'; \
done
test: ## Make and run the Unit tests
test: \
$(APP_DIR)/test-blob \
$(APP_DIR)/test-message \
$(APP_DIR)/test
@echo "\033[0;32m"
@echo "############################"
@echo "### Running normal tests ###"
@echo "############################"
@echo "\033[0m"
env LD_LIBRARY_PATH="$(APP_DIR)" $(APP_DIR)/test-blob --gtest_brief=1
env LD_LIBRARY_PATH="$(APP_DIR)" $(APP_DIR)/test-message --gtest_brief=1
env LD_LIBRARY_PATH="$(APP_DIR)" $(APP_DIR)/test --gtest_brief=1
clean: ## Remove all contents of the build directories.
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
-@rm -rvf $(GEN_DIR)/*
install: ## Install the library globally, requires sudo
# Install the Shared Library
@mkdir -p /usr/local/lib/ghoti.io
@cp $(APP_DIR)/$(TARGET) /usr/local/lib/ghoti.io/
@ln -f -s $(TARGET) /usr/local/lib/ghoti.io/$(SO_NAME)
@ln -f -s $(SO_NAME) /usr/local/lib/ghoti.io/$(BASE_NAME)
@echo "/usr/local/lib/ghoti.io" > /etc/ld.so.conf.d/ghoti.io-wave.conf
# Install the headers
@mkdir -p /usr/local/include/ghoti.io/wave
@cp include/wave.hpp /usr/local/include/ghoti.io/
@#cp include/wave/*.hpp /usr/local/include/ghoti.io/wave/
# Install the pkgconfig files
@mkdir -p /usr/local/share/pkgconfig
@cp pkgconfig/ghoti.io-wave.pc /usr/local/share/pkgconfig/
# Run ldconfig
@ldconfig >> /dev/null 2>&1
@echo "Ghoti.io Wave installed"
docs: ## Generate the documentation in the ./docs subdirectory
doxygen
docs-pdf: docs ## Generate the documentation as a pdf, in ./docs/wave-docs.pdf
cd ./docs/latex/ && make
mv -f ./docs/latex/refman.pdf ./docs/wave-docs.pdf
cloc: ## Count the lines of code used in the project
cloc src include test Makefile
help: ## Display this help
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'