Require gl_ROOT_DEV_INO.
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 89   -*- autoconf -*-
2
3 dnl Misc type-related macros for coreutils.
4
5 # Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005 Free Software
6 # Foundation, Inc.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 # Written by Jim Meyering.
23
24 AC_DEFUN([gl_MACROS],
25 [
26   AC_PREREQ(2.58)
27
28   GNU_PACKAGE="GNU $PACKAGE"
29   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
30     [The concatenation of the strings `GNU ', and PACKAGE.])
31   AC_SUBST(GNU_PACKAGE)
32
33   AM_MISSING_PROG(HELP2MAN, help2man)
34   AC_SUBST(OPTIONAL_BIN_PROGS)
35   AC_SUBST(MAN)
36   AC_SUBST(DF_PROG)
37
38   dnl This macro actually runs replacement code.  See isc-posix.m4.
39   AC_REQUIRE([AC_ISC_POSIX])dnl
40
41   gl_CHECK_ALL_TYPES
42
43   AC_REQUIRE([gl_HOST_OS])
44   AC_REQUIRE([gl_ASSERT])
45   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
46   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
47   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
48   AC_REQUIRE([gl_CHECK_DECLS])
49
50   AC_REQUIRE([gl_PREREQ])
51
52   AC_REQUIRE([gl_FUNC_DIRFD])
53   AC_REQUIRE([AC_FUNC_ACL])
54   AC_REQUIRE([gl_FUNC_LCHOWN])
55   AC_REQUIRE([gl_FUNC_RMDIR_NOTEMPTY])
56   AC_REQUIRE([gl_FUNC_CHOWN])
57   AC_REQUIRE([AC_FUNC_LSTAT])
58   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
59   AC_REQUIRE([AC_FUNC_STRERROR_R])
60   AC_REQUIRE([gl_FUNC_GROUP_MEMBER])
61   AC_REQUIRE([gl_AFS])
62   AC_REQUIRE([gl_AC_FUNC_LINK_FOLLOWS_SYMLINK])
63   AC_REQUIRE([gl_FUNC_FPENDING])
64
65   # This is for od and stat, and any other program that
66   # uses the PRI.MAX macros from inttypes.h.
67   AC_REQUIRE([gt_INTTYPES_PRI])
68   AC_REQUIRE([gl_ULLONG_MAX])
69
70   AC_REQUIRE([gl_FUNC_GETGROUPS])
71
72   AC_REQUIRE([AC_FUNC_FSEEKO])
73   AC_REQUIRE([AC_FUNC_ALLOCA])
74
75   AC_CONFIG_LIBOBJ_DIR([lib])
76   AC_FUNC_GETLOADAVG([lib])
77
78   AC_REQUIRE([gl_SYS_PROC_UPTIME])
79   AC_REQUIRE([gl_FUNC_FTRUNCATE])
80
81   # raise is used by at least sort and ls.
82   AC_REPLACE_FUNCS(raise)
83
84   # By default, argmatch should fail calling usage (1).
85   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
86             [Define to the function xargmatch calls on failures.])
87   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
88             [Define to the declaration of the xargmatch failure function.])
89
90   dnl Used to define SETVBUF in sys2.h.
91   dnl This evokes the following warning from autoconf:
92   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
93   AC_FUNC_SETVBUF_REVERSED
94
95   # used by sleep and shred
96   AC_REQUIRE([gl_CLOCK_TIME])
97   AC_CHECK_FUNCS_ONCE(gettimeofday)
98   AC_FUNC_GETTIMEOFDAY_CLOBBER
99   # used by shred
100   AC_CHECK_FUNCS_ONCE(directio)
101
102   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
103
104   AC_CHECK_FUNCS_ONCE( \
105     endgrent \
106     endpwent \
107     ftruncate \
108     hasmntopt \
109     isascii \
110     iswspace \
111     lchown \
112     listmntent \
113     mempcpy \
114     mkfifo \
115     mbrlen \
116     realpath \
117     sethostname \
118     siginterrupt \
119     sysctl \
120     sysinfo \
121     tcgetpgrp \
122     wcrtomb \
123     tzset \
124   )
125
126   AC_FUNC_STRTOD
127
128   AC_REQUIRE([cu_PREREQ_STAT_PROG])
129
130   # for dd.c and shred.c
131   coreutils_saved_libs=$LIBS
132     AC_SEARCH_LIBS([fdatasync], [rt posix4],
133                    [test "$ac_cv_search_fdatasync" = "none required" ||
134                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
135     AC_SUBST([LIB_FDATASYNC])
136     AC_CHECK_FUNCS(fdatasync)
137   LIBS=$coreutils_saved_libs
138
139   # See if linking `seq' requires -lm.
140   # It does on nearly every system.  The single exception (so far) is
141   # BeOS which has all the math functions in the normal runtime library
142   # and doesn't have a separate math library.
143
144   AC_SUBST(SEQ_LIBM)
145   ac_seq_body='
146      static double x, y;
147      x = floor (x);
148      x = rint (x);
149      x = modf (x, &y);'
150   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
151     [ac_seq_save_LIBS="$LIBS"
152      LIBS="$LIBS -lm"
153      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
154      LIBS="$ac_seq_save_LIBS"
155     ])
156
157   AC_REQUIRE([AM_LANGINFO_CODESET])
158   AC_REQUIRE([gl_GLIBC21])
159   AM_ICONV
160   gl_FUNC_UNLINK_BUSY_TEXT
161
162   # These tests are for df.
163   AC_REQUIRE([gl_FSUSAGE])
164   AC_REQUIRE([gl_MOUNTLIST])
165   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
166     DF_PROG='df$(EXEEXT)'
167   fi
168   AC_REQUIRE([gl_AC_DOS])
169   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
170
171   # If any of these functions don't exist (e.g. DJGPP 2.03),
172   # use the corresponding stub.
173   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
174
175   AC_REQUIRE([gl_FUNC_FREE])
176   AC_REQUIRE([gl_FUNC_CHDIR_LONG])
177   AC_REQUIRE([gl_FUNC_XFTS])
178   AC_REQUIRE([gl_ROOT_DEV_INO])
179 ])
180
181 # These tests must be run before any use of AC_CHECK_TYPE,
182 # because that macro compiles code that tests e.g., HAVE_UNISTD_H.
183 # See the definition of ac_includes_default in `configure'.
184 AC_DEFUN([gl_CHECK_ALL_HEADERS],
185 [
186   AC_CHECK_HEADERS_ONCE( \
187     fcntl.h \
188     hurd.h \
189     memory.h \
190     mntent.h \
191     mnttab.h \
192     netdb.h \
193     paths.h \
194     priv.h \
195     stdlib.h \
196     stdint.h \
197     string.h \
198     sys/filsys.h \
199     sys/fs/s5param.h \
200     sys/fs_types.h \
201     sys/fstyp.h \
202     sys/ioctl.h \
203     sys/mntent.h \
204     sys/param.h \
205     sys/resource.h \
206     sys/socket.h \
207     sys/statfs.h \
208     sys/statvfs.h \
209     sys/systeminfo.h \
210     sys/time.h \
211     sys/timeb.h \
212     sys/vfs.h \
213     sys/wait.h \
214     syslog.h \
215     termios.h \
216     unistd.h \
217     utime.h \
218   )
219   AC_CHECK_HEADERS(sys/mount.h sys/sysctl.h, [], [],
220     [AC_INCLUDES_DEFAULT
221      [#if HAVE_SYS_PARAM_H
222        #include <sys/param.h>
223       #endif]])
224 ])
225
226 # This macro must be invoked before any tests that run the compiler.
227 AC_DEFUN([gl_CHECK_ALL_TYPES],
228 [
229   dnl This test must come as early as possible after the compiler configuration
230   dnl tests, because the choice of the file model can (in principle) affect
231   dnl whether functions and headers are available, whether they work, etc.
232   AC_REQUIRE([AC_SYS_LARGEFILE])
233
234   dnl This test must precede tests of compiler characteristics like
235   dnl that for the inline keyword, since it may change the degree to
236   dnl which the compiler supports such features.
237   AC_REQUIRE([AM_C_PROTOTYPES])
238
239   dnl Checks for typedefs, structures, and compiler characteristics.
240   AC_REQUIRE([AC_C_BIGENDIAN])
241   AC_REQUIRE([AC_C_CONST])
242   AC_REQUIRE([AC_C_VOLATILE])
243   AC_REQUIRE([AC_C_INLINE])
244   AC_REQUIRE([AC_C_LONG_DOUBLE])
245
246   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
247   AC_REQUIRE([AC_HEADER_DIRENT])
248   AC_REQUIRE([AC_HEADER_STDC])
249   AC_CHECK_MEMBERS(
250     [struct stat.st_author,
251      struct stat.st_blksize],,,
252     [$ac_includes_default
253 #include <sys/stat.h>
254   ])
255   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
256
257   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
258   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
259
260   AC_REQUIRE([AC_TYPE_GETGROUPS])
261   AC_REQUIRE([AC_TYPE_MBSTATE_T])
262   AC_REQUIRE([AC_TYPE_MODE_T])
263   AC_REQUIRE([AC_TYPE_OFF_T])
264   AC_REQUIRE([AC_TYPE_PID_T])
265   AC_REQUIRE([AC_TYPE_SIZE_T])
266   AC_REQUIRE([AC_TYPE_UID_T])
267   AC_CHECK_TYPE(ino_t, unsigned long int)
268
269   gt_TYPE_SSIZE_T
270
271   dnl This relies on the fact that autoconf 2.14a's implementation of
272   dnl AC_CHECK_TYPE checks includes unistd.h.
273   AC_CHECK_TYPE(major_t, unsigned int)
274   AC_CHECK_TYPE(minor_t, unsigned int)
275
276   AC_REQUIRE([gl_AC_TYPE_UINT32_T])
277   AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
278   AC_REQUIRE([gl_AC_TYPE_UINTPTR_T])
279   AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG])
280
281   AC_REQUIRE([AC_HEADER_MAJOR])
282   AC_REQUIRE([AC_HEADER_DIRENT])
283
284 ])