From c38151b88290a22c1d933f557e2c9c67600ca818 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 24 Jul 2022 15:52:41 +0300 Subject: [PATCH 40/40] configure: Add cache variable for gettimeofday detection So it can be set to not get the pessimistic default when cross-compiling. See osdn #45050 Signed-off-by: Marko Lindqvist --- configure.ac | 6 +++--- m4/gettimeofday.m4 | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 1b75ca51f2..5c75158be2 100644 --- a/configure.ac +++ b/configure.ac @@ -1543,9 +1543,9 @@ fi AC_CHECK_FUNCS([_mkdir]) -AC_MSG_CHECKING(for working gettimeofday) - FC_CHECK_GETTIMEOFDAY_RUNTIME(,AC_DEFINE([HAVE_GETTIMEOFDAY], [1], - [Define if the gettimeofday function works and is sane.]),) +FC_CHECK_GETTIMEOFDAY_RUNTIME([], + [AC_DEFINE([HAVE_GETTIMEOFDAY], [1], + [Define if the gettimeofday function works and is sane.])]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct ip_mreqn req; req.imr_ifindex = 0;]])], diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index a0601c4b79..bb5cede0eb 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -6,6 +6,8 @@ dnl a huge amount. It seems that glibc 2.3.1 is broken in this respect. AC_DEFUN([FC_CHECK_GETTIMEOFDAY_RUNTIME], [ +AC_CACHE_CHECK([for working gettimeofday], [ac_cv_working_gettimeofday], +[ templibs="$LIBS" LIBS="$1 $LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ @@ -101,9 +103,17 @@ int main(int argc, char **argv) #endif return 0; } -]])],[AC_MSG_RESULT(yes) - [$2]],[AC_MSG_RESULT(no) - [$3]],[AC_MSG_RESULT(unknown: cross-compiling) - [$3]]) -LIBS="$templibs" +]])], +[ac_cv_working_gettimeofday=yes], +[ac_cv_working_gettimeofday=no], +[ac_cv_working_gettimeofday=cross-compiling]) +LIBS="$templibs"]) + +if test "x$ac_cv_working_gettimeofday" = "xyes" ; then + $2 + : +else + $3 + : +fi ]) -- 2.35.1