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.
152 lines
5.2 KiB
Makefile
152 lines
5.2 KiB
Makefile
#
|
|
# Simple non-autotools dependent makefile
|
|
#
|
|
# ./autogen.sh
|
|
# cd src/lib
|
|
# make Makefile
|
|
#
|
|
# Support for out-of-tree builds (VPATH)
|
|
srcdir = @srcdir@
|
|
top_srcdir = @top_srcdir@
|
|
top_builddir = @top_builddir@
|
|
VPATH = @srcdir@:@srcdir@/protocols:@srcdir@/third_party/src:@srcdir@/third_party/src/hll
|
|
|
|
AR = @AR@
|
|
CC = @CC@
|
|
RANLIB = @RANLIB@
|
|
# Preserve user's CFLAGS and LDFLAGS from configure
|
|
CFLAGS = @CFLAGS@
|
|
LDFLAGS = @LDFLAGS@
|
|
#
|
|
# Installation directories
|
|
#
|
|
prefix = @prefix@
|
|
exec_prefix = @exec_prefix@
|
|
libdir = @libdir@
|
|
includedir = @includedir@/ndpi
|
|
# For backwards compatibility
|
|
PREFIX = $(prefix)
|
|
OS_TYPE = @OS_TYPE@
|
|
ifneq ($(OS_TYPE),Windows_NT)
|
|
AM_CFLAGS = -fPIC -DPIC
|
|
else
|
|
AM_CFLAGS =
|
|
endif
|
|
AM_CFLAGS += -I$(srcdir) -I$(top_srcdir)/src/include -I$(top_builddir)/src/include -I$(srcdir)/third_party/include -DNDPI_LIB_COMPILATION @NDPI_CFLAGS@ @GPROF_CFLAGS@ @CUSTOM_NDPI@ @ADDITIONAL_INCS@
|
|
CFLAGS_ndpi_bitmap.c := -Wno-unused-function
|
|
CFLAGS_ndpi_bitmap64_fuse.c := -Wno-unused-function
|
|
CFLAGS_gcrypt_light.c := -Wno-unused-function -Wno-unused-parameter
|
|
CFLAGS_ahocorasick.c := -Wno-unused-function -Wno-unused-parameter
|
|
CFLAGS_roaring.c := -Wno-unused-function -Wno-attributes -Wno-missing-braces -Wno-missing-field-initializers
|
|
# Use AM_LDFLAGS for package flags, never modify user's LDFLAGS
|
|
AM_LDFLAGS = @NDPI_LDFLAGS@
|
|
LIBS = @ADDITIONAL_LIBS@ @LIBS@ @GPROF_LIBS@
|
|
|
|
OBJECTS = $(patsubst $(srcdir)/protocols/%.c, %.o, $(wildcard $(srcdir)/protocols/*.c)) $(patsubst $(srcdir)/third_party/src/%.c, %.o, $(wildcard $(srcdir)/third_party/src/*.c)) $(patsubst $(srcdir)/third_party/src/hll/%.c, %.o, $(wildcard $(srcdir)/third_party/src/hll/*.c)) $(patsubst $(srcdir)/%.c, %.o, $(wildcard $(srcdir)/*.c))
|
|
NDPI_VERSION_MAJOR = @NDPI_MAJOR@
|
|
NDPI_LIB_STATIC = libndpi.a
|
|
NDPI_LIB_SHARED_BASE = libndpi.so
|
|
NDPI_LIB_SHARED = $(NDPI_LIB_SHARED_BASE).@NDPI_VERSION_SHORT@
|
|
ENABLE_SHARED = @enable_shared@
|
|
ENABLE_STATIC = @enable_static@
|
|
USE_HOST_LIBGCRYPT = @USE_HOST_LIBGCRYPT@
|
|
|
|
ifneq ($(USE_HOST_LIBGCRYPT),0)
|
|
TMP_OBJS := $(OBJECTS)
|
|
OBJECTS = $(filter-out gcrypt_light.o,$(TMP_OBJS))
|
|
endif
|
|
|
|
BUILD_MINGW = @BUILD_MINGW@
|
|
|
|
# Platform-specific settings
|
|
ifeq ($(OS_TYPE),Darwin)
|
|
SONAME_FLAG=
|
|
else
|
|
ifneq ($(BUILD_MINGW),)
|
|
NDPI_LIB_SHARED_BASE = libndpi
|
|
NDPI_LIB_SHARED = $(NDPI_LIB_SHARED_BASE)-@NDPI_VERSION_SHORT@.dll
|
|
else
|
|
SONAME_FLAG=-Wl,-soname,$(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
|
|
endif
|
|
endif
|
|
|
|
# Conditionally build libraries based on configure flags
|
|
NDPI_LIBS =
|
|
ifeq ($(ENABLE_STATIC),yes)
|
|
NDPI_LIBS += $(NDPI_LIB_STATIC)
|
|
endif
|
|
ifeq ($(ENABLE_SHARED),yes)
|
|
NDPI_LIBS += $(NDPI_LIB_SHARED)
|
|
endif
|
|
|
|
# Sanity check: at least one library type must be enabled
|
|
ifeq ($(NDPI_LIBS),)
|
|
$(error Cannot build with both --disable-shared and --disable-static)
|
|
endif
|
|
|
|
all: $(NDPI_LIBS)
|
|
|
|
ndpi_main.o: $(srcdir)/ndpi_content_match.c.inc \
|
|
$(srcdir)/ndpi_dga_match.c.inc \
|
|
$(wildcard $(srcdir)/inc_generated/*.c.inc)
|
|
|
|
ndpi_fingerprint.o: $(srcdir)/ndpi_os_fingerprint.c.inc
|
|
|
|
# The generated headers have no compiler-tracked dependency until the first
|
|
# build has produced the .d files, so list them explicitly to order the very
|
|
# first compile.
|
|
$(OBJECTS): $(top_builddir)/src/include/ndpi_config.h $(top_builddir)/src/include/ndpi_define.h
|
|
|
|
# Automatic dependency tracking
|
|
DEPFLAGS = -MMD -MP -MT $@ -MF $(@:.o=.d)
|
|
-include $(wildcard *.d)
|
|
|
|
$(NDPI_LIB_STATIC): $(OBJECTS)
|
|
$(AR) rc $@ $(OBJECTS)
|
|
$(RANLIB) $@
|
|
|
|
$(NDPI_LIB_SHARED): $(OBJECTS)
|
|
$(CC) -shared -fPIC $(AM_CFLAGS) $(CFLAGS) $(SONAME_FLAG) -o $@ $(AM_LDFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS)
|
|
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE)
|
|
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
|
|
|
|
%.o: %.c Makefile
|
|
$(CC) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_$(notdir $<)) $(DEPFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
$(RM) $(NDPI_LIB_STATIC) $(NDPI_LIB_SHARED) $(OBJECTS) *.o *.d *.so *.so.* *.lo *.dll *.la
|
|
$(RM) $(NDPI_LIB_SHARED_BASE) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
|
|
$(RM) -r .libs .deps
|
|
|
|
distdir:
|
|
find $(srcdir) -type d | xargs -I'{}' mkdir -p '$(distdir)/{}'
|
|
find $(top_srcdir)/src/include -type f -name '*.h' \
|
|
-a '!' -name 'ndpi_config.h' \
|
|
-a '!' -name 'ndpi_define.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
|
|
find $(srcdir) -type f -name '*.c' \
|
|
-o -name '*.cc' \
|
|
-o -name '*.c.inc' \
|
|
-o -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
|
|
|
|
distclean: clean
|
|
$(RM) Makefile
|
|
|
|
check:
|
|
true # nothing to do here
|
|
|
|
cppcheck:
|
|
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I $(top_srcdir)/src/include $(srcdir)/*.c $(srcdir)/protocols/*.c
|
|
|
|
install: $(NDPI_LIBS)
|
|
@MKDIR_P@ $(DESTDIR)@libdir@
|
|
cp $(NDPI_LIBS) $(DESTDIR)@libdir@/
|
|
ifeq ($(ENABLE_SHARED),yes)
|
|
cp -P $(NDPI_LIB_SHARED_BASE) $(DESTDIR)@libdir@/
|
|
cp -P $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) $(DESTDIR)@libdir@/
|
|
endif
|
|
@MKDIR_P@ $(DESTDIR)@includedir@/ndpi
|
|
#Avoid installing private header
|
|
# Installing header files to $(DESTDIR)@includedir@/ndpi
|
|
find $(top_srcdir)/src/include/*.h ! -name ndpi_private.h -exec cp "{}" $(DESTDIR)@includedir@/ndpi \;
|
|
cp $(top_builddir)/src/include/ndpi_config.h $(DESTDIR)@includedir@/ndpi/
|
|
cp $(top_builddir)/src/include/ndpi_define.h $(DESTDIR)@includedir@/ndpi/
|