Enable gnulib-tool's --with-tests option.
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 106   -*- autoconf -*-
2
3 dnl Misc type-related macros for coreutils.
4
5 # Copyright (C) 1998, 2000-2007 Free Software Foundation, Inc.
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 # Written by Jim Meyering.
21
22 AC_DEFUN([coreutils_MACROS],
23 [
24   AM_MISSING_PROG(HELP2MAN, help2man)
25   AC_SUBST(MAN)
26
27   dnl This macro actually runs replacement code.  See isc-posix.m4.
28   AC_REQUIRE([AC_ISC_POSIX])dnl
29
30   gl_CHECK_ALL_TYPES
31
32   AC_REQUIRE([gl_CHECK_DECLS])
33
34   AC_REQUIRE([gl_PREREQ])
35
36   AC_REQUIRE([AC_FUNC_FSEEKO])
37
38   # By default, argmatch should fail calling usage (1).
39   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
40             [Define to the function xargmatch calls on failures.])
41   AC_DEFINE(ARGMATCH_DIE_DECL, [void usage ()],
42             [Define to the declaration of the xargmatch failure function.])
43
44   # used by ls
45   AC_REQUIRE([gl_CLOCK_TIME])
46   # used by shred
47   AC_CHECK_FUNCS_ONCE(directio)
48
49   AC_CHECK_FUNCS_ONCE( \
50     endgrent \
51     endpwent \
52     fchown \
53     fchmod \
54     ftruncate \
55     iswspace \
56     mkfifo \
57     mbrlen \
58     setgroups \
59     sethostname \
60     siginterrupt \
61     sync \
62     sysctl \
63     sysinfo \
64     tcgetpgrp \
65   )
66
67   dnl This can't use AC_REQUIRE; I'm not quite sure why.
68   cu_PREREQ_STAT_PROG
69
70   # for dd.c and shred.c
71   coreutils_saved_libs=$LIBS
72     AC_SEARCH_LIBS([fdatasync], [rt posix4],
73                    [test "$ac_cv_search_fdatasync" = "none required" ||
74                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
75     AC_SUBST([LIB_FDATASYNC])
76     AC_CHECK_FUNCS(fdatasync)
77   LIBS=$coreutils_saved_libs
78
79   # See if linking `seq' requires -lm.
80   # It does on nearly every system.  The single exception (so far) is
81   # BeOS which has all the math functions in the normal runtime library
82   # and doesn't have a separate math library.
83
84   AC_SUBST(SEQ_LIBM)
85   ac_seq_body='
86      static double x, y;
87      x = floor (x);
88      x = rint (x);
89      x = modf (x, &y);'
90   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
91     [ac_seq_save_LIBS="$LIBS"
92      LIBS="$LIBS -lm"
93      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
94      LIBS="$ac_seq_save_LIBS"
95     ])
96
97   AC_REQUIRE([AM_LANGINFO_CODESET])
98 ])
99
100 AC_DEFUN([gl_CHECK_ALL_HEADERS],
101 [
102   AC_CHECK_HEADERS_ONCE( \
103     hurd.h \
104     paths.h \
105     priv.h \
106     stropts.h \
107     sys/ioctl.h \
108     sys/param.h \
109     sys/resource.h \
110     sys/systeminfo.h \
111     sys/time.h \
112     sys/wait.h \
113     syslog.h \
114     termios.h \
115   )
116   AC_CHECK_HEADERS(sys/sysctl.h, [], [],
117     [AC_INCLUDES_DEFAULT
118      [#if HAVE_SYS_PARAM_H
119        #include <sys/param.h>
120       #endif]])
121 ])
122
123 # This macro must be invoked before any tests that run the compiler.
124 AC_DEFUN([gl_CHECK_ALL_TYPES],
125 [
126   dnl This test must come as early as possible after the compiler configuration
127   dnl tests, because the choice of the file model can (in principle) affect
128   dnl whether functions and headers are available, whether they work, etc.
129   AC_REQUIRE([AC_SYS_LARGEFILE])
130
131   dnl This test must precede tests of compiler characteristics like
132   dnl that for the inline keyword, since it may change the degree to
133   dnl which the compiler supports such features.
134   AC_REQUIRE([AM_C_PROTOTYPES])
135
136   dnl Checks for typedefs, structures, and compiler characteristics.
137   AC_REQUIRE([AC_C_BIGENDIAN])
138   AC_REQUIRE([AC_C_VOLATILE])
139   AC_REQUIRE([AC_C_INLINE])
140   AC_REQUIRE([AC_C_LONG_DOUBLE])
141   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
142
143   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
144   AC_CHECK_MEMBERS(
145     [struct stat.st_author],,,
146     [$ac_includes_default
147 #include <sys/stat.h>
148   ])
149   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
150
151   AC_REQUIRE([AC_TYPE_GETGROUPS])
152   AC_REQUIRE([AC_TYPE_MBSTATE_T])
153   AC_REQUIRE([AC_TYPE_MODE_T])
154   AC_REQUIRE([AC_TYPE_OFF_T])
155   AC_REQUIRE([AC_TYPE_PID_T])
156   AC_REQUIRE([AC_TYPE_SIZE_T])
157   AC_REQUIRE([AC_TYPE_UID_T])
158   AC_CHECK_TYPE(ino_t, unsigned long int)
159
160   dnl This relies on the fact that Autoconf's implementation of
161   dnl AC_CHECK_TYPE checks includes unistd.h.
162   AC_CHECK_TYPE(major_t, unsigned int)
163   AC_CHECK_TYPE(minor_t, unsigned int)
164
165   AC_REQUIRE([AC_HEADER_MAJOR])
166 ])