(jm_MACROS): Replace jm_INCLUDED_REGEX([lib/regex.c]) with gl_REGEX.
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 66   -*- autoconf -*-
2
3 m4_undefine([AC_LANG_SOURCE(C)])
4 dnl The following is identical to the definition in c.m4
5 dnl from the autoconf cvs repository on 2003-03-07.
6 dnl FIXME: remove this code once we upgrade to autoconf-2.58.
7
8 # We can't use '#line $LINENO "configure"' here, since
9 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
10 # rejects $LINENO greater than 32767, and some configure scripts
11 # are longer than 32767 lines.
12 m4_define([AC_LANG_SOURCE(C)],
13 [/* confdefs.h.  */
14 _ACEOF
15 cat confdefs.h >>conftest.$ac_ext
16 cat >>conftest.$ac_ext <<_ACEOF
17 /* end confdefs.h.  */
18 $1])
19
20
21 dnl Misc type-related macros for fileutils, sh-utils, textutils.
22
23 AC_DEFUN([jm_MACROS],
24 [
25   AC_PREREQ(2.57)
26
27   GNU_PACKAGE="GNU $PACKAGE"
28   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
29     [The concatenation of the strings `GNU ', and PACKAGE.])
30   AC_SUBST(GNU_PACKAGE)
31
32   AM_MISSING_PROG(HELP2MAN, help2man)
33   AC_SUBST(OPTIONAL_BIN_PROGS)
34   AC_SUBST(MAN)
35   AC_SUBST(DF_PROG)
36
37   dnl This macro actually runs replacement code.  See isc-posix.m4.
38   AC_REQUIRE([AC_ISC_POSIX])dnl
39
40   jm_CHECK_ALL_TYPES
41   gl_REGEX
42
43   AC_REQUIRE([UTILS_HOST_OS])
44   AC_REQUIRE([UTILS_FUNC_MKDIR_TRAILING_SLASH])
45   AC_REQUIRE([jm_BISON])
46   AC_REQUIRE([jm_ASSERT])
47   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
48   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
49   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
50   AC_REQUIRE([jm_CHECK_DECLS])
51
52   AC_REQUIRE([jm_PREREQ])
53
54   AC_REQUIRE([UTILS_FUNC_DIRFD])
55   AC_REQUIRE([AC_FUNC_ACL])
56   AC_REQUIRE([AC_FUNC_FTW])
57   AC_REQUIRE([jm_FUNC_LCHOWN])
58   AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
59   AC_REQUIRE([jm_FUNC_CHOWN])
60   AC_REQUIRE([gl_FUNC_MKTIME])
61   AC_REQUIRE([jm_FUNC_LSTAT])
62   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
63   AC_REQUIRE([jm_FUNC_STAT])
64   AC_REQUIRE([AC_FUNC_REALLOC])
65   AC_REQUIRE([AC_FUNC_MALLOC])
66   AC_REQUIRE([AC_FUNC_STRERROR_R])
67   AC_REQUIRE([jm_FUNC_NANOSLEEP])
68   AC_REQUIRE([jm_FUNC_MEMCMP])
69   AC_REQUIRE([gl_MEMCOLL])
70   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
71   AC_REQUIRE([jm_FUNC_GROUP_MEMBER])
72   AC_REQUIRE([jm_FUNC_PUTENV])
73   AC_REQUIRE([jm_AFS])
74   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
75   AC_REQUIRE([jm_AC_PREREQ_XSTRTOIMAX])
76   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
77   AC_REQUIRE([gl_FUNC_FNMATCH_GNU])
78   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
79   AC_REQUIRE([jm_FUNC_FPENDING])
80
81   # This is for od and stat, and any other program that
82   # uses the PRI.MAX macros from inttypes.h.
83   AC_REQUIRE([gt_INTTYPES_PRI])
84
85   AC_REQUIRE([jm_FUNC_GETGROUPS])
86
87   AC_REQUIRE([AC_FUNC_FSEEKO])
88   AC_REQUIRE([AC_FUNC_ALLOCA])
89   AC_REQUIRE([gl_FUNC_ALLOCA])
90
91   AC_REQUIRE([gl_ERROR])
92
93   AC_CONFIG_LIBOBJ_DIR([lib])
94   AC_FUNC_GETLOADAVG
95
96   AC_REQUIRE([jm_SYS_PROC_UPTIME])
97   AC_REQUIRE([jm_FUNC_FTRUNCATE])
98   AC_REQUIRE([vb_FUNC_RENAME])
99
100   AC_REPLACE_FUNCS(strcasecmp strncasecmp)
101   AC_REPLACE_FUNCS(dup2)
102   AC_REPLACE_FUNCS(gethostname getusershell)
103   AC_REPLACE_FUNCS(sig2str)
104   AC_REPLACE_FUNCS(strcspn stpcpy strstr strtol strtoul)
105   AC_REPLACE_FUNCS(strpbrk)
106   AC_REPLACE_FUNCS(euidaccess memcmp rmdir rpmatch strndup strverscmp)
107   AC_REPLACE_FUNCS(atexit)
108   AC_REPLACE_FUNCS(getpass)
109
110   # raise is used by at least sort and ls.
111   AC_REPLACE_FUNCS(raise)
112
113   dnl used by e.g. intl/*domain.c and lib/canon-host.c
114   AC_REPLACE_FUNCS(strdup)
115
116   AC_REPLACE_FUNCS(memchr memcpy memmove memrchr memset)
117   AC_CHECK_FUNCS(getpagesize)
118
119   AC_REQUIRE([UTILS_FUNC_MKSTEMP])
120
121   # By default, argmatch should fail calling usage (1).
122   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
123             [Define to the function xargmatch calls on failures.])
124   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
125             [Define to the declaration of the xargmatch failure function.])
126
127   dnl Used to define SETVBUF in sys2.h.
128   dnl This evokes the following warning from autoconf:
129   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
130   AC_FUNC_SETVBUF_REVERSED
131
132   # used by sleep and shred
133   # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
134   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
135
136   # Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
137   # programs in the package would end up linked with that potentially-shared
138   # library, inducing unnecessary run-time overhead.
139   fetish_saved_libs=$LIBS
140     AC_SEARCH_LIBS(clock_gettime, [rt posix4],
141                    [LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
142     AC_SUBST(LIB_CLOCK_GETTIME)
143     AC_CHECK_FUNCS(clock_gettime clock_settime)
144   LIBS=$fetish_saved_libs
145   AC_CHECK_FUNCS(gettimeofday)
146   AC_FUNC_GETTIMEOFDAY_CLOBBER
147
148   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
149   AC_REQUIRE([jm_FUNC_UTIME])
150   AC_REQUIRE([gl_FUNC_VASPRINTF])
151   AC_REQUIRE([gl_FUNC_VASNPRINTF])
152
153   AC_CHECK_FUNCS( \
154     bcopy \
155     endgrent \
156     endpwent \
157     fchdir \
158     fdatasync \
159     ftime \
160     ftruncate \
161     getcwd \
162     gethrtime \
163     getmntinfo \
164     hasmntopt \
165     isascii \
166     iswspace \
167     lchown \
168     listmntent \
169     localeconv \
170     memcpy \
171     mempcpy \
172     mkfifo \
173     realpath \
174     sethostname \
175     strchr \
176     strerror \
177     strrchr \
178     sysctl \
179     sysinfo \
180     wcrtomb \
181     tzset \
182   )
183
184   # for test.c
185   AC_CHECK_FUNCS(setreuid setregid)
186
187   AM_FUNC_GETLINE
188   gl_GETNDELIM2
189   AC_FUNC_OBSTACK
190
191   AC_FUNC_STRTOD
192   AC_REQUIRE([UTILS_SYS_OPEN_MAX])
193   AC_REQUIRE([GL_FUNC_GETCWD_PATH_MAX])
194   AC_REQUIRE([GL_FUNC_READDIR])
195
196   # See if linking `seq' requires -lm.
197   # It does on nearly every system.  The single exception (so far) is
198   # BeOS which has all the math functions in the normal runtime library
199   # and doesn't have a separate math library.
200
201   AC_SUBST(SEQ_LIBM)
202   ac_seq_body='
203      static double x, y;
204      x = floor (x);
205      x = rint (x);
206      x = modf (x, &y);'
207   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
208     [ac_seq_save_LIBS="$LIBS"
209      LIBS="$LIBS -lm"
210      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
211      LIBS="$ac_seq_save_LIBS"
212     ])
213
214   AM_LANGINFO_CODESET
215   jm_GLIBC21
216   AM_ICONV
217   jm_FUNC_UNLINK_BUSY_TEXT
218
219   # These tests are for df.
220   jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
221   jm_FSTYPENAME
222   jm_FILE_SYSTEM_USAGE([space=yes], [space=no])
223   if test $list_mounted_fs = yes && test $space = yes; then
224     DF_PROG='df$(EXEEXT)'
225     AC_LIBOBJ(fsusage)
226     AC_LIBOBJ(mountlist)
227   fi
228   AC_REQUIRE([jm_AC_DOS])
229   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
230
231   # If any of these functions don't exist (e.g. DJGPP 2.03),
232   # use the corresponding stub.
233   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
234   AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])
235   AC_CHECK_FUNC([lstat], , [AC_LIBOBJ(lstat-stub)])
236   AC_CHECK_FUNC([readlink], , [AC_LIBOBJ(readlink-stub)])
237   AC_REQUIRE([AM_STDBOOL_H])
238
239 ])
240
241 # These tests must be run before any use of AC_CHECK_TYPE,
242 # because that macro compiles code that tests e.g., HAVE_UNISTD_H.
243 # See the definition of ac_includes_default in `configure'.
244 AC_DEFUN([jm_CHECK_ALL_HEADERS],
245 [
246   AC_CHECK_HEADERS( \
247     errno.h  \
248     fcntl.h \
249     float.h \
250     hurd.h \
251     limits.h \
252     memory.h \
253     mntent.h \
254     mnttab.h \
255     netdb.h \
256     paths.h \
257     stdlib.h \
258     stddef.h \
259     stdint.h \
260     string.h \
261     sys/filsys.h \
262     sys/fs/s5param.h \
263     sys/fs_types.h \
264     sys/fstyp.h \
265     sys/ioctl.h \
266     sys/mntent.h \
267     sys/mount.h \
268     sys/param.h \
269     sys/resource.h \
270     sys/socket.h \
271     sys/statfs.h \
272     sys/statvfs.h \
273     sys/sysctl.h \
274     sys/systeminfo.h \
275     sys/time.h \
276     sys/timeb.h \
277     sys/vfs.h \
278     sys/wait.h \
279     syslog.h \
280     termios.h \
281     unistd.h \
282     utime.h \
283     values.h \
284   )
285 ])
286
287 # This macro must be invoked before any tests that run the compiler.
288 AC_DEFUN([jm_CHECK_ALL_TYPES],
289 [
290   dnl This test must come as early as possible after the compiler configuration
291   dnl tests, because the choice of the file model can (in principle) affect
292   dnl whether functions and headers are available, whether they work, etc.
293   AC_REQUIRE([AC_SYS_LARGEFILE])
294
295   dnl This test must precede tests of compiler characteristics like
296   dnl that for the inline keyword, since it may change the degree to
297   dnl which the compiler supports such features.
298   AC_REQUIRE([AM_C_PROTOTYPES])
299
300   dnl Checks for typedefs, structures, and compiler characteristics.
301   AC_REQUIRE([AC_C_BIGENDIAN])
302   AC_REQUIRE([AC_C_CONST])
303   AC_REQUIRE([AC_C_VOLATILE])
304   AC_REQUIRE([AC_C_INLINE])
305   AC_REQUIRE([AC_C_LONG_DOUBLE])
306
307   AC_REQUIRE([jm_CHECK_ALL_HEADERS])
308   AC_REQUIRE([AC_HEADER_DIRENT])
309   AC_REQUIRE([AC_HEADER_STDC])
310   AC_CHECK_MEMBERS(
311     [struct stat.st_author,
312      struct stat.st_blksize],,,
313     [$ac_includes_default
314 #include <sys/stat.h>
315   ])
316   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
317
318   AC_REQUIRE([AC_STRUCT_TM])
319   AC_REQUIRE([AC_STRUCT_TIMEZONE])
320   AC_REQUIRE([AC_HEADER_STAT])
321   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
322   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
323   AC_REQUIRE([gl_TIMESPEC])
324
325   AC_REQUIRE([AC_TYPE_GETGROUPS])
326   AC_REQUIRE([AC_TYPE_MODE_T])
327   AC_REQUIRE([AC_TYPE_OFF_T])
328   AC_REQUIRE([AC_TYPE_PID_T])
329   AC_REQUIRE([AC_TYPE_SIGNAL])
330   AC_REQUIRE([AC_TYPE_SIZE_T])
331   AC_REQUIRE([AC_TYPE_UID_T])
332   AC_CHECK_TYPE(ino_t, unsigned long)
333
334   gt_TYPE_SSIZE_T
335
336   dnl This relies on the fact that autoconf 2.14a's implementation of
337   dnl AC_CHECK_TYPE checks includes unistd.h.
338   AC_CHECK_TYPE(major_t, unsigned int)
339   AC_CHECK_TYPE(minor_t, unsigned int)
340
341   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
342   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
343
344   AC_REQUIRE([AC_HEADER_MAJOR])
345   AC_REQUIRE([AC_HEADER_DIRENT])
346
347 ])