From: Yang Tse Date: Fri, 20 Jun 2008 18:09:48 +0000 (+0000) Subject: Modified configuration script to actually verify if the compiler is good X-Git-Tag: upstream/1.10.0~814 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8dc7f22b9a3a3266d7a0d2c59b17647b57bd95b0;p=platform%2Fupstream%2Fc-ares.git Modified configuration script to actually verify if the compiler is good enough at detecting compilation errors or at least it has been properly configured to do so. Configuration heavily depends on this capability, so if this compiler sanity check fails the configuration process will now fail. --- diff --git a/acinclude.m4 b/acinclude.m4 index 124ed88..7f51d15 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,5 +1,93 @@ +dnl CURL_CHECK_COMPILER_HALT_ON_ERROR +dnl ------------------------------------------------- +dnl Verifies if the compiler actually halts after the +dnl compilation phase without generating any object +dnl code file, when the source compiles with errors. + +AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [ + AC_MSG_CHECKING([if compiler halts on compilation errors]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + ]],[[ + force compilation error + ]]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([compiler does not halt on compilation errors.]) + ],[ + AC_MSG_RESULT([yes]) + ]) +]) + + +dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE +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 define a +dnl type for a constant array with negative dimension. + +AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [ + AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl + AC_MSG_CHECKING([if compiler halts on negative sized arrays]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ]; + ]],[[ + bad_t dummy; + ]]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([compiler does not halt on negative sized arrays.]) + ],[ + AC_MSG_RESULT([yes]) + ]) +]) + + +dnl CURL_CHECK_DEF(SYMBOL, [INCLUDES], [SILENT]) +dnl ------------------------------------------------- +dnl Use the C preprocessor to find out if the given object-style symbol +dnl is defined and get its expansion. This macro will not use default +dnl includes even if no INCLUDES argument is given. This macro will run +dnl silently when invoked with three arguments. + +AC_DEFUN([CURL_CHECK_DEF], [ + AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl + AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl + ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])]) + tmp_exp="" + AC_PREPROC_IFELSE([ + AC_LANG_SOURCE( +ifelse($2,,,[$2])[[ +#ifdef $1 +CURL_DEF_TOKEN $1 +#endif + ]]) + ],[ + tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ + "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ + "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \ + "$SED" 'q' 2>/dev/null` + if test "$tmp_exp" = "$1"; then + tmp_exp="" + fi + ]) + if test -z "$tmp_exp"; then + AS_VAR_SET([ac_HaveDef], [no]) + ifelse($3,,[AC_MSG_RESULT([no])]) + else + AS_VAR_SET([ac_HaveDef], [yes]) + AS_VAR_SET([ac_Def], [$tmp_exp]) + ifelse($3,,[AC_MSG_RESULT([$tmp_exp])]) + fi + AS_VAR_POPDEF([ac_Def])dnl + AS_VAR_POPDEF([ac_HaveDef])dnl +]) + + dnl CURL_CHECK_HEADER_WINDOWS dnl ------------------------------------------------- dnl Check for compilable and valid windows.h header diff --git a/configure.ac b/configure.ac index 0cca59e..6aaf478 100644 --- a/configure.ac +++ b/configure.ac @@ -124,28 +124,6 @@ dnl ********************************************************************** CURL_DETECT_ICC([CFLAGS="$CFLAGS -we 147"]) dnl ********************************************************************** -dnl Make sure that our checks for headers windows.h winsock.h winsock2.h -dnl and ws2tcpip.h take precedence over any other further checks which -dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for -dnl this specific header files. And do them before its results are used. -dnl ********************************************************************** - -CURL_CHECK_HEADER_WINDOWS -CURL_CHECK_NATIVE_WINDOWS -case X-"$ac_cv_native_windows" in - X-yes) - CURL_CHECK_HEADER_WINSOCK - CURL_CHECK_HEADER_WINSOCK2 - CURL_CHECK_HEADER_WS2TCPIP - ;; - *) - ac_cv_header_winsock_h="no" - ac_cv_header_winsock2_h="no" - ac_cv_header_ws2tcpip_h="no" - ;; -esac - -dnl ********************************************************************** dnl platform/compiler/architecture specific checks/flags dnl ********************************************************************** @@ -182,6 +160,42 @@ case $host in # esac +CURL_CHECK_DEF([__xlc__]) +if test "$curl_cv_have_def___xlc__" = "yes"; then + dnl Force xlc to stop after the compilation phase, and not + dnl generate object code file when compilation has errors. + CFLAGS="$CFLAGS -qhalt=e" +fi + +CURL_CHECK_COMPILER_HALT_ON_ERROR +CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE + +dnl ********************************************************************** +dnl Compilation based checks should not be done before this point. +dnl ********************************************************************** + +dnl ********************************************************************** +dnl Make sure that our checks for headers windows.h winsock.h winsock2.h +dnl and ws2tcpip.h take precedence over any other further checks which +dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for +dnl this specific header files. And do them before its results are used. +dnl ********************************************************************** + +CURL_CHECK_HEADER_WINDOWS +CURL_CHECK_NATIVE_WINDOWS +case X-"$ac_cv_native_windows" in + X-yes) + CURL_CHECK_HEADER_WINSOCK + CURL_CHECK_HEADER_WINSOCK2 + CURL_CHECK_HEADER_WS2TCPIP + ;; + *) + ac_cv_header_winsock_h="no" + ac_cv_header_winsock2_h="no" + ac_cv_header_ws2tcpip_h="no" + ;; +esac + dnl ********************************************************************** dnl Checks for libraries. dnl ********************************************************************** @@ -431,9 +445,6 @@ if test "x$RECENTAIX" = "xyes"; then dnl the optimizer assumes that pointers can only point to dnl an object of the same type. CFLAGS="$CFLAGS -qnoansialias" - dnl Force AIX xlc to stop after the compilation phase, and not - dnl generate object code, when the source compiles with errors. - CFLAGS="$CFLAGS -qhalt=e" ) fi