diff --git a/Makefile.am b/Makefile.am index 96c81ca..2adf158 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,9 +39,17 @@ protobuf_c_libprotobuf_c_la_SOURCES = \ protobuf_c_libprotobuf_c_la_LDFLAGS = $(AM_LDFLAGS) \ -version-info $(LIBPROTOBUF_C_CURRENT):$(LIBPROTOBUF_C_REVISION):$(LIBPROTOBUF_C_AGE) \ - -export-symbols-regex "^(protobuf_c_[a-z].*)" \ -no-undefined +if HAVE_LD_VERSION_SCRIPT +protobuf_c_libprotobuf_c_la_LDFLAGS += \ + -Wl,--version-script=$(top_srcdir)/protobuf-c/libprotobuf-c.sym +else +protobuf_c_libprotobuf_c_la_LDFLAGS += \ + -export-symbols-regex "^(protobuf_c_[a-z].*)" +endif +EXTRA_DIST += protobuf-c/libprotobuf-c.sym + pkgconfig_DATA += protobuf-c/libprotobuf-c.pc CLEANFILES += protobuf-c/libprotobuf-c.pc EXTRA_DIST += protobuf-c/libprotobuf-c.pc.in diff --git a/configure.ac b/configure.ac index eb70776..40bca73 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,8 @@ else fi AM_CONDITIONAL([BUILD_COMPILER], [test "x$enable_protoc" != "xno"]) +gl_LD_VERSION_SCRIPT + gl_VALGRIND_TESTS AC_C_BIGENDIAN diff --git a/m4/ld-version-script.m4 b/m4/ld-version-script.m4 new file mode 100644 index 0000000..f8b4a5c --- /dev/null +++ b/m4/ld-version-script.m4 @@ -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 < conftest.map <