forked from xplico/xplico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
269 lines (225 loc) · 7.28 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
# Makefile
#
# $Id: $
#
# Xplico - Internet Traffic Decoder
# By Gianluca Costa <[email protected]>
# Copyright 2007-2014 Gianluca Costa & Andrea de Franceschi. Web: www.xplico.org
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# root directory
ROOT_DIR = $(shell pwd)
ifndef DEFAULT_DIR
DEFAULT_DIR = /opt/xplico
endif
ifdef DESTDIR
INSTALL_DIR = $(DESTDIR)/$(DEFAULT_DIR)
else
INSTALL_DIR = $(DEFAULT_DIR)
endif
# sub directory
SUBDIRS = capt_dissectors common dissectors dispatch manipulators system
# xplico library
XPL_LIB = $(ROOT_DIR)/common/libxplico_core.a $(ROOT_DIR)/capt_dissectors/libxplico_capt.a $(ROOT_DIR)/dispatch/libxplico_dispatch.a $(ROOT_DIR)/dissectors/libxplico_dissector.a
# src file
SRC = xplico.c report.c
# compilation
INCLUDE_DIR = -I$(ROOT_DIR)/include -I$(ROOT_DIR)/common/include -I$(ROOT_DIR)/dissectors/include -I$(ROOT_DIR)/capt_dissectors/include -I$(ROOT_DIR)/dispatch/include
LDFLAGS = -L$(ROOT_DIR) -ldl -lpthread -lz -lssl -lcrypto
CFLAGS = -rdynamic $(INCLUDE_DIR) -Wall -fPIC -D_FILE_OFFSET_BITS=64 -O2
MODULE_PATH = modules
# pedantic statistics
CFLAGS += -DXPL_PEDANTIC_STATISTICS=1
# optmimization
ifdef O3
CFLAGS += -O3
ifndef CHECKOFF
CHECKOFF = 1
endif
else
#CFLAGS += -g -ggdb -dr
CFLAGS += -g -ggdb -O0
endif
# performance
ifdef GPROF
CFLAGS += -pg
endif
# table of flows sorted
ifndef FTBL_NOSORT
CFLAGS += -DFTBL_SORT=1
endif
# enable check code
ifndef CHECKOFF
CFLAGS += -DXPL_CHECK_CODE=1
endif
# architeture type
ifdef CROSS_COMPILE
CC = $(CROSS_COMPILE)gcc
STRIP = $(CROSS_COMPILE)strip
else
STRIP = strip
CFLAGS += -DXPL_X86=1
endif
# timeout connection in realtime acq
ifdef RT_TO
CFLAGS += -DXPL_REALTIME=1
endif
# verify GeoIP library source code
ifdef DISABLE_GEOIP
CFLAGS += -DGEOIP_LIBRARY=0
else
GEOIP_LIB = $(shell pkg-config --libs geoip)
LDFLAGS += $(GEOIP_LIB)
CFLAGS += -DGEOIP_LIBRARY=1
INCLUDE_DIR += $(shell pkg-config --cflags geoip)
endif
# nDPI local version (from source code)
ifdef LOCAL_NDPI
$(shell ln -s $(ROOT_DIR)/../nDPI/src/include $(ROOT_DIR)/../nDPI/src/include/libndpi)
endif
# main cflags
MCFLAGS = $(CFLAGS) -DLOG_COMPONENT=-1
# To make it visible
export CC CCPP ROOT_DIR CFLAGS LDFLAGS INCLUDE_DIR INSTALL_DIR GEOIP_LIB LOCAL_NDPI
all: subdir xplico mdl check_version
help:
@echo "Flags:"
@echo " VER=<string> --> string is the release name, otherwise the date is the name"
@echo " GPROF=1 --> enable gprof compilation"
@echo " FTBL_NOSORT=1 --> disable sort in flows manager"
@echo " DISABLE_GEOIP=1 --> disable GeoIP library"
@echo " LOCAL_NDPI=1 --> use local nDPI, linked statically"
@echo " O3=1 --> enable optimization"
@echo " "
@echo "Comands:"
@echo " help --> this help"
@echo " reset --> delete default tmp data"
@echo " clean --> clean"
@echo " tgz --> project snapshot"
@echo " install --> install in $(INSTALL_DIR)"
@echo " check_version --> check version"
@echo " "
# version name
ifndef VER
VER = $(shell date +%Y_%m_%d)
endif
xplico: $(SRC:.c=.o) $(XPL_LIB)
$(CC) $(MCFLAGS) -o $@ $(SRC:.c=.o) $(XPL_LIB) $(LDFLAGS)
mkdir -p tmp
mkdir -p xdecode
subdir:
@for dir in $(SUBDIRS) ; \
do $(MAKE) -C $$dir || exit 1; \
done
mdl:
mkdir -p $(MODULE_PATH)
cp -a dissectors/*/*.so $(MODULE_PATH)
cp -a capt_dissectors/*/*.so $(MODULE_PATH)
cp -a dispatch/*/*.so $(MODULE_PATH)
clean: reset
@for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean; done
rm -f xplico *.o *~ *.log .depend val.* *.expand
rm -rf $(MODULE_PATH)
rm -rf debian/xplico*
rm -f webmail/*/*~
rm -f */*~
rm -f */*/*~
rm -f *.tgz
installcp: all
rm -rf $(INSTALL_DIR)/*
mkdir -p $(INSTALL_DIR)
chmod 777 $(INSTALL_DIR)
mkdir -p $(INSTALL_DIR)/bin
mkdir -p $(INSTALL_DIR)/bin/modules
mkdir -p $(INSTALL_DIR)/script
mkdir -p $(INSTALL_DIR)/script/db
mkdir -p $(INSTALL_DIR)/cfg
mkdir -p $(INSTALL_DIR)/log
cp -a xplico $(INSTALL_DIR)/bin
# strip -s $(INSTALL_DIR)/bin/xplico
cp -a $(MODULE_PATH)/* $(INSTALL_DIR)/bin/modules
# strip -s $(INSTALL_DIR)/bin/modules/*.so
cp -a LICENSE COPYING* $(INSTALL_DIR)/
cp -a config/xplico_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/xplico_cli_fix.cfg $(INSTALL_DIR)/cfg/xplico_cli.cfg
cp -a config/xplico_cli_fix_nc.cfg $(INSTALL_DIR)/cfg/xplico_cli_nc.cfg
cp -a config/mfbc_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/mfbc_cli_fix.cfg $(INSTALL_DIR)/cfg/mfbc_cli.cfg
cp -a config/mwmail_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/mwmail_cli_fix.cfg $(INSTALL_DIR)/cfg/mwmail_cli.cfg
cp -a config/mfile_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/mfile_cli_fix.cfg $(INSTALL_DIR)/cfg/mfile_cli.cfg
cp -a config/mpaltalk_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/mpaltalk_cli_fix.cfg $(INSTALL_DIR)/cfg/mpaltalk_cli.cfg
cp -a config/mwebymsg_install_*.cfg $(INSTALL_DIR)/cfg
cp -a config/mwebymsg_cli_fix.cfg $(INSTALL_DIR)/cfg/webymsg_cli.cfg
cp -a config/tcp_grb_dig.cfg $(INSTALL_DIR)/cfg/tcp_grb_dig.cfg
ifeq ($(wildcard GeoLiteCity.dat), GeoLiteCity.dat)
cp -a GeoLiteCity.dat $(INSTALL_DIR)/GeoLiteCity.dat
endif
ifeq ($(wildcard GeoLiteCityv6.dat), GeoLiteCityv6.dat)
cp -a GeoLiteCityv6.dat $(INSTALL_DIR)/GeoLiteCityv6.dat
endif
ifeq ($(wildcard pcl6), pcl6)
cp -a pcl6 $(INSTALL_DIR)/bin
endif
ifeq ($(wildcard videosnarf), videosnarf)
cp -a videosnarf $(INSTALL_DIR)/bin
endif
# manipulators
$(MAKE) -C manipulators install
$(MAKE) -C system install
# install and permission
ifndef DESTDIR
install: installcp
chmod 777 $(INSTALL_DIR)
chmod 777 $(INSTALL_DIR)/cfg
chmod a+w $(INSTALL_DIR)/cfg/*
chmod -R 777 $(INSTALL_DIR)/xi/app/tmp
else
install: installcp
chmod 777 $(INSTALL_DIR)
chmod 777 $(INSTALL_DIR)/cfg
chmod a+w $(INSTALL_DIR)/cfg/*
chmod -R 777 $(INSTALL_DIR)/xi/app/tmp
mkdir -p $(DESTDIR)/etc/httpd/conf/extra
mkdir -p $(DESTDIR)/etc/apache2/sites-available/
mkdir -p $(DESTDIR)/etc/apache2/sites-enabled/
cp $(INSTALL_DIR)/cfg/apache_xi $(DESTDIR)/etc/httpd/conf/extra/httpd-xplico.conf
cp $(INSTALL_DIR)/cfg/apache_xi $(DESTDIR)/etc/apache2/sites-available/httpd-xplico.conf
mkdir -p $(DESTDIR)/opt/xplico/xi/app/tmp/cache
chmod -R 777 $(DESTDIR)/opt/xplico/xi/app/tmp/cache
mkdir -p $(DESTDIR)/usr/lib/systemd/system
cp xplico.service $(DESTDIR)/usr/lib/systemd/system/
endif
.PHONY: check_version
check_version:
@./check_version.sh none
.PHONY: reset
reset:
rm -rf tmp/*
rm -rf xdecode
tgz: clean
cd ..; tar cvzf xplico-$(VER).tgz --exclude cscope.files --exclude cscope.out --exclude CVS --exclude .svn --exclude release --exclude .svn xplico*/
mkdir -p release
mv ../xplico-$(VER).tgz release
rm -f release/*.gpg
%.o: %.c
$(CC) $(MCFLAGS) -c -o $@ $<
.depend: $(SRC)
$(CC) -M $(MCFLAGS) $(SRC) > $@
sinclude .depend