* Makefile.am (EXTRA_DIST): Remove these files here, too:
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 103   -*- autoconf -*-
2
3 dnl Misc type-related macros for coreutils.
4
5 # Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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   gl_INIT
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_CHECK_DECLS])
44
45   AC_REQUIRE([gl_PREREQ])
46
47   AC_REQUIRE([AC_FUNC_FSEEKO])
48
49   AC_CONFIG_LIBOBJ_DIR([lib])
50
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.])
56
57   dnl Used to define SETVBUF in ../src/system.h.
58   AC_FUNC_SETVBUF_REVERSED
59
60   # used by ls
61   AC_REQUIRE([gl_CLOCK_TIME])
62   # used by shred
63   AC_CHECK_FUNCS_ONCE(directio)
64
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   )
81
82   AC_REQUIRE([cu_PREREQ_STAT_PROG])
83
84   # for dd.c and shred.c
85   coreutils_saved_libs=$LIBS
86     AC_SEARCH_LIBS([fdatasync], [rt posix4],
87                    [test "$ac_cv_search_fdatasync" = "none required" ||
88                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
89     AC_SUBST([LIB_FDATASYNC])
90     AC_CHECK_FUNCS(fdatasync)
91   LIBS=$coreutils_saved_libs
92
93   # See if linking `seq' requires -lm.
94   # It does on nearly every system.  The single exception (so far) is
95   # BeOS which has all the math functions in the normal runtime library
96   # and doesn't have a separate math library.
97
98   AC_SUBST(SEQ_LIBM)
99   ac_seq_body='
100      static double x, y;
101      x = floor (x);
102      x = rint (x);
103      x = modf (x, &y);'
104   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
105     [ac_seq_save_LIBS="$LIBS"
106      LIBS="$LIBS -lm"
107      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
108      LIBS="$ac_seq_save_LIBS"
109     ])
110
111   AC_REQUIRE([AM_LANGINFO_CODESET])
112
113   # Build df only if there's a point to it.
114   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
115     DF_PROG='df$(EXEEXT)'
116   fi
117
118   # If any of these functions don't exist (e.g. DJGPP 2.03),
119   # use the corresponding stub.
120   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
121 ])
122
123 AC_DEFUN([gl_CHECK_ALL_HEADERS],
124 [
125   AC_CHECK_HEADERS_ONCE( \
126     hurd.h \
127     paths.h \
128     priv.h \
129     stropts.h \
130     sys/ioctl.h \
131     sys/param.h \
132     sys/resource.h \
133     sys/systeminfo.h \
134     sys/time.h \
135     sys/wait.h \
136     syslog.h \
137     termios.h \
138   )
139   AC_CHECK_HEADERS(sys/sysctl.h, [], [],
140     [AC_INCLUDES_DEFAULT
141      [#if HAVE_SYS_PARAM_H
142        #include <sys/param.h>
143       #endif]])
144 ])
145
146 # This macro must be invoked before any tests that run the compiler.
147 AC_DEFUN([gl_CHECK_ALL_TYPES],
148 [
149   dnl This test must come as early as possible after the compiler configuration
150   dnl tests, because the choice of the file model can (in principle) affect
151   dnl whether functions and headers are available, whether they work, etc.
152   AC_REQUIRE([AC_SYS_LARGEFILE])
153
154   dnl This test must precede tests of compiler characteristics like
155   dnl that for the inline keyword, since it may change the degree to
156   dnl which the compiler supports such features.
157   AC_REQUIRE([AM_C_PROTOTYPES])
158
159   dnl Checks for typedefs, structures, and compiler characteristics.
160   AC_REQUIRE([AC_C_BIGENDIAN])
161   AC_REQUIRE([AC_C_VOLATILE])
162   AC_REQUIRE([AC_C_INLINE])
163   AC_REQUIRE([AC_C_LONG_DOUBLE])
164   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
165
166   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
167   AC_CHECK_MEMBERS(
168     [struct stat.st_author],,,
169     [$ac_includes_default
170 #include <sys/stat.h>
171   ])
172   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
173
174   AC_REQUIRE([AC_TYPE_GETGROUPS])
175   AC_REQUIRE([AC_TYPE_MBSTATE_T])
176   AC_REQUIRE([AC_TYPE_MODE_T])
177   AC_REQUIRE([AC_TYPE_OFF_T])
178   AC_REQUIRE([AC_TYPE_PID_T])
179   AC_REQUIRE([AC_TYPE_SIZE_T])
180   AC_REQUIRE([AC_TYPE_UID_T])
181   AC_CHECK_TYPE(ino_t, unsigned long int)
182
183   dnl This relies on the fact that Autoconf's implementation of
184   dnl AC_CHECK_TYPE checks includes unistd.h.
185   AC_CHECK_TYPE(major_t, unsigned int)
186   AC_CHECK_TYPE(minor_t, unsigned int)
187
188   AC_REQUIRE([AC_HEADER_MAJOR])
189 ])