pthread: fix pthread.h creation for srcdir != builddir
[gnulib.git] / m4 / sys_times_h.m4
1 # Configure a replacement for <sys/times.h>.
2 # serial 6
3
4 # Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # Written by Simon Josefsson.
10
11 AC_DEFUN([gl_SYS_TIMES_H],
12 [
13   AC_REQUIRE([gl_SYS_TIMES_H_DEFAULTS])
14
15   dnl <sys/times.h> is always overridden, because of GNULIB_POSIXCHECK.
16   gl_CHECK_NEXT_HEADERS([sys/times.h])
17   AC_CHECK_HEADERS_ONCE([sys/times.h])
18   if test $ac_cv_header_sys_times_h = yes; then
19     HAVE_SYS_TIMES_H=1
20     AC_CHECK_TYPES([struct tms], [], [HAVE_STRUCT_TMS=0], [[
21 #include <sys/times.h>
22       ]])
23   else
24     HAVE_SYS_TIMES_H=0
25     HAVE_STRUCT_TMS=0
26   fi
27   AC_SUBST([HAVE_SYS_TIMES_H])
28
29   dnl Check for declarations of anything we want to poison if the
30   dnl corresponding gnulib module is not in use.
31   gl_WARN_ON_USE_PREPARE([[
32 /* Some systems have incomplete headers.  */
33 #ifndef __GLIBC__
34 # include <time.h>
35 #endif
36 #include <sys/times.h>
37     ]], [times])
38 ])
39
40 AC_DEFUN([gl_SYS_TIMES_MODULE_INDICATOR],
41 [
42   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
43   AC_REQUIRE([gl_SYS_TIMES_H_DEFAULTS])
44   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
45 ])
46
47 AC_DEFUN([gl_SYS_TIMES_H_DEFAULTS],
48 [
49   GNULIB_TIMES=0;     AC_SUBST([GNULIB_TIMES])
50   HAVE_STRUCT_TMS=1;  AC_SUBST([HAVE_STRUCT_TMS])
51   HAVE_TIMES=1;       AC_SUBST([HAVE_TIMES])
52 ])