0d370844548bf392e025ca93fd7acf0d11e60156
[gnulib.git] / m4 / prereq.m4
1 #serial 26
2
3 dnl These are the prerequisite macros for files in the lib/
4 dnl directories of the fileutils, sh-utils, and textutils packages.
5
6 AC_DEFUN([jm_PREREQ],
7 [
8   jm_PREREQ_ADDEXT
9   jm_PREREQ_CANON_HOST
10   jm_PREREQ_DIRNAME
11   jm_PREREQ_ERROR
12   jm_PREREQ_EXCLUDE
13   jm_PREREQ_GETPAGESIZE
14   jm_PREREQ_HARD_LOCALE
15   jm_PREREQ_HASH
16   jm_PREREQ_HUMAN
17   jm_PREREQ_MBSWIDTH
18   jm_PREREQ_MEMCHR
19   jm_PREREQ_PHYSMEM
20   jm_PREREQ_POSIXVER
21   jm_PREREQ_QUOTEARG
22   jm_PREREQ_READUTMP
23   jm_PREREQ_REGEX
24   jm_PREREQ_STAT
25   jm_PREREQ_STRNLEN
26   jm_PREREQ_TEMPNAME # called by mkstemp
27   jm_PREREQ_XGETCWD
28   jm_PREREQ_XREADLINK
29 ])
30
31 AC_DEFUN([jm_PREREQ_ADDEXT],
32 [
33   dnl For addext.c.
34   AC_SYS_LONG_FILE_NAMES
35   AC_CHECK_FUNCS(pathconf)
36   AC_CHECK_HEADERS(limits.h string.h unistd.h)
37 ])
38
39 AC_DEFUN([jm_PREREQ_CANON_HOST],
40 [
41   dnl Add any libraries as early as possible.
42   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
43   dnl so we have to add -lnsl to LIBS before checking for that function.
44   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
45
46   dnl These come from -lnsl on Solaris5.5.1.
47   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
48
49   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
50   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
51                    netinet/in.h arpa/inet.h)
52 ])
53
54 AC_DEFUN([jm_PREREQ_DIRNAME],
55 [
56   AC_HEADER_STDC
57   AC_CHECK_HEADERS(string.h)
58 ])
59
60 AC_DEFUN([jm_PREREQ_EXCLUDE],
61 [
62   jm_FUNC_FNMATCH
63   AC_HEADER_STDBOOL
64 ])
65
66 AC_DEFUN([jm_PREREQ_GETPAGESIZE],
67 [
68   AC_CHECK_FUNCS(getpagesize)
69   AC_CHECK_HEADERS(OS.h unistd.h)
70 ])
71
72 AC_DEFUN([jm_PREREQ_HARD_LOCALE],
73 [
74   AC_CHECK_HEADERS(locale.h stdlib.h string.h)
75   AC_CHECK_FUNCS(setlocale)
76   AM_C_PROTOTYPES
77 ])
78
79 AC_DEFUN([jm_PREREQ_HASH],
80 [
81   AC_CHECK_HEADERS(stdlib.h)
82   AC_HEADER_STDBOOL
83   AC_REQUIRE([jm_CHECK_DECLS])
84 ])
85
86 # If you use human.c, you need the following files:
87 # inttypes.m4 ulonglong.m4
88 AC_DEFUN([jm_PREREQ_HUMAN],
89 [
90   AC_CHECK_HEADERS(limits.h stdlib.h string.h)
91   AC_CHECK_DECLS([getenv])
92   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
93 ])
94
95 AC_DEFUN([jm_PREREQ_MEMCHR],
96 [
97   AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h)
98 ])
99
100 AC_DEFUN([jm_PREREQ_PHYSMEM],
101 [
102   AC_CHECK_HEADERS(sys/pstat.h unistd.h)
103   AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic)
104 ])
105
106 AC_DEFUN([jm_PREREQ_POSIXVER],
107 [
108   AC_CHECK_HEADERS(unistd.h)
109   AC_CHECK_DECLS([getenv])
110 ])
111
112 AC_DEFUN([jm_PREREQ_QUOTEARG],
113 [
114   AC_CHECK_FUNCS(isascii iswprint)
115   jm_FUNC_MBRTOWC
116   AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
117   AC_HEADER_STDC
118   AC_C_BACKSLASH_A
119   AC_TYPE_MBSTATE_T
120   AM_C_PROTOTYPES
121 ])
122
123 AC_DEFUN([jm_PREREQ_READUTMP],
124 [
125   AC_HEADER_STDC
126   AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
127   AC_CHECK_FUNCS(utmpname)
128   AC_CHECK_FUNCS(utmpxname)
129   AM_C_PROTOTYPES
130
131   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
132     utmp_includes="\
133 $ac_includes_default
134 #ifdef HAVE_UTMPX_H
135 # include <utmpx.h>
136 #endif
137 #ifdef HAVE_UTMP_H
138 # include <utmp.h>
139 #endif
140 "
141     AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
142     AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
143     AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
144     AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
145     AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
146     AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
147     AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
148     AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
149     AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
150     AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
151     AC_CHECK_MEMBERS([struct utmpx.ut_exit],,,[$utmp_includes])
152     AC_CHECK_MEMBERS([struct utmp.ut_exit],,,[$utmp_includes])
153     AC_LIBOBJ(readutmp)
154   fi
155 ])
156
157 AC_DEFUN([jm_PREREQ_REGEX],
158 [
159   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
160   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
161   dnl to get them.
162   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
163   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
164   AC_HEADER_STDC
165   AC_FUNC_ALLOCA
166 ])
167
168 AC_DEFUN([jm_PREREQ_STAT],
169 [
170   AC_CHECK_HEADERS(sys/sysmacros.h sys/statvfs.h sys/vfs.h inttypes.h)
171   AC_CHECK_HEADERS(sys/param.h sys/mount.h)
172   AC_CHECK_FUNCS(statvfs)
173   jm_AC_TYPE_LONG_LONG
174
175   statxfs_includes="\
176 $ac_includes_default
177 #if HAVE_SYS_STATVFS_H
178 # include <sys/statvfs.h>
179 #endif
180 #if HAVE_SYS_VFS_H
181 # include <sys/vfs.h>
182 #endif
183 #if ( ! HAVE_SYS_STATVFS_H && ! HAVE_SYS_VFS_H && HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H )
184 /* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
185 # include <sys/param.h>
186 # include <sys/mount.h>
187 #endif
188 "
189   AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes])
190   AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes])
191   AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes])
192   AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes])
193   AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes])
194   AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes])
195   AC_CHECK_MEMBERS([struct statvfs.f_fsid.__val],,,[$statxfs_includes])
196   AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
197   AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
198   AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
199   AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
200 ])
201
202 AC_DEFUN([jm_PREREQ_STRNLEN],
203 [
204   AC_FUNC_STRNLEN
205   AC_HEADER_STDC
206   AC_CHECK_HEADERS(memory.h)
207   AC_CHECK_DECLS([memchr])
208
209   # This is necessary because automake-1.6.1 doens't understand
210   # that the above use of AC_FUNC_STRNLEN means we may have to use
211   # lib/strnlen.c.
212   test $ac_cv_func_strnlen_working = yes \
213     && AC_LIBOBJ(strnlen)
214 ])
215
216 AC_DEFUN([jm_PREREQ_TEMPNAME],
217 [
218   AC_HEADER_STDC
219   AC_HEADER_STAT
220   AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h)
221   AC_CHECK_FUNCS(__secure_getenv gettimeofday)
222   AC_CHECK_DECLS([getenv])
223 ])
224
225 AC_DEFUN([jm_PREREQ_XGETCWD],
226 [
227   AC_C_PROTOTYPES
228   AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h)
229   AC_CHECK_FUNCS(getcwd)
230   AC_FUNC_GETCWD_NULL
231 ])
232
233 AC_DEFUN([jm_PREREQ_XREADLINK],
234 [
235   AC_C_PROTOTYPES
236   AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h)
237 ])