aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-06-20 18:09:48 +0000
committerYang Tse <yangsita@gmail.com>2008-06-20 18:09:48 +0000
commit2c61e9c76a9665ca0f93d6a21a17030fe22b8f1c (patch)
treecb1269ccb10f0154aadbae384553e1c80f3aaa24
parentda97f78ae0e3ab2cbcf76503c4a159da761d0f57 (diff)
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.
-rw-r--r--CHANGES6
-rw-r--r--acinclude.m488
-rw-r--r--ares/acinclude.m488
-rw-r--r--ares/configure.ac61
-rw-r--r--configure.ac69
5 files changed, 258 insertions, 54 deletions
diff --git a/CHANGES b/CHANGES
index 7c3c99311..be600cbc7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,12 @@
Changelog
+Yang Tse (20 Jun 2008)
+- 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.
+
Daniel Stenberg (20 Jun 2008)
- Phil Pellouchoud found a case where libcurl built with NSS failed to
handshake with a SSLv2 server, and it turned out to be because it didn't
diff --git a/acinclude.m4 b/acinclude.m4
index 792ceaede..b72604ab7 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -22,6 +22,94 @@
###########################################################################
+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/ares/acinclude.m4 b/ares/acinclude.m4
index 124ed88ff..7f51d1503 100644
--- a/ares/acinclude.m4
+++ b/ares/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/ares/configure.ac b/ares/configure.ac
index 0cca59e3b..6aaf47896 100644
--- a/ares/configure.ac
+++ b/ares/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
diff --git a/configure.ac b/configure.ac
index 227a54bd5..ab20f827c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,32 +213,6 @@ dnl check if there's a way to force code inline
AC_C_INLINE
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
- CURL_CHECK_HEADER_WINLDAP
- CURL_CHECK_HEADER_WINBER
- ;;
- *)
- ac_cv_header_winsock_h="no"
- ac_cv_header_winsock2_h="no"
- ac_cv_header_ws2tcpip_h="no"
- ac_cv_header_winldap_h="no"
- ac_cv_header_winber_h="no"
- ;;
-esac
-
-dnl **********************************************************************
dnl platform/compiler/architecture specific checks/flags
dnl **********************************************************************
@@ -275,6 +249,46 @@ 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
+ CURL_CHECK_HEADER_WINLDAP
+ CURL_CHECK_HEADER_WINBER
+ ;;
+ *)
+ ac_cv_header_winsock_h="no"
+ ac_cv_header_winsock2_h="no"
+ ac_cv_header_ws2tcpip_h="no"
+ ac_cv_header_winldap_h="no"
+ ac_cv_header_winber_h="no"
+ ;;
+esac
+
dnl ************************************************************
dnl switch off particular protocols
dnl
@@ -1821,9 +1835,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"
)