no longer needed.
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 93   -*- 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_STRERROR_R])
59   AC_REQUIRE([gl_FUNC_GROUP_MEMBER])
60   AC_REQUIRE([gl_AFS])
61   AC_REQUIRE([gl_AC_FUNC_LINK_FOLLOWS_SYMLINK])
62   AC_REQUIRE([gl_FUNC_FPENDING])
63
64   # This is for od and stat, and any other program that
65   # uses the PRI.MAX macros from inttypes.h.
66   AC_REQUIRE([gt_INTTYPES_PRI])
67   AC_REQUIRE([gl_ULLONG_MAX])
68
69   AC_REQUIRE([gl_FUNC_GETGROUPS])
70
71   AC_REQUIRE([AC_FUNC_FSEEKO])
72   AC_REQUIRE([AC_FUNC_ALLOCA])
73
74   AC_CONFIG_LIBOBJ_DIR([lib])
75   AC_FUNC_GETLOADAVG([lib])
76
77   AC_REQUIRE([gl_SYS_PROC_UPTIME])
78   AC_REQUIRE([gl_FUNC_FTRUNCATE])
79
80   # raise is used by at least sort and ls.
81   AC_REPLACE_FUNCS(raise)
82
83   # By default, argmatch should fail calling usage (1).
84   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
85             [Define to the function xargmatch calls on failures.])
86   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
87             [Define to the declaration of the xargmatch failure function.])
88
89   dnl Used to define SETVBUF in sys2.h.
90   dnl This evokes the following warning from autoconf:
91   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
92   AC_FUNC_SETVBUF_REVERSED
93
94   # used by sleep and shred
95   AC_REQUIRE([gl_CLOCK_TIME])
96   AC_CHECK_FUNCS_ONCE(gettimeofday)
97   AC_FUNC_GETTIMEOFDAY_CLOBBER
98   # used by shred
99   AC_CHECK_FUNCS_ONCE(directio)
100
101   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
102
103   AC_CHECK_FUNCS_ONCE( \
104     endgrent \
105     endpwent \
106     ftruncate \
107     hasmntopt \
108     isascii \
109     iswspace \
110     lchown \
111     listmntent \
112     mempcpy \
113     mkfifo \
114     mbrlen \
115     realpath \
116     sethostname \
117     siginterrupt \
118     sysctl \
119     sysinfo \
120     tcgetpgrp \
121     wcrtomb \
122     tzset \
123   )
124
125   AC_FUNC_STRTOD
126
127   AC_REQUIRE([cu_PREREQ_STAT_PROG])
128
129   # for dd.c and shred.c
130   coreutils_saved_libs=$LIBS
131     AC_SEARCH_LIBS([fdatasync], [rt posix4],
132                    [test "$ac_cv_search_fdatasync" = "none required" ||
133                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
134     AC_SUBST([LIB_FDATASYNC])
135     AC_CHECK_FUNCS(fdatasync)
136   LIBS=$coreutils_saved_libs
137
138   # See if linking `seq' requires -lm.
139   # It does on nearly every system.  The single exception (so far) is
140   # BeOS which has all the math functions in the normal runtime library
141   # and doesn't have a separate math library.
142
143   AC_SUBST(SEQ_LIBM)
144   ac_seq_body='
145      static double x, y;
146      x = floor (x);
147      x = rint (x);
148      x = modf (x, &y);'
149   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
150     [ac_seq_save_LIBS="$LIBS"
151      LIBS="$LIBS -lm"
152      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
153      LIBS="$ac_seq_save_LIBS"
154     ])
155
156   AC_REQUIRE([AM_LANGINFO_CODESET])
157   AC_REQUIRE([gl_GLIBC21])
158   AM_ICONV
159   gl_FUNC_UNLINK_BUSY_TEXT
160
161   # These tests are for df.
162   AC_REQUIRE([gl_FSUSAGE])
163   AC_REQUIRE([gl_MOUNTLIST])
164   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
165     DF_PROG='df$(EXEEXT)'
166   fi
167   AC_REQUIRE([gl_AC_DOS])
168   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
169
170   # If any of these functions don't exist (e.g. DJGPP 2.03),
171   # use the corresponding stub.
172   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
173
174   AC_REQUIRE([gl_FUNC_FREE])
175   AC_REQUIRE([gl_FUNC_CHDIR_LONG])
176   AC_REQUIRE([gl_FUNC_XFTS])
177   AC_REQUIRE([gl_ROOT_DEV_INO])
178   AC_REQUIRE([gl_VERSION_ETC])
179   AC_REQUIRE([gl_DIACRIT])
180 ])
181
182 AC_DEFUN([gl_CHECK_ALL_HEADERS],
183 [
184   AC_CHECK_HEADERS_ONCE( \
185     hurd.h \
186     paths.h \
187     priv.h \
188     stropts.h \
189     sys/ioctl.h \
190     sys/param.h \
191     sys/resource.h \
192     sys/statvfs.h \
193     sys/systeminfo.h \
194     sys/time.h \
195     sys/vfs.h \
196     sys/wait.h \
197     syslog.h \
198     termios.h \
199     utime.h \
200   )
201   AC_CHECK_HEADERS(sys/mount.h sys/sysctl.h, [], [],
202     [AC_INCLUDES_DEFAULT
203      [#if HAVE_SYS_PARAM_H
204        #include <sys/param.h>
205       #endif]])
206 ])
207
208 # This macro must be invoked before any tests that run the compiler.
209 AC_DEFUN([gl_CHECK_ALL_TYPES],
210 [
211   dnl This test must come as early as possible after the compiler configuration
212   dnl tests, because the choice of the file model can (in principle) affect
213   dnl whether functions and headers are available, whether they work, etc.
214   AC_REQUIRE([AC_SYS_LARGEFILE])
215
216   dnl This test must precede tests of compiler characteristics like
217   dnl that for the inline keyword, since it may change the degree to
218   dnl which the compiler supports such features.
219   AC_REQUIRE([AM_C_PROTOTYPES])
220
221   dnl Checks for typedefs, structures, and compiler characteristics.
222   AC_REQUIRE([AC_C_BIGENDIAN])
223   AC_REQUIRE([AC_C_CONST])
224   AC_REQUIRE([AC_C_VOLATILE])
225   AC_REQUIRE([AC_C_INLINE])
226   AC_REQUIRE([AC_C_LONG_DOUBLE])
227
228   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
229   AC_REQUIRE([AC_HEADER_DIRENT])
230   AC_REQUIRE([AC_HEADER_STDC])
231   AC_CHECK_MEMBERS(
232     [struct stat.st_author,
233      struct stat.st_blksize],,,
234     [$ac_includes_default
235 #include <sys/stat.h>
236   ])
237   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
238
239   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
240
241   AC_REQUIRE([AC_TYPE_GETGROUPS])
242   AC_REQUIRE([AC_TYPE_MBSTATE_T])
243   AC_REQUIRE([AC_TYPE_MODE_T])
244   AC_REQUIRE([AC_TYPE_OFF_T])
245   AC_REQUIRE([AC_TYPE_PID_T])
246   AC_REQUIRE([AC_TYPE_SIZE_T])
247   AC_REQUIRE([AC_TYPE_UID_T])
248   AC_CHECK_TYPE(ino_t, unsigned long int)
249
250   gt_TYPE_SSIZE_T
251
252   dnl This relies on the fact that autoconf 2.14a's implementation of
253   dnl AC_CHECK_TYPE checks includes unistd.h.
254   AC_CHECK_TYPE(major_t, unsigned int)
255   AC_CHECK_TYPE(minor_t, unsigned int)
256
257   AC_REQUIRE([gl_AC_TYPE_UINT32_T])
258   AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
259   AC_REQUIRE([gl_AC_TYPE_UINTPTR_T])
260   AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG])
261
262   AC_REQUIRE([AC_HEADER_MAJOR])
263   AC_REQUIRE([AC_HEADER_DIRENT])
264
265 ])