diff options
Diffstat (limited to 'm4/cares-compilers.m4')
-rw-r--r-- | m4/cares-compilers.m4 | 114 |
1 files changed, 64 insertions, 50 deletions
diff --git a/m4/cares-compilers.m4 b/m4/cares-compilers.m4 index 5d3035c..2b98a68 100644 --- a/m4/cares-compilers.m4 +++ b/m4/cares-compilers.m4 @@ -1,6 +1,6 @@ #*************************************************************************** # -# Copyright (C) 2009-2011 by Daniel Stenberg et al +# Copyright (C) 2009-2013 by Daniel Stenberg et al # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided @@ -15,7 +15,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 67 +# serial 75 dnl CARES_CHECK_COMPILER @@ -23,7 +23,6 @@ dnl ------------------------------------------------- dnl Verify if the C compiler being used is known. AC_DEFUN([CARES_CHECK_COMPILER], [ - AC_BEFORE([$0],[CARES_CHECK_NO_UNDEFINED])dnl # compiler_id="unknown" compiler_num="0" @@ -156,6 +155,7 @@ AC_DEFUN([CARES_CHECK_COMPILER_GNU_C], [ flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" flags_opt_yes="-O2" flags_opt_off="-O0" + CURL_CHECK_DEF([_WIN32], [], [silent]) else AC_MSG_RESULT([no]) fi @@ -850,8 +850,6 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [ CLANG) # if test "$want_warnings" = "yes"; then - dnl All versions of clang support the same warnings as at least - dnl gcc 4.2.1 except -Wunused. tmp_CFLAGS="$tmp_CFLAGS -pedantic" tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra" tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" @@ -959,6 +957,11 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [ tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" fi # + dnl Only gcc 4.0 or later + if test "$compiler_num" -ge "400"; then + tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3" + fi + # dnl Only gcc 4.2 or later if test "$compiler_num" -ge "402"; then tmp_CFLAGS="$tmp_CFLAGS -Wcast-align" @@ -972,6 +975,14 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [ tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla" fi # + dnl Only gcc 4.5 or later + if test "$compiler_num" -ge "405"; then + dnl Only windows targets + if test "$curl_cv_have_def__WIN32" = "yes"; then + tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format" + fi + fi + # fi # dnl Do not issue warnings for code in system include paths. @@ -1180,6 +1191,7 @@ dnl shared libraries support undefined symbols, along with dnl an equally configured libcurl. AC_DEFUN([CARES_CHECK_CURLDEBUG], [ + AC_REQUIRE([XC_LIBTOOL])dnl AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl cares_builddir=`pwd` supports_curldebug="unknown" @@ -1196,7 +1208,7 @@ AC_DEFUN([CARES_CHECK_CURLDEBUG], [ fi if test "$supports_curldebug" != "no"; then if test "$enable_shared" = "yes" && - test "$need_no_undefined" = "yes"; then + test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then supports_curldebug="no" AC_MSG_WARN([shared library does not support undefined symbols.]) fi @@ -1258,46 +1270,6 @@ AC_DEFUN([CARES_CHECK_CURLDEBUG], [ ]) -dnl CARES_CHECK_NO_UNDEFINED -dnl ------------------------------------------------- -dnl Checks if the -no-undefined flag must be used when -dnl building shared libraries. This is required on all -dnl systems on which shared libraries should not have -dnl references to undefined symbols. This check should -dnl not be done before AC-PROG-LIBTOOL. - -AC_DEFUN([CARES_CHECK_NO_UNDEFINED], [ - AC_BEFORE([$0],[CARES_CHECK_CURLDEBUG])dnl - AC_MSG_CHECKING([if shared libraries need -no-undefined]) - need_no_undefined="no" - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*) - need_no_undefined="yes" - ;; - esac - if test "x$allow_undefined" = "xno"; then - need_no_undefined="yes" - elif test "x$allow_undefined_flag" = "xunsupported"; then - need_no_undefined="yes" - fi - AC_MSG_RESULT($need_no_undefined) -]) - - -dnl CARES_CHECK_PROG_CC -dnl ------------------------------------------------- -dnl Check for compiler program, preventing CFLAGS and -dnl CPPFLAGS from being unexpectedly changed. - -AC_DEFUN([CARES_CHECK_PROG_CC], [ - ac_save_CFLAGS="$CFLAGS" - ac_save_CPPFLAGS="$CPPFLAGS" - AC_PROG_CC - CFLAGS="$ac_save_CFLAGS" - CPPFLAGS="$ac_save_CPPFLAGS" -]) - - dnl CARES_CHECK_COMPILER_HALT_ON_ERROR dnl ------------------------------------------------- dnl Verifies if the compiler actually halts after the @@ -1425,7 +1397,7 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ case "$compiler_id" in CLANG) dnl All versions of clang support -fvisibility= - tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" ;; @@ -1433,7 +1405,7 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ dnl Only gcc 3.4 or later if test "$compiler_num" -ge "304"; then if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then - tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" fi @@ -1452,7 +1424,7 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ printf("icc fvisibility bug test"); ]]) ],[ - tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" ]) @@ -1484,12 +1456,18 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ } ]],[[ char b[16]; - char *r = dummy(&b); + char *r = dummy(&b[0]); if(r) return (int)*r; ]]) ],[ supports_symbol_hiding="yes" + if test -f conftest.err; then + grep 'visibility' conftest.err >/dev/null + if test "$?" -eq "0"; then + supports_symbol_hiding="no" + fi + fi ],[ supports_symbol_hiding="no" echo " " >&6 @@ -1509,6 +1487,42 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ ]) +dnl CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH +dnl ------------------------------------------------- +dnl Verifies if the compiler actually halts after the +dnl compilation phase without generating any object +dnl code file, when the source code tries to redefine +dnl a prototype which does not match previous one. + +AC_DEFUN([CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH], [ + AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl + AC_MSG_CHECKING([if compiler halts on function prototype mismatch]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +# include <stdlib.h> + int rand(int n); + int rand(int n) + { + if(n) + return ++n; + else + return n; + } + ]],[[ + int i[2]; + int j = rand(i[0]); + if(j) + return j; + ]]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([compiler does not halt on function prototype mismatch.]) + ],[ + AC_MSG_RESULT([yes]) + ]) +]) + + dnl CARES_VAR_MATCH (VARNAME, VALUE) dnl ------------------------------------------------- dnl Verifies if shell variable VARNAME contains VALUE. |