2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991-2012 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])
56 AC_PROG_GCC_TRADITIONAL
63 # The test suite needs to know if we have a working perl.
64 # FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
65 # with an ACTION-IF-NOT-FOUND argument ...
67 case $PERL in *"/missing ") cu_have_perl=no;; esac
68 AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
70 AC_ARG_ENABLE([gcc-warnings],
71 [AS_HELP_STRING([--enable-gcc-warnings],
72 [turn on lots of GCC warnings (for developers)])],
75 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
77 gl_gcc_warnings=$enableval],
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 if test "$gl_gcc_warnings" = yes; then
100 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
101 AC_SUBST([WERROR_CFLAGS])
104 # This, $nw, is the list of warnings we disable.
105 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
106 nw="$nw -Waggregate-return" # anachronistic
107 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
108 nw="$nw -Wc++-compat" # We don't care about C++ compilers
109 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
110 nw="$nw -Wtraditional" # Warns on #elif which we use often
111 nw="$nw -Wcast-qual" # Too many warnings for now
112 nw="$nw -Wconversion" # Too many warnings for now
113 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
114 nw="$nw -Wsign-conversion" # Too many warnings for now
115 nw="$nw -Wtraditional-conversion" # Too many warnings for now
116 nw="$nw -Wunreachable-code" # Too many warnings for now
117 nw="$nw -Wpadded" # Our structs are not padded
118 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
119 nw="$nw -Wlogical-op" # any use of fwrite provokes this
120 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
121 nw="$nw -Wvla" # warnings in gettext.h
122 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
123 nw="$nw -Wswitch-enum" # Too many warnings for now
124 nw="$nw -Wswitch-default" # Too many warnings for now
125 nw="$nw -Wstack-protector" # not worth working around
126 # things I might fix soon:
127 nw="$nw -Wfloat-equal" # sort.c, seq.c
128 nw="$nw -Wmissing-format-attribute" # copy.c
129 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
130 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
132 # Using -Wstrict-overflow is a pain, but the alternative is worse.
133 # For an example, see the code that provoked this report:
134 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
135 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
137 gl_MANYWARN_ALL_GCC([ws])
138 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
142 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
143 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
144 gl_WARN_ADD([-Wsuggest-attribute=const])
145 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
146 gl_WARN_ADD([-Wno-format-nonliteral])
148 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
149 # it suggests test.c's advance function may be pure, even though it
150 # increments a global variable. Oops.
151 # Normally we'd write code to test for the precise failure, but that
152 # requires a relatively large input to make gcc exhibit the failure.
153 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
155 # In spite of excluding -Wlogical-op above, it is enabled, as of
156 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
157 gl_WARN_ADD([-Wno-logical-op])
159 gl_WARN_ADD([-fdiagnostics-show-option])
160 gl_WARN_ADD([-funit-at-a-time])
162 AC_SUBST([WARN_CFLAGS])
164 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
165 AH_VERBATIM([FORTIFY_SOURCE],
166 [/* Enable compile-time and run-time bounds-checking, and some warnings,
167 without upsetting glibc 2.15+. */
168 #if defined __OPTIMIZE__ && __OPTIMIZE__
169 # define _FORTIFY_SOURCE 2
172 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
174 # We use a slightly smaller set of warning options for lib/.
175 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
177 nw="$nw -Wstrict-overflow"
178 nw="$nw -Wuninitialized"
179 nw="$nw -Wunused-macros"
180 nw="$nw -Wmissing-prototypes"
181 nw="$nw -Wold-style-definition"
182 # FIXME: it may be easy to remove this, since it affects only one file:
183 # the snprintf call at ftoastr.c:132.
184 nw="$nw -Wdouble-promotion"
185 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
186 AC_SUBST([GNULIB_WARN_CFLAGS])
188 # For gnulib-tests, the set is slightly smaller still.
190 nw="$nw -Wstrict-prototypes"
191 # It's not worth being this picky about test programs.
192 nw="$nw -Wsuggest-attribute=const"
193 nw="$nw -Wsuggest-attribute=pure"
194 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
195 [$GNULIB_WARN_CFLAGS], [$nw])
196 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
202 AC_CHECK_FUNCS([chroot],
203 gl_ADD_PROG([optional_bin_progs], [chroot]))
204 AC_CHECK_FUNCS([gethostid],
205 gl_ADD_PROG([optional_bin_progs], [hostid]))
209 AC_MSG_CHECKING([whether localtime caches TZ])
210 AC_CACHE_VAL([utils_cv_localtime_cache],
211 [if test x$ac_cv_func_tzset = xyes; then
212 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
216 extern char **environ;
220 for (to = from = environ; (*to = *from); from++)
221 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
226 time_t now = time ((time_t *) 0);
227 int hour_GMT0, hour_unset;
228 if (putenv ("TZ=GMT0") != 0)
230 hour_GMT0 = localtime (&now)->tm_hour;
232 hour_unset = localtime (&now)->tm_hour;
233 if (putenv ("TZ=PST8") != 0)
235 if (localtime (&now)->tm_hour == hour_GMT0)
238 if (localtime (&now)->tm_hour != hour_unset)
242 [utils_cv_localtime_cache=no],
243 [utils_cv_localtime_cache=yes],
244 [# If we have tzset, assume the worst when cross-compiling.
245 utils_cv_localtime_cache=yes])
247 # If we lack tzset, report that localtime does not cache TZ,
248 # since we can't invalidate the cache if we don't have tzset.
249 utils_cv_localtime_cache=no
251 AC_MSG_RESULT([$utils_cv_localtime_cache])
252 if test $utils_cv_localtime_cache = yes; then
253 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
256 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
257 AC_CHECK_FUNCS([initgroups])
258 if test $ac_cv_func_initgroups = no; then
259 AC_CHECK_LIB([os], [initgroups])
262 AC_CHECK_FUNCS([syslog])
263 if test $ac_cv_func_syslog = no; then
264 # syslog is not in the default libraries. See if it's in some other.
265 for lib in bsd socket inet; do
266 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
267 LIBS="$LIBS -l$lib"; break])
271 AC_CACHE_CHECK([for 3-argument setpriority function],
272 [utils_cv_func_setpriority],
275 [[#include <sys/time.h>
276 #include <sys/resource.h>
278 [[setpriority (0, 0, 0);]])],
279 [utils_cv_func_setpriority=yes],
280 [utils_cv_func_setpriority=no])])
281 if test $utils_cv_func_setpriority = no; then
282 AC_CHECK_FUNCS([nice])
284 case $utils_cv_func_setpriority,$ac_cv_func_nice in
286 gl_ADD_PROG([optional_bin_progs], [nice])
289 AC_DEFUN([coreutils_DUMMY_1],
291 AC_REQUIRE([gl_READUTMP])
292 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
293 gl_ADD_PROG([optional_bin_progs], [who])
294 gl_ADD_PROG([optional_bin_progs], [users])
295 gl_ADD_PROG([optional_bin_progs], [pinky])
300 AC_MSG_CHECKING([ut_host in struct utmp])
301 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
302 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
303 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
304 [su_cv_func_ut_host_in_utmp=yes],
305 [su_cv_func_ut_host_in_utmp=no])])
306 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
307 if test $su_cv_func_ut_host_in_utmp = yes; then
309 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
312 if test -z "$have_ut_host"; then
313 AC_MSG_CHECKING([ut_host in struct utmpx])
314 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
315 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
316 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
317 [su_cv_func_ut_host_in_utmpx=yes],
318 [su_cv_func_ut_host_in_utmpx=no])])
319 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
320 if test $su_cv_func_ut_host_in_utmpx = yes; then
321 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
322 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
326 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
328 AC_SYS_POSIX_TERMIOS()
329 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
331 if test $ac_cv_sys_posix_termios = yes; then
332 gl_ADD_PROG([optional_bin_progs], [stty])
334 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
335 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
336 [AC_EGREP_CPP([yes], [#include <termios.h>
339 #endif], su_cv_sys_termios_needs_xopen_source=no,
340 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
344 #endif], su_cv_sys_termios_needs_xopen_source=yes,
345 su_cv_sys_termios_needs_xopen_source=no))])
346 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
347 test $su_cv_sys_termios_needs_xopen_source = yes &&
348 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
350 AC_MSG_CHECKING([c_line in struct termios])
351 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
352 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
353 #define _XOPEN_SOURCE
355 #include <sys/types.h>
356 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
357 [su_cv_sys_c_line_in_termios=yes],
358 [su_cv_sys_c_line_in_termios=no])])
359 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
360 test $su_cv_sys_c_line_in_termios = yes \
361 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
364 # FIXME: note that this macro appears above, too.
365 # I'm leaving it here for now. This whole thing needs to be modernized...
368 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
370 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
371 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
372 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
373 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
374 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
375 #ifdef WINSIZE_IN_PTEM
376 # include <sys/stream.h>
377 # include <sys/ptem.h>
379 #include <sys/ioctl.h>
381 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
382 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
383 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
384 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
386 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
387 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
388 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
392 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
394 #include <signal.h>])
398 # Build df only if there's a point to it.
399 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
400 gl_ADD_PROG([optional_bin_progs], [df])
403 # Limit stdbuf to ELF systems with GCC
404 AC_MSG_CHECKING([whether this is an ELF system])
405 AC_EGREP_CPP([yes], [#if __ELF__
407 #endif], [elf_sys=yes], [elf_sys=no])
408 AC_MSG_RESULT([$elf_sys])
409 if test "$elf_sys" = "yes" && \
410 test "$GCC" = "yes"; then
411 gl_ADD_PROG([optional_bin_progs], [stdbuf])
414 ############################################################################
416 dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
417 dnl Issue proper calls to the macros gl_INCLUDE_EXCLUDE_PROG and
418 dnl gl_ADD_PROG (updating $optional_bin_progs), and generate the list
419 dnl of coreutils programs to be built only upon explicit user request,
420 dnl saving that list in the $no_install_progs_default shell variable.
421 m4_include([m4/cu-progs.m4])
423 # Now that we know which programs will actually be built up, figure out
424 # which optional helper progs should be compiled.
425 optional_pkglib_progs=
426 case " $optional_bin_progs " in
427 *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
431 for p in $optional_bin_progs; do
432 # Change "ginstall.1" to "install.1" in $MAN.
433 test $p = ginstall && p=install
434 # Ignore the "[" program, since writing a portable make rule to
435 # generate its manpage is not practical.
436 dnl Use the autoconf-provided quadrigraph to represent "[",
437 dnl otherwise we will incur in dreadful quoting issues.
438 test x$p = x'@<:@' && continue
441 # Normalize whitespace.
444 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
445 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
446 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
447 AC_SUBST([OPTIONAL_BIN_PROGS])
448 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
449 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
451 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
453 ############################################################################
455 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
456 # translatable strings, we must use need-formatstring-macros here.
457 AM_GNU_GETTEXT([external], [need-formatstring-macros])
458 AM_GNU_GETTEXT_VERSION([0.18.1])
460 # For a test of uniq: it uses the $LOCALE_FR envvar.
469 gnulib-tests/Makefile