tests: avoid FP failure due to suspension
[platform/upstream/coreutils.git] / m4 / jm-macros.m4
1 #serial 110   -*- autoconf -*-
2
3 dnl Misc type-related macros for coreutils.
4
5 # Copyright (C) 1998, 2000-2011 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 (EXIT_FAILURE).
39   AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
40             [Define to the function xargmatch calls on failures.])
41   AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
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   # Used by install.c.
50   coreutils_saved_libs=$LIBS
51     LIBS="$LIBS $LIB_SELINUX"
52     AC_CHECK_FUNCS([matchpathcon_init_prefix], [],
53     [
54       case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
55         no:*) # SELinux disabled
56           ;;
57         *:no) # SELinux disabled
58           ;;
59         *)
60         AC_MSG_WARN([SELinux enabled, but matchpathcon_init_prefix not found])
61         AC_MSG_WARN([The install utility may run slowly])
62       esac
63     ])
64   LIBS=$coreutils_saved_libs
65
66   # Used by sort.c.
67   AC_CHECK_FUNCS_ONCE([nl_langinfo])
68
69   # Used by tail.c.
70   AC_CHECK_FUNCS([inotify_init],
71     [AC_DEFINE([HAVE_INOTIFY], [1],
72      [Define to 1 if you have usable inotify support.])])
73
74   AC_CHECK_FUNCS_ONCE( \
75     endgrent \
76     endpwent \
77     fchown \
78     fchmod \
79     ftruncate \
80     iswspace \
81     mkfifo \
82     mbrlen \
83     setgroups \
84     sethostname \
85     siginterrupt \
86     sync \
87     sysctl \
88     sysinfo \
89     tcgetpgrp \
90   )
91
92   dnl This can't use AC_REQUIRE; I'm not quite sure why.
93   cu_PREREQ_STAT_PROG
94
95   # for dd.c and shred.c
96   coreutils_saved_libs=$LIBS
97     LIB_FDATASYNC=
98     AC_SEARCH_LIBS([fdatasync], [rt posix4],
99                    [test "$ac_cv_search_fdatasync" = "none required" ||
100                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
101     AC_SUBST([LIB_FDATASYNC])
102     AC_CHECK_FUNCS([fdatasync])
103   LIBS=$coreutils_saved_libs
104
105   # Check whether libcap is usable -- for ls --color support
106   LIB_CAP=
107   AC_ARG_ENABLE([libcap],
108     AC_HELP_STRING([--disable-libcap], [disable libcap support]))
109   if test "X$enable_libcap" != "Xno"; then
110     AC_CHECK_LIB([cap], [cap_get_file],
111       [AC_CHECK_HEADER([sys/capability.h],
112         [LIB_CAP=-lcap
113          AC_DEFINE([HAVE_CAP], [1], [libcap usability])]
114       )])
115     if test "X$LIB_CAP" = "X"; then
116       if test "X$enable_libcap" = "Xyes"; then
117         AC_MSG_ERROR([libcap library was not found or not usable])
118       else
119         AC_MSG_WARN([libcap library was not found or not usable.])
120         AC_MSG_WARN([AC_PACKAGE_NAME will be built without capability support.])
121       fi
122     fi
123   else
124     AC_MSG_WARN([libcap support disabled by user])
125   fi
126   AC_SUBST([LIB_CAP])
127
128   # See if linking `seq' requires -lm.
129   # It does on nearly every system.  The single exception (so far) is
130   # BeOS which has all the math functions in the normal runtime library
131   # and doesn't have a separate math library.
132
133   AC_SUBST([SEQ_LIBM])
134   ac_seq_body='
135      static double x, y;
136      x = floor (x);
137      x = rint (x);
138      x = modf (x, &y);'
139   AC_TRY_LINK([#include <math.h>], [$ac_seq_body], ,
140     [ac_seq_save_LIBS="$LIBS"
141      LIBS="$LIBS -lm"
142      AC_TRY_LINK([#include <math.h>], [$ac_seq_body], [SEQ_LIBM=-lm])
143      LIBS="$ac_seq_save_LIBS"
144     ])
145
146   AC_REQUIRE([AM_LANGINFO_CODESET])
147
148   # Accept configure options: --with-tty-group[=GROUP], --without-tty-group
149   # You can determine the group of a TTY via 'stat --format %G /dev/tty'
150   # Omitting this option is equivalent to using --without-tty-group.
151   AC_ARG_WITH([tty-group],
152     AS_HELP_STRING([--with-tty-group[[[=NAME]]]],
153       [group used by system for TTYs, "tty" when not specified]
154       [ (default: do not rely on any group used for TTYs)]),
155     [tty_group_name=$withval],
156     [tty_group_name=no])
157
158   if test "x$tty_group_name" != xno; then
159     if test "x$tty_group_name" = xyes; then
160       tty_group_name=tty
161     fi
162     AC_MSG_NOTICE([TTY group used by system set to "$tty_group_name"])
163     AC_DEFINE_UNQUOTED([TTY_GROUP_NAME], ["$tty_group_name"],
164       [group used by system for TTYs])
165   fi
166 ])
167
168 AC_DEFUN([gl_CHECK_ALL_HEADERS],
169 [
170   AC_CHECK_HEADERS_ONCE( \
171     hurd.h \
172     paths.h \
173     priv.h \
174     stropts.h \
175     sys/param.h \
176     sys/resource.h \
177     sys/systeminfo.h \
178     syslog.h \
179   )
180   AC_CHECK_HEADERS([sys/sysctl.h], [], [],
181     [AC_INCLUDES_DEFAULT
182      [#if HAVE_SYS_PARAM_H
183        #include <sys/param.h>
184       #endif]])
185 ])
186
187 # This macro must be invoked before any tests that run the compiler.
188 AC_DEFUN([gl_CHECK_ALL_TYPES],
189 [
190   dnl This test must precede tests of compiler characteristics like
191   dnl that for the inline keyword, since it may change the degree to
192   dnl which the compiler supports such features.
193   AC_REQUIRE([AM_C_PROTOTYPES])
194
195   dnl Checks for typedefs, structures, and compiler characteristics.
196   AC_REQUIRE([gl_BIGENDIAN])
197   AC_REQUIRE([AC_C_VOLATILE])
198   AC_REQUIRE([AC_C_INLINE])
199   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
200
201   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
202   AC_CHECK_MEMBERS(
203     [struct stat.st_author],,,
204     [$ac_includes_default
205 #include <sys/stat.h>
206   ])
207   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
208
209   AC_REQUIRE([AC_TYPE_GETGROUPS])
210   AC_REQUIRE([AC_TYPE_MBSTATE_T])
211   AC_REQUIRE([AC_TYPE_MODE_T])
212   AC_REQUIRE([AC_TYPE_OFF_T])
213   AC_REQUIRE([AC_TYPE_PID_T])
214   AC_REQUIRE([AC_TYPE_SIZE_T])
215   AC_REQUIRE([AC_TYPE_UID_T])
216   AC_CHECK_TYPE([ino_t], [unsigned long int])
217
218   dnl This relies on the fact that Autoconf's implementation of
219   dnl AC_CHECK_TYPE checks includes unistd.h.
220   AC_CHECK_TYPE([major_t], [unsigned int])
221   AC_CHECK_TYPE([minor_t], [unsigned int])
222
223   AC_REQUIRE([AC_HEADER_MAJOR])
224 ])