tzset: Avoid guessing wrong when cross-compiling to glibc systems.
authorBruno Haible <bruno@clisp.org>
Sat, 5 May 2012 10:31:27 +0000 (12:31 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 5 May 2012 10:31:27 +0000 (12:31 +0200)
* m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require AC_CANONICAL_HOST. When
cross-compiling to a glibc platform, set gl_cv_func_tzset_clobber to
"guessing no".
* m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Update.

ChangeLog
m4/gettimeofday.m4
m4/tzset.m4

index 9f6d6c4..2a39ae4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-05-05  Bruno Haible  <bruno@clisp.org>
 
+       tzset: Avoid guessing wrong when cross-compiling to glibc systems.
+       * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require AC_CANONICAL_HOST. When
+       cross-compiling to a glibc platform, set gl_cv_func_tzset_clobber to
+       "guessing no".
+       * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Update.
+
+2012-05-05  Bruno Haible  <bruno@clisp.org>
+
        d-ino: Avoid guessing "no" when cross-compiling to glibc/Linux systems.
        * m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Require
        AC_CANONICAL_HOST. When cross-compiling to a glibc/Linux platform,
index 2e65eb5..eda9702 100644 (file)
@@ -1,4 +1,4 @@
-# serial 19
+# serial 20
 
 # Copyright (C) 2001-2003, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -56,14 +56,16 @@ int gettimeofday (struct timeval *restrict, struct timezone *restrict);
     fi
     m4_ifdef([gl_FUNC_TZSET_CLOBBER], [
       gl_FUNC_TZSET_CLOBBER
-      if test $gl_cv_func_tzset_clobber = yes; then
-        REPLACE_GETTIMEOFDAY=1
-        gl_GETTIMEOFDAY_REPLACE_LOCALTIME
-        AC_DEFINE([tzset], [rpl_tzset],
-          [Define to rpl_tzset if the wrapper function should be used.])
-        AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
-          [Define if tzset clobbers localtime's static buffer.])
-      fi
+      case "$gl_cv_func_tzset_clobber" in
+        *yes)
+          REPLACE_GETTIMEOFDAY=1
+          gl_GETTIMEOFDAY_REPLACE_LOCALTIME
+          AC_DEFINE([tzset], [rpl_tzset],
+            [Define to rpl_tzset if the wrapper function should be used.])
+          AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
+            [Define if tzset clobbers localtime's static buffer.])
+          ;;
+      esac
     ])
   fi
   AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
index c3ef373..54b11bd 100644 (file)
@@ -1,4 +1,4 @@
-# serial 6
+# serial 7
 
 # Copyright (C) 2003, 2007, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -20,6 +20,7 @@ AC_DEFUN([gl_FUNC_TZSET], [])
 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
 [
   AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
                  gl_cv_func_tzset_clobber,
   [
@@ -47,7 +48,13 @@ main ()
   ]])],
        [gl_cv_func_tzset_clobber=no],
        [gl_cv_func_tzset_clobber=yes],
-       [gl_cv_func_tzset_clobber=yes])])
+       [case "$host_os" in
+                  # Guess all is fine on glibc systems.
+          *-gnu*) gl_cv_func_tzset_clobber="guessing no" ;;
+                  # If we don't know, assume the worst.
+          *)      gl_cv_func_tzset_clobber="guessing yes" ;;
+        esac
+       ])])
 
   AC_DEFINE([HAVE_RUN_TZSET_TEST], [1],
     [Define to 1 if you have run the test for working tzset.])