--- configure.ac.orig	2012-10-23 04:13:47.000000000 +0200
+++ configure.ac	2012-11-15 14:46:19.000000000 +0100
@@ -97,9 +97,10 @@
 AX_PTHREAD()
 
 LIBS="$PTHREAD_LIBS $LIBS"
-CFLAGS="$PTHREAD_CFLAGS $CFLAGS -fvisibility=hidden"
-CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
 CC="$PTHREAD_CC"
+AS_IF([ `$(CC) -dumpversion | cut -f1 -d.` -ge 4 ],
+      [CFLAGS="$PTHREAD_CFLAGS $CFLAGS -fvisibility=hidden" CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"],
+      [CFLAGS="$PTHREAD_CFLAGS $CFLAGS" CXXFLAGS="$CXXFLAGS"])
 
 AS_ECHO
 AS_ECHO "Checking for boost libraries:"

--- configure.ac.orig	2012-10-23 04:13:47.000000000 +0200
+++ configure.ac	2012-11-21 07:55:14.000000000 +0100
@@ -97,10 +97,24 @@
 AX_PTHREAD()
 
 LIBS="$PTHREAD_LIBS $LIBS"
-CFLAGS="$PTHREAD_CFLAGS $CFLAGS -fvisibility=hidden"
-CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
+CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
 CC="$PTHREAD_CC"
 
+AS_ECHO "Checking for visibility support:"
+AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
+    ac_cv_hidden_visibility_attribute, [
+    echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > visibility_conftest.c
+    ac_cv_hidden_visibility_attribute=no
+    if AC_TRY_COMMAND(${CC-cc} -fvisibility=hidden -S visibility_conftest.c -o visibility_conftest.s 1>&AS_MESSAGE_LOG_FD);
+    then
+        AS_ECHO "found"
+        ac_cv_hidden_visibility_attribute=yes
+        CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
+        CFLAGS="$CFLAGS -fvisibility=hidden"
+    fi
+    rm -f visibility_conftest.*
+])
+
 AS_ECHO
 AS_ECHO "Checking for boost libraries:"
 

Update fix-visibility patch for libtorrent
Update fix-visibility patch for libtorrent
