d70e1c90f8dc393327200f7f90d884c89aa78951
[gnulib.git] / m4 / check-decl.m4
1 #serial 20
2
3 dnl This is just a wrapper function to encapsulate this kludge.
4 dnl Putting it in a separate file like this helps share it between
5 dnl different packages.
6 AC_DEFUN([gl_CHECK_DECLS],
7 [
8   AC_REQUIRE([_gl_DECL_HEADERS])
9   AC_REQUIRE([AC_HEADER_TIME])
10   headers='
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14
15 #if HAVE_UNISTD_H
16 # include <unistd.h>
17 #endif
18
19 #include <sys/types.h>
20 #if TIME_WITH_SYS_TIME
21 # include <sys/time.h>
22 # include <time.h>
23 #else
24 # if HAVE_SYS_TIME_H
25 #  include <sys/time.h>
26 # else
27 #  include <time.h>
28 # endif
29 #endif
30
31 #if HAVE_UTMP_H
32 # include <utmp.h>
33 #endif
34
35 #if HAVE_GRP_H
36 # include <grp.h>
37 #endif
38
39 #if HAVE_PWD_H
40 # include <pwd.h>
41 #endif
42 '
43
44   AC_CHECK_DECLS([
45     free,
46     getenv,
47     geteuid,
48     getgrgid,
49     getlogin,
50     getpwuid,
51     getuid,
52     getutent,
53     lseek,
54     malloc,
55     memchr,
56     memrchr,
57     nanosleep,
58     realloc,
59     stpcpy,
60     strndup,
61     strnlen,
62     strstr,
63     strtoul,
64     strtoull,
65     ttyname], , , $headers)
66 ])
67
68 dnl FIXME: when autoconf has support for it.
69 dnl This is a little helper so we can require these header checks.
70 AC_DEFUN([_gl_DECL_HEADERS],
71 [
72   AC_REQUIRE([AC_HEADER_STDC])
73   AC_CHECK_HEADERS(grp.h memory.h pwd.h string.h strings.h stdlib.h \
74                    unistd.h sys/time.h utmp.h utmpx.h)
75 ])