aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-09-10 17:33:15 +0000
committerYang Tse <yangsita@gmail.com>2008-09-10 17:33:15 +0000
commitea1362a9367f78f59dbeafd7fbaaaf633f0bbc6a (patch)
treeabc07a8697c5e0fff1209aaa03c0a0cae0634413
parentf62a5b83a95d88f3d70d16d47d343ddaca64e549 (diff)
improve detection of gmtime_r() and strtoll()
-rw-r--r--configure.ac45
-rw-r--r--m4/curl-functions.m4273
2 files changed, 276 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac
index cad4a09d5..c396e9508 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1881,47 +1881,6 @@ if test "x$RECENTAIX" = "xyes"; then
checkfor_gmtime_r="yes"
fi
-if test x$cross_compiling != xyes; then
-
- if test x$checkfor_gmtime_r = xyes; then
-
- dnl if gmtime_r was found, verify that it actually works, as (at least) HPUX
- dnl 10.20 is known to have a buggy one. If it doesn't work, disable use of
- dnl it.
-
- AC_MSG_CHECKING([if gmtime_r exists and works])
- AC_RUN_IFELSE([[
- #include <time.h>
- int main(void)
- {
- time_t local = 1170352587;
- struct tm *gmt;
- struct tm keeper;
- putenv("TZ=CST6CDT");
- tzset();
- gmt = gmtime_r(&local, &keeper);
- if(gmt) {
- return 0;
- }
- return 1; /* failure */
- }
- ]],
- dnl success, do nothing
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_GMTIME_R, 1, [if you have (a working) gmtime_r])
- ,
- dnl failure, now disable the function
- AC_MSG_RESULT(no)
- ,
- dnl not invoked when crosscompiling)
- echo "hej"
- )
- fi
-else
- dnl and for crosscompiling
- AC_CHECK_FUNCS(gmtime_r)
-fi
-
dnl **********************************************************************
dnl Back to "normal" configuring
@@ -2075,6 +2034,9 @@ CURL_CHECK_FUNC_RECVFROM
CURL_CHECK_FUNC_SEND
CURL_CHECK_MSG_NOSIGNAL
+CURL_CHECK_FUNC_GMTIME_R
+CURL_CHECK_FUNC_STRTOLL
+
dnl Checks for library functions.
dnl AC_PROG_GCC_TRADITIONAL
@@ -2121,7 +2083,6 @@ AC_CHECK_FUNCS([basename \
strlcat \
strstr \
strtok_r \
- strtoll \
uname \
utime
],[
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
new file mode 100644
index 000000000..abe52a0cd
--- /dev/null
+++ b/m4/curl-functions.m4
@@ -0,0 +1,273 @@
+#***************************************************************************
+# _ _ ____ _
+# Project ___| | | | _ \| |
+# / __| | | | |_) | |
+# | (__| |_| | _ <| |___
+# \___|\___/|_| \_\_____|
+#
+# Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://curl.haxx.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# $Id$
+#***************************************************************************
+
+# File version for 'aclocal' use. Keep it a single number.
+# serial 1
+
+
+dnl CURL_INCLUDES_STDLIB
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when stdlib.h is to be included.
+
+AC_DEFUN([CURL_INCLUDES_STDLIB], [
+curl_includes_stdlib="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+/* includes end */"
+ AC_CHECK_HEADERS(
+ sys/types.h stdlib.h,
+ [], [], [$curl_includes_stdlib])
+])
+
+
+dnl CURL_INCLUDES_TIME
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when time.h is to be included.
+
+AC_DEFUN([CURL_INCLUDES_TIME], [
+AC_REQUIRE([AC_HEADER_TIME])dnl
+curl_includes_time="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# ifdef TIME_WITH_SYS_TIME
+# include <time.h>
+# endif
+#else
+# ifdef HAVE_TIME_H
+# include <time.h>
+# endif
+#endif
+/* includes end */"
+ AC_CHECK_HEADERS(
+ sys/types.h sys/time.h time.h,
+ [], [], [$curl_includes_time])
+])
+
+
+dnl CURL_CHECK_FUNC_GMTIME_R
+dnl -------------------------------------------------
+dnl Verify if gmtime_r is available, prototyped, can
+dnl be compiled and seems to work. If all of these are
+dnl true, and usage has not been previously disallowed
+dnl with shell variable curl_disallow_gmtime_r, then
+dnl HAVE_GMTIME_R will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
+ AC_REQUIRE([CURL_INCLUDES_TIME])dnl
+ #
+ tst_links_gmtime_r="unknown"
+ tst_proto_gmtime_r="unknown"
+ tst_compi_gmtime_r="unknown"
+ tst_works_gmtime_r="unknown"
+ tst_allow_gmtime_r="unknown"
+ #
+ AC_MSG_CHECKING([if gmtime_r can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([gmtime_r])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_gmtime_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_gmtime_r="no"
+ ])
+ #
+ if test "$tst_links_gmtime_r" = "yes"; then
+ AC_MSG_CHECKING([if gmtime_r is prototyped])
+ AC_EGREP_CPP([gmtime_r],[
+ $curl_includes_time
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_gmtime_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_gmtime_r="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_gmtime_r" = "yes"; then
+ AC_MSG_CHECKING([if gmtime_r is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_time
+ ]],[[
+ gmtime_r(0, 0);
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gmtime_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gmtime_r="no"
+ ])
+ fi
+ #
+ dnl only do runtime verification when not cross-compiling
+ if test "x$cross_compiling" != "xyes" &&
+ test "$tst_compi_gmtime_r" = "yes"; then
+ AC_MSG_CHECKING([if gmtime_r seems to work])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_time
+ ]],[[
+ time_t local = 1170352587;
+ struct tm *gmt = 0;
+ struct tm result;
+ gmt = gmtime_r(&local, &result);
+ if(gmt)
+ exit(0);
+ else
+ exit(1);
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_works_gmtime_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_works_gmtime_r="no"
+ ])
+ fi
+ #
+ if test "$tst_works_gmtime_r" != "no"; then
+ AC_MSG_CHECKING([if gmtime_r usage allowed])
+ if test "x$curl_disallow_gmtime_r" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_gmtime_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_gmtime_r="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if gmtime_r might be used])
+ if test "$tst_links_gmtime_r" = "yes" &&
+ test "$tst_proto_gmtime_r" = "yes" &&
+ test "$tst_compi_gmtime_r" = "yes" &&
+ test "$tst_allow_gmtime_r" = "yes" &&
+ test "$tst_works_gmtime_r" != "no"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
+ [Define to 1 if you have a working gmtime_r function.])
+ ac_cv_func_gmtime_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_gmtime_r="no"
+ fi
+])
+
+
+dnl CURL_CHECK_FUNC_STRTOLL
+dnl -------------------------------------------------
+dnl Verify if strtoll is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_strtoll, then
+dnl HAVE_STRTOLL will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
+ AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
+ #
+ tst_links_strtoll="unknown"
+ tst_proto_strtoll="unknown"
+ tst_compi_strtoll="unknown"
+ tst_allow_strtoll="unknown"
+ #
+ AC_MSG_CHECKING([if strtoll can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([strtoll])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_strtoll="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_strtoll="no"
+ ])
+ #
+ if test "$tst_links_strtoll" = "yes"; then
+ AC_MSG_CHECKING([if strtoll is prototyped])
+ AC_EGREP_CPP([strtoll],[
+ $curl_includes_stdlib
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_strtoll="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_strtoll="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_strtoll" = "yes"; then
+ AC_MSG_CHECKING([if strtoll is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_stdlib
+ ]],[[
+ strtoll(0, 0, 0);
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_strtoll="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_strtoll="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_strtoll" = "yes"; then
+ AC_MSG_CHECKING([if strtoll usage allowed])
+ if test "x$curl_disallow_strtoll" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_strtoll="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_strtoll="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if strtoll might be used])
+ if test "$tst_links_strtoll" = "yes" &&
+ test "$tst_proto_strtoll" = "yes" &&
+ test "$tst_compi_strtoll" = "yes" &&
+ test "$tst_allow_strtoll" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
+ [Define to 1 if you have the strtoll function.])
+ ac_cv_func_strtoll="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_strtoll="no"
+ fi
+])
+
+