(libfetish_a_SOURCES): Add mmap-stack.h.
[coreutils.git] / m4 / prereq.m4
blob7f4c654e5eb0fdaf65536cc96c8a6e832a20cb8b
1 #serial 30
3 dnl We use jm_ for non Autoconf macros.
4 m4_pattern_forbid([^jm_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
6 # These are the prerequisite macros for files in the lib/
7 # directory of the coreutils package.
9 AC_DEFUN([jm_PREREQ],
11   AC_REQUIRE([jm_PREREQ_ADDEXT])
12   AC_REQUIRE([jm_PREREQ_C_STACK])
13   AC_REQUIRE([jm_PREREQ_CANON_HOST])
14   AC_REQUIRE([jm_PREREQ_DIRNAME])
15   AC_REQUIRE([jm_PREREQ_ERROR])
16   AC_REQUIRE([jm_PREREQ_EXCLUDE])
17   AC_REQUIRE([jm_PREREQ_GETPAGESIZE])
18   AC_REQUIRE([jm_PREREQ_HARD_LOCALE])
19   AC_REQUIRE([jm_PREREQ_HASH])
20   AC_REQUIRE([jm_PREREQ_HUMAN])
21   AC_REQUIRE([jm_PREREQ_MBSWIDTH])
22   AC_REQUIRE([jm_PREREQ_MEMCHR])
23   AC_REQUIRE([jm_PREREQ_PHYSMEM])
24   AC_REQUIRE([jm_PREREQ_POSIXVER])
25   AC_REQUIRE([jm_PREREQ_QUOTEARG])
26   AC_REQUIRE([jm_PREREQ_READUTMP])
27   AC_REQUIRE([jm_PREREQ_STAT])
28   AC_REQUIRE([jm_PREREQ_STRNLEN])
29   AC_REQUIRE([jm_PREREQ_TEMPNAME]) # called by mkstemp
30   AC_REQUIRE([jm_PREREQ_XGETCWD])
31   AC_REQUIRE([jm_PREREQ_XREADLINK])
34 AC_DEFUN([jm_PREREQ_ADDEXT],
36   dnl For addext.c.
37   AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
38   AC_CHECK_FUNCS(pathconf)
39   AC_CHECK_HEADERS(limits.h string.h unistd.h)
42 AC_DEFUN([jm_PREREQ_CANON_HOST],
44   dnl Add any libraries as early as possible.
45   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
46   dnl so we have to add -lnsl to LIBS before checking for that function.
47   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
49   dnl These come from -lnsl on Solaris5.5.1.
50   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
52   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
53                    netinet/in.h arpa/inet.h)
56 AC_DEFUN([jm_PREREQ_DIRNAME],
58   AC_REQUIRE([AC_HEADER_STDC])
59   AC_CHECK_HEADERS(string.h)
62 AC_DEFUN([jm_PREREQ_EXCLUDE],
64   AC_REQUIRE([AC_FUNC_FNMATCH_GNU])
65   AC_REQUIRE([AC_HEADER_STDBOOL])
68 AC_DEFUN([jm_PREREQ_GETPAGESIZE],
70   AC_CHECK_FUNCS(getpagesize)
71   AC_CHECK_HEADERS(OS.h unistd.h)
74 AC_DEFUN([jm_PREREQ_HARD_LOCALE],
76   AC_CHECK_HEADERS(locale.h stdlib.h string.h)
77   AC_CHECK_FUNCS(setlocale)
78   AC_REQUIRE([AM_C_PROTOTYPES])
81 AC_DEFUN([jm_PREREQ_HASH],
83   AC_CHECK_HEADERS(stdlib.h)
84   AC_REQUIRE([AC_HEADER_STDBOOL])
85   AC_REQUIRE([jm_CHECK_DECLS])
88 # If you use human.c, you need the following files:
89 # inttypes.m4 longlong.m4
90 AC_DEFUN([jm_PREREQ_HUMAN],
92   AC_CHECK_HEADERS(locale.h)
93   AC_CHECK_DECLS([getenv])
94   AC_CHECK_FUNCS(localeconv)
95   AC_REQUIRE([AC_HEADER_STDBOOL])
96   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
99 AC_DEFUN([jm_PREREQ_MEMCHR],
101   AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h)
104 AC_DEFUN([jm_PREREQ_PHYSMEM],
106   AC_CHECK_HEADERS(sys/pstat.h unistd.h sys/sysget.h sys/sysinfo.h)
107   AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysget)
110 AC_DEFUN([jm_PREREQ_POSIXVER],
112   AC_CHECK_HEADERS(unistd.h)
113   AC_CHECK_DECLS([getenv])
116 AC_DEFUN([jm_PREREQ_QUOTEARG],
118   AC_CHECK_FUNCS(isascii iswprint)
119   AC_REQUIRE([jm_FUNC_MBRTOWC])
120   AC_REQUIRE([jm_FUNC_MEMCMP])
121   AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
122   AC_REQUIRE([AC_HEADER_STDC])
123   AC_REQUIRE([AC_C_BACKSLASH_A])
124   AC_REQUIRE([AC_TYPE_MBSTATE_T])
125   AC_REQUIRE([AM_C_PROTOTYPES])
128 AC_DEFUN([jm_PREREQ_READUTMP],
130   AC_REQUIRE([AC_HEADER_STDC])
131   AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
132   AC_CHECK_FUNCS(utmpname)
133   AC_CHECK_FUNCS(utmpxname)
134   AC_REQUIRE([AM_C_PROTOTYPES])
136   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
137     utmp_includes="\
138 $ac_includes_default
139 #ifdef HAVE_UTMPX_H
140 # include <utmpx.h>
141 #endif
142 #ifdef HAVE_UTMP_H
143 # include <utmp.h>
144 #endif
146     AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
147     AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
148     AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
149     AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
150     AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
151     AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
152     AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
153     AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
154     AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
155     AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
157     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
158     AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_exit],,,[$utmp_includes])
159     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
160     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
162     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
163     AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_termination],,,[$utmp_includes])
164     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
165     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
166     AC_LIBOBJ(readutmp)
167   fi
170 AC_DEFUN([jm_PREREQ_STAT],
172   AC_CHECK_HEADERS(sys/sysmacros.h sys/statvfs.h sys/vfs.h inttypes.h)
173   AC_CHECK_HEADERS(sys/param.h sys/mount.h)
174   AC_CHECK_FUNCS(statvfs)
175   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
177   statxfs_includes="\
178 $ac_includes_default
179 #if HAVE_SYS_STATVFS_H
180 # include <sys/statvfs.h>
181 #endif
182 #if HAVE_SYS_VFS_H
183 # include <sys/vfs.h>
184 #endif
185 #if ( ! HAVE_SYS_STATVFS_H && ! HAVE_SYS_VFS_H && HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H )
186 /* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
187 # include <sys/param.h>
188 # include <sys/mount.h>
189 #endif
191   AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes])
192   AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes])
193   AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes])
194   AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes])
195   AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes])
196   AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes])
197   AC_CHECK_MEMBERS([struct statvfs.f_fsid.__val],,,[$statxfs_includes])
198   AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
199   AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
200   AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
201   AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
204 AC_DEFUN([jm_PREREQ_STRNLEN],
206   AC_REQUIRE([AC_FUNC_STRNLEN])
207   AC_REQUIRE([AC_HEADER_STDC])
208   AC_CHECK_HEADERS(memory.h)
209   AC_CHECK_DECLS([memchr])
211   # This is necessary because automake-1.6.1 doesn't understand
212   # that the above use of AC_FUNC_STRNLEN means we may have to use
213   # lib/strnlen.c.
214   test $ac_cv_func_strnlen_working = yes \
215     && AC_LIBOBJ(strnlen)
218 AC_DEFUN([jm_PREREQ_TEMPNAME],
220   AC_REQUIRE([AC_HEADER_STDC])
221   AC_REQUIRE([AC_HEADER_STAT])
222   AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h)
223   AC_CHECK_FUNCS(__secure_getenv gettimeofday)
224   AC_CHECK_DECLS([getenv])
225   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
228 AC_DEFUN([jm_PREREQ_XGETCWD],
230   AC_REQUIRE([AC_C_PROTOTYPES])
231   AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h)
232   AC_CHECK_FUNCS(getcwd)
233   AC_REQUIRE([AC_FUNC_GETCWD_NULL])
236 AC_DEFUN([jm_PREREQ_XREADLINK],
238   AC_REQUIRE([AC_C_PROTOTYPES])
239   AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h)