From 489df85c88631e13cf259b0751c650861c4837b0 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Tue, 3 Mar 2015 18:50:40 +0100 Subject: [PATCH] Check if linker supports scripts for versioning Use ld's option --version-script where available and fall back to plain symbol file otherwise. This check uses the m4 macro AX_CHECK_LINK_FLAG --- Makefile.am | 6 +++--- configure.ac | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index eac8f946..6944660b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,9 +87,9 @@ libcoap_include_HEADERS = \ ## Instruct libtool to include API version information in the generated shared ## library file (.so). The library ABI version will later defined in configure.ac, ## so that all version information is kept in one place. -libcoap_@LIBCOAP_API_VERSION@_la_LDFLAGS = \ - -version-info $(LT_LIBCOAP_CURRENT):$(LT_LIBCOAP_REVISION):$(LT_LIBCOAP_AGE) \ - -Wl,--version-script=$(srcdir)/libcoap-$(LIBCOAP_API_VERSION).map \ +libcoap_@LIBCOAP_API_VERSION@_la_LDFLAGS = \ + -version-info $(LT_LIBCOAP_CURRENT):$(LT_LIBCOAP_REVISION):$(LT_LIBCOAP_AGE) \ + @libcoap_SYMBOLS@ \ -pie # This helper is called by libcoap-$(LIBCOAP_API_VERSION).{map,sym} to see if diff --git a/configure.ac b/configure.ac index 5539a9ed..2663d55d 100644 --- a/configure.ac +++ b/configure.ac @@ -118,6 +118,12 @@ AX_CHECK_COMPILE_FLAG([-fdiagnostics-color], [CFLAGS="$CFLAGS -fdiagnostics-colo AC_SUBST([WARNING_CFLAGS]) +AX_CHECK_LINK_FLAG([-Wl,--version-script=./libcoap-${LIBCOAP_API_VERSION}.map], + [libcoap_SYMBOLS="-Wl,--version-script=\$(srcdir)/libcoap-\$(LIBCOAP_API_VERSION).map"], + [libcoap_SYMBOLS="-export-symbols \$(srcdir)/libcoap-\$(LIBCOAP_API_VERSION).sym"]) + +AC_SUBST(libcoap_SYMBOLS) + # configure options # __documentation__ AC_ARG_ENABLE([documentation],