forked from Mirror/frr
build: add --enable-static-bin option
This option can be used to get statically linked binaries. Note: libfrr.la is removed from modules' library dependency list. This is intentional and explained in a comment in lib/subdir.am. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
eec50add22
commit
d6e7625706
|
@ -12,6 +12,7 @@ AM_CPPFLAGS = \
|
||||||
-I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/lib
|
-I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/lib
|
||||||
AM_LDFLAGS = \
|
AM_LDFLAGS = \
|
||||||
-export-dynamic \
|
-export-dynamic \
|
||||||
|
$(AC_LDFLAGS) \
|
||||||
$(SAN_FLAGS) \
|
$(SAN_FLAGS) \
|
||||||
# end
|
# end
|
||||||
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DCONFDATE=$(CONFDATE)
|
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DCONFDATE=$(CONFDATE)
|
||||||
|
@ -154,6 +155,7 @@ EXTRA_DIST += \
|
||||||
aclocal.m4 \
|
aclocal.m4 \
|
||||||
README.md \
|
README.md \
|
||||||
m4/README.txt \
|
m4/README.txt \
|
||||||
|
m4/libtool-whole-archive.patch \
|
||||||
\
|
\
|
||||||
python/clidef.py \
|
python/clidef.py \
|
||||||
python/clippy/__init__.py \
|
python/clippy/__init__.py \
|
||||||
|
|
11
configure.ac
11
configure.ac
|
@ -310,7 +310,18 @@ AC_CHECK_TOOL(AR, ar)
|
||||||
dnl -------
|
dnl -------
|
||||||
dnl libtool
|
dnl libtool
|
||||||
dnl -------
|
dnl -------
|
||||||
|
AC_ARG_ENABLE(static-bin,
|
||||||
|
AS_HELP_STRING([--enable-static-bin], [link binaries statically]))
|
||||||
LT_INIT
|
LT_INIT
|
||||||
|
_LT_CONFIG_LIBTOOL([
|
||||||
|
patch -N -i "${srcdir}/m4/libtool-whole-archive.patch" libtool >&AS_MESSAGE_LOG_FD || \
|
||||||
|
AC_MSG_WARN([Could not patch libtool for static linking support. Loading modules into a statically linked daemon will fail.])
|
||||||
|
])
|
||||||
|
if test "$enable_static_bin" = "yes"; then
|
||||||
|
AC_LDFLAGS="-static"
|
||||||
|
fi
|
||||||
|
AC_SUBST(AC_LDFLAGS)
|
||||||
|
AM_CONDITIONAL([STATIC_BIN], [test "x$enable_static_bin" = "xyes"])
|
||||||
|
|
||||||
dnl ----------------------
|
dnl ----------------------
|
||||||
dnl Packages configuration
|
dnl Packages configuration
|
||||||
|
|
|
@ -207,6 +207,17 @@ noinst_HEADERS += \
|
||||||
lib/plist_int.h \
|
lib/plist_int.h \
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
# General note about module and module helper library (libfrrsnmp, libfrrzmq)
|
||||||
|
# linking: If we're linking libfrr statically into daemons, we *must* remove
|
||||||
|
# libfrr from modules because modules will always link it in dynamically and
|
||||||
|
# thus 2 copies of libfrr will be loaded... hilarity ensues.
|
||||||
|
#
|
||||||
|
# Not linking libfrr into modules should generally work fine because the
|
||||||
|
# executable refers to libfrr either way and the dynamic linker should make
|
||||||
|
# libfrr available to modules. If some OS platform has a dynamic linker that
|
||||||
|
# doesn't do that, libfrr needs to be readded to modules, but _only_ _if_
|
||||||
|
# it's not linked into daemons statically.
|
||||||
|
|
||||||
#
|
#
|
||||||
# SNMP support
|
# SNMP support
|
||||||
#
|
#
|
||||||
|
@ -216,7 +227,7 @@ endif
|
||||||
|
|
||||||
lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99
|
lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99
|
||||||
lib_libfrrsnmp_la_LDFLAGS = -version-info 0:0:0
|
lib_libfrrsnmp_la_LDFLAGS = -version-info 0:0:0
|
||||||
lib_libfrrsnmp_la_LIBADD = lib/libfrr.la $(SNMP_LIBS)
|
lib_libfrrsnmp_la_LIBADD = $(SNMP_LIBS)
|
||||||
lib_libfrrsnmp_la_SOURCES = \
|
lib_libfrrsnmp_la_SOURCES = \
|
||||||
lib/agentx.c \
|
lib/agentx.c \
|
||||||
lib/snmp.c \
|
lib/snmp.c \
|
||||||
|
@ -232,7 +243,7 @@ endif
|
||||||
|
|
||||||
lib_libfrrzmq_la_CFLAGS = $(WERROR) $(ZEROMQ_CFLAGS)
|
lib_libfrrzmq_la_CFLAGS = $(WERROR) $(ZEROMQ_CFLAGS)
|
||||||
lib_libfrrzmq_la_LDFLAGS = -version-info 0:0:0
|
lib_libfrrzmq_la_LDFLAGS = -version-info 0:0:0
|
||||||
lib_libfrrzmq_la_LIBADD = lib/libfrr.la $(ZEROMQ_LIBS)
|
lib_libfrrzmq_la_LIBADD = $(ZEROMQ_LIBS)
|
||||||
lib_libfrrzmq_la_SOURCES = \
|
lib_libfrrzmq_la_SOURCES = \
|
||||||
lib/frr_zmq.c \
|
lib/frr_zmq.c \
|
||||||
#end
|
#end
|
||||||
|
|
1
m4/.gitignore
vendored
1
m4/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
*.m4
|
*.m4
|
||||||
|
!*.patch
|
||||||
|
|
||||||
!ax_compare_version.m4
|
!ax_compare_version.m4
|
||||||
!ax_prog_perl_modules.m4
|
!ax_prog_perl_modules.m4
|
||||||
|
|
18
m4/libtool-whole-archive.patch
Normal file
18
m4/libtool-whole-archive.patch
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
--- /usr/share/libtool/build-aux/ltmain.sh 2017-08-01 07:13:09.611041402 +0200
|
||||||
|
+++ ltmain.sh 2018-08-31 17:32:15.381903718 +0200
|
||||||
|
@@ -8439,8 +8439,13 @@
|
||||||
|
# shared platforms.
|
||||||
|
if test unsupported != "$hardcode_direct"; then
|
||||||
|
test -n "$old_library" && linklib=$old_library
|
||||||
|
- compile_deplibs="$dir/$linklib $compile_deplibs"
|
||||||
|
- finalize_deplibs="$dir/$linklib $finalize_deplibs"
|
||||||
|
+ if test yes,yes = "$export_dynamic,$with_gnu_ld"; then
|
||||||
|
+ compile_deplibs="-Wl,--no-whole-archive $dir/$linklib -Wl,--whole-archive $compile_deplibs"
|
||||||
|
+ finalize_deplibs="-Wl,--no-whole-archive $dir/$linklib -Wl,--whole-archive $finalize_deplibs"
|
||||||
|
+ else
|
||||||
|
+ compile_deplibs="$dir/$linklib $compile_deplibs"
|
||||||
|
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
|
||||||
|
+ fi
|
||||||
|
else
|
||||||
|
compile_deplibs="-l$name -L$dir $compile_deplibs"
|
||||||
|
finalize_deplibs="-l$name -L$dir $finalize_deplibs"
|
|
@ -23,9 +23,21 @@ endif
|
||||||
|
|
||||||
ospfclient_ospfclient_LDADD = \
|
ospfclient_ospfclient_LDADD = \
|
||||||
ospfclient/libfrrospfapiclient.la \
|
ospfclient/libfrrospfapiclient.la \
|
||||||
lib/libfrr.la \
|
|
||||||
@LIBCAP@ \
|
@LIBCAP@ \
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
if STATIC_BIN
|
||||||
|
# libfrr is linked in through libfrrospfapiclient. If we list it here too,
|
||||||
|
# it gets linked twice and we get a ton of symbol collisions.
|
||||||
|
|
||||||
|
else # !STATIC_BIN
|
||||||
|
# For most systems we don't need this, except Debian, who patch their linker
|
||||||
|
# to disallow transitive references *while* *als* not patching their libtool
|
||||||
|
# to work appropriately. RedHat has the same linker behaviour, but things
|
||||||
|
# work as expected since they also patch libtool.
|
||||||
|
ospfclient_ospfclient_LDADD += lib/libfrr.la
|
||||||
|
endif
|
||||||
|
|
||||||
ospfclient_ospfclient_SOURCES = \
|
ospfclient_ospfclient_SOURCES = \
|
||||||
ospfclient/ospfclient.c \
|
ospfclient/ospfclient.c \
|
||||||
# end
|
# end
|
||||||
|
|
Loading…
Reference in a new issue