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