Reflect the renamings.
[gnulib.git] / m4 / jm-macros.m4
1 #serial 72   -*- autoconf -*-
2
3 dnl Misc type-related macros for fileutils, sh-utils, textutils.
4
5 AC_DEFUN([gl_MACROS],
6 [
7   AC_PREREQ(2.58)
8
9   GNU_PACKAGE="GNU $PACKAGE"
10   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
11     [The concatenation of the strings `GNU ', and PACKAGE.])
12   AC_SUBST(GNU_PACKAGE)
13
14   AM_MISSING_PROG(HELP2MAN, help2man)
15   AC_SUBST(OPTIONAL_BIN_PROGS)
16   AC_SUBST(MAN)
17   AC_SUBST(DF_PROG)
18
19   dnl This macro actually runs replacement code.  See isc-posix.m4.
20   AC_REQUIRE([AC_ISC_POSIX])dnl
21
22   gl_CHECK_ALL_TYPES
23
24   AC_REQUIRE([gl_HOST_OS])
25   AC_REQUIRE([gl_ASSERT])
26   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
27   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
28   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
29   AC_REQUIRE([gl_CHECK_DECLS])
30
31   AC_REQUIRE([gl_PREREQ])
32
33   AC_REQUIRE([gl_FUNC_DIRFD])
34   AC_REQUIRE([AC_FUNC_ACL])
35   AC_REQUIRE([gl_FUNC_LCHOWN])
36   AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
37   AC_REQUIRE([gl_FUNC_CHOWN])
38   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
39   AC_REQUIRE([AC_FUNC_STRERROR_R])
40   AC_REQUIRE([gl_FUNC_GROUP_MEMBER])
41   AC_REQUIRE([gl_AFS])
42   AC_REQUIRE([gl_AC_FUNC_LINK_FOLLOWS_SYMLINK])
43   AC_REQUIRE([gl_FUNC_FPENDING])
44
45   # This is for od and stat, and any other program that
46   # uses the PRI.MAX macros from inttypes.h.
47   AC_REQUIRE([gt_INTTYPES_PRI])
48
49   AC_REQUIRE([gl_FUNC_GETGROUPS])
50
51   AC_REQUIRE([AC_FUNC_FSEEKO])
52   AC_REQUIRE([AC_FUNC_ALLOCA])
53
54   AC_CONFIG_LIBOBJ_DIR([lib])
55   AC_FUNC_GETLOADAVG([lib])
56
57   AC_REQUIRE([gl_SYS_PROC_UPTIME])
58   AC_REQUIRE([gl_FUNC_FTRUNCATE])
59
60   # raise is used by at least sort and ls.
61   AC_REPLACE_FUNCS(raise)
62
63   # By default, argmatch should fail calling usage (1).
64   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
65             [Define to the function xargmatch calls on failures.])
66   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
67             [Define to the declaration of the xargmatch failure function.])
68
69   dnl Used to define SETVBUF in sys2.h.
70   dnl This evokes the following warning from autoconf:
71   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
72   AC_FUNC_SETVBUF_REVERSED
73
74   # used by sleep and shred
75   AC_REQUIRE([gl_CLOCK_TIME])
76   AC_CHECK_FUNCS(gettimeofday)
77   AC_FUNC_GETTIMEOFDAY_CLOBBER
78
79   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
80
81   AC_CHECK_FUNCS( \
82     endgrent \
83     endpwent \
84     fdatasync \
85     ftruncate \
86     gethrtime \
87     hasmntopt \
88     isascii \
89     iswspace \
90     lchown \
91     listmntent \
92     localeconv \
93     memcpy \
94     mempcpy \
95     mkfifo \
96     realpath \
97     sethostname \
98     strchr \
99     strerror \
100     strrchr \
101     sysctl \
102     sysinfo \
103     wcrtomb \
104     tzset \
105   )
106
107   # for test.c
108   AC_CHECK_FUNCS(setreuid setregid)
109
110   AC_FUNC_STRTOD
111   AC_REQUIRE([GL_FUNC_GETCWD_PATH_MAX])
112   AC_REQUIRE([GL_FUNC_READDIR])
113
114   # See if linking `seq' requires -lm.
115   # It does on nearly every system.  The single exception (so far) is
116   # BeOS which has all the math functions in the normal runtime library
117   # and doesn't have a separate math library.
118
119   AC_SUBST(SEQ_LIBM)
120   ac_seq_body='
121      static double x, y;
122      x = floor (x);
123      x = rint (x);
124      x = modf (x, &y);'
125   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
126     [ac_seq_save_LIBS="$LIBS"
127      LIBS="$LIBS -lm"
128      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
129      LIBS="$ac_seq_save_LIBS"
130     ])
131
132   AM_LANGINFO_CODESET
133   gl_GLIBC21
134   AM_ICONV
135   gl_FUNC_UNLINK_BUSY_TEXT
136
137   # These tests are for df.
138   AC_REQUIRE([gl_FSUSAGE])
139   AC_REQUIRE([gl_MOUNTLIST])
140   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
141     DF_PROG='df$(EXEEXT)'
142   fi
143   AC_REQUIRE([gl_AC_DOS])
144   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
145
146   # If any of these functions don't exist (e.g. DJGPP 2.03),
147   # use the corresponding stub.
148   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
149   AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])
150
151   AC_REQUIRE([gl_FUNC_FREE])
152 ])
153
154 # These tests must be run before any use of AC_CHECK_TYPE,
155 # because that macro compiles code that tests e.g., HAVE_UNISTD_H.
156 # See the definition of ac_includes_default in `configure'.
157 AC_DEFUN([gl_CHECK_ALL_HEADERS],
158 [
159   AC_CHECK_HEADERS( \
160     errno.h  \
161     fcntl.h \
162     float.h \
163     hurd.h \
164     limits.h \
165     memory.h \
166     mntent.h \
167     mnttab.h \
168     netdb.h \
169     paths.h \
170     stdlib.h \
171     stddef.h \
172     stdint.h \
173     string.h \
174     sys/filsys.h \
175     sys/fs/s5param.h \
176     sys/fs_types.h \
177     sys/fstyp.h \
178     sys/ioctl.h \
179     sys/mntent.h \
180     sys/mount.h \
181     sys/param.h \
182     sys/resource.h \
183     sys/socket.h \
184     sys/statfs.h \
185     sys/statvfs.h \
186     sys/sysctl.h \
187     sys/systeminfo.h \
188     sys/time.h \
189     sys/timeb.h \
190     sys/vfs.h \
191     sys/wait.h \
192     syslog.h \
193     termios.h \
194     unistd.h \
195     utime.h \
196     values.h \
197   )
198 ])
199
200 # This macro must be invoked before any tests that run the compiler.
201 AC_DEFUN([gl_CHECK_ALL_TYPES],
202 [
203   dnl This test must come as early as possible after the compiler configuration
204   dnl tests, because the choice of the file model can (in principle) affect
205   dnl whether functions and headers are available, whether they work, etc.
206   AC_REQUIRE([AC_SYS_LARGEFILE])
207
208   dnl This test must precede tests of compiler characteristics like
209   dnl that for the inline keyword, since it may change the degree to
210   dnl which the compiler supports such features.
211   AC_REQUIRE([AM_C_PROTOTYPES])
212
213   dnl Checks for typedefs, structures, and compiler characteristics.
214   AC_REQUIRE([AC_C_BIGENDIAN])
215   AC_REQUIRE([AC_C_CONST])
216   AC_REQUIRE([AC_C_VOLATILE])
217   AC_REQUIRE([AC_C_INLINE])
218   AC_REQUIRE([AC_C_LONG_DOUBLE])
219
220   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
221   AC_REQUIRE([AC_HEADER_DIRENT])
222   AC_REQUIRE([AC_HEADER_STDC])
223   AC_CHECK_MEMBERS(
224     [struct stat.st_author,
225      struct stat.st_blksize],,,
226     [$ac_includes_default
227 #include <sys/stat.h>
228   ])
229   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
230
231   AC_REQUIRE([AC_HEADER_STAT])
232   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
233   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
234
235   AC_REQUIRE([AC_TYPE_GETGROUPS])
236   AC_REQUIRE([AC_TYPE_MODE_T])
237   AC_REQUIRE([AC_TYPE_OFF_T])
238   AC_REQUIRE([AC_TYPE_PID_T])
239   AC_REQUIRE([AC_TYPE_SIGNAL])
240   AC_REQUIRE([AC_TYPE_SIZE_T])
241   AC_REQUIRE([AC_TYPE_UID_T])
242   AC_CHECK_TYPE(ino_t, unsigned long int)
243   AC_CHECK_TYPE(uintptr_t, size_t)
244
245   gt_TYPE_SSIZE_T
246
247   dnl This relies on the fact that autoconf 2.14a's implementation of
248   dnl AC_CHECK_TYPE checks includes unistd.h.
249   AC_CHECK_TYPE(major_t, unsigned int)
250   AC_CHECK_TYPE(minor_t, unsigned int)
251
252   AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
253   AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG])
254
255   AC_REQUIRE([AC_HEADER_MAJOR])
256   AC_REQUIRE([AC_HEADER_DIRENT])
257
258 ])