519b23ac3ec7983c26533bbbc7f91db020616564
[platform/upstream/coreutils.git] / m4 / check-decl.m4
1 #serial 22
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 #include <unistd.h>
16
17 #include <sys/types.h>
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
20 # include <time.h>
21 #else
22 # if HAVE_SYS_TIME_H
23 #  include <sys/time.h>
24 # else
25 #  include <time.h>
26 # endif
27 #endif
28
29 #if HAVE_UTMP_H
30 # include <utmp.h>
31 #endif
32
33 #if HAVE_GRP_H
34 # include <grp.h>
35 #endif
36
37 #if HAVE_PWD_H
38 # include <pwd.h>
39 #endif
40 '
41
42   AC_CHECK_DECLS([
43     free,
44     getenv,
45     geteuid,
46     getgrgid,
47     getlogin,
48     getpwuid,
49     getuid,
50     getutent,
51     lseek,
52     malloc,
53     memchr,
54     memrchr,
55     nanosleep,
56     realloc,
57     stpcpy,
58     strndup,
59     strnlen,
60     strstr,
61     strtoul,
62     strtoull,
63     ttyname], , , $headers)
64
65   AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
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_CHECK_HEADERS_ONCE(grp.h pwd.h sys/time.h utmp.h)
73 ])