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.1 no-dist-gzip dist-xz color-tests parallel-tests])
36 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
38 dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
39 dnl (more than 10% execution time) to ./configure, with no benefit for
40 dnl most users. Using it to look for bugs requires:
41 dnl GNULIB_POSIXCHECK=1 autoreconf -f
45 dnl make CFLAGS=-DGNULIB_POSIXCHECK=1
46 dnl FIXME: Once we figure out how to avoid false positives, we should
47 dnl have 'make my-distcheck' in dist-check.mk exercise this.
48 m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
49 m4_if(m4_sysval, [0], [], [dnl
50 gl_ASSERT_NO_GNULIB_POSIXCHECK])
55 AC_PROG_GCC_TRADITIONAL
62 AC_ARG_ENABLE([gcc-warnings],
63 [AS_HELP_STRING([--enable-gcc-warnings],
64 [turn on lots of GCC warnings (for developers)])],
67 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
69 gl_gcc_warnings=$enableval],
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],
81 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
84 # error "your version of gcc is older than $1.$2"
91 if test "$gl_gcc_warnings" = yes; then
92 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
93 AC_SUBST([WERROR_CFLAGS])
96 # This, $nw, is the list of warnings we disable.
97 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
98 nw="$nw -Waggregate-return" # anachronistic
99 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
100 nw="$nw -Wc++-compat" # We don't care about C++ compilers
101 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
102 nw="$nw -Wtraditional" # Warns on #elif which we use often
103 nw="$nw -Wcast-qual" # Too many warnings for now
104 nw="$nw -Wconversion" # Too many warnings for now
105 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
106 nw="$nw -Wsign-conversion" # Too many warnings for now
107 nw="$nw -Wtraditional-conversion" # Too many warnings for now
108 nw="$nw -Wunreachable-code" # Too many warnings for now
109 nw="$nw -Wpadded" # Our structs are not padded
110 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
111 nw="$nw -Wlogical-op" # any use of fwrite provokes this
112 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
113 nw="$nw -Wvla" # warnings in gettext.h
114 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
115 nw="$nw -Wswitch-enum" # Too many warnings for now
116 nw="$nw -Wswitch-default" # Too many warnings for now
117 nw="$nw -Wstack-protector" # not worth working around
118 # things I might fix soon:
119 nw="$nw -Wfloat-equal" # sort.c, seq.c
120 nw="$nw -Wmissing-format-attribute" # copy.c
121 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
122 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
124 # Using -Wstrict-overflow is a pain, but the alternative is worse.
125 # For an example, see the code that provoked this report:
126 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
127 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
129 gl_MANYWARN_ALL_GCC([ws])
130 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
134 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
135 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
136 gl_WARN_ADD([-Wsuggest-attribute=const])
137 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
138 gl_WARN_ADD([-Wno-format-nonliteral])
140 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
141 # it suggests test.c's advance function may be pure, even though it
142 # increments a global variable. Oops.
143 # Normally we'd write code to test for the precise failure, but that
144 # requires a relatively large input to make gcc exhibit the failure.
145 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
147 # In spite of excluding -Wlogical-op above, it is enabled, as of
148 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
149 gl_WARN_ADD([-Wno-logical-op])
151 gl_WARN_ADD([-fdiagnostics-show-option])
152 gl_WARN_ADD([-funit-at-a-time])
154 AC_SUBST([WARN_CFLAGS])
156 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
157 AC_DEFINE([_FORTIFY_SOURCE], [2],
158 [enable compile-time and run-time bounds-checking, and some warnings])
159 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
161 # We use a slightly smaller set of warning options for lib/.
162 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
164 nw="$nw -Wstrict-overflow"
165 nw="$nw -Wuninitialized"
166 nw="$nw -Wunused-macros"
167 nw="$nw -Wmissing-prototypes"
168 nw="$nw -Wold-style-definition"
169 # FIXME: it may be easy to remove this, since it affects only one file:
170 # the snprintf call at ftoastr.c:132.
171 nw="$nw -Wdouble-promotion"
172 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
173 AC_SUBST([GNULIB_WARN_CFLAGS])
175 # For gnulib-tests, the set is slightly smaller still.
177 nw="$nw -Wstrict-prototypes"
178 # It's not worth being this picky about test programs.
179 nw="$nw -Wsuggest-attribute=const"
180 nw="$nw -Wsuggest-attribute=pure"
181 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
182 [$GNULIB_WARN_CFLAGS], [$nw])
183 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
189 AC_CHECK_FUNCS([chroot],
190 gl_ADD_PROG([optional_bin_progs], [chroot]))
191 AC_CHECK_FUNCS([gethostid],
192 gl_ADD_PROG([optional_bin_progs], [hostid]))
196 AC_MSG_CHECKING([whether localtime caches TZ])
197 AC_CACHE_VAL([utils_cv_localtime_cache],
198 [if test x$ac_cv_func_tzset = xyes; then
199 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
203 extern char **environ;
207 for (to = from = environ; (*to = *from); from++)
208 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
213 time_t now = time ((time_t *) 0);
214 int hour_GMT0, hour_unset;
215 if (putenv ("TZ=GMT0") != 0)
217 hour_GMT0 = localtime (&now)->tm_hour;
219 hour_unset = localtime (&now)->tm_hour;
220 if (putenv ("TZ=PST8") != 0)
222 if (localtime (&now)->tm_hour == hour_GMT0)
225 if (localtime (&now)->tm_hour != hour_unset)
229 [utils_cv_localtime_cache=no],
230 [utils_cv_localtime_cache=yes],
231 [# If we have tzset, assume the worst when cross-compiling.
232 utils_cv_localtime_cache=yes])
234 # If we lack tzset, report that localtime does not cache TZ,
235 # since we can't invalidate the cache if we don't have tzset.
236 utils_cv_localtime_cache=no
238 AC_MSG_RESULT([$utils_cv_localtime_cache])
239 if test $utils_cv_localtime_cache = yes; then
240 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
243 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
244 AC_CHECK_FUNCS([initgroups])
245 if test $ac_cv_func_initgroups = no; then
246 AC_CHECK_LIB([os], [initgroups])
249 AC_CHECK_FUNCS([syslog])
250 if test $ac_cv_func_syslog = no; then
251 # syslog is not in the default libraries. See if it's in some other.
252 for lib in bsd socket inet; do
253 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
254 LIBS="$LIBS -l$lib"; break])
258 AC_CACHE_CHECK([for 3-argument setpriority function],
259 [utils_cv_func_setpriority],
262 [[#include <sys/time.h>
263 #include <sys/resource.h>
265 [[setpriority (0, 0, 0);]])],
266 [utils_cv_func_setpriority=yes],
267 [utils_cv_func_setpriority=no])])
268 if test $utils_cv_func_setpriority = no; then
269 AC_CHECK_FUNCS([nice])
271 case $utils_cv_func_setpriority,$ac_cv_func_nice in
273 gl_ADD_PROG([optional_bin_progs], [nice])
276 AC_DEFUN([coreutils_DUMMY_1],
278 AC_REQUIRE([gl_READUTMP])
279 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
280 gl_ADD_PROG([optional_bin_progs], [who])
281 gl_ADD_PROG([optional_bin_progs], [users])
282 gl_ADD_PROG([optional_bin_progs], [pinky])
287 AC_MSG_CHECKING([ut_host in struct utmp])
288 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
289 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
290 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
291 [su_cv_func_ut_host_in_utmp=yes],
292 [su_cv_func_ut_host_in_utmp=no])])
293 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
294 if test $su_cv_func_ut_host_in_utmp = yes; then
296 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
299 if test -z "$have_ut_host"; then
300 AC_MSG_CHECKING([ut_host in struct utmpx])
301 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
302 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
303 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
304 [su_cv_func_ut_host_in_utmpx=yes],
305 [su_cv_func_ut_host_in_utmpx=no])])
306 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
307 if test $su_cv_func_ut_host_in_utmpx = yes; then
308 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
309 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
313 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
315 AC_SYS_POSIX_TERMIOS()
316 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
318 if test $ac_cv_sys_posix_termios = yes; then
319 gl_ADD_PROG([optional_bin_progs], [stty])
321 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
322 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
323 [AC_EGREP_CPP([yes], [#include <termios.h>
326 #endif], su_cv_sys_termios_needs_xopen_source=no,
327 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
331 #endif], su_cv_sys_termios_needs_xopen_source=yes,
332 su_cv_sys_termios_needs_xopen_source=no))])
333 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
334 test $su_cv_sys_termios_needs_xopen_source = yes &&
335 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
337 AC_MSG_CHECKING([c_line in struct termios])
338 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
339 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
340 #define _XOPEN_SOURCE
342 #include <sys/types.h>
343 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
344 [su_cv_sys_c_line_in_termios=yes],
345 [su_cv_sys_c_line_in_termios=no])])
346 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
347 test $su_cv_sys_c_line_in_termios = yes \
348 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
351 # FIXME: note that this macro appears above, too.
352 # I'm leaving it here for now. This whole thing needs to be modernized...
355 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
357 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
358 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
359 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
360 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
361 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
362 #ifdef WINSIZE_IN_PTEM
363 # include <sys/stream.h>
364 # include <sys/ptem.h>
366 #include <sys/ioctl.h>
368 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
369 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
370 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
371 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
373 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
374 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
375 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
379 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
381 #include <signal.h>])
385 # Build df only if there's a point to it.
386 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
387 gl_ADD_PROG([optional_bin_progs], [df])
390 # Limit stdbuf to ELF systems with GCC
391 AC_MSG_CHECKING([whether this is an ELF system])
392 AC_EGREP_CPP([yes], [#if __ELF__
394 #endif], [elf_sys=yes], [elf_sys=no])
395 AC_MSG_RESULT([$elf_sys])
396 if test "$elf_sys" = "yes" && \
397 test "$GCC" = "yes"; then
398 gl_ADD_PROG([optional_bin_progs], [stdbuf])
401 ############################################################################
402 mk="$srcdir/src/Makefile.am"
403 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
404 # in $mk but don't expand the variable references.
405 # Append each literal name to $optional_bin_progs.
407 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
408 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
409 | tr -s '\\015\\012\\\\' ' '`; do
410 gl_ADD_PROG([optional_bin_progs], $gl_i)
413 # As above, extract literal names from the definition of $(no_install__progs)
414 # in $mk but don't expand the variable references.
416 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
417 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
418 | tr -s '\\015\\012\\\\' ' '`
419 # Remove any trailing space.
420 no_install_progs_default=`echo "$t"|sed 's/ $//'`
422 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
423 # of default-not-installed programs, "arch hostname", must appear in two
424 # places: in this file below, and in $mk. Using "$no_install_progs_default"
425 # below cannot work. And we can't substitute the names into $mk because
426 # automake needs the literals, too.
427 # The compromise is to ensure that the space-separated list extracted
428 # above matches the literal 2nd argument below.
429 c="$srcdir/configure.ac"
430 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
431 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
434 $no_install_progs_default) ;;
435 *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
436 does not match the list of default-not-installed programs
437 ($no_install_progs_default) also recorded in $mk]],
441 # Given the name of a variable containing a space-separated list of
442 # install-by-default programs and the actual list do-not-install-by-default
443 # programs, modify the former variable to reflect any "do-install" and
444 # "don't-install" requests.
445 # I.e., add any program name specified via --enable-install-program=..., and
446 # remove any program name specified via --enable-no-install-program=...
447 # Note how the second argument below is a literal, with "," separators.
448 # That is required due to the way the macro works, and since the
449 # corresponding ./configure option argument is comma-separated on input.
450 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname])
452 # Now that we know which programs will actually be built up, figure out
453 # which optional helper progs should be compiled.
454 optional_pkglib_progs=
455 case " $optional_bin_progs " in
456 *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
459 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
461 # Change "ginstall.1" to "install.1" in $MAN.
462 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
463 | tr '\015\012' ' '; echo`
465 # Remove [.1, since writing a portable rule for it in man/Makefile.am
466 # is not practical. The sed LHS below uses the autoconf quadrigraph
468 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
470 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
471 AC_SUBST([OPTIONAL_BIN_PROGS])
472 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
473 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
474 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
475 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
477 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
479 # Arrange to rerun configure whenever the file, src/Makefile.am,
480 # containing the list of program names changes.
481 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
482 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
483 ############################################################################
485 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
486 # translatable strings, we must use need-formatstring-macros here.
487 AM_GNU_GETTEXT([external], [need-formatstring-macros])
488 AM_GNU_GETTEXT_VERSION([0.18.1])
490 # For a test of uniq: it uses the $LOCALE_FR envvar.
501 gnulib-tests/Makefile