From: Francesco Chemolli Date: Tue, 24 Nov 2009 17:08:07 +0000 (+0100) Subject: Implemented compiler detection and warnings-are-errors-flag detection X-Git-Tag: SQUID_3_2_0_1~310^2~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9d138eba9489107e6dc90ae5f6c1e1eb100c384;p=thirdparty%2Fsquid.git Implemented compiler detection and warnings-are-errors-flag detection --- diff --git a/acinclude/compiler-flags.m4 b/acinclude/compiler-flags.m4 index fe40600356..1bab39618e 100644 --- a/acinclude/compiler-flags.m4 +++ b/acinclude/compiler-flags.m4 @@ -47,7 +47,7 @@ AC_DEFUN([SQUID_TEST_COMPILER_FLAG],[ ]) # check if the c++ compiler supports the -fhuge-objects flag -# sets the vartiable squid_cv_test_checkforhugeobjects to either "yes" or "no" +# sets the variable squid_cv_test_checkforhugeobjects to either "yes" or "no" AC_DEFUN([SQUID_CXX_CHECK_FHUGEOBJECTS],[ AC_LANG_PUSH([C++]) if test "$GCC" = "yes"; then @@ -57,3 +57,49 @@ AC_DEFUN([SQUID_CXX_CHECK_FHUGEOBJECTS],[ fi AC_LANG_POP([C++]) ]) + +# 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 +# - gcc +# - sunstudio + +AC_DEFUN([SQUID_GUESS_CC_VARIANT], [ + AC_CACHE_CHECK([what kind of compiler we're using],[squid_cv_compiler], + [ + AC_REQUIRE([AC_PROG_CC]) + if test "$GCC" = "yes" ; then + squid_cv_compiler="gcc" + fi + dnl repeat the next block for each compiler, changing the + dnl preprocessor definition type so that it depends on platform-specific + dnl predefined macros + dnl SunPro CC + if test -z "$squid_cv_compiler" ; then + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#if !defined(__SUNPRO_C) && !defined(__SUNPRO_CC) +#error "not sunpro c" +#endif + ]])],[squid_cv_compiler="sunstudio"],[]) + fi + dnl end of block to be repeated + if test -z "$squid_cv_compiler" ; then + squid_cv_compiler="unknown" + fi + ]) + ]) + +# define the flag to use to have the compiler treat warnings as errors +# requirs SQUID_GUESS_CC_VARIANT +# sets the variable squid_cv_cc_werror_flag to the right flag +AC_DEFUN([SQUID_GUESS_CC_WERROR_FLAG], [ + AC_REQUIRE([SQUID_GUESS_CC_VARIANT]) + AC_MSG_CHECKING([for compiler warnings-are-errors flag]) + case "$squid_cv_compiler" in + gcc) squid_cv_cc_werror_flag="-Werror" ;; + sunstudio) squid_cv_cc_werror_flag="-errwarn=%all" ;; + *) ;; + esac + AC_MSG_RESULT([$squid_cv_cc_werror_flag]) +]) diff --git a/configure.in b/configure.in index cccc34a5e2..b46643f3ad 100644 --- a/configure.in +++ b/configure.in @@ -67,6 +67,7 @@ esac AC_SUBST(AR_R) AC_PATH_PROG(CPPUNITCONFIG, cppunit-config, false) + dnl Make the squid top srcdir available to sub-packages as --with-squid=PATH new_configure_args="$ac_configure_args --with-squid=$ac_abs_confdir" ac_configure_args="$new_configure_args" @@ -135,6 +136,10 @@ then fi +dnl ********************************* KK *********************** +SQUID_GUESS_CC_VARIANT +SQUID_GUESS_CC_WERROR_FLAG + REGEXLIB='' # -lregex # LIBREGEX='' # libregex.a