b1e0a45828676cdaa08e9f7e1c985e6ec337ac0d
[gnulib.git] / m4 / check-decl.m4
1 #serial 15
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(jm_CHECK_DECLS,
7 [
8   AC_REQUIRE([_jm_DECL_HEADERS])
9   AC_REQUIRE([AC_HEADER_TIME])
10   headers='
11 #include <stdio.h>
12 #if HAVE_STRING_H
13 # if !STDC_HEADERS && HAVE_MEMORY_H
14 #  include <memory.h>
15 # endif
16 # include <string.h>
17 #else
18 # if HAVE_STRINGS_H
19 #  include <strings.h>
20 # endif
21 #endif
22 #if HAVE_STDLIB_H
23 # include <stdlib.h>
24 #endif
25 #if HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif
28
29 #include <sys/types.h>
30 #if TIME_WITH_SYS_TIME
31 # include <sys/time.h>
32 # include <time.h>
33 #else
34 # if HAVE_SYS_TIME_H
35 #  include <sys/time.h>
36 # else
37 #  include <time.h>
38 # endif
39 #endif
40
41 #if !HAVE_UTMPX_H
42 # include <utmp.h>
43 #endif
44 '
45
46   AC_CHECK_DECLS([
47     free,
48     getenv,
49     geteuid,
50     getgrgid
51     getlogin,
52     getpwuid
53     getuid
54     getutent,
55     lseek,
56     malloc,
57     memchr,
58     nanosleep,
59     realloc,
60     stpcpy,
61     strndup,
62     strnlen,
63     strstr,
64     strtoul,
65     strtoull,
66     ttyname], , , $headers)
67 ])
68
69 dnl FIXME: when autoconf has support for it.
70 dnl This is a little helper so we can require these header checks.
71 AC_DEFUN(_jm_DECL_HEADERS,
72 [
73   AC_REQUIRE([AC_HEADER_STDC])
74   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
75                    utmp.h utmpx.h)
76 ])