lib: build shared library on Linux

Building the shared library on Linux is not something by default.
Instead a user must opt-in to building by running the
"make libsuricata.so" target in the src/ directory.

Currently shared library support is only available on Linux. More
OSs will be supported as we can test them.
pull/5866/head
Jason Ish 5 years ago
parent a178ec6bef
commit e227d97e5e

@ -299,7 +299,10 @@
LDFLAGS="${LDFLAGS} -L/opt/local/lib"
;;
*-*-linux*)
# Always compile with -fPIC on Linux for shared library support.
CFLAGS="${CFLAGS} -fPIC"
RUST_LDADD="-ldl -lrt -lm"
can_build_shared_library="yes"
;;
*-*-mingw32*|*-*-msys)
CFLAGS="${CFLAGS} -DOS_WIN32"
@ -2678,6 +2681,8 @@ AC_SUBST(PACKAGE_VERSION)
AC_SUBST(RUST_FEATURES)
AC_SUBST(RUST_SURICATA_LIBDIR)
AM_CONDITIONAL([BUILD_SHARED_LIBRARY], [test "x$enable_shared" = "xyes"] && [test "x$can_build_shared_library" = "xyes"])
AC_CONFIG_FILES(Makefile src/Makefile rust/Makefile rust/Cargo.toml rust/.cargo/config)
AC_CONFIG_FILES(qa/Makefile qa/coccinelle/Makefile)
AC_CONFIG_FILES(rules/Makefile doc/Makefile doc/userguide/Makefile doc/devguide/Makefile)

@ -595,6 +595,19 @@ suricata_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
suricata_LDADD = libsuricata_c.a $(HTP_LDADD) $(RUST_LDADD)
suricata_DEPENDENCIES = libsuricata_c.a
if BUILD_SHARED_LIBRARY
libsuricata.so.$(VERSION): libsuricata_c.a
$(CC) -shared -o $@ -Wl,-soname,$@ -Wl,--whole-archive \
libsuricata_c.a \
$(RUST_SURICATA_LIB) \
-Wl,--no-whole-archive
libsuricata.so: libsuricata.so.$(VERSION)
else
libsuricata.so:
@echo "shared library support not enabled"
@exit 1
endif
if BUILD_FUZZTARGETS
LDFLAGS_FUZZ = $(all_libraries) $(SECLDFLAGS)

Loading…
Cancel
Save