2
OS := $(shell uname -s)
4
INSTALL_DIR=@INSTALL_DIR@
7
NDPI_INC=-I./nDPI/src/include
8
NDPI_LIB=./nDPI/src/lib/.libs/libndpi.a
12
MONGOOSE_HOME=./third-party/mongoose
13
MONGOOSE_INC=-I$(MONGOOSE_HOME)
15
HAS_LUAJIT=$(shell pkg-config --exists luajit; echo $$?)
16
ifeq ($(HAS_LUAJIT), 0)
17
LUAJIT_INC = $(shell pkg-config --cflags luajit)
18
LUAJIT_LIB = $(shell pkg-config --libs luajit)
20
LUAJIT_HOME=./third-party/LuaJIT-2.0.3
21
LUAJIT_INC=-I$(LUAJIT_HOME)/src
22
LUAJIT_LIB=$(LUAJIT_HOME)/src/libluajit.a
25
LIBRRDTOOL_HOME=third-party/rrdtool-1.4.8
26
HAS_LIBRRDTOOL=$(shell pkg-config --exists librrd; echo $$?)
27
ifeq ($(HAS_LIBRRDTOOL), 0)
28
LIBRRDTOOL_INC = $(shell pkg-config --cflags librrd)
29
LIBRRDTOOL_LIB = $(shell pkg-config --libs librrd)
31
LIBRRDTOOL_INC=-I$(LIBRRDTOOL_HOME)/src/
32
LIBRRDTOOL_LIB=$(LIBRRDTOOL_HOME)/src/.libs/librrd_th.a
35
HTTPCLIENT_INC=third-party/http-client-c/src/
37
HAS_JSON=$(shell pkg-config --exists json-c; echo $$?)
39
JSON_INC = $(shell pkg-config --cflags json-c)
40
JSON_LIB = $(shell pkg-config --libs json-c)
42
JSON_HOME=third-party/json-c
43
JSON_INC=-I$(JSON_HOME)
44
JSON_LIB=$(JSON_HOME)/.libs/libjson-c.a
47
HAS_ZEROMQ=$(shell pkg-config --exists libzmq; echo $$?)
48
ifeq ($(HAS_ZEROMQ), 0)
49
ZEROMQ_INC = $(shell pkg-config --cflags libzmq)
50
ZMQ_STATIC=/usr/local/lib/libzmq.a
51
ifeq ($(wildcard $(ZMQ_STATIC)),)
52
ZEROMQ_LIB = $(shell pkg-config --libs libzmq)
54
ZEROMQ_LIB = $(ZMQ_STATIC)
57
ZEROMQ_HOME=./third-party/zeromq-3.2.4
58
ZEROMQ_INC=-I$(ZEROMQ_HOME)/include
59
ZEROMQ_LIB=$(ZEROMQ_HOME)/src/.libs/libzmq.a
62
EWH_HOME=third-party/EWAHBoolArray
63
EWH_INC=$(EWH_HOME)/headers
66
LIBS = @LDFLAGS@ $(NDPI_LIB) $(LIBPCAP) $(LUAJIT_LIB) $(LIBRRDTOOL_LIB) $(ZEROMQ_LIB) $(JSON_LIB) @HIREDIS_LIB@ @SQLITE_LIB@ @LINK_OPTS@ @GEOIP_LIB@ @DL_LIB@ @NL_LIB@ -lm -lpthread
67
CPPFLAGS = -g @CFLAGS@ @HIREDIS_INC@ $(MONGOOSE_INC) $(JSON_INC) $(NDPI_INC) $(LUAJIT_INC) $(LIBRRDTOOL_INC) $(ZEROMQ_INC) @CPPFLAGS@ -I$(HTTPCLIENT_INC) -I$(EWH_INC) # -D_GLIBCXX_DEBUG
69
# ntopng-1.0_1234.x86_64.rpm
71
REVISION = @SVN_RELEASE@
72
PACKAGE_VERSION = @PACKAGE_VERSION@
73
NTOPNG_VERSION = @NTOPNG_VERSION@
74
RPM_PKG = $(TARGET)-$(NTOPNG_VERSION)-$(REVISION).$(PLATFORM).rpm
75
RPM_DATA_PKG = $(TARGET)-data-$(NTOPNG_VERSION)-$(REVISION).noarch.rpm
84
ifneq ($(HAS_LUAJIT), 0)
85
LIB_TARGETS += $(LUAJIT_LIB)
88
ifneq ($(HAS_ZEROMQ), 0)
89
LIB_TARGETS += $(ZEROMQ_LIB)
92
ifneq ($(HAS_LIBRRDTOOL), 0)
93
LIB_TARGETS += $(LIBRRDTOOL_LIB)
96
ifneq ($(HAS_JSON), 0)
97
LIB_TARGETS += $(JSON_LIB)
100
.PHONY: default all clean docs test
102
.NOTPARALLEL: default all
104
default: $(NDPI_LIB) $(LIB_TARGETS) $(TARGET)
108
OBJECTS = $(patsubst %.cpp, %.o, $(wildcard *.cpp))
109
HEADERS = $(wildcard *.h)
111
%.o: %.c $(HEADERS) Makefile
112
$(GPP) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
114
%.o: %.cpp $(HEADERS) Makefile
115
$(GPP) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
117
.PRECIOUS: $(TARGET) $(OBJECTS)
119
$(TARGET): $(OBJECTS) $(LIBRRDTOOL) Makefile
120
$(GPP) $(OBJECTS) -Wall $(LIBS) -o $@
123
cd nDPI; if test ! -f Makefile; then ./autogen.sh ; ./configure; fi; make
126
svn co https://svn.ntop.org/svn/ntop/trunk/nDPI/
129
cd $(LUAJIT_HOME); @GMAKE@
132
cd $(ZEROMQ_HOME); ./configure --without-documentation; @GMAKE@
135
cd $(LIBRRDTOOL_HOME); ./configure --disable-rrd_graph --disable-libdbi --disable-libwrap --disable-rrdcgi --disable-libtool-lock --disable-nls --disable-rpath --disable-perl --disable-ruby --disable-lua --disable-tcl --disable-python --disable-dependency-tracking; cd src; @GMAKE@ librrd_th.la
138
cd $(JSON_HOME); ./autogen.sh; ./configure; @GMAKE@
141
-rm -f *.o *~ svn-commit.* #config.h
145
openssl req -new -x509 -sha1 -extensions v3_ca -nodes -days 365 -out cert.pem
146
cat privkey.pem cert.pem > httpdocs/ssl/ntopng-cert.pem
147
/bin/rm -f privkey.pem cert.pem
153
geoip: httpdocs/geoip/GeoLiteCity.dat httpdocs/geoip/GeoLiteCityv6.dat httpdocs/geoip/GeoIPASNum.dat httpdocs/geoip/GeoIPASNumv6.dat
155
httpdocs/geoip/GeoLiteCity.dat:
156
cd httpdocs/geoip; wget -nc http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz; gunzip -f GeoLiteCity.dat.gz
158
httpdocs/geoip/GeoLiteCityv6.dat:
159
cd httpdocs/geoip; wget -nc http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz; gunzip -f GeoLiteCityv6.dat.gz
161
httpdocs/geoip/GeoIPASNum.dat:
162
cd httpdocs/geoip; wget -nc http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz; gunzip -f GeoIPASNum.dat.gz
164
httpdocs/geoip/GeoIPASNumv6.dat:
165
cd httpdocs/geoip; wget -nc http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz; gunzip -f GeoIPASNumv6.dat.gz
169
# Do NOT build package as root (http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment)
170
# mkdir -p $(HOME)/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
171
# echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
173
build-rpm: build-rpm-ntopng build-rpm-ntopng-data
177
rm -rf ntopng-@NTOPNG_VERSION@
178
mkdir ntopng-@NTOPNG_VERSION@
179
cp -r doc *.cpp *.h configure COPYING README.* *.in ntopng.8 httpdocs scripts packages third-party ntopng-@NTOPNG_VERSION@
180
find ntopng-@NTOPNG_VERSION@ -name ".svn" | xargs /bin/rm -rf
181
cd ntopng-@NTOPNG_VERSION@; svn co https://svn.ntop.org/svn/ntop/trunk/nDPI/; cd ..
182
tar cvfz ntopng-@NTOPNG_VERSION@.tgz ntopng-@NTOPNG_VERSION@
184
rm -f $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(RPM_PKG)
185
cp ntopng-@NTOPNG_VERSION@.tgz $(HOME)/rpmbuild/SOURCES/
187
rpmbuild -bb ./packages/ntopng.spec
188
@./packages/rpm-sign.exp $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(RPM_PKG)
190
@echo "Package contents:"
191
@rpm -qpl $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(RPM_PKG)
192
@echo "The package is now available in $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(RPM_PKG)"
193
-rm -rf ntopng-@NTOPNG_VERSION@ ntopng_@NTOPNG_VERSION@.tgz
196
build-rpm-ntopng-data:
197
rm -rf ntopng-data-@NTOPNG_VERSION@
198
mkdir -p ntopng-data-@NTOPNG_VERSION@/usr/share/ntopng/httpdocs/geoip/
199
@if test -d ~/dat_files ; then \
200
cp ~/dat_files/* ntopng-data-@NTOPNG_VERSION@/usr/share/ntopng/httpdocs/geoip/; \
202
cp ./httpdocs/geoip/* ntopng-data-@NTOPNG_VERSION@/usr/share/ntopng/httpdocs/geoip/ ;\
204
#gunzip ntopng-data-@PACKAGE_VERSION@/usr/local/share/ntopng/httpdocs/geoip/*.gz
205
tar cvfz ntopng-data-@NTOPNG_VERSION@.tgz ntopng-data-@NTOPNG_VERSION@
207
rm -f $(HOME)/rpmbuild/RPMS/noarch/$(RPM_DATA_PKG)
208
cp ntopng-data-@NTOPNG_VERSION@.tgz $(HOME)/rpmbuild/SOURCES/
209
cd $(HOME)/rpmbuild/SOURCES;tar xvfz $(HOME)/rpmbuild/SOURCES/ntopng-data-@NTOPNG_VERSION@.tgz
210
rpmbuild -bb ./packages/ntopng-data.spec
211
@./packages/rpm-sign.exp $(HOME)/rpmbuild/RPMS/noarch/$(RPM_DATA_PKG)
213
@echo "Package contents:"
214
@rpm -qpl $(HOME)/rpmbuild/RPMS/noarch/$(RPM_DATA_PKG)
215
@echo "The package is now available in $(HOME)/rpmbuild/RPMS/noarch/$(RPM_DATA_PKG)"
216
-rm -rf ntopng-data-@NTOPNG_VERSION@ ntopng-data_@NTOPNG_VERSION@.tgz
219
cd doc && doxygen doxygen.conf
222
rm -rf ntopng-@NTOPNG_VERSION@
223
mkdir ntopng-@NTOPNG_VERSION@
224
cd ntopng-@NTOPNG_VERSION@; svn co https://svn.ntop.org/svn/ntop/trunk/ntopng/; cd ntopng; svn co https://svn.ntop.org/svn/ntop/trunk/nDPI/; cd ..; mv ntopng ntopng-@NTOPNG_VERSION@; tar cvfz ../ntopng-@NTOPNG_VERSION@.tgz ntopng-@NTOPNG_VERSION@
226
install: ntopng geoip
227
@echo "While we provide you an install make target, we encourage you"
228
@echo "to create a package and install that"
229
@echo "rpm - do 'make build-rpm'"
230
@echo "deb - do 'cd packages/ubuntu;./configure;make"
231
mkdir -p $(INSTALL_DIR)/share/ntopng $(MAN_DIR)/man/man8 $(INSTALL_DIR)/bin
232
cp ntopng $(INSTALL_DIR)/bin
233
cp ./ntopng.8 $(MAN_DIR)/man/man8
234
cp -r ./httpdocs $(INSTALL_DIR)/share/ntopng
235
cp -r ./scripts $(INSTALL_DIR)/share/ntopng
236
find $(INSTALL_DIR)/share/ntopng -name "*~" | xargs /bin/rm -f
237
find $(INSTALL_DIR)/share/ntopng -name ".svn" | xargs /bin/rm -rf
240
if test -f $(INSTALL_DIR)/bin/ntopng; then rm $(INSTALL_DIR)/bin/ntopng; fi;
241
if test -f $(MAN_DIR)/man/man8/ntopng.8; then rm $(MAN_DIR)/man/man8/ntopng.8; fi;
242
if test -d $(INSTALL_DIR)/share/ntopng; then rm -r $(INSTALL_DIR)/share/ntopng; fi;
244
Makefile: @SVN_WC_DB@
246
@echo "Re-running configure as the SVN release has changed"