Fix bug reported today by Mike Frysinger: mkdir -pv is logging the
[coreutils/bo.git] / m4 / jm-macros.m4
blobe0188e66b4d13590889477d998bce24ad14e4ccb
1 #serial 103   -*- autoconf -*-
3 dnl Misc type-related macros for coreutils.
5 # Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
6 # Foundation, Inc.
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.
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.
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.
22 # Written by Jim Meyering.
24 AC_DEFUN([gl_MACROS],
26   gl_INIT
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)
33   AM_MISSING_PROG(HELP2MAN, help2man)
34   AC_SUBST(OPTIONAL_BIN_PROGS)
35   AC_SUBST(MAN)
36   AC_SUBST(DF_PROG)
38   dnl This macro actually runs replacement code.  See isc-posix.m4.
39   AC_REQUIRE([AC_ISC_POSIX])dnl
41   gl_CHECK_ALL_TYPES
43   AC_REQUIRE([gl_CHECK_DECLS])
45   AC_REQUIRE([gl_PREREQ])
47   AC_REQUIRE([AC_FUNC_FSEEKO])
49   AC_CONFIG_LIBOBJ_DIR([lib])
51   # By default, argmatch should fail calling usage (1).
52   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
53             [Define to the function xargmatch calls on failures.])
54   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
55             [Define to the declaration of the xargmatch failure function.])
57   dnl Used to define SETVBUF in ../src/system.h.
58   AC_FUNC_SETVBUF_REVERSED
60   # used by ls
61   AC_REQUIRE([gl_CLOCK_TIME])
62   # used by shred
63   AC_CHECK_FUNCS_ONCE(directio)
65   AC_CHECK_FUNCS_ONCE( \
66     endgrent \
67     endpwent \
68     fchown \
69     ftruncate \
70     iswspace \
71     mkfifo \
72     mbrlen \
73     setgroups \
74     sethostname \
75     siginterrupt \
76     sync \
77     sysctl \
78     sysinfo \
79     tcgetpgrp \
80   )
82   dnl This can't use AC_REQUIRE; I'm not quite sure why.
83   cu_PREREQ_STAT_PROG
85   # for dd.c and shred.c
86   coreutils_saved_libs=$LIBS
87     AC_SEARCH_LIBS([fdatasync], [rt posix4],
88                    [test "$ac_cv_search_fdatasync" = "none required" ||
89                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
90     AC_SUBST([LIB_FDATASYNC])
91     AC_CHECK_FUNCS(fdatasync)
92   LIBS=$coreutils_saved_libs
94   # See if linking `seq' requires -lm.
95   # It does on nearly every system.  The single exception (so far) is
96   # BeOS which has all the math functions in the normal runtime library
97   # and doesn't have a separate math library.
99   AC_SUBST(SEQ_LIBM)
100   ac_seq_body='
101      static double x, y;
102      x = floor (x);
103      x = rint (x);
104      x = modf (x, &y);'
105   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
106     [ac_seq_save_LIBS="$LIBS"
107      LIBS="$LIBS -lm"
108      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
109      LIBS="$ac_seq_save_LIBS"
110     ])
112   AC_REQUIRE([AM_LANGINFO_CODESET])
114   # Build df only if there's a point to it.
115   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
116     DF_PROG='df$(EXEEXT)'
117   fi
119   # If any of these functions don't exist (e.g. DJGPP 2.03),
120   # use the corresponding stub.
121   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
124 AC_DEFUN([gl_CHECK_ALL_HEADERS],
126   AC_CHECK_HEADERS_ONCE( \
127     hurd.h \
128     paths.h \
129     priv.h \
130     stropts.h \
131     sys/ioctl.h \
132     sys/param.h \
133     sys/resource.h \
134     sys/systeminfo.h \
135     sys/time.h \
136     sys/wait.h \
137     syslog.h \
138     termios.h \
139   )
140   AC_CHECK_HEADERS(sys/sysctl.h, [], [],
141     [AC_INCLUDES_DEFAULT
142      [#if HAVE_SYS_PARAM_H
143        #include <sys/param.h>
144       #endif]])
147 # This macro must be invoked before any tests that run the compiler.
148 AC_DEFUN([gl_CHECK_ALL_TYPES],
150   dnl This test must come as early as possible after the compiler configuration
151   dnl tests, because the choice of the file model can (in principle) affect
152   dnl whether functions and headers are available, whether they work, etc.
153   AC_REQUIRE([AC_SYS_LARGEFILE])
155   dnl This test must precede tests of compiler characteristics like
156   dnl that for the inline keyword, since it may change the degree to
157   dnl which the compiler supports such features.
158   AC_REQUIRE([AM_C_PROTOTYPES])
160   dnl Checks for typedefs, structures, and compiler characteristics.
161   AC_REQUIRE([AC_C_BIGENDIAN])
162   AC_REQUIRE([AC_C_VOLATILE])
163   AC_REQUIRE([AC_C_INLINE])
164   AC_REQUIRE([AC_C_LONG_DOUBLE])
165   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
167   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
168   AC_CHECK_MEMBERS(
169     [struct stat.st_author],,,
170     [$ac_includes_default
171 #include <sys/stat.h>
172   ])
173   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
175   AC_REQUIRE([AC_TYPE_GETGROUPS])
176   AC_REQUIRE([AC_TYPE_MBSTATE_T])
177   AC_REQUIRE([AC_TYPE_MODE_T])
178   AC_REQUIRE([AC_TYPE_OFF_T])
179   AC_REQUIRE([AC_TYPE_PID_T])
180   AC_REQUIRE([AC_TYPE_SIZE_T])
181   AC_REQUIRE([AC_TYPE_UID_T])
182   AC_CHECK_TYPE(ino_t, unsigned long int)
184   dnl This relies on the fact that Autoconf's implementation of
185   dnl AC_CHECK_TYPE checks includes unistd.h.
186   AC_CHECK_TYPE(major_t, unsigned int)
187   AC_CHECK_TYPE(minor_t, unsigned int)
189   AC_REQUIRE([AC_HEADER_MAJOR])