From 10489879f731465f3d2105870e7533c2b355af5d Mon Sep 17 00:00:00 2001
From: Dan Fandrich <dan@coneharvesters.com>
Date: Tue, 11 Jul 2006 21:35:35 +0000
Subject: [PATCH] Enable --enable-hidden-symbols for SunPro C

---
 configure.ac        | 21 +++++++++++++++++----
 include/curl/curl.h |  9 +++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index c5486a387b..55a442f311 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1962,29 +1962,42 @@ AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
 dnl ************************************************************
 dnl Enable hiding of internal symbols in library to reduce its size and
 dnl speed dynamic linking of applications.  This currently is only supported
-dnl on gcc >= 4.0
+dnl on gcc >= 4.0 and SunPro C.
 dnl
 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
 AC_ARG_ENABLE(hidden-symbols,
-AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library (gcc>=4)])
+AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
 [ case "$enableval" in
   no)
        AC_MSG_RESULT(no)
        ;;
   *)   
+       AC_MSG_CHECKING([whether $CC supports it])
        if test "$GCC" = yes ; then
-         AC_MSG_CHECKING([whether $CC supports it])
          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
 	   AC_MSG_RESULT(yes)
 	   AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
 	   AC_SUBST(CURL_HIDDEN_SYMBOLS)
+	   AC_DEFINE(CURL_EXTERN_SYMBOL, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
+	   AC_SUBST(CURL_EXTERN_SYMBOL)
 	   CFLAGS="$CFLAGS -fvisibility=hidden"
          else
             AC_MSG_RESULT(no)
           fi
+
        else
-          AC_MSG_RESULT([no (not gcc)])
+       	 dnl Test for SunPro cc
+       	 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
+           AC_MSG_RESULT(yes)
+	   AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
+	   AC_SUBST(CURL_HIDDEN_SYMBOLS)
+	   AC_DEFINE(CURL_EXTERN_SYMBOL, [__global], [to make a symbol visible])
+	   AC_SUBST(CURL_EXTERN_SYMBOL)
+	   CFLAGS="$CFLAGS -xldscope=hidden"
+         else
+           AC_MSG_RESULT(no)
+         fi
        fi
        ;;
   esac ],
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 1a118a36c6..b9b341deef 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -61,11 +61,12 @@ extern "C" {
 
 #ifdef CURL_HIDDEN_SYMBOLS
 /*
- * On gcc >= 4 if -fvisibility=hidden is given then this is used to cause
- * external definitions to be put into the shared library.  It makes no
- * difference to applications whether this is set or not, only the library.
+ * This definition is used to make external definitions visibile in the 
+ * shared library when symbols are hidden by default.  It makes no
+ * difference when compiling applications whether this is set or not,
+ * only when compiling the library.
  */
-#define CURL_EXTERN __attribute__ ((visibility ("default")))
+#define CURL_EXTERN CURL_EXTERN_SYMBOL
 #else
 #define CURL_EXTERN 
 #endif
-- 
GitLab