From 3e1ce5967a90de265df1b4f4ce6010aa462858e4 Mon Sep 17 00:00:00 2001 From: Karl Benoit Date: Fri, 11 May 2012 17:45:20 +1200 Subject: [PATCH] Bug 2885: AIX: check and set required compiler flags --- acinclude/compiler-flags.m4 | 27 +++++++++++++++++++++++++++ configure.ac | 37 +++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/acinclude/compiler-flags.m4 b/acinclude/compiler-flags.m4 index 5757c5c804..3f4bdc8953 100644 --- a/acinclude/compiler-flags.m4 +++ b/acinclude/compiler-flags.m4 @@ -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 diff --git a/configure.ac b/configure.ac index 3b5902d556..857c4849ab 100644 --- a/configure.ac +++ b/configure.ac @@ -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 +#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(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_" -- 2.47.2