File 0001-add-symbol-versioning-support.patch of Package libcares2

From f2f268450d2aff0c7bcbb848b8a1c7b1e1d38291 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
Date: Fri, 3 Feb 2012 16:01:16 -0300
Subject: [PATCH] add symbol versioning support

---
 Makefile.am             |   11 ++++---
 c-ares.map              |   72 +++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac            |    9 +----
 m4/ld-version-script.m4 |   53 ++++++++++++++++++++++++++++++++++
 4 files changed, 133 insertions(+), 12 deletions(-)
 create mode 100644 c-ares.map
 create mode 100644 m4/ld-version-script.m4

--- c-ares-1.7.5.orig/Makefile.am
+++ c-ares-1.7.5/Makefile.am
@@ -93,12 +93,13 @@ VER=-version-info 2:0:0
 # set age to 0. (c:r:a=0)
 #
 
-if NO_UNDEFINED
-# The -no-undefined flag is crucial for this to build fine on some platforms
-UNDEF = -no-undefined
-endif
+libcares_la_LDFLAGS = -no-undefined $(UNDEF) $(VER)
 
-libcares_la_LDFLAGS = $(UNDEF) $(VER)
+if HAVE_LD_VERSION_SCRIPT
+libcares_la_LDFLAGS += -Wl,--version-script=$(srcdir)/c-ares.map
+else
+libcares_la_LDFLAGS += -export-symbols-regex '^ares_.*'
+endif
 
 # Add -Werror if defined
 CFLAGS += @CARES_CFLAG_EXTRAS@
--- /dev/null
+++ c-ares-1.7.5/c-ares.map
@@ -0,0 +1,72 @@
+CARES_1.2.0 {
+global:
+    ares_cancel;
+    ares_destroy;
+    ares_expand_name;
+    ares_expand_string;
+    ares_fds;
+    ares_free_data;
+    ares_free_hostent;
+    ares_free_string;
+    ares_get_servers;
+    ares_gethostbyaddr;
+    ares_gethostbyname;
+    ares_init;
+    ares_init_options;
+    ares_mkquery;
+    ares_parse_a_reply;
+    ares_parse_ptr_reply;
+    ares_process;
+    ares_query;
+    ares_search;
+    ares_send;
+    ares_set_local_dev;
+    ares_set_local_ip4;
+    ares_set_local_ip6;
+    ares_set_servers;
+    ares_set_servers_csv;
+    ares_strerror;
+    ares_timeout;
+    ares_version;
+local: *;
+};
+
+CARES_1.3.1 {
+global:
+    ares_parse_aaaa_reply;
+    ares_getnameinfo;
+    ares_getsock;
+} CARES_1.2.0;
+
+CARES_1.4.0 {
+global:
+    ares_save_options;
+    ares_destroy_options;
+    ares_parse_ns_reply;
+    ares_process_fd;
+} CARES_1.3.1;
+
+CARES_1.6.0 {
+global:
+    ares_dup;
+    ares_gethostbyname_file;
+} CARES_1.4.0;
+
+CARES_1.7.0 {
+global:
+    ares_set_socket_callback;
+    ares_parse_txt_reply;
+    ares_parse_srv_reply;
+    ares_library_init;
+    ares_library_cleanup;
+} CARES_1.6.0;
+
+CARES_1.7.1 {
+global:
+    ares_reinit;
+} CARES_1.7.0;
+
+CARES_1.7.2 {
+global:
+    ares_parse_mx_reply;
+} CARES_1.7.1;
--- c-ares-1.7.5.orig/configure.ac
+++ c-ares-1.7.5/configure.ac
@@ -97,9 +97,6 @@ case $host_os in
     ;;
 esac
 
-dnl support building of Windows DLLs
-AC_LIBTOOL_WIN32_DLL
-
 dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
 AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
 case $host in
@@ -124,7 +121,8 @@ case $CC in
 esac
 
 dnl libtool setup
-AC_PROG_LIBTOOL
+LT_INIT([win32-dll pic-only disable-static])
+gl_LD_VERSION_SCRIPT
 
 AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY])
 case $host in
@@ -171,9 +169,6 @@ CARES_CHECK_COMPILER_HALT_ON_ERROR
 CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
 CARES_CHECK_COMPILER_SYMBOL_HIDING
 
-CARES_CHECK_NO_UNDEFINED
-AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
-
 CARES_CHECK_CURLDEBUG
 AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)
 
--- /dev/null
+++ c-ares-1.7.5/m4/ld-version-script.m4
@@ -0,0 +1,53 @@
+# ld-version-script.m4 serial 3
+dnl Copyright (C) 2008-2012 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")
+])
openSUSE Build Service is sponsored by