maint: omit some unused function tests
[coreutils.git] / configure.ac
blobeec1107906a4cb441f832a33d5765d94956999b6
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991-2023 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_GCC_TRADITIONAL
59 AC_PROG_RANLIB
60 AC_PROG_EGREP
61 AC_PROG_LN_S
62 gl_EARLY
63 gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
64 gl_INIT
65 coreutils_MACROS
67 # These are safe, since 'sort', coreutils's only multithreaded app,
68 # does not use the relevant modules.
69 AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
70   [Define to 1 if apps call 'exclude' functions from a single thread.])
71 AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
72   [Define to 1 if apps call 'regex' functions from a single thread.])
73 # Although 'sort' is multithreaded and can use these functions,
74 # it uses them only from the main thread.
75 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
76   [Define to 1 if apps call mbrtowc, mbrtoc32, and 'regex' functions
77    from a single thread.])
78 # This is safe, since all apps set locale early.
79 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
80   [Define to 1 if apps don't set the locale after calling
81    locale-sensitive functions like mbrtowc and wcwidth.])
83 AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
84   [Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
85    that glibc does not support.])
87 # The test suite needs to know if we have a working perl.
88 AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
90 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
91 # ------------------------------------------------
92 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
93 # Otherwise, run RUN-IF-NOT-FOUND.
94 AC_DEFUN([gl_GCC_VERSION_IFELSE],
95   [AC_PREPROC_IFELSE(
96     [AC_LANG_PROGRAM(
97       [[
98 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
99 /* ok */
100 #else
101 # error "your version of gcc is older than $1.$2"
102 #endif
103       ]]),
104     ], [$3], [$4])
105   ]
108 AC_ARG_ENABLE([single-binary],
109   [AS_HELP_STRING([--enable-single-binary=[shebangs|symlinks]],
110      [Compile all the tools in a single binary, reducing the overall size.
111       When compiled this way, shebangs (default when enabled) or symlinks are
112       installed for each tool that points to the single binary.])],
113   [gl_single_binary=no ;
114    case $enableval in
115      yes) gl_single_binary=shebangs ;;
116      no|shebangs|symlinks) gl_single_binary=$enableval ;;
117      *)      AC_MSG_ERROR([bad value $enableval for single-binary option.
118                            Options are: symlinks, shebangs, no.]) ;;
119    esac],
120   [gl_single_binary=no]
122 AC_ARG_ENABLE([single-binary-exceptions],
123   [AS_HELP_STRING([--enable-single-binary-exceptions=PROG_LIST],
124      [When used with --enable-single-binary, exclude the PROG_LIST from
125       it, so these programs are compiled as separated files
126       (comma-separated, default none))])],
127   [gl_single_binary_exceptions=$enableval],
128   [gl_single_binary_exceptions=]
130 if test "$gl_single_binary" = 'symlinks'; then
131   if ! test "`echo ls | sed \"$program_transform_name\"`" = 'ls'; then
132     AC_MSG_ERROR([program name transformations are not currently supported
133                   with --enable-single-binary=symlinks.])
134   fi
136 AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no])
138 AC_ARG_ENABLE([bold-man-page-references],
139   [AS_HELP_STRING([--disable-bold-man-page-references],
140      [When generating man pages, do not apply bold style around any
141       references like name(1) etc.])],
142   [gl_bold_manpages=yes ;
143    case $enableval in
144      no|yes) gl_bold_manpages=$enableval ;;
145      *)      AC_MSG_ERROR([bad value $enableval for bold-man-page-references.
146                            Options are: yes, no.]) ;;
147    esac],
148   [gl_bold_manpages=yes]
150 AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
152 AC_ARG_ENABLE([gcc-warnings],
153   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
154     [control generation of GCC warnings.  The TYPE 'no' disables
155      warnings (default for non-developer builds); 'yes' generates
156      cheap warnings if available (default for developer builds);
157      'expensive' in addition generates expensive-to-compute warnings
158      if available.])],
159   [case $enableval in
160      no|yes|expensive) ;;
161      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
162    esac
163    gl_gcc_warnings=$enableval],
164   [
165    # GCC provides fine-grained control over diagnostics which
166    # is used in gnulib for example to suppress warnings from
167    # certain sections of code.  So if this is available and
168    # we're running from a git repo, then auto enable the warnings.
169    gl_gcc_warnings=no
170    gl_GCC_VERSION_IFELSE([4], [6],
171                          [test -d "$srcdir"/.git \
172                           && ! test -f "$srcdir"/.tarball-version \
173                           && gl_gcc_warnings=yes])]
176 if test $gl_gcc_warnings != no; then
177   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
178   AC_SUBST([WERROR_CFLAGS])
180   ew=
181   AS_IF([test $gl_gcc_warnings != expensive],
182     [# -fanalyzer and related options slow GCC considerably.
183      ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
185   # This, $nw, is the list of warnings we disable.
186   nw=$ew
187   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
188   nw="$nw -Waggregate-return"       # anachronistic
189   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
190   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
191   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
192   nw="$nw -Wtraditional"            # Warns on #elif which we use often
193   nw="$nw -Wcast-qual"              # Too many warnings for now
194   nw="$nw -Wconversion"             # Too many warnings for now
195   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
196   nw="$nw -Wsign-conversion"        # Too many warnings for now
197   nw="$nw -Wtraditional-conversion" # Too many warnings for now
198   nw="$nw -Wunreachable-code"       # Too many warnings for now
199   nw="$nw -Wpadded"                 # Our structs are not padded
200   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
201   nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
202   nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
203   nw="$nw -Wswitch-enum"            # Too many warnings for now
204   nw="$nw -Wswitch-default"         # Too many warnings for now
205   nw="$nw -Wstack-protector"        # not worth working around
206   nw="$nw -Wformat-overflow=2"      # False alarms due to GCC bug 110333
207   nw="$nw -Wformat-truncation=2"    # False alarm in ls.c, probably related
208   # things I might fix soon:
209   nw="$nw -Wfloat-equal"            # sort.c, seq.c
210   nw="$nw -Wmissing-format-attribute" # copy.c
211   nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
212   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
213   nw="$nw -Wvector-operation-performance" # warns about randperm.c
215   # Suppress noreturn warnings with single binaries; otherwise
216   # GCC complains about the renamed 'main' not being declared noreturn
217   # because 'main_exit' calls 'exit' when linting.
218   if test "$gl_single_binary" != no; then
219     nw="$nw -Wsuggest-attribute=noreturn"
220   fi
222   # Using -Wstrict-overflow is a pain, but the alternative is worse.
223   # For an example, see the code that provoked this report:
224   # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
225   # Code like that still infloops with gcc-4.6.0 and -O2.  Scary indeed.
227   gl_MANYWARN_ALL_GCC([ws])
228   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
229   for w in $ws; do
230     gl_WARN_ADD([$w])
231   done
232   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
233   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
234   gl_WARN_ADD([-Wno-format-nonliteral])
236   # clang is unduly picky about some things.
237   AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
238     [AC_COMPILE_IFELSE(
239        [AC_LANG_PROGRAM([[
240             #ifndef __clang__
241               #error "not clang"
242             #endif
243           ]])],
244        [utils_cv_clang=yes],
245        [utils_cv_clang=no])])
246   if test $utils_cv_clang = yes; then
247     gl_WARN_ADD([-Wno-format-extra-args])
248     gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
249   fi
251   gl_WARN_ADD([-fdiagnostics-show-option])
252   gl_WARN_ADD([-funit-at-a-time])
254   AC_SUBST([WARN_CFLAGS])
256   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
257   AH_VERBATIM([FORTIFY_SOURCE],
258   [/* Enable compile-time and run-time bounds-checking, and some warnings,
259       without upsetting glibc 2.15+. */
260    #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
261    # define _FORTIFY_SOURCE 2
262    #endif
263   ])
264   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
266   # We use a slightly smaller set of warning options for lib/.
267   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
268   nw=$ew
269   nw="$nw -Wduplicated-branches"    # Too many false alarms
270   nw="$nw -Wformat-truncation=2"
271   nw="$nw -Wstrict-overflow"
272   nw="$nw -Wuninitialized"
273   nw="$nw -Wunused-macros"
274   nw="$nw -Wmissing-prototypes"
275   nw="$nw -Wold-style-definition"
276   # FIXME: it may be easy to remove this, since it affects only one file:
277   # the snprintf call at ftoastr.c:132.
278   nw="$nw -Wdouble-promotion"
280   # FIXME: remove this line when gcc improves
281   # FP in careadlinkat.c w/gcc 10.0.1 20200205
282   gl_WARN_ADD([-Wno-return-local-addr])
284   # FIXME: remove this line when gcc improves
285   # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
286   gl_WARN_ADD([-Wno-stringop-overflow])
288   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
289   AC_SUBST([GNULIB_WARN_CFLAGS])
291   # For gnulib-tests, the set is slightly smaller still.
292   nw=
293   nw="$nw -Wstrict-prototypes"
294   # It's not worth being this picky about test programs.
295   nw="$nw -Wsuggest-attribute=const"
296   nw="$nw -Wsuggest-attribute=format"
297   nw="$nw -Wsuggest-attribute=pure"
298   gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
299                          [$GNULIB_WARN_CFLAGS], [$nw])
300   AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
303 AC_FUNC_FORK
305 optional_bin_progs=
306 AC_CHECK_FUNCS([chroot],
307         gl_ADD_PROG([optional_bin_progs], [chroot]))
308 AC_CHECK_FUNCS([gethostid],
309         gl_ADD_PROG([optional_bin_progs], [hostid]))
310 AC_CHECK_FUNCS([sigsuspend],
311         gl_ADD_PROG([optional_bin_progs], [timeout]))
313 gl_WINSIZE_IN_PTEM
315 AC_MSG_CHECKING([whether localtime caches TZ])
316 AC_CACHE_VAL([utils_cv_localtime_cache],
317 [if test x$ac_cv_func_tzset = xyes; then
318 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
319 #if STDC_HEADERS
320 # include <stdlib.h>
321 #endif
322 extern char **environ;
323 void unset_TZ (void)
325   char **from, **to;
326   for (to = from = environ; (*to = *from); from++)
327     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
328       to++;
331 main ()
333   time_t now = time ((time_t *) 0);
334   int hour_GMT0, hour_unset;
335   if (putenv ("TZ=GMT0") != 0)
336     return 1;
337   hour_GMT0 = localtime (&now)->tm_hour;
338   unset_TZ ();
339   hour_unset = localtime (&now)->tm_hour;
340   if (putenv ("TZ=PST8") != 0)
341     return 1;
342   if (localtime (&now)->tm_hour == hour_GMT0)
343     return 1;
344   unset_TZ ();
345   if (localtime (&now)->tm_hour != hour_unset)
346     return 1;
347   return 0;
348 }]])],
349 [utils_cv_localtime_cache=no],
350 [utils_cv_localtime_cache=yes],
351 [# If we have tzset, assume the worst when cross-compiling.
352 utils_cv_localtime_cache=yes])
353 else
354         # If we lack tzset, report that localtime does not cache TZ,
355         # since we can't invalidate the cache if we don't have tzset.
356         utils_cv_localtime_cache=no
357 fi])dnl
358 AC_MSG_RESULT([$utils_cv_localtime_cache])
359 if test $utils_cv_localtime_cache = yes; then
360   AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
363 # macOS >= 10.12
364 AC_CHECK_FUNCS([fclonefileat])
366 # Assume that if getattrat exists, it's compatible with Solaris 11.
367 AC_CHECK_FUNCS([getattrat])
368 if test $ac_cv_func_getattrat = yes; then
369   LIB_NVPAIR=-lnvpair
370   AC_SUBST([LIB_NVPAIR])
373 # glibc >= 2.28 and linux kernel >= 4.11
374 AC_CHECK_FUNCS([statx])
376 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
377 AC_CHECK_FUNCS([initgroups])
378 if test $ac_cv_func_initgroups = no; then
379   AC_CHECK_LIB([os], [initgroups])
382 AC_CHECK_FUNCS([syslog])
383 if test $ac_cv_func_syslog = no; then
384   # syslog is not in the default libraries.  See if it's in some other.
385   for lib in bsd socket inet; do
386     AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
387       LIBS="$LIBS -l$lib"; break])
388   done
391 AC_CACHE_CHECK([for 3-argument setpriority function],
392   [utils_cv_func_setpriority],
393   [AC_LINK_IFELSE(
394     [AC_LANG_PROGRAM(
395        [[#include <sys/time.h>
396          #include <sys/resource.h>
397        ]],
398        [[setpriority (0, 0, 0);]])],
399     [utils_cv_func_setpriority=yes],
400     [utils_cv_func_setpriority=no])])
401 if test $utils_cv_func_setpriority = no; then
402   AC_CHECK_FUNCS([nice])
404 case $utils_cv_func_setpriority,$ac_cv_func_nice in
405 *yes*)
406   gl_ADD_PROG([optional_bin_progs], [nice])
407 esac
409 if test "$cross_compiling" = yes || test -c /dev/stdin <.; then
410   AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1],
411     [Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be
412      character-special devices whose minor device number is the file
413      descriptor number, such as on Solaris.  Leave undefined if they are
414      definitely the actual files.  This determination should be done after any
415      symbolic links are followed.])
418 AC_DEFUN([coreutils_DUMMY_1],
420   AC_REQUIRE([gl_READUTMP])
421   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
422     gl_ADD_PROG([optional_bin_progs], [who])
423     gl_ADD_PROG([optional_bin_progs], [users])
424     gl_ADD_PROG([optional_bin_progs], [pinky])
425   fi
427 coreutils_DUMMY_1
429 AC_SYS_POSIX_TERMIOS()
430 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
432 if test $ac_cv_sys_posix_termios = yes; then
433   gl_ADD_PROG([optional_bin_progs], [stty])
435   AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
436   AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
437   [AC_EGREP_CPP([yes], [#include <termios.h>
438 #ifdef IUCLC
440 #endif], su_cv_sys_termios_needs_xopen_source=no,
441    AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
442 #include <termios.h>
443 #ifdef IUCLC
445 #endif], su_cv_sys_termios_needs_xopen_source=yes,
446    su_cv_sys_termios_needs_xopen_source=no))])
447   AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
448   test $su_cv_sys_termios_needs_xopen_source = yes &&
449     AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
451   AC_MSG_CHECKING([c_line in struct termios])
452   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
453   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
454                                       #define _XOPEN_SOURCE
455                                      #endif
456                                      #include <sys/types.h>
457                                      #include <termios.h>
458                                      struct termios t;
459                                      int s = sizeof t.c_line;]])],
460     [su_cv_sys_c_line_in_termios=yes],
461     [su_cv_sys_c_line_in_termios=no])])
462   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
463   test $su_cv_sys_c_line_in_termios = yes \
464     && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
467 # FIXME: note that this macro appears above, too.
468 # I'm leaving it here for now.  This whole thing needs to be modernized...
469 gl_WINSIZE_IN_PTEM
471 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
473 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
474    test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
475   AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
476   AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
477   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
478 #ifdef WINSIZE_IN_PTEM
479 # include <sys/stream.h>
480 # include <sys/ptem.h>
481 #endif
482 #include <sys/ioctl.h>
483 #include <sys/tty.h>
484 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
485     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
486     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
487   AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
489   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
490       && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
491                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
494 # Build df only if there's a point to it.
495 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
496   gl_ADD_PROG([optional_bin_progs], [df])
499 # Build stdbuf only if supported
500 ac_save_CFLAGS=$CFLAGS
501 ac_save_LDFLAGS=$LDFLAGS
502 cu_save_c_werror_flag=$ac_c_werror_flag
503 AC_LANG_WERROR
504 # Detect warnings about ignored "constructor" attributes.
505 gl_WARN_ADD([-Werror], [CFLAGS])
506 gl_WARN_ADD([-errwarn], [CFLAGS])
507 # Put this message here, after gl_WARN_ADD's chatter.
508 AC_MSG_CHECKING([whether this system supports stdbuf])
509 CFLAGS="-fPIC $CFLAGS"
510 LDFLAGS="-shared $LDFLAGS"
511 stdbuf_supported=no
512 # Note we only LINK here rather than RUN to support cross compilation
513 AC_LINK_IFELSE(
514   [AC_LANG_PROGRAM([[
515     static int stdbuf = 0;
517     void __attribute__ ((constructor))
518     stdbuf_init (void)
519     {
520       stdbuf = 1;
521     }]],[[
522     if (stdbuf != 1)
523       return 1;]])
524   ],
525   [stdbuf_supported=yes])
526 AC_MSG_RESULT([$stdbuf_supported])
527 if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
528   gl_ADD_PROG([optional_bin_progs], [stdbuf])
530 CFLAGS=$ac_save_CFLAGS
531 LDFLAGS=$ac_save_LDFLAGS
532 ac_c_werror_flag=$cu_save_c_werror_flag
534 ac_save_CFLAGS=$CFLAGS
535 CFLAGS="-mavx -mpclmul $CFLAGS"
536 AC_MSG_CHECKING([if pclmul intrinsic exists])
537 AC_LINK_IFELSE(
538   [AC_LANG_SOURCE([[
539     #include <x86intrin.h>
541     int
542     main (void)
543     {
544       __m128i a, b;
545       a = _mm_clmulepi64_si128 (a, b, 0x00);
546       a = _mm_shuffle_epi8 (a, b);
547       return __builtin_cpu_supports ("pclmul");
548     }
549   ]])
550   ],[
551     pclmul_intrinsic_exists=yes
552   ],[
553     pclmul_intrinsic_exists=no
554   ])
555 AC_MSG_RESULT([$pclmul_intrinsic_exists])
556 if test $pclmul_intrinsic_exists = yes; then
557   AC_DEFINE([USE_PCLMUL_CRC32], [1],
558             [CRC32 calculation by pclmul hardware instruction enabled])
560 AM_CONDITIONAL([USE_PCLMUL_CRC32],
561                [test $pclmul_intrinsic_exists = yes])
562 CFLAGS=$ac_save_CFLAGS
564 CFLAGS="-mavx2 $CFLAGS"
565 AC_MSG_CHECKING([for avx2 intrinsics])
566 AC_LINK_IFELSE(
567   [AC_LANG_SOURCE([[
568     #include <x86intrin.h>
570     int
571     main (void)
572     {
573       __m256i a, b;
574       a = _mm256_sad_epu8 (a, b);
575       return __builtin_cpu_supports ("avx2");
576     }
577   ]])
578   ],[
579     avx2_intrinsic_exists=yes
580   ],[
581     avx2_intrinsic_exists=no
582   ])
583 AC_MSG_RESULT([$avx2_intrinsic_exists])
584 if test $avx2_intrinsic_exists = yes; then
585   AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
587 AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
588                [test $avx2_intrinsic_exists = yes])
590 CFLAGS=$ac_save_CFLAGS
592 ############################################################################
594 dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
595 dnl Issue proper calls to the macros gl_INCLUDE_EXCLUDE_PROG and
596 dnl gl_ADD_PROG (updating $optional_bin_progs), and generate the list
597 dnl of coreutils programs to be built only upon explicit user request,
598 dnl saving that list in the $no_install_progs_default shell variable.
599 m4_include([m4/cu-progs.m4])
601 # Now that we know which programs will actually be built, determine
602 # which optional helper progs should be compiled.
603 # Note it adding to pkglibexec_PROGRAMS, $(transform) in src/local.mk
604 # may need to be updated accordingly.
605 case " $optional_bin_progs " in
606   *' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so';;
607   *) pkglibexec_PROGRAMS='';;
608 esac
610 man1_MANS=`
611   for p in $optional_bin_progs; do
612     # Change "ginstall.1" to "install.1".
613     test $p = ginstall && p=install
614     # Ignore the "[" program, since writing a portable make rule to
615     # generate its manpage is not practical.
616     dnl Use the autoconf-provided quadrigraph to represent "[",
617     dnl otherwise we will incur in dreadful quoting issues.
618     test x$p = x'@<:@' && continue
619     echo "man/$p.1"
620   done`
622 # Not installed by "make install", but must be built when creating
623 # a distribution tarball.
624 EXTRA_MANS=`for p in $no_install_progs_default $gl_no_install_prog; do
625               echo man/$p.1
626             done`
628 # Replace all the programs by the single binary and symlinks if specified.
629 single_binary_progs=
630 single_binary_libs=
631 single_binary_deps=
632 single_binary_install_type=
633 if test "$gl_single_binary" != no; then
634   man1_MANS="$man1_MANS man/coreutils.1"
635   # Convert the list to a space separated list
636   gl_single_binary_exceptions=`echo $gl_single_binary_exceptions | tr ',' ' '`
638   single_binary_progs=`echo $optional_bin_progs`
639   optional_bin_progs="coreutils"
640   for prog in $gl_single_binary_exceptions; do
641     # Fail if requested to exclude a program than was not part of coreutils.
642     case " $single_binary_progs " in
643       *" $prog "*)
644         gl_REMOVE_PROG([single_binary_progs], [$prog]) ;
645         gl_ADD_PROG([optional_bin_progs], [$prog]) ;;
646       *) AC_MSG_ERROR(['$prog' is not being compiled.]) ;;
647     esac
648   done
650   # single_binary_libs holds the list of libs required by the selected
651   # programs, such as for example -lrt.
652   single_binary_libs=`
653     for p in $single_binary_progs; do
654       # Convert '[' to '_'
655       test x"$p" = x'@<:@' && p='_'
656       printf '$(src_libsinglebin_%s_a_ldadd) ' "$p"
657     done`
658   # single_binary_deps holds the list of libsinglebin_*.a files that have the
659   # compiled code of each selected program in a "library" format.
660   single_binary_deps=`
661     for p in $single_binary_progs; do
662       # Convert '[' to '_'
663       test x"$p" = x'@<:@' && p='_'
664       printf 'src/libsinglebin_%s.a ' "$p"
665     done`
666   single_binary_install_type="$gl_single_binary"
668 AC_SUBST([single_binary_progs], [$single_binary_progs])
669 AC_SUBST([single_binary_libs], [$single_binary_libs])
670 AC_SUBST([single_binary_deps], [$single_binary_deps])
671 AC_SUBST([single_binary_install_type], [$single_binary_install_type])
674 # The programs built and installed by "make && make install".
675 # Since this is AC_SUBST'd, Automake won't be able to perform rewrite
676 # with $(EXEEXT) appending on it, so we have to do it ourselves -- in
677 # this case, only for $(bin_PROGRAMS).
678 bin_PROGRAMS=`
679   for p in $optional_bin_progs; do echo src/"$p"'$(EXEEXT)'; done`
681 # Normalize whitespace.
682 man1_MANS=`echo $man1_MANS`
683 EXTRA_MANS=`echo $EXTRA_MANS`
684 bin_PROGRAMS=`echo $bin_PROGRAMS`
685 pkglibexec_PROGS=`echo $pkglibexec_PROGRAMS`
687 AC_SUBST([bin_PROGRAMS])        AM_SUBST_NOTMAKE([bin_PROGRAMS])
688 AC_SUBST([pkglibexec_PROGRAMS]) AM_SUBST_NOTMAKE([pkglibexec_PROGRAMS])
689 AC_SUBST([man1_MANS])           AM_SUBST_NOTMAKE([man1_MANS])
690 AC_SUBST([EXTRA_MANS])          AM_SUBST_NOTMAKE([EXTRA_MANS])
692 AC_SUBST([built_programs], [$optional_bin_progs])
694 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
696 ############################################################################
698 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
699 # translatable strings, we must use need-formatstring-macros here.
700 AM_GNU_GETTEXT([external], [need-formatstring-macros])
701 AM_GNU_GETTEXT_VERSION([0.19.2])
703 # For a test of uniq: it uses the $LOCALE_FR envvar.
704 gt_LOCALE_FR
706 AC_CONFIG_FILES(
707   Makefile
708   po/Makefile.in
709   gnulib-tests/Makefile
710   )
711 AC_OUTPUT