nDPI/rrdtool/Makefile.in
Ivan Nardi d76007054c
Build system: Fix --disable-shared and --disable-static flags being ignored (#3044)
The configure flags --disable-shared and --disable-static were properly
recognized by libtool but ignored by nDPI's custom src/lib/Makefile.in,
which always built both static and shared libraries regardless of the
flags specified.

This commit fixes the issue by:

1. Exporting enable_shared and enable_static variables from configure.ac
   via AC_SUBST so they're available in Makefiles

2. Adding configure-time error checks:
   - Prevent both --disable-shared and --disable-static simultaneously
   - Require static library for --enable-fuzztargets (fuzz targets need
     static linking for proper instrumentation)

3. Modifying src/lib/Makefile.in to conditionally build libraries

4. Updating all build targets to support dynamic linking when static
   library is disabled.
   These targets now:
   - Use static library when available (preferred, default behavior)
   - Fall back to dynamic linking with -lndpi when --disable-static

5. Adding configuration summary output showing which libraries will be
   built (enabled/disabled status for both shared and static)

fuzz: disable creation of (unused) shared library

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-25 15:32:29 +01:00

50 lines
1.4 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@
CFLAGS=@CFLAGS@
AM_CFLAGS=@NDPI_CFLAGS@
INC=-I $(top_srcdir)/src/include -I $(top_builddir)/src/include -I/usr/local/include
AM_LDFLAGS=@NDPI_LDFLAGS@
ENABLE_STATIC = @enable_static@
ifeq ($(ENABLE_STATIC),yes)
LIBDPI=$(top_builddir)/src/lib/libndpi.a
LIBDPI_DEP=$(LIBDPI)
else
LIBDPI=-lndpi
LIBDPI_DEP=$(top_builddir)/src/lib/libndpi.so
AM_LDFLAGS+=-L$(top_builddir)/src/lib
endif
LIB=$(LIBDPI) @ADDITIONAL_LIBS@ @LIBRRD@ @LIBS@ -lm -lpthread
GEN_HEADERS=$(top_builddir)/src/include/ndpi_config.h $(top_builddir)/src/include/ndpi_define.h
TOOLS=rrd_anomaly rrd_similarity
all: $(TOOLS)
rrd_anomaly: $(srcdir)/rrd_anomaly.c Makefile $(LIBDPI_DEP) $(GEN_HEADERS)
$(CC) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(INC) $(AM_LDFLAGS) $(LDFLAGS) $(srcdir)/rrd_anomaly.c -o rrd_anomaly $(LIB)
rrd_similarity: $(srcdir)/rrd_similarity.c Makefile $(LIBDPI_DEP) $(GEN_HEADERS)
$(CC) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(INC) $(AM_LDFLAGS) $(LDFLAGS) $(srcdir)/rrd_similarity.c -o rrd_similarity $(LIB)
clean:
$(RM) *.o *.lo $(TOOLS) *~
$(RM) -r .libs .deps
distclean: clean
$(RM) Makefile
distdir:
find $(srcdir) -type f -name '*.c' \
-o -name '*.txt' | xargs -I'{}' cp '{}' '$(distdir)/{}'
install:
@echo -n ""
check:
true # nothing to do here