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