mirror of
https://github.com/vel21ripn/nDPI.git
synced 2026-11-29 11:11:52 +00:00
The hand-written Makefiles compiled objects with a rule of the form
"%.o: %.c $(HEADERS)" where $(HEADERS) was a hand-maintained list. That list
missed transitive headers, third_party/include/*.h, the generated *.c.inc
files, and the ndpi-pro/nDPI-custom protocol snippets that tls.c #includes, so
editing any of those did not trigger a rebuild.
Replace it with automatic dependency tracking: compile with -MMD -MP so the
compiler writes an exact .d fragment per object, and read those back with
-include $(wildcard *.d). -MP emits phony targets for each header so a removed
header does not break the build. The explicit $(HEADERS) list is dropped
(kept only the generated-header ordering for the first compile); .d files are
removed by "make clean" and ignored via *.d in .gitignore.
Applied to src/lib, src/lib/plugins, example, tests/unit and tests/dga; the
automake-generated Makefiles already do this.
Also fix a typo that made --with-ndpi-pro a no-op: the AS_IF tested
${with_npri_pro} instead of ${with_ndpi_pro}, so CUSTOM_NDPI /
-DCUSTOM_NDPI_PROTOCOLS was never set.
88 lines
1.8 KiB
Makefile
88 lines
1.8 KiB
Makefile
# Support for out-of-tree builds (VPATH)
|
|
srcdir = @srcdir@
|
|
top_srcdir = @top_srcdir@
|
|
top_builddir = @top_builddir@
|
|
VPATH = @srcdir@
|
|
|
|
CC=@CC@
|
|
LDFLAGS=@LDFLAGS@
|
|
CXX=@CXX@
|
|
CFLAGS=@CFLAGS@
|
|
BUILD_MINGW=@BUILD_MINGW@
|
|
EXE_SUFFIX=@EXE_SUFFIX@
|
|
|
|
SRCHOME=$(top_srcdir)/src
|
|
|
|
ifneq ($(OS),Windows_NT)
|
|
AM_CFLAGS=-fPIC -DPIC
|
|
else
|
|
AM_CFLAGS=
|
|
endif
|
|
AM_CFLAGS+=-I$(SRCHOME)/include -I$(top_builddir)/src/include @NDPI_CFLAGS@ @JSONC_CFLAGS@ @PCAP_INC@ @ADDITIONAL_INCS@
|
|
AM_LDFLAGS=@NDPI_LDFLAGS@
|
|
ENABLE_STATIC = @enable_static@
|
|
ifeq ($(ENABLE_STATIC),yes)
|
|
LIBNDPI=$(top_builddir)/src/lib/libndpi.a
|
|
LIBNDPI_DEP=$(LIBNDPI)
|
|
else
|
|
LIBNDPI=-lndpi
|
|
LIBNDPI_DEP=$(top_builddir)/src/lib/libndpi.so
|
|
AM_LDFLAGS+=-L$(top_builddir)/src/lib
|
|
endif
|
|
LIBS=$(LIBNDPI) @PCAP_LIB@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ @LIBS@
|
|
OBJS=unit
|
|
PREFIX?=@prefix@
|
|
|
|
DEPFLAGS = -MMD -MP -MT $@ -MF $(@:.o=.d)
|
|
|
|
ifneq ($(BUILD_MINGW),)
|
|
|
|
ifeq ($(DISABLE_NPCAP),0)
|
|
AM_CFLAGS+=-I@srcdir@/../windows/WpdPack/Include -I@srcdir@/../windows/WpdPack/Include/pcap
|
|
else
|
|
AM_CFLAGS+=-DDISABLE_NPCAP
|
|
endif
|
|
|
|
ifeq ($(DISABLE_NPCAP),0)
|
|
|
|
ifneq ($(BUILD_MINGW_X64),)
|
|
LIBS+=@srcdir@/../windows/WpdPack/Lib/x64/wpcap.lib
|
|
else
|
|
LIBS+=@srcdir@/../windows/WpdPack/Lib/wpcap.lib
|
|
endif
|
|
|
|
endif
|
|
|
|
LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
|
|
else
|
|
LIBS+=-pthread
|
|
endif
|
|
|
|
all: unit$(EXE_SUFFIX)
|
|
|
|
EXECUTABLE_SOURCES := unit.c
|
|
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
|
|
|
|
unit$(EXE_SUFFIX): $(LIBNDPI_DEP) unit.o
|
|
$(CC) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_LDFLAGS) $(LDFLAGS) unit.o $(LIBS) -o $@
|
|
|
|
%.o: %.c Makefile
|
|
$(CC) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
|
|
|
-include $(wildcard *.d)
|
|
|
|
clean:
|
|
$(RM) *.o *.d *.lo unit$(EXE_SUFFIX)
|
|
$(RM) .*.o.cmd .*.o.d
|
|
$(RM) -r build .libs .deps
|
|
|
|
install:
|
|
echo ""
|
|
|
|
distdir:
|
|
|
|
distclean: clean
|
|
$(RM) Makefile
|
|
|
|
check:
|
|
true # nothing to do here, done by invoking tests/do-unit.sh
|