Check if gcc supports -fvisibility=hidden before adding to CFLAGS
authorAlan Coopersmith <alan.coopersmith@sun.com>
Sun, 17 Jan 2010 02:34:23 +0000 (18:34 -0800)
committerAlan Coopersmith <alan.coopersmith@sun.com>
Tue, 19 Jan 2010 18:15:55 +0000 (10:15 -0800)
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
configure.ac

index d01d0f188466094e5eb40f0d4ebbe518b886807f..f121002d4bee2352a18592fa138bac088ea162ea 100644 (file)
@@ -96,7 +96,14 @@ esac
 
 dnl Add flags for gcc and g++
 if test "x$GCC" = xyes; then
-    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden"
+    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
+
+    # Enable -fvisibility=hidden if using a gcc that supports it
+    save_CFLAGS="$CFLAGS"
+    AC_MSG_CHECKING([whether $(CC) supports -fvisibility=hidden])
+    CFLAGS="$CFLAGS -fvisibility=hidden"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
+                  [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]);
 
     # Work around aliasing bugs - developers should comment this out
     CFLAGS="$CFLAGS -fno-strict-aliasing"