]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
strptime check for OSX.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 29 Sep 2010 08:31:31 +0000 (08:31 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 29 Sep 2010 08:31:31 +0000 (08:31 +0000)
git-svn-id: file:///svn/unbound/trunk@2265 be551aaa-1e26-0410-a405-d3ace91eadb9

config.h.in
configure
configure.ac

index 322bcdbc2638322b29625393426e6cbf6e7c239b..d962977f4877657a28b63788e5858b315b0f96fd 100644 (file)
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* use default strptime. */
+#undef STRPTIME_WORKS
+
 /* Use win32 resources and API */
 #undef UB_ON_WINDOWS
 
@@ -815,7 +818,7 @@ int memcmp(const void *x, const void *y, size_t n);
 char *ctime_r(const time_t *timep, char *buf);
 #endif
 
-#ifndef HAVE_STRPTIME
+#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
 #define strptime unbound_strptime
 struct tm;
 char *strptime(const char *s, const char *format, struct tm *tm);
index ad70f899bcd9a110c26dd506e37455e5bc7d474e..0720178e2dac3cfa8993a9d9f508159164d61774 100755 (executable)
--- a/configure
+++ b/configure
@@ -16131,6 +16131,7 @@ fi
 
 fi
 
+# check wether strptime also works
 for ac_func in strptime
 do :
   ac_fn_c_check_func "$LINENO" "strptime" "ac_cv_func_strptime"
@@ -16139,6 +16140,54 @@ if test "x$ac_cv_func_strptime" = x""yes; then :
 #define HAVE_STRPTIME 1
 _ACEOF
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strptime works" >&5
+$as_echo_n "checking whether strptime works... " >&6; }
+if test c${cross_compiling} = cno; then
+if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run test program while cross compiling
+See \`config.log' for more details." "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#define _XOPEN_SOURCE
+#include <time.h>
+int main(void) { struct tm tm; char *res;
+res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
+if (!res) return 1; return 0; }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  eval "ac_cv_c_strptime_works=yes"
+else
+  eval "ac_cv_c_strptime_works=no"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+else
+eval "ac_cv_c_strptime_works=maybe"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_strptime_works" >&5
+$as_echo "$ac_cv_c_strptime_works" >&6; }
+if test $ac_cv_c_strptime_works = no; then
+case " $LIBOBJS " in
+  *" strptime.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS strptime.$ac_objext"
+ ;;
+esac
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define STRPTIME_WORKS 1
+_ACEOF
+
+fi
+
 else
   case " $LIBOBJS " in
   *" strptime.$ac_objext "* ) ;;
index 7af37e0c340473e9f1a60072bd5787f397c3c058..b0bff8efdf2303355af5cc55e630bd4d74c227a4 100644 (file)
@@ -654,7 +654,29 @@ if test $ac_cv_func_daemon = yes; then
 ])
 fi
 
-AC_CHECK_FUNCS([strptime],,[AC_LIBOBJ([strptime])])
+# check wether strptime also works
+AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
+[AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether strptime works)
+if test c${cross_compiling} = cno; then
+AC_TRY_RUN([
+#define _XOPEN_SOURCE
+#include <time.h>
+int main(void) { struct tm tm; char *res;
+res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
+if (!res) return 1; return 0; }
+] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
+else
+eval "ac_cv_c_strptime_works=maybe"
+fi
+AC_MSG_RESULT($ac_cv_c_strptime_works)
+if test $ac_cv_c_strptime_works = no; then
+AC_LIBOBJ(strptime)
+else
+AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
+fi
+])dnl
+AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
 AC_SEARCH_LIBS([setusercontext], [util])
 AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex])
 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
@@ -822,7 +844,7 @@ AHX_MEMCMP_BROKEN(unbound)
 char *ctime_r(const time_t *timep, char *buf);
 #endif
 
-#ifndef HAVE_STRPTIME
+#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
 #define strptime unbound_strptime
 struct tm;
 char *strptime(const char *s, const char *format, struct tm *tm);