]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Check gcc support for -Wno-unused-result
authorTravis Cross <tc@traviscross.com>
Thu, 28 Aug 2014 13:29:23 +0000 (13:29 +0000)
committerTravis Cross <tc@traviscross.com>
Thu, 28 Aug 2014 13:37:37 +0000 (13:37 +0000)
We're using -Wno-unused-result to work around what is arguably a GCC
bug, but this option is not supported on older GCC versions.  So on
those versions we won't pass -Werror either.

ref: commit b874048efcee4ea985cf9e5592d289ddef2df40a

configure.ac

index 58c8a3bf204dd0ff34defc222017ba62a6e3697e..8b0a47e478544cfab2735ad4b4193e8abee591e8 100644 (file)
@@ -331,6 +331,17 @@ if test "${LIBTOOL_MAJOR_VERSION}" = "2" ; then
 fi
 AC_MSG_RESULT([using libtool library extension... ${LIBTOOL_LIB_EXTEN}])
 
+if test "$ax_cv_c_compiler_vendor" = "gnu"; then
+  saved_CFLAGS="$CFLAGS"
+  AC_CACHE_CHECK([whether compiler supports -Wno-unused-result],
+    [ac_cv_gcc_supports_w_no_unused_result], [
+      CFLAGS="$CFLAGS -Wno-unused-result"
+      AC_TRY_COMPILE([],[return 0;],
+        [ac_cv_gcc_supports_w_no_unused_result=yes],
+        [ac_cv_gcc_supports_w_no_unused_result=no])])
+  CFLAGS="$saved_CFLAGS"
+  AC_MSG_RESULT($ac_cv_gcc_supports_w_no_unused_result)
+fi
 
 # tweak compiler specific flags
 if test "x${ax_cv_c_compiler_vendor}"  =  "xsun" ; then
@@ -360,7 +371,9 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
 elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
     APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC)
     APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC)
-    APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
+    if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
+      APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
+    fi
     if test "${enable_64}" = "yes"; then
        case "$host" in
              *darwin12.*|*darwin11.*|*darwin10.*|*darwin9.*|*darwin8.*)
@@ -464,7 +477,9 @@ if test "${enable_debug}" = "yes"; then
        CFLAGS="$saved_CFLAGS"  
 
        if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
-           APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-unused-result)
+           if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
+             APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-unused-result)
+           fi
            APR_ADDTO(SWITCH_AM_CFLAGS, -g -ggdb)
            export DEBUG_CFLAGS="-g -ggdb"
        fi