summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-11-18 13:26:12 +0100
committerToni Uhlig <matzeton@googlemail.com>2020-11-18 13:26:12 +0100
commitdd5ff3b8ed94aad2e3aeda958ea6a14b95010c12 (patch)
treeb21afbafe21438814a4a4fe91f02f260a3b1904d
parent54dd72676d54b35b821eac6b9dddecd4ba62ee0a (diff)
Refactored Makefile pkg-config part to be able to work with multiple pkg-config based projects.
* added lua as new dependency for examples/c-captured * improved `make help' print Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--.travis.yml8
-rw-r--r--Makefile35
2 files changed, 30 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml
index c3bbbd14f..5fdf68e44 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,10 @@
language: c
before_install:
- sudo apt-get -qq update
-- sudo apt-get install -y build-essential make binutils gcc autoconf automake libtool pkg-config git libpcap-dev libgcrypt-dev libgpg-error-dev libjson-c-dev
+- sudo apt-get install -y build-essential make binutils gcc autoconf automake libtool pkg-config git libpcap-dev libgcrypt-dev libgpg-error-dev libjson-c-dev liblua5.1.0-dev
script:
- git clone https://github.com/ntop/nDPI.git
-- cd nDPI && ./autogen.sh --prefix=/usr --with-sanitizer --with-only-libndpi && make install DESTDIR="$(realpath ./_install)" && cd ..
-- make NDPI_WITH_GCRYPT=yes CUSTOM_LIBNDPI=./nDPI/_install/usr/lib/libndpi.a ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all
+- cd nDPI && ./autogen.sh --prefix=$(realpath ./_install) --with-sanitizer --with-only-libndpi && make install -j4 && cd ..
+- make NDPI_WITH_GCRYPT=yes CUSTOM_LIBNDPI=./nDPI/_install/lib/libndpi.a ENABLE_LUA=yes ENABLE_DEBUG=yes ENABLE_SANITIZER=yes LUA_LIBNAME=lua5.1 all examples
- make clean
-- make NDPI_WITH_GCRYPT=yes PKG_CONFIG_BIN=pkg-config PKG_CONFIG_PREFIX=./nDPI/_install/usr ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all
+- PKG_CONFIG_PATH="$(realpath ./nDPI/_install/lib/pkgconfig)" make PKG_CONFIG_BIN=pkg-config ENABLE_LUA=yes ENABLE_DEBUG=yes ENABLE_SANITIZER=yes LUA_LIBNAME=lua5.1 all examples
diff --git a/Makefile b/Makefile
index 792916588..12aa8d53e 100644
--- a/Makefile
+++ b/Makefile
@@ -7,16 +7,16 @@ GOCC =
GOFLAGS = -ldflags='-s -w'
ifneq ($(PKG_CONFIG_BIN),)
-ifneq ($(PKG_CONFIG_PREFIX),)
-PC_CFLAGS=$(shell PKG_CONFIG_PATH=$(shell realpath $(PKG_CONFIG_PREFIX))/lib/pkgconfig $(PKG_CONFIG_BIN) --define-variable=prefix=$(shell realpath $(PKG_CONFIG_PREFIX)) --cflags libndpi)
-PC_LDFLAGS=$(shell PKG_CONFIG_PATH=$(shell realpath $(PKG_CONFIG_PREFIX))/lib/pkgconfig $(PKG_CONFIG_BIN) --define-variable=prefix=$(shell realpath $(PKG_CONFIG_PREFIX)) --libs libndpi)
-PROJECT_CFLAGS += -Wl,-rpath='$(shell realpath $(PKG_CONFIG_PREFIX)/lib)'
-else
PC_CFLAGS=$(shell $(PKG_CONFIG_BIN) --cflags libndpi)
PC_LDFLAGS=$(shell $(PKG_CONFIG_BIN) --libs libndpi)
+
+ifeq ($(ENABLE_LUA),yes)
+LUA_LIBNAME=lua
+LUA_CFLAGS=$(shell $(PKG_CONFIG_BIN) --cflags $(LUA_LIBNAME))
+LUA_LIBS=$(shell $(PKG_CONFIG_BIN) --libs $(LUA_LIBNAME))
endif
-else
+else # PKG_CONFIG_BIN
ifeq ($(NDPI_WITH_GCRYPT),yes)
LIBS += -lgcrypt -lgpg-error
@@ -36,7 +36,7 @@ STATIC_NDPI_LIB =
LIBS += -lndpi
endif
-endif
+endif # PKG_CONFIG_BIN
ifeq ($(ENABLE_DEBUG),yes)
PROJECT_CFLAGS += -O0 -g3 -fno-omit-frame-pointer -fno-inline
@@ -67,7 +67,15 @@ nDPIsrvd: nDPIsrvd.c utils.c
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(STATIC_NDPI_LIB) $(LIBS)
examples/c-captured/c-captured: examples/c-captured/c-captured.c
- $(CC) $(PROJECT_CFLAGS) $(CFLAGS) $(JSMN_CFLAGS) $@.c -o $@ $(LDFLAGS) $(LIBS)
+ifneq ($(PKG_CONFIG_BIN),)
+ifeq ($(ENABLE_LUA),yes)
+ $(CC) $(PROJECT_CFLAGS) $(CFLAGS) $(JSMN_CFLAGS) $(LUA_CFLAGS) $@.c -o $@ $(LDFLAGS) $(LIBS) $(LUA_LIBS)
+else
+ @echo '*** Not building examples/c-captured/c-captured as it requires ENABLE_LUA=yes ***'
+endif
+else
+ @echo '*** Not building examples/c-captured/c-captured as it requires PKG_CONFIG_BIN to be set to your target pkg-config executable ***'
+endif
examples/c-json-stdout/c-json-stdout: examples/c-json-stdout/c-json-stdout.c
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $(JSMN_CFLAGS) $@.c -o $@ $(LDFLAGS) $(LIBS)
@@ -76,6 +84,8 @@ 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/c-captured/c-captured as it requires GOCC to be set ***'
endif
clean:
@@ -84,7 +94,7 @@ clean:
help:
@echo '------------------------------------'
@echo 'PKG_CONFIG_BIN = $(PKG_CONFIG_BIN)'
- @echo 'PKG_CONFIG_PREFIX = $(PKG_CONFIG_PREFIX)'
+ @echo 'PKG_CONFIG_PATH = $(PKG_CONFIG_PATH)'
@echo 'PC_CFLAGS = $(PC_CFLAGS)'
@echo 'PC_LDFLAGS = $(PC_LDFLAGS)'
@echo 'CC = $(CC)'
@@ -94,6 +104,7 @@ help:
@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'
@@ -105,6 +116,12 @@ ifeq ($(NDPI_WITH_PCRE),yes)
else
@echo 'NDPI_WITH_PCRE = no'
endif
+endif # PKG_CONFIG_BIN
+ifeq ($(ENABLE_LUA),yes)
+ @echo 'ENABLE_LUA = yes'
+else
+ @echo 'ENABLE_LUA = no'
+endif
ifeq ($(ENABLE_DEBUG),yes)
@echo 'ENABLE_DEBUG = yes'
else