From: Francesco Chemolli Date: Tue, 24 Nov 2009 13:35:41 +0000 (+0100) Subject: Refactored check for CXX -fhuge-objects out of the main configure.in X-Git-Tag: SQUID_3_2_0_1~310^2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a56798fc944b124c1ee7e245e9c70942e43ab8e;p=thirdparty%2Fsquid.git Refactored check for CXX -fhuge-objects out of the main configure.in --- diff --git a/acinclude.m4 b/acinclude.m4 index 95e7a8827a..73c36220bf 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -62,38 +62,6 @@ SQUID_DEFAULT_INCLUDES #endif ]) -dnl -dnl thanks to autogen, for the template.. -dnl -dnl @synopsis AC_TEST_CHECKFORHUGEOBJECTS -dnl -dnl Test whether -fhuge-objects is available with this c++ compiler. gcc-29.5 series compilers need this on some platform with large objects. -dnl -AC_DEFUN([AC_TEST_CHECKFORHUGEOBJECTS],[ - AC_MSG_CHECKING([whether compiler accepts -fhuge-objects]) - AC_CACHE_VAL([ac_cv_test_checkforhugeobjects],[ - ac_cv_test_checkforhugeobjects=`echo "int main(int argc, char **argv) { int foo; }" > conftest.cc -${CXX} -Werror -fhuge-objects -o conftest.bin conftest.cc 2>/dev/null -res=$? -rm -f conftest.* -echo yes -exit $res` - if [[ $? -ne 0 ]] - then ac_cv_test_checkforhugeobjects=no - else if [[ -z "$ac_cv_test_checkforhugeobjects" ]] - then ac_cv_test_checkforhugeobjects=yes - fi ; fi - ]) # end of CACHE_VAL - AC_MSG_RESULT([${ac_cv_test_checkforhugeobjects}]) - - if test "X${ac_cv_test_checkforhugeobjects}" != Xno - then - HUGE_OBJECT_FLAG="-fhuge-objects" - else - HUGE_OBJECT_FLAG="" - fi -]) # end of AC_DEFUN of AC_TEST_CHECKFORHUGEOBJECTS - dnl =========================================================================== dnl http://autoconf-archive.cryp.to/ax_with_prog.html diff --git a/acinclude/compiler-flags.m4 b/acinclude/compiler-flags.m4 new file mode 100644 index 0000000000..fe40600356 --- /dev/null +++ b/acinclude/compiler-flags.m4 @@ -0,0 +1,59 @@ +dnl +dnl AUTHOR: Francesco Chemolli +dnl +dnl SQUID Web Proxy Cache http://www.squid-cache.org/ +dnl ---------------------------------------------------------- +dnl Squid is the result of efforts by numerous individuals from +dnl the Internet community; see the CONTRIBUTORS file for full +dnl details. Many organizations have provided support for Squid's +dnl development; see the SPONSORS file for full details. Squid is +dnl Copyrighted (C) 2001 by the Regents of the University of +dnl California; see the COPYRIGHT file for full details. Squid +dnl incorporates software developed and/or copyrighted by other +dnl sources; see the CREDITS file for full details. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + + +# check if the compiler accepts a supplied flag +# first argument is the variable containing the result (will be set to "yes" or "no" +# second argument is the flag to be tested, verbatim + +AC_DEFUN([SQUID_TEST_COMPILER_FLAG],[ + AC_CACHE_CHECK([whether compiler accepts $2],[$1], + [{ + AC_REQUIRE([AC_PROG_CC]) + SAVED_FLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + CFLAGS="$CXXFLAGS $2" + CXXFLAGS="$CXXFLAGS $2" + AC_TRY_LINK([],[int foo; ], + [$1=yes],[$1=no]) + CFLAGS="$SAVED_CFLAGS" + CXXFLAGS="$SAVED_CXXFLAGS" + }]) +]) + +# check if the c++ compiler supports the -fhuge-objects flag +# sets the vartiable squid_cv_test_checkforhugeobjects to either "yes" or "no" +AC_DEFUN([SQUID_CXX_CHECK_FHUGEOBJECTS],[ + AC_LANG_PUSH([C++]) + if test "$GCC" = "yes"; then + SQUID_TEST_COMPILER_FLAG([squid_cv_test_checkforhugeobjects],[-Werror -fhuge-objects]) + else + squid_cv_test_checkforhugeobjects=no + fi + AC_LANG_POP([C++]) +]) diff --git a/configure.in b/configure.in index f11b60fd30..28aa562b43 100644 --- a/configure.in +++ b/configure.in @@ -14,6 +14,8 @@ AC_REVISION($Revision$)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE +m4_include([acinclude/compiler-flags.m4]) + PRESET_CFLAGS="$CFLAGS" PRESET_LDFLAGS="$LDFLAGS" @@ -306,8 +308,10 @@ fi AC_SUBST(SQUID_CFLAGS) AC_SUBST(SQUID_CXXFLAGS) -AC_TEST_CHECKFORHUGEOBJECTS -SQUID_CXXFLAGS="$SQUID_CXXFLAGS $HUGE_OBJECT_FLAG" +SQUID_CXX_CHECK_FHUGEOBJECTS +if test "$squid_cv_test_checkforhugeobjects" = "yes"; then + SQUID_CXXFLAGS="$SQUID_CXXFLAGS -fhuge-objects" +fi dnl Set LDFLAGS if test -z "$PRESET_LDFLAGS"; then diff --git a/lib/libTrie/configure.in b/lib/libTrie/configure.in index d7003a99ff..2f62720934 100644 --- a/lib/libTrie/configure.in +++ b/lib/libTrie/configure.in @@ -66,8 +66,10 @@ else TRIE_CXXFLAGS= fi -AC_TEST_CHECKFORHUGEOBJECTS -TRIE_CXXFLAGS="$TRIE_CXXFLAGS $HUGE_OBJECT_FLAG" +if test "$GCC" = "yes" ; then + AC_TEST_CHECKFORHUGEOBJECTS + TRIE_CXXFLAGS="$TRIE_CXXFLAGS $HUGE_OBJECT_FLAG" +fi AC_SUBST(TRIE_CFLAGS) AC_SUBST(TRIE_CXXFLAGS)