]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactored check for CXX -fhuge-objects out of the main configure.in
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 24 Nov 2009 13:35:41 +0000 (14:35 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 24 Nov 2009 13:35:41 +0000 (14:35 +0100)
acinclude.m4
acinclude/compiler-flags.m4 [new file with mode: 0644]
configure.in
lib/libTrie/configure.in

index 95e7a8827aad661c555dcf3a9d4e786461f68f51..73c36220bf38f674bead0bedc08568bd3fd953c0 100644 (file)
@@ -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 (file)
index 0000000..fe40600
--- /dev/null
@@ -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++])
+])
index f11b60fd30001d161012024955070ebd44424b15..28aa562b43435f61fa0eaff6e2ade49a669ec22b 100644 (file)
@@ -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
index d7003a99ff4eaf15f0c463e2ed2e6882776dfc9d..2f6272093493641fde8c17b14e850693bfed4a97 100644 (file)
@@ -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)