From b503900b1456e8bd4b60d1deb0ef7cc3665676f1 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 4 Apr 2021 21:59:14 +0200 Subject: First step of cleaning up the Makefile.in hell. The goal is to get rid of the Makefile.in's (replace it with Automake Makefile.am's) as they duplicate lot's of text. That decreases readability and is in general a bad design pattern. It seems appropriate to use Automake for an Autoconf based project. Currently achieved: * using libtool to build the core library (+libtool's semantic versioning) * out-of-source builds should work right now * introducing Automake based Makefile in src/ * removed some (maybe) unused GIT ignored files * provide some small python fixes Signed-off-by: Toni Uhlig --- example/Makefile.dpdk.in | 2 +- example/Makefile.in | 72 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 23 deletions(-) (limited to 'example') diff --git a/example/Makefile.dpdk.in b/example/Makefile.dpdk.in index cd703414b..016a6520c 100644 --- a/example/Makefile.dpdk.in +++ b/example/Makefile.dpdk.in @@ -15,7 +15,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc include $(RTE_SDK)/mk/rte.vars.mk APP = ndpiReader.dpdk -LIBNDPI = $(PWD)/../src/lib/libndpi.a +LIBNDPI = ../src/.libs/libndpi.a SRCS-y := reader_util.c intrusion_detection.c ndpiReader.c diff --git a/example/Makefile.in b/example/Makefile.in index cef1edb63..79847087a 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -1,12 +1,20 @@ CC=@CC@ CXX=@CXX@ BUILD_MINGW=@BUILD_MINGW@ -SRCHOME=../src -CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@ -LIBNDPI=$(SRCHOME)/lib/libndpi.a -LDFLAGS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ -lpthread @LDFLAGS@ -HEADERS=intrusion_detection.h reader_util.h $(SRCHOME)/include/ndpi_api.h \ - $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h +DPDK_TARGET=@DPDK_TARGET@ + +BUILD_SRC=../src +ROOT_SRC=@srcdir@/../src +ROOT_EXAMPLES=@srcdir@ + +CFLAGS=-g -fPIC -DPIC -I$(ROOT_SRC)/include -I$(BUILD_SRC)/include @PCAP_INC@ @CFLAGS@ +LIBNDPI=$(BUILD_SRC)/.libs/libndpi.a +LDFLAGS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ -lpthread @LDFLAGS@ +HEADERS=$(ROOT_EXAMPLES)/intrusion_detection.h \ + $(ROOT_EXAMPLES)/reader_util.h \ + $(BUILD_SRC)/include/ndpi_api.h \ + $(ROOT_SRC)/include/ndpi_typedefs.h \ + $(ROOT_SRC)/include/ndpi_protocol_ids.h OBJS=ndpiReader.o reader_util.o intrusion_detection.o PREFIX?=@prefix@ @@ -16,47 +24,67 @@ all: else -all: ndpiReader @DPDK_TARGET@ - -EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c -COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c )) +all: ndpiReader $(DPDK_TARGET) -libndpiReader.a: $(COMMON_SOURCES:%.c=%.o) $(LIBNDPI) - ar rsv libndpiReader.a $(COMMON_SOURCES:%.c=%.o) +libndpiReader.a: $(LIBNDPI) reader_util.o intrusion_detection.o + ar rsv libndpiReader.a reader_util.o intrusion_detection.o -ndpiReader: libndpiReader.a $(LIBNDPI) ndpiReader.o - $(CC) $(CFLAGS) ndpiReader.o libndpiReader.a -o $@ $(LDFLAGS) +ndpiReader: libndpiReader.a ndpiReader.o + $(CC) $(CFLAGS) ndpiReader.o -o $@ libndpiReader.a $(LDFLAGS) ndpiSimpleIntegration: ndpiSimpleIntegration.o $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -%.o: %.c $(HEADERS) Makefile - $(CC) $(CFLAGS) -c $< -o $@ +%.o: $(ROOT_EXAMPLES)/%.c $(HEADERS) Makefile + $(CC) $(CFLAGS) -c $< -o $(notdir $@) install: ndpiReader mkdir -p $(DESTDIR)$(PREFIX)/bin/ mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi cp ndpiReader $(DESTDIR)$(PREFIX)/bin/ - cp protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt - cp mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt + cp $(ROOT_EXAMPLES)/protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt + cp $(ROOT_EXAMPLES)/categories.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt + cp $(ROOT_EXAMPLES)/mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomHosts.txt [ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true [ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true dpdk: +ifneq ($(DPDK_TARGET),) make -f Makefile.dpdk +else + @echo 'Skipping. DPDK needs to be enabled during configure.' +endif check: - cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include *.c + cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force \ + -I$(ROOT_SRC)/include \ + -I$(BUILD_SRC)/include \ + -I. \ + $(ROOT_EXAMPLES)/*.c clean: - /bin/rm -f *.o ndpiReader ndpiReader.dpdk + /bin/rm -f *.o ndpiReader ndpiReader.dpdk ndpiSimpleIntegration libndpiReader.a /bin/rm -f .*.dpdk.cmd .*.o.cmd *.dpdk.map .*.o.d /bin/rm -f _install _postbuild _postinstall _preinstall /bin/rm -rf build distdir: - cp categories.txt mining_hosts.txt protos.txt README.DPDK '$(distdir)/' - find . -maxdepth 1 -type f -name '*.c' -o -name '*.h' -o -name '*.py' | xargs -I'{}' cp '{}' '$(distdir)/{}' + cp \ + $(ROOT_EXAMPLES)/categories.txt \ + $(ROOT_EXAMPLES)/mining_hosts.txt \ + $(ROOT_EXAMPLES)/protos.txt \ + $(ROOT_EXAMPLES)/risky_domains.txt \ + $(ROOT_EXAMPLES)/ja3_fingerprints.csv \ + $(ROOT_EXAMPLES)/sha1_fingerprints.csv \ + $(ROOT_EXAMPLES)/README.DPDK \ + $(ROOT_EXAMPLES)/intrusion_detection.h \ + $(ROOT_EXAMPLES)/ndpiSimpleIntegration.c \ + $(ROOT_EXAMPLES)/reader_util.c \ + $(ROOT_EXAMPLES)/ndpiReader.c \ + $(ROOT_EXAMPLES)/ndpi2timeline.py \ + $(ROOT_EXAMPLES)/intrusion_detection.c \ + $(ROOT_EXAMPLES)/reader_util.h \ + '$(distdir)/' distclean: clean /bin/rm -f Makefile.dpdk -- cgit v1.2.3