* modules/sys_time (Makefile.am): Build sys/time.h only when it's the
[pspp] / m4 / sys_time_h.m4
index 1943abf447621837713c05f5824c90538081e1f5..fc29f88e5fba210bd4448f3df73e904bf26cb931 100644 (file)
@@ -8,6 +8,14 @@
 # Written by Paul Eggert and Martin Lambers.
 
 AC_DEFUN([gl_HEADER_SYS_TIME_H],
+[
+  dnl Use AC_REQUIRE here, so that the GETTIMEOFDAY_REPLACEMENT=0 statement
+  dnl below is expanded once only, before all GETTIMEOFDAY_REPLACEMENT=1
+  dnl statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
 [
   AC_REQUIRE([AC_C_RESTRICT])
   AC_CHECK_HEADERS_ONCE([sys/time.h])
@@ -44,4 +52,10 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H],
   dnl Assume POSIX behavior unless another module says otherwise.
   GETTIMEOFDAY_REPLACEMENT=0
   AC_SUBST([GETTIMEOFDAY_REPLACEMENT])
+  if test $HAVE_SYS_TIME_H = 0 || test $HAVE_STRUCT_TIMEVAL = 0; then
+    SYS_TIME_H=sys/time.h
+  else
+    SYS_TIME_H=
+  fi
+  AC_SUBST([SYS_TIME_H])
 ])