(jm_MACROS): Include $(EXEEXT) in DF_PROG's program
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 61   -*- 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.56)
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(OPTIONAL_BIN_ZCRIPTS)
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   jm_CHECK_ALL_TYPES
42   jm_INCLUDED_REGEX([lib/regex.c])
43
44   AC_REQUIRE([UTILS_HOST_OS])
45   AC_REQUIRE([UTILS_FUNC_MKDIR_TRAILING_SLASH])
46   AC_REQUIRE([jm_BISON])
47   AC_REQUIRE([jm_ASSERT])
48   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
49   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
50   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
51   AC_REQUIRE([jm_CHECK_DECLS])
52
53   AC_REQUIRE([jm_PREREQ])
54
55   AC_REQUIRE([UTILS_FUNC_DIRFD])
56   AC_REQUIRE([AC_FUNC_ACL])
57   AC_REQUIRE([AC_FUNC_FTW])
58   AC_REQUIRE([jm_FUNC_LCHOWN])
59   AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
60   AC_REQUIRE([jm_FUNC_CHOWN])
61   AC_REQUIRE([jm_FUNC_MKTIME])
62   AC_REQUIRE([jm_FUNC_LSTAT])
63   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
64   AC_REQUIRE([jm_FUNC_STAT])
65   AC_REQUIRE([AC_FUNC_REALLOC])
66   AC_REQUIRE([AC_FUNC_MALLOC])
67   AC_REQUIRE([AC_FUNC_STRERROR_R])
68   AC_REQUIRE([jm_FUNC_NANOSLEEP])
69   AC_REQUIRE([jm_FUNC_MEMCMP])
70   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
71   AC_REQUIRE([AC_FUNC_FNMATCH_GNU])
72   AC_REQUIRE([jm_FUNC_GROUP_MEMBER])
73   AC_REQUIRE([jm_FUNC_PUTENV])
74   AC_REQUIRE([jm_AFS])
75   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
76   AC_REQUIRE([jm_AC_PREREQ_XSTRTOIMAX])
77   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
78   AC_REQUIRE([AC_FUNC_ERROR_AT_LINE])
79   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
80   AC_REQUIRE([jm_FUNC_MKTIME])
81   AC_REQUIRE([jm_FUNC_FPENDING])
82
83   # This is for od and stat, and any other program that
84   # uses the PRI.MAX macros from inttypes.h.
85   AC_REQUIRE([gt_INTTYPES_PRI])
86
87   AC_REQUIRE([jm_FUNC_GETGROUPS])
88
89   AC_REQUIRE([AC_FUNC_FSEEKO])
90   AC_REQUIRE([AC_FUNC_VPRINTF])
91   AC_REQUIRE([AC_FUNC_ALLOCA])
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
151   AC_CHECK_FUNCS( \
152     bcopy \
153     endgrent \
154     endpwent \
155     fchdir \
156     fdatasync \
157     ftime \
158     ftruncate \
159     getcwd \
160     gethrtime \
161     getmntinfo \
162     hasmntopt \
163     isascii \
164     iswspace \
165     lchown \
166     listmntent \
167     localeconv \
168     memcpy \
169     mempcpy \
170     mkfifo \
171     realpath \
172     sethostname \
173     strchr \
174     strerror \
175     strrchr \
176     sysctl \
177     sysinfo \
178     wcrtomb \
179     tzset \
180   )
181
182   # for test.c
183   AC_CHECK_FUNCS(setreuid setregid)
184
185   AM_FUNC_GETLINE
186   if test $am_cv_func_working_getline != yes; then
187     AC_CHECK_FUNCS(getdelim)
188   fi
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
195   # See if linking `seq' requires -lm.
196   # It does on nearly every system.  The single exception (so far) is
197   # BeOS which has all the math functions in the normal runtime library
198   # and doesn't have a separate math library.
199
200   AC_SUBST(SEQ_LIBM)
201   ac_seq_body='
202      static double x, y;
203      x = floor (x);
204      x = rint (x);
205      x = modf (x, &y);'
206   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
207     [ac_seq_save_LIBS="$LIBS"
208      LIBS="$LIBS -lm"
209      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
210      LIBS="$ac_seq_save_LIBS"
211     ])
212
213   AM_LANGINFO_CODESET
214   jm_GLIBC21
215   AM_ICONV
216   jm_FUNC_UNLINK_BUSY_TEXT
217
218   # These tests are for df.
219   jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
220   jm_FSTYPENAME
221   jm_FILE_SYSTEM_USAGE([space=yes], [space=no])
222   if test $list_mounted_fs = yes && test $space = yes; then
223     DF_PROG='df$(EXEEXT)'
224     AC_LIBOBJ(fsusage)
225     AC_LIBOBJ(mountlist)
226   fi
227   AC_REQUIRE([jm_AC_DOS])
228   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
229
230   # If any of these functions don't exist (e.g. DJGPP 2.03),
231   # use the corresponding stub.
232   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
233   AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])
234   AC_CHECK_FUNC([lstat], , [AC_LIBOBJ(lstat-stub)])
235   AC_CHECK_FUNC([readlink], , [AC_LIBOBJ(readlink-stub)])
236
237 ])
238
239 # These tests must be run before any use of AC_CHECK_TYPE,
240 # because that macro compiles code that tests e.g., HAVE_UNISTD_H.
241 # See the definition of ac_includes_default in `configure'.
242 AC_DEFUN([jm_CHECK_ALL_HEADERS],
243 [
244   AC_CHECK_HEADERS( \
245     errno.h  \
246     fcntl.h \
247     float.h \
248     hurd.h \
249     limits.h \
250     memory.h \
251     mntent.h \
252     mnttab.h \
253     netdb.h \
254     paths.h \
255     stdlib.h \
256     stddef.h \
257     stdint.h \
258     string.h \
259     sys/filsys.h \
260     sys/fs/s5param.h \
261     sys/fs_types.h \
262     sys/fstyp.h \
263     sys/ioctl.h \
264     sys/mntent.h \
265     sys/mount.h \
266     sys/param.h \
267     sys/resource.h \
268     sys/socket.h \
269     sys/statfs.h \
270     sys/statvfs.h \
271     sys/sysctl.h \
272     sys/systeminfo.h \
273     sys/time.h \
274     sys/timeb.h \
275     sys/vfs.h \
276     sys/wait.h \
277     syslog.h \
278     termios.h \
279     unistd.h \
280     utime.h \
281     values.h \
282   )
283 ])
284
285 # This macro must be invoked before any tests that run the compiler.
286 AC_DEFUN([jm_CHECK_ALL_TYPES],
287 [
288   dnl This test must come as early as possible after the compiler configuration
289   dnl tests, because the choice of the file model can (in principle) affect
290   dnl whether functions and headers are available, whether they work, etc.
291   AC_REQUIRE([AC_SYS_LARGEFILE])
292
293   dnl This test must precede tests of compiler characteristics like
294   dnl that for the inline keyword, since it may change the degree to
295   dnl which the compiler supports such features.
296   AC_REQUIRE([AM_C_PROTOTYPES])
297
298   dnl Checks for typedefs, structures, and compiler characteristics.
299   AC_REQUIRE([AC_C_BIGENDIAN])
300   AC_REQUIRE([AC_C_CONST])
301   AC_REQUIRE([AC_C_VOLATILE])
302   AC_REQUIRE([AC_C_INLINE])
303   AC_REQUIRE([AC_C_LONG_DOUBLE])
304
305   AC_REQUIRE([jm_CHECK_ALL_HEADERS])
306   AC_REQUIRE([AC_HEADER_DIRENT])
307   AC_REQUIRE([AC_HEADER_STDC])
308   AC_CHECK_MEMBERS(
309     [struct stat.st_author,
310      struct stat.st_blksize],,,
311     [$ac_includes_default
312 #include <sys/stat.h>
313   ])
314   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
315
316   AC_REQUIRE([AC_STRUCT_TM])
317   AC_REQUIRE([AC_STRUCT_TIMEZONE])
318   AC_REQUIRE([AC_HEADER_STAT])
319   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
320   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
321   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
322
323   AC_REQUIRE([AC_TYPE_GETGROUPS])
324   AC_REQUIRE([AC_TYPE_MODE_T])
325   AC_REQUIRE([AC_TYPE_OFF_T])
326   AC_REQUIRE([AC_TYPE_PID_T])
327   AC_REQUIRE([AC_TYPE_SIGNAL])
328   AC_REQUIRE([AC_TYPE_SIZE_T])
329   AC_REQUIRE([AC_TYPE_UID_T])
330   AC_CHECK_TYPE(ino_t, unsigned long)
331
332   dnl This relies on the fact that autoconf 2.14a's implementation of
333   dnl AC_CHECK_TYPE checks includes unistd.h.
334   AC_CHECK_TYPE(ssize_t, int)
335   AC_CHECK_TYPE(major_t, unsigned int)
336   AC_CHECK_TYPE(minor_t, unsigned int)
337
338   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
339   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
340
341   AC_REQUIRE([AC_HEADER_MAJOR])
342   AC_REQUIRE([AC_HEADER_DIRENT])
343
344 ])