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