maint: add lib/stdbit.h to .gitignore
[coreutils.git] / configure.ac
blobdb7664e7fe3b36c64df0333519d7fde3c114988c
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 dnl Written by Jim Meyering.
21 AC_PREREQ([2.69])
23 # Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
24 # indicates that it is built from the 219th delta (in _some_ repository)
25 # following the v6.9 tag, and that 58ddd is a prefix of the commit SHA1.
26 # The explicit URL can be removed when autoconf > 2.69 is released.
27 AC_INIT([GNU coreutils],
28         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
29         [bug-coreutils@gnu.org],
30         [coreutils],
31         [https://www.gnu.org/software/coreutils/])
33 AC_CONFIG_SRCDIR([src/ls.c])
35 AC_CONFIG_AUX_DIR([build-aux])
36 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
38 AM_INIT_AUTOMAKE([1.11.2 dist-xz color-tests parallel-tests subdir-objects])
39 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
41 dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
42 dnl (more than 10% execution time) to ./configure, with no benefit for
43 dnl most users.  Using it to look for bugs requires:
44 dnl   GNULIB_POSIXCHECK=1 autoreconf -f
45 dnl   ./configure
46 dnl   make
47 dnl   make -C src clean
48 dnl   make CFLAGS=-DGNULIB_POSIXCHECK=1
49 dnl FIXME: Once we figure out how to avoid false positives, we should
50 dnl have 'make my-distcheck' in dist-check.mk exercise this.
51 m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
52 m4_if(m4_sysval, [0], [], [dnl
53 gl_ASSERT_NO_GNULIB_POSIXCHECK])
55 AC_PROG_CC
56 AM_PROG_CC_C_O
57 AC_PROG_CPP
58 AC_PROG_RANLIB
59 AC_PROG_EGREP
60 AC_PROG_LN_S
61 gl_EARLY
62 gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
63 gl_INIT
64 coreutils_MACROS
66 # These are safe, since 'sort', coreutils's only multithreaded app,
67 # does not use the relevant modules.
68 AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
69   [Define to 1 if apps call 'exclude' functions from a single thread.])
70 AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
71   [Define to 1 if apps call 'regex' functions from a single thread.])
72 # Although 'sort' is multithreaded and can use these functions,
73 # it uses them only from the main thread.
74 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
75   [Define to 1 if apps call mbrtowc, mbrtoc32, and 'regex' functions
76    from a single thread.])
77 # This is safe, since all apps set locale early.
78 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
79   [Define to 1 if apps don't set the locale after calling
80    locale-sensitive functions like mbrtowc and wcwidth.])
82 AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
83   [Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
84    that glibc does not support.])
86 # The test suite needs to know if we have a working perl.
87 AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
89 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
90 # ------------------------------------------------
91 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
92 # Otherwise, run RUN-IF-NOT-FOUND.
93 AC_DEFUN([gl_GCC_VERSION_IFELSE],
94   [AC_PREPROC_IFELSE(
95     [AC_LANG_PROGRAM(
96       [[
97 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
98 /* ok */
99 #else
100 # error "your version of gcc is older than $1.$2"
101 #endif
102       ]]),
103     ], [$3], [$4])
104   ]
107 AC_ARG_ENABLE([single-binary],
108   [AS_HELP_STRING([--enable-single-binary=[shebangs|symlinks]],
109      [Compile all the tools in a single binary, reducing the overall size.
110       When compiled this way, shebangs (default when enabled) or symlinks are
111       installed for each tool that points to the single binary.])],
112   [gl_single_binary=no ;
113    case $enableval in
114      yes) gl_single_binary=shebangs ;;
115      no|shebangs|symlinks) gl_single_binary=$enableval ;;
116      *)      AC_MSG_ERROR([bad value $enableval for single-binary option.
117                            Options are: symlinks, shebangs, no.]) ;;
118    esac],
119   [gl_single_binary=no]
121 AC_ARG_ENABLE([single-binary-exceptions],
122   [AS_HELP_STRING([--enable-single-binary-exceptions=PROG_LIST],
123      [When used with --enable-single-binary, exclude the PROG_LIST from
124       it, so these programs are compiled as separated files
125       (comma-separated, default none))])],
126   [gl_single_binary_exceptions=$enableval],
127   [gl_single_binary_exceptions=]
129 if test "$gl_single_binary" = 'symlinks'; then
130   if ! test "`echo ls | sed \"$program_transform_name\"`" = 'ls'; then
131     AC_MSG_ERROR([program name transformations are not currently supported
132                   with --enable-single-binary=symlinks.])
133   fi
135 AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no])
137 AC_ARG_ENABLE([bold-man-page-references],
138   [AS_HELP_STRING([--disable-bold-man-page-references],
139      [When generating man pages, do not apply bold style around any
140       references like name(1) etc.])],
141   [gl_bold_manpages=yes ;
142    case $enableval in
143      no|yes) gl_bold_manpages=$enableval ;;
144      *)      AC_MSG_ERROR([bad value $enableval for bold-man-page-references.
145                            Options are: yes, no.]) ;;
146    esac],
147   [gl_bold_manpages=yes]
149 AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
151 AC_ARG_ENABLE([gcc-warnings],
152   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
153     [control generation of GCC warnings.  The TYPE 'no' disables
154      warnings (default for non-developer builds); 'yes' generates
155      cheap warnings if available (default for developer builds);
156      'expensive' in addition generates expensive-to-compute warnings
157      if available.])],
158   [case $enableval in
159      no|yes|expensive) ;;
160      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
161    esac
162    gl_gcc_warnings=$enableval],
163   [
164    # GCC provides fine-grained control over diagnostics which
165    # is used in gnulib for example to suppress warnings from
166    # certain sections of code.  So if this is available and
167    # we're running from a git repo, then auto enable the warnings.
168    gl_gcc_warnings=no
169    gl_GCC_VERSION_IFELSE([4], [6],
170                          [test -d "$srcdir"/.git \
171                           && ! test -f "$srcdir"/.tarball-version \
172                           && gl_gcc_warnings=yes])]
175 # clang is unduly picky about some things, even by default.
176 if test "$gl_cv_compiler_clang" = yes; then
177   gl_WARN_ADD([-Wno-format-extra-args])
178   gl_WARN_ADD([-Wno-implicit-const-int-float-conversion])
179   gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
182 if test $gl_gcc_warnings != no; then
183   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
184   AC_SUBST([WERROR_CFLAGS])
186   ew=
187   AS_IF([test $gl_gcc_warnings != expensive],
188     [# -fanalyzer and related options slow GCC considerably.
189      ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
191   # This, $nw, is the list of warnings we disable.
192   nw=$ew
193   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
194   nw="$nw -Waggregate-return"       # anachronistic
195   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
196   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
197   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
198   nw="$nw -Wtraditional"            # Warns on #elif which we use often
199   nw="$nw -Wcast-qual"              # Too many warnings for now
200   nw="$nw -Wconversion"             # Too many warnings for now
201   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
202   nw="$nw -Wsign-conversion"        # Too many warnings for now
203   nw="$nw -Wtraditional-conversion" # Too many warnings for now
204   nw="$nw -Wunreachable-code"       # Too many warnings for now
205   nw="$nw -Wpadded"                 # Our structs are not padded
206   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
207   nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
208   nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
209   nw="$nw -Wswitch-enum"            # Too many warnings for now
210   nw="$nw -Wswitch-default"         # Too many warnings for now
211   nw="$nw -Wstack-protector"        # not worth working around
212   nw="$nw -Wformat-overflow=2"      # False alarms due to GCC bug 110333
213   nw="$nw -Wformat-truncation=2"    # False alarm in ls.c, probably related
214   # things I might fix soon:
215   nw="$nw -Wfloat-equal"            # sort.c, seq.c
216   nw="$nw -Wmissing-format-attribute" # copy.c
217   nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
218   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
219   nw="$nw -Wvector-operation-performance" # warns about randperm.c
221   # Suppress noreturn warnings with single binaries; otherwise
222   # GCC complains about the renamed 'main' not being declared noreturn
223   # because 'main_exit' calls 'exit' when linting.
224   if test "$gl_single_binary" != no; then
225     nw="$nw -Wsuggest-attribute=noreturn"
226   fi
228   # Using -Wstrict-overflow is a pain, but the alternative is worse.
229   # For an example, see the code that provoked this report:
230   # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
231   # Code like that still infloops with gcc-4.6.0 and -O2.  Scary indeed.
233   gl_MANYWARN_ALL_GCC([ws])
234   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
235   for w in $ws; do
236     gl_WARN_ADD([$w])
237   done
238   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
239   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
240   gl_WARN_ADD([-Wno-format-nonliteral])
242   gl_WARN_ADD([-fdiagnostics-show-option])
243   gl_WARN_ADD([-funit-at-a-time])
245   AC_SUBST([WARN_CFLAGS])
247   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
248   AH_VERBATIM([FORTIFY_SOURCE],
249   [/* Enable compile-time and run-time bounds-checking, and some warnings,
250       without upsetting glibc 2.15+. */
251    #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
252    # define _FORTIFY_SOURCE 2
253    #endif
254   ])
255   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
257   # We use a slightly smaller set of warning options for lib/.
258   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
259   nw=$ew
260   nw="$nw -Wduplicated-branches"    # Too many false alarms
261   nw="$nw -Wformat-truncation=2"
262   nw="$nw -Wmissing-variable-declarations"
263   nw="$nw -Wstrict-overflow"
264   nw="$nw -Wuninitialized"
265   nw="$nw -Wunused-macros"
266   nw="$nw -Wmissing-prototypes"
267   nw="$nw -Wold-style-definition"
268   # FIXME: it may be easy to remove this, since it affects only one file:
269   # the snprintf call at ftoastr.c:132.
270   nw="$nw -Wdouble-promotion"
272   # FIXME: remove this line when gcc improves
273   # FP in careadlinkat.c w/gcc 10.0.1 20200205
274   gl_WARN_ADD([-Wno-return-local-addr])
276   # FIXME: remove this line when gcc improves
277   # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
278   gl_WARN_ADD([-Wno-stringop-overflow])
280   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
281   AC_SUBST([GNULIB_WARN_CFLAGS])
283   # For gnulib-tests, the set is slightly smaller still.
284   nw=
285   nw="$nw -Wstrict-prototypes"
286   # It's not worth being this picky about test programs.
287   nw="$nw -Wsuggest-attribute=cold"
288   nw="$nw -Wsuggest-attribute=const"
289   nw="$nw -Wsuggest-attribute=format"
290   nw="$nw -Wsuggest-attribute=pure"
291   gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
292                          [$GNULIB_WARN_CFLAGS], [$nw])
293   AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
296 AC_FUNC_FORK
298 optional_bin_progs=
299 AC_CHECK_FUNCS([chroot],
300         gl_ADD_PROG([optional_bin_progs], [chroot]))
301 AC_CHECK_FUNCS([gethostid],
302         gl_ADD_PROG([optional_bin_progs], [hostid]))
303 AC_CHECK_FUNCS([sigsuspend],
304         gl_ADD_PROG([optional_bin_progs], [timeout]))
306 gl_WINSIZE_IN_PTEM
308 AC_MSG_CHECKING([whether localtime caches TZ])
309 AC_CACHE_VAL([utils_cv_localtime_cache],
310 [if test x$ac_cv_func_tzset = xyes; then
311 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
312 #if STDC_HEADERS
313 # include <stdlib.h>
314 #endif
315 extern char **environ;
316 void unset_TZ (void)
318   char **from, **to;
319   for (to = from = environ; (*to = *from); from++)
320     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
321       to++;
324 main ()
326   time_t now = time ((time_t *) 0);
327   int hour_GMT0, hour_unset;
328   if (putenv ("TZ=GMT0") != 0)
329     return 1;
330   hour_GMT0 = localtime (&now)->tm_hour;
331   unset_TZ ();
332   hour_unset = localtime (&now)->tm_hour;
333   if (putenv ("TZ=PST8") != 0)
334     return 1;
335   if (localtime (&now)->tm_hour == hour_GMT0)
336     return 1;
337   unset_TZ ();
338   if (localtime (&now)->tm_hour != hour_unset)
339     return 1;
340   return 0;
341 }]])],
342 [utils_cv_localtime_cache=no],
343 [utils_cv_localtime_cache=yes],
344 [# If we have tzset, assume the worst when cross-compiling.
345 utils_cv_localtime_cache=yes])
346 else
347         # If we lack tzset, report that localtime does not cache TZ,
348         # since we can't invalidate the cache if we don't have tzset.
349         utils_cv_localtime_cache=no
350 fi])dnl
351 AC_MSG_RESULT([$utils_cv_localtime_cache])
352 if test $utils_cv_localtime_cache = yes; then
353   AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
356 # Find the library for dynamic loading of shared libraries.
357 AC_SEARCH_LIBS([dlopen], [dl])
358 AS_CASE([$ac_cv_search_dlopen],
359   [no | 'none required'],
360     [LIB_DL=],
361   [*],
362     [LIB_DL="$ac_cv_search_dlopen"])
363 AC_SUBST([LIB_DL])
365 # Should 'sort' link libcrypto dynamically?
366 AS_CASE([$LIB_CRYPTO],
367   [-lcrypto],
368     [# Check for dlopen and libcrypto dynamic linking in one program,
369      # as there's little point to checking them separately.
370      AC_CACHE_CHECK([for dlopen and whether libcrypto is linked dynamically],
371        [utils_cv_dlopen_libcrypto],
372        [utils_cv_dlopen_libcrypto=no
373         saved_LIBS=$LIBS
374         LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
375         AC_LINK_IFELSE(
376           [AC_LANG_PROGRAM(
377              [[#include <dlfcn.h>
378                #include <openssl/sha.h>
379                /* Use SHA512 rather than MD5 here to avoid deprecation warnings.
380                   So need to check HAVE_OPENSSL_MD5.. with DLOPEN_LIBCRYPTO. */
381              ]],
382              [[return !(dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL)
383                         && SHA512 (0, 0, 0));]])],
384           [# readelf works with cross-builds; ldd works on more platforms.
385            LIBCRYPTO_SONAME="`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
386                               ) 2>/dev/null |
387                               sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
388            AS_CASE([$LIBCRYPTO_SONAME],
389              [*libcrypto*],
390                [utils_cv_dlopen_libcrypto=yes])])
391         LIBS=$saved_LIBS])
392      AS_CASE([$utils_cv_dlopen_libcrypto],
393        [yes],
394          [AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
395                     [Define to 1 if dlopen exists and libcrypto is
396                      linked dynamically.])
397           AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
398                              [versioned libcrypto])
399          ])])
401 # macOS >= 10.12
402 AC_CHECK_FUNCS([fclonefileat])
404 # Assume that if getattrat exists, it's compatible with Solaris 11.
405 AC_CHECK_FUNCS([getattrat])
406 if test $ac_cv_func_getattrat = yes; then
407   LIB_NVPAIR=-lnvpair
408   AC_SUBST([LIB_NVPAIR])
411 # glibc >= 2.28 and linux kernel >= 4.11
412 AC_CHECK_FUNCS([statx])
414 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
415 AC_CHECK_FUNCS([initgroups])
416 if test $ac_cv_func_initgroups = no; then
417   AC_CHECK_LIB([os], [initgroups])
420 AC_CHECK_FUNCS([syslog])
421 if test $ac_cv_func_syslog = no; then
422   # syslog is not in the default libraries.  See if it's in some other.
423   for lib in bsd socket inet; do
424     AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
425       LIBS="$LIBS -l$lib"; break])
426   done
429 AC_CACHE_CHECK([for 3-argument setpriority function],
430   [utils_cv_func_setpriority],
431   [AC_LINK_IFELSE(
432     [AC_LANG_PROGRAM(
433        [[#include <sys/time.h>
434          #include <sys/resource.h>
435        ]],
436        [[setpriority (0, 0, 0);]])],
437     [utils_cv_func_setpriority=yes],
438     [utils_cv_func_setpriority=no])])
439 if test $utils_cv_func_setpriority = no; then
440   AC_CHECK_FUNCS([nice])
442 case $utils_cv_func_setpriority,$ac_cv_func_nice in
443 *yes*)
444   gl_ADD_PROG([optional_bin_progs], [nice])
445 esac
447 if test "$cross_compiling" = yes || test -c /dev/stdin <.; then
448   AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1],
449     [Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be
450      character-special devices whose minor device number is the file
451      descriptor number, such as on Solaris.  Leave undefined if they are
452      definitely the actual files.  This determination should be done after any
453      symbolic links are followed.])
456 AC_DEFUN([coreutils_DUMMY_1],
458   AC_REQUIRE([gl_READUTMP])
459   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
460     gl_ADD_PROG([optional_bin_progs], [who])
461     gl_ADD_PROG([optional_bin_progs], [users])
462     gl_ADD_PROG([optional_bin_progs], [pinky])
463   fi
465 coreutils_DUMMY_1
467 AC_SYS_POSIX_TERMIOS()
468 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
470 if test $ac_cv_sys_posix_termios = yes; then
471   gl_ADD_PROG([optional_bin_progs], [stty])
473   AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
474   AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
475   [AC_EGREP_CPP([yes], [#include <termios.h>
476 #ifdef IUCLC
478 #endif], su_cv_sys_termios_needs_xopen_source=no,
479    AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
480 #include <termios.h>
481 #ifdef IUCLC
483 #endif], su_cv_sys_termios_needs_xopen_source=yes,
484    su_cv_sys_termios_needs_xopen_source=no))])
485   AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
486   test $su_cv_sys_termios_needs_xopen_source = yes &&
487     AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
489   AC_MSG_CHECKING([c_line in struct termios])
490   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
491   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
492                                       #define _XOPEN_SOURCE
493                                      #endif
494                                      #include <sys/types.h>
495                                      #include <termios.h>
496                                      struct termios t;
497                                      int s = sizeof t.c_line;]])],
498     [su_cv_sys_c_line_in_termios=yes],
499     [su_cv_sys_c_line_in_termios=no])])
500   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
501   test $su_cv_sys_c_line_in_termios = yes \
502     && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
505 # FIXME: note that this macro appears above, too.
506 # I'm leaving it here for now.  This whole thing needs to be modernized...
507 gl_WINSIZE_IN_PTEM
509 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
511 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
512    test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
513   AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
514   AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
515   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
516 #ifdef WINSIZE_IN_PTEM
517 # include <sys/stream.h>
518 # include <sys/ptem.h>
519 #endif
520 #include <sys/ioctl.h>
521 #include <sys/tty.h>
522 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
523     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
524     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
525   AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
527   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
528       && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
529                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
532 # Build df only if there's a point to it.
533 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
534   gl_ADD_PROG([optional_bin_progs], [df])
537 # Build stdbuf only if supported
538 ac_save_CFLAGS=$CFLAGS
539 ac_save_LDFLAGS=$LDFLAGS
540 cu_save_c_werror_flag=$ac_c_werror_flag
541 AC_LANG_WERROR
542 # Detect warnings about ignored "constructor" attributes.
543 gl_WARN_ADD([-Werror], [CFLAGS])
544 gl_WARN_ADD([-errwarn], [CFLAGS])
545 # Put this message here, after gl_WARN_ADD's chatter.
546 AC_MSG_CHECKING([whether this system supports stdbuf])
547 CFLAGS="-fPIC $CFLAGS"
548 LDFLAGS="-shared $LDFLAGS"
549 AC_CACHE_VAL([utils_cv_stdbuf_supported],[
550 utils_cv_stdbuf_supported=no
551 # Note we only LINK here rather than RUN to support cross compilation
552 AC_LINK_IFELSE(
553   [AC_LANG_PROGRAM([[
554     static int stdbuf = 0;
556     void __attribute__ ((constructor))
557     stdbuf_init (void)
558     {
559       stdbuf = 1;
560     }]],[[
561     if (stdbuf != 1)
562       return 1;]])
563   ],
564   [utils_cv_stdbuf_supported=yes])])
565 AC_MSG_RESULT([$utils_cv_stdbuf_supported])
566 if test "$utils_cv_stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
567   gl_ADD_PROG([optional_bin_progs], [stdbuf])
569 CFLAGS=$ac_save_CFLAGS
570 LDFLAGS=$ac_save_LDFLAGS
571 ac_c_werror_flag=$cu_save_c_werror_flag
573 # Test compiler support for half precision floating point types (for od)
574 AC_MSG_CHECKING([IEEE 16 bit floating point])
575 AC_CACHE_VAL([utils_cv_ieee_16_bit_supported],[
576  AC_RUN_IFELSE(
577    [AC_LANG_SOURCE([[
578      int
579      main (void)
580      {
581         volatile _Float16 hf = 1;
582         float f = hf;  /* Ensure compiler can promote to float.  */
583         return !(f == 1.0f);
584      }
585   ]])
586   ],[
587     utils_cv_ieee_16_bit_supported=yes
588   ],[
589     utils_cv_ieee_16_bit_supported=no
590   ],[
591     utils_cv_ieee_16_bit_supported=no
592   ])])
593 AC_MSG_RESULT([$utils_cv_ieee_16_bit_supported])
594 if test $utils_cv_ieee_16_bit_supported = yes; then
595   AC_DEFINE([FLOAT16_SUPPORTED], [1], [IEEE 16 bit float supported])
598 AC_MSG_CHECKING([Brain 16 bit floating point])
599 AC_CACHE_VAL([utils_cv_brain_16_bit_supported],[
600  AC_RUN_IFELSE(
601    [AC_LANG_SOURCE([[
602      int
603      main (void)
604      {
605         volatile __bf16 hf = 1;
606         float f = hf;  /* Ensure compiler can promote to float.  */
607         return !(f == 1.0f);
608      }
609   ]])
610   ],[
611     utils_cv_brain_16_bit_supported=yes
612   ],[
613     utils_cv_brain_16_bit_supported=no
614   ],[
615     utils_cv_brain_16_bit_supported=no
616   ])])
617 AC_MSG_RESULT([$utils_cv_brain_16_bit_supported])
618 if test $utils_cv_brain_16_bit_supported = yes; then
619   AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
622 ac_save_CFLAGS=$CFLAGS
623 CFLAGS="-mavx -mpclmul $CFLAGS"
624 AC_MSG_CHECKING([if pclmul intrinsic exists])
625 AC_CACHE_VAL([utils_cv_pclmul_intrinsic_exists],[
626 AC_LINK_IFELSE(
627   [AC_LANG_SOURCE([[
628     #include <x86intrin.h>
630     int
631     main (void)
632     {
633       __m128i a, b;
634       a = _mm_clmulepi64_si128 (a, b, 0x00);
635       a = _mm_shuffle_epi8 (a, b);
636       return __builtin_cpu_supports ("pclmul");
637     }
638   ]])
639   ],[
640     utils_cv_pclmul_intrinsic_exists=yes
641   ],[
642     utils_cv_pclmul_intrinsic_exists=no
643   ])])
644 AC_MSG_RESULT([$utils_cv_pclmul_intrinsic_exists])
645 if test $utils_cv_pclmul_intrinsic_exists = yes; then
646   AC_DEFINE([USE_PCLMUL_CRC32], [1],
647             [CRC32 calculation by pclmul hardware instruction enabled])
649 AM_CONDITIONAL([USE_PCLMUL_CRC32],
650                [test $utils_cv_pclmul_intrinsic_exists = yes])
651 CFLAGS=$ac_save_CFLAGS
653 CFLAGS="-mavx2 $CFLAGS"
654 AC_MSG_CHECKING([for avx2 intrinsics])
655 AC_CACHE_VAL([utils_cv_avx2_intrinsic_exists],[
656 AC_LINK_IFELSE(
657   [AC_LANG_SOURCE([[
658     #include <x86intrin.h>
660     int
661     main (void)
662     {
663       __m256i matches = _mm256_setzero_si256 ();
664       int mask = _mm256_movemask_epi8 (matches);
665       int lines = __builtin_popcount (mask);
666       return __builtin_cpu_supports ("avx2");
667     }
668   ]])
669   ],[
670     utils_cv_avx2_intrinsic_exists=yes
671   ],[
672     utils_cv_avx2_intrinsic_exists=no
673   ])])
674 AC_MSG_RESULT([$utils_cv_avx2_intrinsic_exists])
675 if test $utils_cv_avx2_intrinsic_exists = yes; then
676   AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
678 AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
679                [test $utils_cv_avx2_intrinsic_exists = yes])
681 CFLAGS=$ac_save_CFLAGS
683 ############################################################################
685 dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
686 dnl Issue proper calls to the macros gl_INCLUDE_EXCLUDE_PROG and
687 dnl gl_ADD_PROG (updating $optional_bin_progs), and generate the list
688 dnl of coreutils programs to be built only upon explicit user request,
689 dnl saving that list in the $no_install_progs_default shell variable.
690 m4_include([m4/cu-progs.m4])
692 # Now that we know which programs will actually be built, determine
693 # which optional helper progs should be compiled.
694 # Note it adding to pkglibexec_PROGRAMS, $(transform) in src/local.mk
695 # may need to be updated accordingly.
696 case " $optional_bin_progs " in
697   *' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so';;
698   *) pkglibexec_PROGRAMS='';;
699 esac
701 man1_MANS=`
702   for p in $optional_bin_progs; do
703     # Change "ginstall.1" to "install.1".
704     test $p = ginstall && p=install
705     # Ignore the "[" program, since writing a portable make rule to
706     # generate its manpage is not practical.
707     dnl Use the autoconf-provided quadrigraph to represent "[",
708     dnl otherwise we will incur in dreadful quoting issues.
709     test x$p = x'@<:@' && continue
710     echo "man/$p.1"
711   done`
713 # Not installed by "make install", but must be built when creating
714 # a distribution tarball.
715 EXTRA_MANS=`for p in $no_install_progs_default $gl_no_install_prog; do
716               echo man/$p.1
717             done`
719 # Replace all the programs by the single binary and symlinks if specified.
720 single_binary_progs=
721 single_binary_libs=
722 single_binary_deps=
723 single_binary_install_type=
724 if test "$gl_single_binary" != no; then
725   man1_MANS="$man1_MANS man/coreutils.1"
726   # Convert the list to a space separated list
727   gl_single_binary_exceptions=`echo $gl_single_binary_exceptions | tr ',' ' '`
729   single_binary_progs=`echo $optional_bin_progs`
730   optional_bin_progs="coreutils"
731   for prog in $gl_single_binary_exceptions; do
732     # Fail if requested to exclude a program than was not part of coreutils.
733     case " $single_binary_progs " in
734       *" $prog "*)
735         gl_REMOVE_PROG([single_binary_progs], [$prog]) ;
736         gl_ADD_PROG([optional_bin_progs], [$prog]) ;;
737       *) AC_MSG_ERROR(['$prog' is not being compiled.]) ;;
738     esac
739   done
741   # single_binary_libs holds the list of libs required by the selected
742   # programs, such as for example -lrt.
743   single_binary_libs=`
744     for p in $single_binary_progs; do
745       # Convert '[' to '_'
746       test x"$p" = x'@<:@' && p='_'
747       printf '$(src_libsinglebin_%s_a_ldadd) ' "$p"
748     done`
749   # single_binary_deps holds the list of libsinglebin_*.a files that have the
750   # compiled code of each selected program in a "library" format.
751   single_binary_deps=`
752     for p in $single_binary_progs; do
753       # Convert '[' to '_'
754       test x"$p" = x'@<:@' && p='_'
755       printf 'src/libsinglebin_%s.a ' "$p"
756     done`
757   single_binary_install_type="$gl_single_binary"
759 AC_SUBST([single_binary_progs], [$single_binary_progs])
760 AC_SUBST([single_binary_libs], [$single_binary_libs])
761 AC_SUBST([single_binary_deps], [$single_binary_deps])
762 AC_SUBST([single_binary_install_type], [$single_binary_install_type])
765 # The programs built and installed by "make && make install".
766 # Since this is AC_SUBST'd, Automake won't be able to perform rewrite
767 # with $(EXEEXT) appending on it, so we have to do it ourselves -- in
768 # this case, only for $(bin_PROGRAMS).
769 bin_PROGRAMS=`
770   for p in $optional_bin_progs; do echo src/"$p"'$(EXEEXT)'; done`
772 # Normalize whitespace.
773 man1_MANS=`echo $man1_MANS`
774 EXTRA_MANS=`echo $EXTRA_MANS`
775 bin_PROGRAMS=`echo $bin_PROGRAMS`
776 pkglibexec_PROGS=`echo $pkglibexec_PROGRAMS`
778 AC_SUBST([bin_PROGRAMS])        AM_SUBST_NOTMAKE([bin_PROGRAMS])
779 AC_SUBST([pkglibexec_PROGRAMS]) AM_SUBST_NOTMAKE([pkglibexec_PROGRAMS])
780 AC_SUBST([man1_MANS])           AM_SUBST_NOTMAKE([man1_MANS])
781 AC_SUBST([EXTRA_MANS])          AM_SUBST_NOTMAKE([EXTRA_MANS])
783 AC_SUBST([built_programs], [$optional_bin_progs])
785 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
787 ############################################################################
789 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
790 # translatable strings, we must use need-formatstring-macros here.
791 AM_GNU_GETTEXT([external], [need-formatstring-macros])
792 AM_GNU_GETTEXT_VERSION([0.19.2])
794 # For a test of uniq: it uses the $LOCALE_FR envvar.
795 gt_LOCALE_FR
797 AC_CONFIG_FILES(
798   Makefile
799   po/Makefile.in
800   gnulib-tests/Makefile
801   )
802 AC_OUTPUT