From e578c035beb87cbb34c3cadfd9e7ee5639bfcfa8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 5 May 2012 12:31:27 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ m4/gettimeofday.m4 | 20 +++++++++++--------- m4/tzset.m4 | 11 +++++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f6d6c460..2a39ae426 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2012-05-05 Bruno Haible + 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 + 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, diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 2e65eb5c1..eda97027a 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -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], diff --git a/m4/tzset.m4 b/m4/tzset.m4 index c3ef37321..54b11bd7a 100644 --- a/m4/tzset.m4 +++ b/m4/tzset.m4 @@ -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.]) -- 2.11.0