freeciv: Use gettimeofday() instead of deprecated ftime()

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
This commit is contained in:
Marko Lindqvist
2022-07-08 08:04:13 +03:00
parent 27279cb821
commit fe967cd28c
2 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
diff --git a/configure.ac b/configure.ac
index ee311c6fb3..655c45c425 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1478,9 +1478,9 @@ CPPFLAGS="$CPPFLAGS -Werror $EXTRA_DEBUG_CFLAGS"
AC_CHECK_FUNCS([_mkdir])
CPPFLAGS="$fc_save_CPPFLAGS"
-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 <netinet/in.h>]],
[[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
])

View File

@@ -4,6 +4,11 @@ require freeciv-qt5.inc
SRC_URI += "\
${SOURCEFORGE_MIRROR}/freeciv/freeciv-${PV}.tar.xz \
file://dummy-qtver.patch \
file://CacheVarForGettimeofday.patch \
"
EXTRA_OECONF += "\
ac_cv_working_gettimeofday=yes \
"
SRC_URI[sha256sum] = "7407ea1a08267b1c5ee3439dc2db5c2d7b90ece7fcc3664ca2ad594435a57175"