]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2885: AIX: check and set required compiler flags
authorKarl Benoit <karl.isatwork@gmail.com>
Fri, 11 May 2012 05:45:20 +0000 (17:45 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 11 May 2012 05:45:20 +0000 (17:45 +1200)
acinclude/compiler-flags.m4
configure.ac

index 5757c5c804bc8777e80027ec598c4b45ed410eca..3f4bdc895352a339e6917fbe4291e5724b37d7bd 100644 (file)
@@ -47,6 +47,33 @@ AC_DEFUN([SQUID_CC_CHECK_ARGUMENT],[
   }])
 ])
 
+# Check if the compiler requires a supplied flag to build a test program.
+# When cross-compiling set flags explicitly.
+#
+# first argument is the variable containing the result 
+# (will be set to "yes" or "no")
+# second argument is the flag to be tested, verbatim
+# third is the #include and global setup for test program, verbatim
+# fourth is the test program to compile, verbatim
+#
+AC_DEFUN([SQUID_CC_REQUIRE_ARGUMENT],[
+  AC_CACHE_CHECK([whether compiler requires $2],[$1],
+  [{
+    AC_REQUIRE([AC_PROG_CC])
+    SAVED_FLAGS="$CFLAGS"
+    SAVED_CXXFLAGS="$CXXFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM($3,$4)],[$1=no],[],[$1=no])
+    if test "$1" != "no" ; then
+      CFLAGS="$CXXFLAGS $2"
+      CXXFLAGS="$CXXFLAGS $2"
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM($3,$4)],[$1=yes],[$1=no],[$1=no])
+    fi
+    CFLAGS="$SAVED_CFLAGS"
+    CXXFLAGS="$SAVED_CXXFLAGS"
+  }])
+  AC_MSG_RESULT([$1])
+])
+
 # detect what kind of compiler we're using, either by using hints from
 # autoconf itself, or by using predefined preprocessor macros
 # sets the variable squid_cv_compiler to one of
index 3b5902d556e59fc9608e6ed66a0ba5e002afea3b..857c4849abd84aa8a1f36ec8dda0769c9f7ffe58 100644 (file)
@@ -3005,19 +3005,36 @@ dnl Please change your configure script.  AIX doesn't need -lbsd.
   *-ibm-aix*)
     AC_MSG_NOTICE([Removing -lbsd for AIX...])
     LIBS=`echo $LIBS | sed -e s/-lbsd//`
-    AC_MSG_CHECKING(for aix xlc c++ comments support)
-    AC_LANG_PUSH([C])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[//c++ cmt]])],
-      [AIX_CPPCMT_SUPPORT=yes],[AIX_CPPCMT_SUPPORT=no])        
-    AC_MSG_RESULT($AIX_CPPCMT_SUPPORT)
-    if test -n `echo $CC | grep cc` 2>/dev/null && \
-      test -n `cc -qversion 2>/dev/null | grep "IBM XL C/C++ for AIX"` 2>/dev/null; then
-        if test "$AIX_CPPCMT_SUPPORT"="no";then
-          SQUID_CFLAGS="-qcpluscmt $SQUID_CFLAGS"
-        fi
+
+    SQUID_CC_REQUIRE_ARGUMENT([ac_cv_require_rtti],[-rtti],[[
+#include <assert.h>
+#ifndef NULL
+#define NULL 0
+#endif
+class Foo{
+public:virtual ~Foo(){}
+};
+class Bar:public Foo{
+public:Bar():Foo(){}
+};
+      ]],[[
+Foo * myFoo=new Bar();
+Bar * myBar=dynamic_cast<Bar *>(myFoo);
+assert(myBar != NULL);
+      ]])
+    if test "$ac_cv_require_rtti" = "yes"; then
+      SQUID_CFLAGS="-rtti $SQUID_CFLAGS"
+      SQUID_CXXFLAGS="-rtti $SQUID_CXXFLAGS"
     fi
+
+    AC_LANG_PUSH([C])
+    SQUID_CC_REQUIRE_ARGUMENT([ac_cv_require_qcpluscmt],[-qcpluscmt],[[]],[[//c++ cmt]])
     AC_LANG_POP([C])
+    if test "$ac_cv_require_qcpluscmt" = "yes"; then
+      SQUID_CFLAGS="-qcpluscmt $SQUID_CFLAGS"
+    fi
     ;;
+
     *m88k*)
       SQUID_CFLAGS="$SQUID_CFLAGS -D_SQUID_MOTOROLA_"
       SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_SQUID_MOTOROLA_"