From e0d34e60038035b4874d3a5ca79612828bc61d2a Mon Sep 17 00:00:00 2001 From: Karl Benoit Date: Mon, 4 Jun 2012 04:27:26 -0600 Subject: [PATCH] Bug 2885: AIX: check and set required compiler flags --- acinclude/compiler-flags.m4 | 27 +++++++++++++++++++++++++++ acinclude/squid-util.m4 | 2 +- configure.ac | 37 +++++++++++++++++++++++++++---------- 3 files changed, 55 insertions(+), 11 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/acinclude/squid-util.m4 b/acinclude/squid-util.m4 index 5e8055a7af..721a81ead5 100644 --- a/acinclude/squid-util.m4 +++ b/acinclude/squid-util.m4 @@ -41,7 +41,7 @@ $1_LIBS="${LIBS}" $1_CC="${CC}" $1_CXX="${CXX}" $1_squid_saved_vars="$2" -for squid_util_var_tosave in $2 +for squid_util_var_tosave in $$1_squid_saved_vars do squid_util_var_tosave2="$1_${squid_util_var_tosave}" eval "${squid_util_var_tosave2}=\"${squid_util_var_tosave}\"" diff --git a/configure.ac b/configure.ac index a60fcde71f..32bd974d81 100644 --- a/configure.ac +++ b/configure.ac @@ -2987,19 +2987,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