d5a2c156f4c8977ae66ec1ed5e0529b04b204a41
[gnulib.git] / m4 / prereq.m4
1 #serial 10
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_ERROR
11   jm_PREREQ_GETPAGESIZE
12   jm_PREREQ_HUMAN
13   jm_PREREQ_QUOTEARG
14   jm_PREREQ_READUTMP
15   jm_PREREQ_REGEX
16 ])
17
18 AC_DEFUN(jm_PREREQ_ADDEXT,
19 [
20   dnl For addext.c.
21   AC_SYS_LONG_FILE_NAMES
22   AC_CHECK_FUNCS(pathconf)
23   AC_CHECK_HEADERS(limits.h string.h unistd.h)
24 ])
25
26 AC_DEFUN(jm_PREREQ_CANON_HOST,
27 [
28   dnl Add any libraries as early as possible.
29   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
30   dnl so we have to add -lnsl to LIBS before checking for that function.
31   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
32
33   dnl These come from -lnsl on Solaris5.5.1.
34   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
35
36   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
37   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
38                    netinet/in.h arpa/inet.h)
39 ])
40
41 # If you use human.c, you need the following files:
42 # uintmax_t.m4 inttypes_h.m4 ulonglong.m4
43 AC_DEFUN(jm_PREREQ_HUMAN,
44 [
45   AC_CHECK_HEADERS(limits.h stdlib.h string.h)
46   AC_CHECK_DECLS([getenv])
47   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
48   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
49 ])
50
51 AC_DEFUN(jm_PREREQ_GETPAGESIZE,
52 [
53   AC_CHECK_FUNCS(getpagesize)
54   AC_CHECK_HEADERS(OS.h unistd.h)
55 ])
56
57 AC_DEFUN(jm_PREREQ_QUOTEARG,
58 [
59   AC_CHECK_FUNCS(isascii iswprint mbrtowc)
60   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
61   AC_HEADER_STDC
62   AC_C_BACKSLASH_A
63   AC_MBSTATE_T
64   AM_C_PROTOTYPES
65 ])
66
67 AC_DEFUN(jm_PREREQ_READUTMP,
68 [
69   AC_HEADER_STDC
70   AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
71   AC_CHECK_FUNCS(utmpname)
72   AC_CHECK_FUNCS(utmpxname)
73   AM_C_PROTOTYPES
74
75   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
76     utmp_includes="\
77 $ac_includes_default
78 #ifdef HAVE_UTMPX_H
79 # include <utmpx.h>
80 #else
81 # include <utmp.h>
82 #endif
83 "
84     AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
85     AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
86     AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
87     AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
88     AC_LIBOBJ(readutmp)
89   fi
90 ])
91
92 AC_DEFUN(jm_PREREQ_REGEX,
93 [
94   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
95   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
96   dnl to get them.
97   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
98   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
99   AC_HEADER_STDC
100   AC_FUNC_ALLOCA
101 ])