maint: omit some unused function tests
[coreutils.git] / m4 / jm-macros.m4
blob350964f0e240626ee2604222a127cf934eac581b
1 #serial 115   -*- autoconf -*-
3 dnl Misc type-related macros for coreutils.
5 # Copyright (C) 1998-2023 Free Software Foundation, Inc.
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.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 # Written by Jim Meyering.
22 AC_DEFUN([coreutils_MACROS],
24   AM_MISSING_PROG(HELP2MAN, help2man)
25   AC_SUBST([MAN])
27   gl_CHECK_ALL_TYPES
29   AC_REQUIRE([gl_CHECK_DECLS])
31   AC_REQUIRE([gl_PREREQ])
33   AC_REQUIRE([AC_FUNC_FSEEKO])
35   # By default, argmatch should fail calling usage (EXIT_FAILURE).
36   AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
37             [Define to the function xargmatch calls on failures.])
38   AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
39             [Define to the declaration of the xargmatch failure function.])
41   # Ensure VLAs are not used.
42   # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
43   AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
45   # used by shred
46   AC_CHECK_FUNCS_ONCE([directio])
48   coreutils_saved_libs=$LIBS
49     LIBS="$LIBS $LIB_SELINUX"
50     # Used by selinux.c.
51     AC_CHECK_FUNCS([mode_to_security_class], [], [])
52   LIBS=$coreutils_saved_libs
54   # Used by sort.c.
55   AC_CHECK_FUNCS_ONCE([nl_langinfo])
56   # Used by timeout.c
57   AC_CHECK_FUNCS_ONCE([setitimer setrlimit prctl])
59   # Used by tail.c.
60   AC_CHECK_FUNCS([inotify_init],
61     [AC_DEFINE([HAVE_INOTIFY], [1],
62      [Define to 1 if you have usable inotify support.])])
64   AC_CHECK_FUNCS_ONCE([
65     endgrent
66     endpwent
67     fallocate
68     fchown
69     fchmod
70     setgroups
71     sethostname
72     siginterrupt
73     sync
74     syncfs
75     sysinfo
76     tcgetpgrp
77   ])
79   # These checks are for Interix, to avoid its getgr* functions, in favor
80   # of these replacements.  The replacement functions are much more efficient
81   # because they do not query the domain controller for user information
82   # when it is not needed.
83   AC_CHECK_FUNCS_ONCE([
84     getgrgid_nomembers
85     getgrnam_nomembers
86     getgrent_nomembers
87   ])
89   dnl This can't use AC_REQUIRE; I'm not quite sure why.
90   cu_PREREQ_STAT_PROG
92   # Check whether libcap is usable -- for ls --color support
93   LIB_CAP=
94   AC_ARG_ENABLE([libcap],
95     AS_HELP_STRING([--disable-libcap], [disable libcap support]))
96   if test "X$enable_libcap" != "Xno"; then
97     AC_CHECK_LIB([cap], [cap_get_file],
98       [AC_CHECK_HEADER([sys/capability.h],
99         [LIB_CAP=-lcap
100          AC_DEFINE([HAVE_CAP], [1], [libcap usability])]
101       )])
102     if test "X$LIB_CAP" = "X"; then
103       if test "X$enable_libcap" = "Xyes"; then
104         AC_MSG_ERROR([libcap library was not found or not usable])
105       else
106         AC_MSG_WARN([libcap library was not found or not usable.])
107         AC_MSG_WARN([AC_PACKAGE_NAME will be built without capability support.])
108       fi
109     fi
110   else
111     AC_MSG_WARN([libcap support disabled by user])
112   fi
113   AC_SUBST([LIB_CAP])
115   # See if linking 'seq' requires -lm.
116   # It does on nearly every system.  The single exception (so far) is
117   # BeOS which has all the math functions in the normal runtime library
118   # and doesn't have a separate math library.
120   AC_SUBST([SEQ_LIBM])
121   jm_break=:
122   for jm_seqlibs in '' '-lm'; do
123     jm_seq_save_LIBS=$LIBS
124     AC_LINK_IFELSE(
125       [AC_LANG_PROGRAM(
126          [[#include <math.h>
127          ]],
128          [[static double x, y;
129            x = floor (x);
130            x = rint (x);
131            x = modf (x, &y);]])],
132       [SEQ_LIBM=$jm_seqlibs
133        jm_break=break])
134     LIBS=$jm_seq_save_LIBS
135     $jm_break
136   done
138   # See is fpsetprec() required to use extended double precision
139   # This is needed on 32 bit FreeBSD to give accurate conversion of:
140   # `numfmt 9223372036854775808`
141   AC_LINK_IFELSE(
142     [AC_LANG_PROGRAM(
143        [[#include <ieeefp.h>
144        ]],
145        [[#ifdef __i386__
146           fpsetprec (FP_PE);
147          #else
148          # error not required on 64 bit
149          #endif
150        ]])],
151     [ac_have_fpsetprec=yes],
152     [ac_have_fpsetprec=no])
153   if test "$ac_have_fpsetprec" = "yes" ; then
154     AC_DEFINE([HAVE_FPSETPREC], 1, [whether fpsetprec is present and required])
155   fi
157   AC_REQUIRE([AM_LANGINFO_CODESET])
159   # Accept configure options: --with-tty-group[=GROUP], --without-tty-group
160   # You can determine the group of a TTY via 'stat --format %G /dev/tty'
161   # Omitting this option is equivalent to using --without-tty-group.
162   AC_ARG_WITH([tty-group],
163     AS_HELP_STRING([--with-tty-group[[[=NAME]]]],
164       [group used by system for TTYs, "tty" when not specified]
165       [ (default: do not rely on any group used for TTYs)]),
166     [tty_group_name=$withval],
167     [tty_group_name=no])
169   if test "x$tty_group_name" != xno; then
170     if test "x$tty_group_name" = xyes; then
171       tty_group_name=tty
172     fi
173     AC_MSG_NOTICE([TTY group used by system set to "$tty_group_name"])
174     AC_DEFINE_UNQUOTED([TTY_GROUP_NAME], ["$tty_group_name"],
175       [group used by system for TTYs])
176   fi
179 AC_DEFUN([gl_CHECK_ALL_HEADERS],
181   AC_CHECK_HEADERS_ONCE([
182     hurd.h
183     linux/falloc.h
184     linux/fs.h
185     paths.h
186     priv.h
187     stropts.h
188     sys/mtio.h
189     sys/param.h
190     sys/systeminfo.h
191     syslog.h
192   ])
193   AC_CHECK_HEADERS([sys/sysctl.h], [], [],
194     [AC_INCLUDES_DEFAULT
195      [#if HAVE_SYS_PARAM_H
196        #include <sys/param.h>
197       #endif]])
200 # This macro must be invoked before any tests that run the compiler.
201 AC_DEFUN([gl_CHECK_ALL_TYPES],
203   dnl Checks for typedefs, structures, and compiler characteristics.
204   AC_REQUIRE([gl_BIGENDIAN])
205   AC_REQUIRE([AC_C_VOLATILE])
206   AC_REQUIRE([AC_C_INLINE])
207   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
209   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
210   AC_CHECK_MEMBERS(
211     [struct stat.st_author],,,
212     [$ac_includes_default
213 #include <sys/stat.h>
214   ])
215   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
217   AC_REQUIRE([AC_TYPE_GETGROUPS])
218   AC_REQUIRE([AC_TYPE_MBSTATE_T])
219   AC_REQUIRE([AC_TYPE_MODE_T])
220   AC_REQUIRE([AC_TYPE_OFF_T])
221   AC_REQUIRE([AC_TYPE_PID_T])
222   AC_REQUIRE([AC_TYPE_SIZE_T])
223   AC_REQUIRE([AC_TYPE_UID_T])
224   AC_CHECK_TYPE([ino_t], [unsigned long int])
226   dnl This relies on the fact that Autoconf's implementation of
227   dnl AC_CHECK_TYPE checks includes unistd.h.
228   AC_CHECK_TYPE([major_t], [unsigned int])
229   AC_CHECK_TYPE([minor_t], [unsigned int])
231   AC_REQUIRE([AC_HEADER_MAJOR])