2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991-2013 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 <http://www.gnu.org/licenses/>.
19 dnl Written by Jim Meyering.
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 AC_INIT([GNU coreutils],
27 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
28 [bug-coreutils@gnu.org])
30 AC_CONFIG_SRCDIR([src/ls.c])
32 AC_CONFIG_AUX_DIR([build-aux])
33 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
35 AM_INIT_AUTOMAKE([1.11.2 no-dist-gzip dist-xz color-tests parallel-tests
37 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
39 dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
40 dnl (more than 10% execution time) to ./configure, with no benefit for
41 dnl most users. Using it to look for bugs requires:
42 dnl GNULIB_POSIXCHECK=1 autoreconf -f
46 dnl make CFLAGS=-DGNULIB_POSIXCHECK=1
47 dnl FIXME: Once we figure out how to avoid false positives, we should
48 dnl have 'make my-distcheck' in dist-check.mk exercise this.
49 m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
50 m4_if(m4_sysval, [0], [], [dnl
51 gl_ASSERT_NO_GNULIB_POSIXCHECK])
53 dnl Enable use of libcrypto if available.
54 dnl Note we could do this as follows:
55 dnl AS_VAR_SET_IF([with_openssl], [], [with_openssl=optional])
56 dnl However that would not document the coreutils adjusted default,
57 dnl so we add another --with-openssl description just to document that
58 AC_ARG_WITH([openssl],
59 [AC_HELP_STRING([--with-openssl],
60 [The coreutils default is: --with-openssl=optional])],
62 [with_openssl=optional])
67 AC_PROG_GCC_TRADITIONAL
74 # The test suite needs to know if we have a working perl.
75 # FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
76 # with an ACTION-IF-NOT-FOUND argument ...
78 case $PERL in *"/missing "*) cu_have_perl=no;; esac
79 AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
81 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
82 # ------------------------------------------------
83 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
84 # Otherwise, run RUN-IF-NOT-FOUND.
85 AC_DEFUN([gl_GCC_VERSION_IFELSE],
89 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
92 # error "your version of gcc is older than $1.$2"
99 AC_ARG_ENABLE([gcc-warnings],
100 [AS_HELP_STRING([--enable-gcc-warnings],
101 [turn on many GCC warnings (for developers; best with GNU make)])],
104 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
106 gl_gcc_warnings=$enableval],
108 # GCC provides fine-grained control over diagnostics which
109 # is used in gnulib for example to suppress warnings from
110 # certain sections of code. So if this is available and
111 # we're running from a git repo, then auto enable the warnings.
113 gl_GCC_VERSION_IFELSE([4], [6],
114 [test -d "$srcdir"/.git && gl_gcc_warnings=yes])]
117 if test "$gl_gcc_warnings" = yes; then
118 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
119 AC_SUBST([WERROR_CFLAGS])
122 # This, $nw, is the list of warnings we disable.
123 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
124 nw="$nw -Waggregate-return" # anachronistic
125 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
126 nw="$nw -Wc++-compat" # We don't care about C++ compilers
127 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
128 nw="$nw -Wtraditional" # Warns on #elif which we use often
129 nw="$nw -Wcast-qual" # Too many warnings for now
130 nw="$nw -Wconversion" # Too many warnings for now
131 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
132 nw="$nw -Wsign-conversion" # Too many warnings for now
133 nw="$nw -Wtraditional-conversion" # Too many warnings for now
134 nw="$nw -Wunreachable-code" # Too many warnings for now
135 nw="$nw -Wpadded" # Our structs are not padded
136 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
137 nw="$nw -Wlogical-op" # any use of fwrite provokes this
138 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
139 nw="$nw -Wvla" # warnings in gettext.h
140 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
141 nw="$nw -Wswitch-enum" # Too many warnings for now
142 nw="$nw -Wswitch-default" # Too many warnings for now
143 nw="$nw -Wstack-protector" # not worth working around
144 # things I might fix soon:
145 nw="$nw -Wfloat-equal" # sort.c, seq.c
146 nw="$nw -Wmissing-format-attribute" # copy.c
147 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
148 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
149 nw="$nw -Wsuggest-attribute=format" # warns about copy.c and factor.c
151 # Using -Wstrict-overflow is a pain, but the alternative is worse.
152 # For an example, see the code that provoked this report:
153 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
154 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
156 gl_MANYWARN_ALL_GCC([ws])
157 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
161 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
162 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
163 gl_WARN_ADD([-Wsuggest-attribute=const])
164 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
165 gl_WARN_ADD([-Wno-format-nonliteral])
167 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
168 # it suggests test.c's advance function may be pure, even though it
169 # increments a global variable. Oops.
170 # Normally we'd write code to test for the precise failure, but that
171 # requires a relatively large input to make gcc exhibit the failure.
172 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
174 # In spite of excluding -Wlogical-op above, it is enabled, as of
175 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
176 gl_WARN_ADD([-Wno-logical-op])
178 # clang is unduly picky about some things.
179 AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
186 [utils_cv_clang=yes],
187 [utils_cv_clang=no])])
188 if test $utils_cv_clang = yes; then
189 gl_WARN_ADD([-Wno-format-extra-args])
190 gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
193 gl_WARN_ADD([-fdiagnostics-show-option])
194 gl_WARN_ADD([-funit-at-a-time])
196 AC_SUBST([WARN_CFLAGS])
198 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
199 AH_VERBATIM([FORTIFY_SOURCE],
200 [/* Enable compile-time and run-time bounds-checking, and some warnings,
201 without upsetting glibc 2.15+. */
202 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
203 # define _FORTIFY_SOURCE 2
206 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
208 # We use a slightly smaller set of warning options for lib/.
209 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
211 nw="$nw -Wstrict-overflow"
212 nw="$nw -Wuninitialized"
213 nw="$nw -Wunused-macros"
214 nw="$nw -Wmissing-prototypes"
215 nw="$nw -Wold-style-definition"
216 # FIXME: it may be easy to remove this, since it affects only one file:
217 # the snprintf call at ftoastr.c:132.
218 nw="$nw -Wdouble-promotion"
219 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
220 AC_SUBST([GNULIB_WARN_CFLAGS])
222 # For gnulib-tests, the set is slightly smaller still.
224 nw="$nw -Wstrict-prototypes"
225 # It's not worth being this picky about test programs.
226 nw="$nw -Wsuggest-attribute=const"
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])
236 AC_CHECK_FUNCS([chroot],
237 gl_ADD_PROG([optional_bin_progs], [chroot]))
238 AC_CHECK_FUNCS([gethostid],
239 gl_ADD_PROG([optional_bin_progs], [hostid]))
243 AC_MSG_CHECKING([whether localtime caches TZ])
244 AC_CACHE_VAL([utils_cv_localtime_cache],
245 [if test x$ac_cv_func_tzset = xyes; then
246 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
250 extern char **environ;
254 for (to = from = environ; (*to = *from); from++)
255 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
260 time_t now = time ((time_t *) 0);
261 int hour_GMT0, hour_unset;
262 if (putenv ("TZ=GMT0") != 0)
264 hour_GMT0 = localtime (&now)->tm_hour;
266 hour_unset = localtime (&now)->tm_hour;
267 if (putenv ("TZ=PST8") != 0)
269 if (localtime (&now)->tm_hour == hour_GMT0)
272 if (localtime (&now)->tm_hour != hour_unset)
276 [utils_cv_localtime_cache=no],
277 [utils_cv_localtime_cache=yes],
278 [# If we have tzset, assume the worst when cross-compiling.
279 utils_cv_localtime_cache=yes])
281 # If we lack tzset, report that localtime does not cache TZ,
282 # since we can't invalidate the cache if we don't have tzset.
283 utils_cv_localtime_cache=no
285 AC_MSG_RESULT([$utils_cv_localtime_cache])
286 if test $utils_cv_localtime_cache = yes; then
287 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
290 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
291 AC_CHECK_FUNCS([initgroups])
292 if test $ac_cv_func_initgroups = no; then
293 AC_CHECK_LIB([os], [initgroups])
296 AC_CHECK_FUNCS([syslog])
297 if test $ac_cv_func_syslog = no; then
298 # syslog is not in the default libraries. See if it's in some other.
299 for lib in bsd socket inet; do
300 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
301 LIBS="$LIBS -l$lib"; break])
305 AC_CACHE_CHECK([for 3-argument setpriority function],
306 [utils_cv_func_setpriority],
309 [[#include <sys/time.h>
310 #include <sys/resource.h>
312 [[setpriority (0, 0, 0);]])],
313 [utils_cv_func_setpriority=yes],
314 [utils_cv_func_setpriority=no])])
315 if test $utils_cv_func_setpriority = no; then
316 AC_CHECK_FUNCS([nice])
318 case $utils_cv_func_setpriority,$ac_cv_func_nice in
320 gl_ADD_PROG([optional_bin_progs], [nice])
323 AC_DEFUN([coreutils_DUMMY_1],
325 AC_REQUIRE([gl_READUTMP])
326 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
327 gl_ADD_PROG([optional_bin_progs], [who])
328 gl_ADD_PROG([optional_bin_progs], [users])
329 gl_ADD_PROG([optional_bin_progs], [pinky])
334 AC_MSG_CHECKING([ut_host in struct utmp])
335 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
336 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
337 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
338 [su_cv_func_ut_host_in_utmp=yes],
339 [su_cv_func_ut_host_in_utmp=no])])
340 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
341 if test $su_cv_func_ut_host_in_utmp = yes; then
343 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
346 if test -z "$have_ut_host"; then
347 AC_MSG_CHECKING([ut_host in struct utmpx])
348 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
349 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
350 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
351 [su_cv_func_ut_host_in_utmpx=yes],
352 [su_cv_func_ut_host_in_utmpx=no])])
353 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
354 if test $su_cv_func_ut_host_in_utmpx = yes; then
355 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
356 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
360 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
362 AC_SYS_POSIX_TERMIOS()
363 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
365 if test $ac_cv_sys_posix_termios = yes; then
366 gl_ADD_PROG([optional_bin_progs], [stty])
368 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
369 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
370 [AC_EGREP_CPP([yes], [#include <termios.h>
373 #endif], su_cv_sys_termios_needs_xopen_source=no,
374 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
378 #endif], su_cv_sys_termios_needs_xopen_source=yes,
379 su_cv_sys_termios_needs_xopen_source=no))])
380 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
381 test $su_cv_sys_termios_needs_xopen_source = yes &&
382 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
384 AC_MSG_CHECKING([c_line in struct termios])
385 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
386 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
387 #define _XOPEN_SOURCE
389 #include <sys/types.h>
390 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
391 [su_cv_sys_c_line_in_termios=yes],
392 [su_cv_sys_c_line_in_termios=no])])
393 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
394 test $su_cv_sys_c_line_in_termios = yes \
395 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
398 # FIXME: note that this macro appears above, too.
399 # I'm leaving it here for now. This whole thing needs to be modernized...
402 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
404 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
405 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
406 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
407 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
408 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
409 #ifdef WINSIZE_IN_PTEM
410 # include <sys/stream.h>
411 # include <sys/ptem.h>
413 #include <sys/ioctl.h>
415 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
416 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
417 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
418 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
420 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
421 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
422 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
426 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
428 #include <signal.h>])
432 # Build df only if there's a point to it.
433 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
434 gl_ADD_PROG([optional_bin_progs], [df])
437 # Limit stdbuf to ELF systems with GCC
438 AC_MSG_CHECKING([whether this is an ELF system])
439 AC_EGREP_CPP([yes], [#if __ELF__
441 #endif], [elf_sys=yes], [elf_sys=no])
442 AC_MSG_RESULT([$elf_sys])
443 if test "$elf_sys" = "yes" && \
444 test "$GCC" = "yes"; then
445 gl_ADD_PROG([optional_bin_progs], [stdbuf])
448 ############################################################################
450 dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
451 dnl Issue proper calls to the macros gl_INCLUDE_EXCLUDE_PROG and
452 dnl gl_ADD_PROG (updating $optional_bin_progs), and generate the list
453 dnl of coreutils programs to be built only upon explicit user request,
454 dnl saving that list in the $no_install_progs_default shell variable.
455 m4_include([m4/cu-progs.m4])
457 # Now that we know which programs will actually be built, determine
458 # which optional helper progs should be compiled.
459 case " $optional_bin_progs " in
460 *' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so';;
461 *) pkglibexec_PROGRAMS='';;
465 for p in $optional_bin_progs; do
466 # Change "ginstall.1" to "install.1".
467 test $p = ginstall && p=install
468 # Ignore the "[" program, since writing a portable make rule to
469 # generate its manpage is not practical.
470 dnl Use the autoconf-provided quadrigraph to represent "[",
471 dnl otherwise we will incur in dreadful quoting issues.
472 test x$p = x'@<:@' && continue
476 # Not installed by "make install", but must be built when creating
477 # a distribution tarball.
478 EXTRA_MANS=`for p in $no_install_progs_default; do echo man/$p.1; done`
480 # The programs built and installed by "make && make install".
481 # Since this is AC_SUBST'd, Automake won't be able to perform rewrite
482 # with $(EXEEXT) appending on it, so we have to do it ourselves -- in
483 # this case, only for $(bin_PROGRAMS).
485 for p in $optional_bin_progs; do echo src/"$p"'$(EXEEXT)'; done`
487 # Normalize whitespace.
488 man1_MANS=`echo $man1_MANS`
489 EXTRA_MANS=`echo $EXTRA_MANS`
490 bin_PROGRAMS=`echo $bin_PROGRAMS`
491 pkglibexec_PROGS=`echo $pkglibexec_PROGRAMS`
493 AC_SUBST([bin_PROGRAMS]) AM_SUBST_NOTMAKE([bin_PROGRAMS])
494 AC_SUBST([pkglibexec_PROGRAMS]) AM_SUBST_NOTMAKE([pkglibexec_PROGRAMS])
495 AC_SUBST([man1_MANS]) AM_SUBST_NOTMAKE([man1_MANS])
496 AC_SUBST([EXTRA_MANS]) AM_SUBST_NOTMAKE([EXTRA_MANS])
498 AC_SUBST([built_programs], [$optional_bin_progs])
500 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
502 ############################################################################
504 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
505 # translatable strings, we must use need-formatstring-macros here.
506 AM_GNU_GETTEXT([external], [need-formatstring-macros])
507 AM_GNU_GETTEXT_VERSION([0.18.1])
509 # For a test of uniq: it uses the $LOCALE_FR envvar.
515 gnulib-tests/Makefile