Files
nDPId/Makefile.old
Toni Uhlig 0a7ad7a76a nDPId-test: added JSON distribution + JSON parsing (Multithreaded design re-using most of nDPId/nDPIsrvd core)
* improved Makefile.old install targets
 * splitted nDPIsrvd_parse into nDPIsrvd_parse_line and nDPIsrvd_parse_all for the sake of readability
 * minor Python script improvments (check for nDPIsrvd.py on multiple locations, may be superseeded by setuptools in the future)
 * some paths needs to be absolute (chdir() during daemonize) and therefor additional checks introduced
 * test run script checks and fails if certain files are are missing (PCAP file <=> result output file)
 * removed not very useful "internal format error" JSON serialization if a BUG for same exists
 * fixed invalid l4 type statistics counters for nDPIsrvd-collectd

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-04-09 00:18:35 +02:00

193 lines
6.5 KiB
Makefile

CC = gcc
PROJECT_CFLAGS += -Wall -Wextra $(EXTRA_CFLAGS) -I.
DEPS_CFLAGS := -DJSMN_STATIC=1 -DJSMN_STRICT=1 -Idependencies -Idependencies/jsmn -Idependencies/uthash/src
LIBS += -pthread -lpcap -lm
GOCC =
GOFLAGS = -ldflags='-s -w'
UNIX_SOCK_DISTRIBUTOR = /tmp/ndpid-distributor.sock
UNIX_SOCK_COLLECTOR = /tmp/ndpid-collector.sock
ifneq ($(PKG_CONFIG_BIN),)
PC_CFLAGS=$(shell $(PKG_CONFIG_BIN) --cflags libndpi)
PC_LDFLAGS=$(shell $(PKG_CONFIG_BIN) --libs libndpi)
ifneq ($(PKG_CONFIG_PATH),)
PROJECT_CFLAGS += -Wl,-rpath='$(shell dirname $(PKG_CONFIG_PATH))'
endif
else # PKG_CONFIG_BIN
ifeq ($(NDPI_WITH_GCRYPT),yes)
LIBS += -lgcrypt -lgpg-error
endif
ifeq ($(NDPI_WITH_PCRE),yes)
LIBS += -lpcre
endif
ifeq ($(NDPI_WITH_MAXMINDDB),yes)
LIBS += -lmaxminddb
endif
ifneq ($(CUSTOM_LIBNDPI),)
STATIC_NDPI_LIB += '$(CUSTOM_LIBNDPI)'
PROJECT_CFLAGS += '-I$(shell dirname $(CUSTOM_LIBNDPI))/../include/ndpi'
ifeq ($(findstring $*.so, $(CUSTOM_LIBNDPI)),.so)
PROJECT_CFLAGS += -Wl,-rpath='$(shell dirname $(CUSTOM_LIBNDPI))'
endif
else
LIBS += -lndpi
endif
endif # PKG_CONFIG_BIN
ifeq ($(ENABLE_MEMORY_PROFILING),yes)
MEMORY_PROFILING_CFLAGS += -DENABLE_MEMORY_PROFILING=1 -Duthash_malloc=nDPIsrvd_uthash_malloc -Duthash_free=nDPIsrvd_uthash_free
endif
ifeq ($(ENABLE_DEBUG),yes)
PROJECT_CFLAGS += -O0 -g3 -fno-omit-frame-pointer -fno-inline
endif
ifeq ($(ENABLE_SANITIZER),yes)
PROJECT_CFLAGS += -fsanitize=address -fsanitize=undefined -fsanitize=enum -fsanitize=leak
LIBS += -lasan -lubsan
endif
ifeq ($(ENABLE_SANITIZER_THREAD),yes)
PROJECT_CFLAGS += -fsanitize=undefined -fsanitize=enum -fsanitize=thread
LIBS += -lubsan
endif
GO_DASHBOARD_SRCS := examples/go-dashboard/main.go examples/go-dashboard/ui/ui.go
RM = rm -f
INSTALL = install
ifeq ($(ENABLE_DEBUG),yes)
INSTALL_ARGS_STRIP = -s
endif
all: help nDPId nDPIsrvd nDPId-test examples
examples: examples/c-collectd/c-collectd examples/c-captured/c-captured examples/c-json-stdout/c-json-stdout examples/go-dashboard/go-dashboard
nDPId: nDPId.c utils.c
$(CC) $(PROJECT_CFLAGS) $(MEMORY_PROFILING_CFLAGS) $(CFLAGS) $(PC_CFLAGS) $^ -o $@ $(LDFLAGS) $(PC_LDFLAGS) $(STATIC_NDPI_LIB) $(LIBS)
nDPIsrvd: nDPIsrvd.c utils.c
$(CC) $(PROJECT_CFLAGS) $(MEMORY_PROFILING_CFLAGS) $(CFLAGS) $(DEPS_CFLAGS) $^ -o $@ $(LDFLAGS)
nDPId-test: nDPId-test.c utils.c
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $(DEPS_CFLAGS) $(PC_CFLAGS) -D_GNU_SOURCE=1 -DNO_MAIN=1 -Dsyslog=mock_syslog_stderr -Wno-unused-function $^ -o $@ $(LDFLAGS) $(PC_LDFLAGS) $(STATIC_NDPI_LIB) $(LIBS)
examples/c-collectd/c-collectd: examples/c-collectd/c-collectd.c
$(CC) $(PROJECT_CFLAGS) $(MEMORY_PROFILING_CFLAGS) $(CFLAGS) $(DEPS_CFLAGS) $@.c -o $@ $(LDFLAGS)
examples/c-captured/c-captured: examples/c-captured/c-captured.c utils.c
$(CC) $(PROJECT_CFLAGS) $(MEMORY_PROFILING_CFLAGS) $(CFLAGS) $(DEPS_CFLAGS) $^ -o $@ $(LDFLAGS) -lpcap
examples/c-json-stdout/c-json-stdout: examples/c-json-stdout/c-json-stdout.c
$(CC) $(PROJECT_CFLAGS) $(MEMORY_PROFILING_CFLAGS) $(CFLAGS) $(DEPS_CFLAGS) $@.c -o $@ $(LDFLAGS)
examples/go-dashboard/go-dashboard: $(GO_DASHBOARD_SRCS)
ifneq ($(GOCC),)
cd examples/go-dashboard && GO111MODULE=on $(GOCC) mod vendor
cd examples/go-dashboard && GO111MODULE=on $(GOCC) build $(GOFLAGS) .
else
@echo '*** Not building examples/go-dashboard/go-dashboard as it requires GOCC to be set ***'
endif
install: all
$(INSTALL) -d \
'$(DESTDIR)$(PREFIX)/bin' \
'$(DESTDIR)$(PREFIX)/sbin' \
'$(DESTDIR)$(PREFIX)/share/nDPId'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./nDPId-test '$(DESTDIR)$(PREFIX)/bin'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./nDPIsrvd '$(DESTDIR)$(PREFIX)/bin'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./nDPId '$(DESTDIR)$(PREFIX)/sbin'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./examples/c-captured/c-captured '$(DESTDIR)$(PREFIX)/bin/nDPIsrvd-captured'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./examples/c-json-stdout/c-json-stdout '$(DESTDIR)$(PREFIX)/bin/nDPIsrvd-json-dump'
$(INSTALL) $(INSTALL_ARGS_STRIP) ./examples/c-collectd/c-collectd '$(DESTDIR)$(PREFIX)/bin/nDPIsrvd-collectd'
$(INSTALL) ./dependencies/nDPIsrvd.py '$(DESTDIR)$(PREFIX)/share/nDPId/nDPIsrvd.py'
$(INSTALL) ./examples/py-flow-info/flow-info.py '$(DESTDIR)$(PREFIX)/bin/nDPIsrvd-flow-info.py'
ifneq ($(GOCC),)
$(INSTALL) $(INSTALL_ARGS_STRIP) -t '$(DESTDIR)$(PREFIX)/bin' examples/go-dashboard/go-dashboard
endif
clean:
$(RM) -f nDPId nDPIsrvd nDPId-test examples/c-collectd/c-collectd examples/c-captured/c-captured examples/c-json-stdout/c-json-stdout examples/go-dashboard/go-dashboard
help:
@echo '------------------------------------'
@echo 'PKG_CONFIG_BIN = $(PKG_CONFIG_BIN)'
@echo 'PKG_CONFIG_PATH = $(PKG_CONFIG_PATH)'
@echo 'PC_CFLAGS = $(PC_CFLAGS)'
@echo 'PC_LDFLAGS = $(PC_LDFLAGS)'
@echo 'CC = $(CC)'
@echo 'CFLAGS = $(CFLAGS)'
@echo 'EXTRA_CFLAGS = $(EXTRA_CFLAGS)'
@echo 'LDFLAGS = $(LDFLAGS)'
@echo 'PROJECT_CFLAGS = $(PROJECT_CFLAGS)'
@echo 'LIBS = $(LIBS)'
@echo 'GOCC = $(GOCC)'
@echo 'GOFLAGS = $(GOFLAGS)'
ifeq ($(PKG_CONFIG_BIN),)
@echo 'CUSTOM_LIBNDPI = $(CUSTOM_LIBNDPI)'
ifeq ($(NDPI_WITH_GCRYPT),yes)
@echo 'NDPI_WITH_GCRYPT = yes'
else
@echo 'NDPI_WITH_GCRYPT = no'
endif
ifeq ($(NDPI_WITH_PCRE),yes)
@echo 'NDPI_WITH_PCRE = yes'
else
@echo 'NDPI_WITH_PCRE = no'
endif
ifeq ($(NDPI_WITH_MAXMINDDB),yes)
@echo 'NDPI_WITH_MAXMINDDB = yes'
else
@echo 'NDPI_WITH_MAXMINDDB = no'
endif
endif # PKG_CONFIG_BIN
ifeq ($(ENABLE_MEMORY_PROFILING),yes)
@echo 'ENABLE_MEMORY_PROFILING = yes'
else
@echo 'ENABLE_MEMORY_PROFILING = no'
endif
ifeq ($(ENABLE_DEBUG),yes)
@echo 'ENABLE_DEBUG = yes'
else
@echo 'ENABLE_DEBUG = no'
endif
ifeq ($(ENABLE_SANITIZER),yes)
@echo 'ENABLE_SANITIZER = yes'
else
@echo 'ENABLE_SANITIZER = no'
endif
ifeq ($(ENABLE_SANITIZER_THREAD),yes)
@echo 'ENABLE_SANITIZER_THREAD = yes'
else
@echo 'ENABLE_SANITIZER_THREAD = no'
endif
@echo '------------------------------------'
@echo 'Example:'
@echo ' make ENABLE_DEBUG=yes ENABLE_SANITIZER=yes GOCC=go-1.14.1 \\'
@echo ' CUSTOM_LIBNDPI="~/git/libnDPI/_install/lib/libndpi.a)" \\'
@echo ' NDPI_WITH_GCRYPT=yes ENABLE_MEMORY_PROFILING=no all'
@echo
run-mocksrvd:
nc -k -l -U $(UNIX_SOCK_COLLECTOR)
run-raw-out:
nc -U $(UNIX_SOCK_DISTRIBUTOR)
run-nDPIsrvd: nDPIsrvd
./nDPIsrvd -l -c $(UNIX_SOCK_COLLECTOR) -s $(UNIX_SOCK_DISTRIBUTOR)
run-nDPId: nDPId
sudo ./nDPId -l -c $(UNIX_SOCK_COLLECTOR) -a run-test -u $(shell id -u -n)
.PHONY: all examples install clean help run-mocksrvd run-raw-out run-nDPIsrvd run-nDPId