]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
build: use symbol versioning for liblldpctl
authorVincent Bernat <vincent@bernat.im>
Tue, 16 Jun 2015 15:02:07 +0000 (17:02 +0200)
committerVincent Bernat <vincent@bernat.im>
Tue, 16 Jun 2015 15:03:00 +0000 (17:03 +0200)
NEWS
configure.ac
m4/ld-version-script.m4 [new file with mode: 0644]
src/lib/Makefile.am
src/lib/lldpctl.map [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a05fa361524e244b2df2515cf786871ae3ecfcbc..7773fa854938716f27b1ae19c71dcb947ff92d47 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 lldpd (0.7.16)
+  * Features:
+    + Use symbol versioning for liblldpctl.so.
   * Fix:
     + Fix build on OS X.
 
index 47d8d80575e10bfe555e62ea3dae064af2de7e1e..66821f4441bbcf3a26a2ececf8cb076deef8e70b 100644 (file)
@@ -37,6 +37,7 @@ AM_PROG_AR
 
 # Configure libtool
 LT_INIT
+gl_LD_VERSION_SCRIPT
 
 #######################
 ### Checks
diff --git a/m4/ld-version-script.m4 b/m4/ld-version-script.m4
new file mode 100644 (file)
index 0000000..f8b4a5c
--- /dev/null
@@ -0,0 +1,53 @@
+# ld-version-script.m4 serial 3
+dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# FIXME: The test below returns a false positive for mingw
+# cross-compiles, 'local:' statements does not reduce number of
+# exported symbols in a DLL.  Use --disable-ld-version-script to work
+# around the problem.
+
+# gl_LD_VERSION_SCRIPT
+# --------------------
+# Check if LD supports linker scripts, and define automake conditional
+# HAVE_LD_VERSION_SCRIPT if so.
+AC_DEFUN([gl_LD_VERSION_SCRIPT],
+[
+  AC_ARG_ENABLE([ld-version-script],
+    AS_HELP_STRING([--enable-ld-version-script],
+      [enable linker version script (default is enabled when possible)]),
+      [have_ld_version_script=$enableval], [])
+  if test -z "$have_ld_version_script"; then
+    AC_MSG_CHECKING([if LD -Wl,--version-script works])
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
+    cat > conftest.map <<EOF
+foo
+EOF
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+                   [accepts_syntax_errors=yes], [accepts_syntax_errors=no])
+    if test "$accepts_syntax_errors" = no; then
+      cat > conftest.map <<EOF
+VERS_1 {
+        global: sym;
+};
+
+VERS_2 {
+        global: sym;
+} VERS_1;
+EOF
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+                     [have_ld_version_script=yes], [have_ld_version_script=no])
+    else
+      have_ld_version_script=no
+    fi
+    rm -f conftest.map
+    LDFLAGS="$save_LDFLAGS"
+    AC_MSG_RESULT($have_ld_version_script)
+  fi
+  AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
+])
index ffb1322014badeadc4de3eec8ce0c8db1a9a8240..3cf92f674fa3a0a1228976460fc4508cfdd28187 100644 (file)
@@ -14,10 +14,22 @@ liblldpctl_la_SOURCES = \
        atoms/interface.c atoms/med.c atoms/mgmt.c atoms/port.c \
        atoms/custom.c
 liblldpctl_la_LIBADD  = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la
-liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -export-symbols-regex '^lldpctl_' -version-info 10:0:6
 
 # -version-info format is `current`:`revision`:`age`. For more details, see:
 #   http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
+#
+# -version-number could be computed from -version-info, mostly major
+# is `current` - `age`, minor is `age` and revision is `revision' and
+# major.minor should be used when updaing lldpctl.map.
+liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -version-info 10:0:6
+liblldpctl_la_DEPENDENCIES = libfixedpoint.la
+
+if HAVE_LD_VERSION_SCRIPT
+liblldpctl_la_DEPENDENCIES += lldpctl.map
+liblldpctl_la_LDFLAGS += -Wl,--version-script=$(srcdir)/lldpctl.map
+else
+liblldpctl_la_LDFLAGS += -export-symbols-regex '^lldpctl_'
+endif
 
 pkgconfig_DATA = lldpctl.pc
 
diff --git a/src/lib/lldpctl.map b/src/lib/lldpctl.map
new file mode 100644 (file)
index 0000000..899149b
--- /dev/null
@@ -0,0 +1,38 @@
+LIBLLDPCTL_4.6 {
+ global:
+  lldpctl_atom_create;
+  lldpctl_atom_dec_ref;
+  lldpctl_atom_get;
+  lldpctl_atom_get_buffer;
+  lldpctl_atom_get_connection;
+  lldpctl_atom_get_int;
+  lldpctl_atom_get_str;
+  lldpctl_atom_inc_ref;
+  lldpctl_atom_iter;
+  lldpctl_atom_iter_next;
+  lldpctl_atom_iter_value;
+  lldpctl_atom_set;
+  lldpctl_atom_set_buffer;
+  lldpctl_atom_set_int;
+  lldpctl_atom_set_str;
+  lldpctl_get_configuration;
+  lldpctl_get_default_transport;
+  lldpctl_get_interfaces;
+  lldpctl_get_port;
+  lldpctl_key_get_map;
+  lldpctl_last_error;
+  lldpctl_log_callback;
+  lldpctl_log_level;
+  lldpctl_new;
+  lldpctl_new_name;
+  lldpctl_process_conn_buffer;
+  lldpctl_recv;
+  lldpctl_release;
+  lldpctl_send;
+  lldpctl_strerror;
+  lldpctl_watch;
+  lldpctl_watch_callback;
+
+ local:
+  *;
+};