-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
279 lines (225 loc) · 10.8 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# makefile of the emgAcquire package
#
# currently working only for the client
#
# Developer: Iason Batzianoulis
# email: iasonbatz@gmail.com
# License: GNU GPL v3
# define collors for printing to the console
redC := $(shell tput setaf 1)
greenC := $(shell tput setaf 2)
yellowC := $(shell tput setaf 3)
blueC := $(shell tput setaf 4)
boldT := $(shell tput bold)
reset:=$(shell tput sgr0)
# get the current path and export it
EMGACQUIRE_DIR = $(shell pwd)
# set output directory, where the executables will be built
OUTPUT_DIR = ./build
OUTPUT_OBJ_DIRx64 = $(OUTPUT_DIR)/obj/x64
OUTPUT_OBJ_DIRx86 = $(OUTPUT_DIR)/obj/x86
EXP_LIB_OUTPUT_DIRx64 = ./lib/linux/shared/x64
EXP_LIB_OUTPUT_DIRx86 = ./lib/linux/shared/x86
EXP_LIB_OUTPUT_STATIC_DIRx64 = ./lib/linux/static/x64
EXP_LIB_OUTPUT_STATIC_DIRx86 = ./lib/linux/static/x86
# set the compiler and its flags
CXX = g++
CXXFLAGS = -std=c++11 -Wall
CXX_x86_FLAG = -m32
CXX_x64_FLAG = -m64
# set include directories
INCLUDE_DIR = ./include ${CPP_DEPENDENCIES}/rapidjson/include ./socketStream/include
INCLUDE_PARAMS = $(foreach d, $(INCLUDE_DIR), -I $d)
# set the source directory
SRC_DIR = ./src
SOCKETSTREAM_SRC_DIR = ./socketStream/src
EXAMPLES_DIR = ./client_examples
# set objects to be created
_CLIENT_OBJS = emgAcquire.o acquireFilters.o socketStream.o jsonWrapper.o md5.o
CLIENT_OBJSx64 = $(patsubst %,$(OUTPUT_OBJ_DIRx64)/%,$(_CLIENT_OBJS))
CLIENT_OBJSx86 = $(patsubst %,$(OUTPUT_OBJ_DIRx86)/%,$(_CLIENT_OBJS))
# set the libraries needed for compiling
LIBS = -lpthread
test: makeOutDir clientExample
all: makeOutDir makeObjetsDir makeLibsDir clientExample generateObjectsx64 generateLibx64 generateStaticLibx64 generateObjectsx86 generateLibx86 generateStaticLibx86
libs: makeOutDir makeObjetsDir makeLibsDir generateObjectsx64 generateLibx64 generateStaticLibx64 generateObjectsx86 generateLibx86 generateStaticLibx86
libsx64 : makeObjetsDir generateObjectsx64 generateLibx64 generateStaticLibx64
libsx86: makeObjetsDir generateObjectsx86 generateLibx86 generateStaticLibx86
$(OUTPUT_OBJ_DIRx64)/emgAcquire.o: $(info $(greenC)$(boldT) --> generating emgAcquireClient object x64 $(yellowC)==>$(reset)) $(SRC_DIR)/emgAcquire.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x64_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx64)/acquireFilters.o: $(info $(greenC)$(boldT) --> generating acquireFilters object x64 $(yellowC)==>$(reset)) $(SRC_DIR)/acquireFilters.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x64_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx64)/socketStream.o: $(info $(greenC)$(boldT) --> generating socketStream object x64 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/socketStream.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x64_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx64)/jsonWrapper.o: $(info $(greenC)$(boldT) --> generating jsonWrapper object x64 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/jsonWrapper.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x64_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx64)/md5.o: $(info $(greenC)$(boldT) --> generating md5 object x64 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/md5.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x64_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
generateObjectsx64: $(info $(greenC)$(boldT) --> generating emgAcquire client objects x64 $(yellowC)==>$(reset)) $(CLIENT_OBJSx64)
$(CXX) -c -o $^ $(CXXFLAGS) $(CXX_x64_FLAG) $(LIBS)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
# generate shared libraries
generateLibx64:
$(info $(greenC)$(boldT) --> generating emgAcquire client shared library x64 $(yellowC)==>$(reset))
@$(CXX) $(CXXFLAGS) $(CXX_x64_FLAG) \
-shared -o ${EXP_LIB_OUTPUT_DIRx64}/libemgAcquireClient.so \
$(CLIENT_OBJSx64) \
$(INCLUDE_PARAMS) \
$(LIBS)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx86)/emgAcquire.o: $(info $(greenC)$(boldT) --> generating emgAcquireClient object x86 $(yellowC)==>$(reset)) $(SRC_DIR)/emgAcquire.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x86_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx86)/acquireFilters.o: $(info $(greenC)$(boldT) --> generating acquireFilters object x86 $(yellowC)==>$(reset)) $(SRC_DIR)/acquireFilters.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x86_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx86)/socketStream.o: $(info $(greenC)$(boldT) --> generating socketStream object x86 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/socketStream.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x86_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx86)/jsonWrapper.o: $(info $(greenC)$(boldT) --> generating jsonWrapper object x86 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/jsonWrapper.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x86_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
$(OUTPUT_OBJ_DIRx86)/md5.o: $(info $(greenC)$(boldT) --> generating md5 object x86 $(yellowC)==>$(reset)) $(SOCKETSTREAM_SRC_DIR)/md5.cpp
$(CXX) -c -o $@ $< $(INCLUDE_PARAMS) $(CXXFLAGS) $(CXX_x86_FLAG) -fpic
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
generateObjectsx86: $(info $(greenC)$(boldT) --> generating emgAcquire client objects x86 $(yellowC)==>$(reset)) $(CLIENT_OBJSx86)
$(CXX) -c -o $^ $(CXXFLAGS) $(CXX_x86_FLAG) $(LIBS)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
# generate shared libraries
generateLibx86:
$(info $(greenC)$(boldT) --> generating emgAcquire client shared library x86 $(yellowC)==>$(reset))
@$(CXX) $(CXXFLAGS) $(CXX_x86_FLAG) \
-shared -o ${EXP_LIB_OUTPUT_DIRx86}/libemgAcquireClient.so \
$(CLIENT_OBJSx86) \
$(INCLUDE_PARAMS) \
$(LIBS)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
# build emgAcquire client
clientExample:
$(info $(greenC)$(boldT) --> building emgAcquire client example $(yellowC)==>$(reset))
@$(CXX) $(CXXFLAGS) $(EXAMPLES_DIR)/client_example.cpp \
$(SRC_DIR)/emgAcquire.cpp $(SRC_DIR)/acquireFilters.cpp $(SOCKETSTREAM_SRC_DIR)/socketStream.cpp $(SOCKETSTREAM_SRC_DIR)/jsonWrapper.cpp $(SOCKETSTREAM_SRC_DIR)/md5.cpp \
-o ${OUTPUT_DIR}/emgAcquireClient \
$(INCLUDE_PARAMS) \
$(LIBS)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
# generate static libraries
generateStaticLibx64:
$(info $(greenC)$(boldT) --> generating emgAcquire client static library x64 $(yellowC)==>$(reset))
@ar rcs $(EXP_LIB_OUTPUT_STATIC_DIRx64)/libemgAcquireClient.a $(CLIENT_OBJSx64)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
generateStaticLibx86:
$(info $(greenC)$(boldT) --> generating emgAcquire client static library x86 $(yellowC)==>$(reset))
@ar rcs $(EXP_LIB_OUTPUT_STATIC_DIRx86)/libemgAcquireClient.a $(CLIENT_OBJSx86)
@if test $$? -eq 0;\
then tput setaf 4; tput bold; echo " --> OK"; tput sgr0; \
fi
# echo the path of the cpp dependencies
echoEvnVariable:
@echo ${CPP_DEPENDENCIES}
@echo $(PATH)
@echo $(CLIENT_OBJS)
# create a directory for the builts, if it doesn't exist
makeOutDir:
@if test -d ${OUTPUT_DIR}; \
then \
tput setaf 4; tput bold; printf " --> output folder "${OUTPUT_DIR}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating output folder ${OUTPUT_DIR} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${OUTPUT_DIR}; \
fi
# create a sub-directory for the objects, if it doesn't exist
makeObjetsDir:
@if test -d ${OUTPUT_OBJ_DIRx64}; \
then \
tput setaf 4; tput bold; printf " --> output object folder "${OUTPUT_OBJ_DIRx64}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating output object folder ${OUTPUT_OBJ_DIRx64} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${OUTPUT_OBJ_DIRx64}; \
fi
@if test -d ${OUTPUT_OBJ_DIRx86}; \
then \
tput setaf 4; tput bold; printf " --> output object folder "${OUTPUT_OBJ_DIRx86}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating output object folder ${OUTPUT_OBJ_DIRx86} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${OUTPUT_OBJ_DIRx86}; \
fi
# create a directory for the library, if it doesn't exist
makeLibsDir:
@if test -d ${EXP_LIB_OUTPUT_DIRx64}; \
then \
tput setaf 4; tput bold; printf " --> export libs directory "${EXP_LIB_OUTPUT_DIRx64}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating export libs directory ${EXP_LIB_OUTPUT_DIRx64} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${EXP_LIB_OUTPUT_DIRx64}; \
fi
@if test -d ${EXP_LIB_OUTPUT_DIRx86}; \
then \
tput setaf 4; tput bold; printf " --> export libs directory "${EXP_LIB_OUTPUT_DIRx86}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating export libs directory ${EXP_LIB_OUTPUT_DIRx86} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${EXP_LIB_OUTPUT_DIRx86}; \
fi
@if test -d ${EXP_LIB_OUTPUT_STATIC_DIRx64}; \
then \
tput setaf 4; tput bold; printf " --> export libs directory "${EXP_LIB_OUTPUT_STATIC_DIRx64}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating export libs directory ${EXP_LIB_OUTPUT_STATIC_DIRx64} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${EXP_LIB_OUTPUT_STATIC_DIRx64}; \
fi
@if test -d ${EXP_LIB_OUTPUT_STATIC_DIRx86}; \
then \
tput setaf 4; tput bold; printf " --> export libs directory "${EXP_LIB_OUTPUT_STATIC_DIRx86}" alread exists"; tput setaf 3; printf " ==>\n";\
tput sgr0;\
else \
tput setaf 2; printf " -->"; tput bold; printf " creating export libs directory ${EXP_LIB_OUTPUT_STATIC_DIRx86} " ; tput setaf 3; printf " ==>\n"; tput sgr0;\
mkdir -p ${EXP_LIB_OUTPUT_STATIC_DIRx86}; \
fi
.PHONY: clean
clean:
@tput setaf 2; printf " -->"; tput bold; printf " cleaning up ${OUTPUT_DIR} folder\n"; tput sgr0;
@rm -r ${OUTPUT_DIR}/*
@tput setaf 4; printf " -->"; tput bold; printf " output folder ${OUTPUT_DIR} is empty\n"; tput sgr0;\