2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-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.
41 AC_PROG_GCC_TRADITIONAL
48 AC_ARG_ENABLE([gcc-warnings],
49 [AS_HELP_STRING([--enable-gcc-warnings],
50 [turn on lots of GCC warnings (for developers)])],
53 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
55 gl_gcc_warnings=$enableval],
59 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
60 # ------------------------------------------------
61 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
62 # Otherwise, run RUN-IF-NOT-FOUND.
63 AC_DEFUN([gl_GCC_VERSION_IFELSE],
67 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
70 # error "your version of gcc is older than $1.$2"
77 if test "$gl_gcc_warnings" = yes; then
78 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
79 AC_SUBST([WERROR_CFLAGS])
82 # This, $nw, is the list of warnings we disable.
83 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
84 nw="$nw -Waggregate-return" # anachronistic
85 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
86 nw="$nw -Wc++-compat" # We don't care about C++ compilers
87 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
88 nw="$nw -Wtraditional" # Warns on #elif which we use often
89 nw="$nw -Wcast-qual" # Too many warnings for now
90 nw="$nw -Wconversion" # Too many warnings for now
91 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
92 nw="$nw -Wsign-conversion" # Too many warnings for now
93 nw="$nw -Wtraditional-conversion" # Too many warnings for now
94 nw="$nw -Wunreachable-code" # Too many warnings for now
95 nw="$nw -Wpadded" # Our structs are not padded
96 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
97 nw="$nw -Wlogical-op" # any use of fwrite provokes this
98 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
99 nw="$nw -Wvla" # warnings in gettext.h
100 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
101 nw="$nw -Wswitch-enum" # Too many warnings for now
102 nw="$nw -Wswitch-default" # Too many warnings for now
103 nw="$nw -Wstack-protector" # not worth working around
104 # things I might fix soon:
105 nw="$nw -Wfloat-equal" # sort.c, seq.c
106 nw="$nw -Wmissing-format-attribute" # copy.c
107 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
108 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
110 # Using -Wstrict-overflow is a pain, but the alternative is worse.
111 # For an example, see the code that provoked this report:
112 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
113 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
115 gl_MANYWARN_ALL_GCC([ws])
116 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
120 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
121 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
122 gl_WARN_ADD([-Wsuggest-attribute=const])
123 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
124 gl_WARN_ADD([-Wno-format-nonliteral])
126 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
127 # it suggests test.c's advance function may be pure, even though it
128 # increments a global variable. Oops.
129 # Normally we'd write code to test for the precise failure, but that
130 # requires a relatively large input to make gcc exhibit the failure.
131 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
133 # In spite of excluding -Wlogical-op above, it is enabled, as of
134 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
135 gl_WARN_ADD([-Wno-logical-op])
137 gl_WARN_ADD([-fdiagnostics-show-option])
138 gl_WARN_ADD([-funit-at-a-time])
140 AC_SUBST([WARN_CFLAGS])
142 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
143 AC_DEFINE([_FORTIFY_SOURCE], [2],
144 [enable compile-time and run-time bounds-checking, and some warnings])
145 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
147 # We use a slightly smaller set of warning options for lib/.
148 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
150 nw="$nw -Wstrict-overflow"
151 nw="$nw -Wuninitialized"
152 nw="$nw -Wunused-macros"
153 nw="$nw -Wmissing-prototypes"
154 nw="$nw -Wold-style-definition"
155 # FIXME: it may be easy to remove this, since it affects only one file:
156 # the snprintf call at ftoastr.c:132.
157 nw="$nw -Wdouble-promotion"
158 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
159 AC_SUBST([GNULIB_WARN_CFLAGS])
161 # For gnulib-tests, the set is slightly smaller still.
163 nw="$nw -Wstrict-prototypes"
164 # It's not worth being this picky about test programs.
165 nw="$nw -Wsuggest-attribute=const"
166 nw="$nw -Wsuggest-attribute=pure"
167 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
168 [$GNULIB_WARN_CFLAGS], [$nw])
169 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
175 AC_CHECK_FUNCS([chroot],
176 gl_ADD_PROG([optional_bin_progs], [chroot]))
177 AC_CHECK_FUNCS([gethostid],
178 gl_ADD_PROG([optional_bin_progs], [hostid]))
182 AC_MSG_CHECKING([whether localtime caches TZ])
183 AC_CACHE_VAL([utils_cv_localtime_cache],
184 [if test x$ac_cv_func_tzset = xyes; then
185 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
189 extern char **environ;
193 for (to = from = environ; (*to = *from); from++)
194 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
199 time_t now = time ((time_t *) 0);
200 int hour_GMT0, hour_unset;
201 if (putenv ("TZ=GMT0") != 0)
203 hour_GMT0 = localtime (&now)->tm_hour;
205 hour_unset = localtime (&now)->tm_hour;
206 if (putenv ("TZ=PST8") != 0)
208 if (localtime (&now)->tm_hour == hour_GMT0)
211 if (localtime (&now)->tm_hour != hour_unset)
215 [utils_cv_localtime_cache=no],
216 [utils_cv_localtime_cache=yes],
217 [# If we have tzset, assume the worst when cross-compiling.
218 utils_cv_localtime_cache=yes])
220 # If we lack tzset, report that localtime does not cache TZ,
221 # since we can't invalidate the cache if we don't have tzset.
222 utils_cv_localtime_cache=no
224 AC_MSG_RESULT([$utils_cv_localtime_cache])
225 if test $utils_cv_localtime_cache = yes; then
226 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
229 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
230 AC_CHECK_FUNCS([initgroups])
231 if test $ac_cv_func_initgroups = no; then
232 AC_CHECK_LIB([os], [initgroups])
235 AC_CHECK_FUNCS([syslog])
236 if test $ac_cv_func_syslog = no; then
237 # syslog is not in the default libraries. See if it's in some other.
238 for lib in bsd socket inet; do
239 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
240 LIBS="$LIBS -l$lib"; break])
244 AC_CACHE_CHECK([for 3-argument setpriority function],
245 [utils_cv_func_setpriority],
248 [[#include <sys/time.h>
249 #include <sys/resource.h>
251 [[setpriority (0, 0, 0);]])],
252 [utils_cv_func_setpriority=yes],
253 [utils_cv_func_setpriority=no])])
254 if test $utils_cv_func_setpriority = no; then
255 AC_CHECK_FUNCS([nice])
257 case $utils_cv_func_setpriority,$ac_cv_func_nice in
259 gl_ADD_PROG([optional_bin_progs], [nice])
262 AC_DEFUN([coreutils_DUMMY_1],
264 AC_REQUIRE([gl_READUTMP])
265 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
266 gl_ADD_PROG([optional_bin_progs], [who])
267 gl_ADD_PROG([optional_bin_progs], [users])
268 gl_ADD_PROG([optional_bin_progs], [pinky])
273 AC_MSG_CHECKING([ut_host in struct utmp])
274 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
275 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
276 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
277 [su_cv_func_ut_host_in_utmp=yes],
278 [su_cv_func_ut_host_in_utmp=no])])
279 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
280 if test $su_cv_func_ut_host_in_utmp = yes; then
282 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
285 if test -z "$have_ut_host"; then
286 AC_MSG_CHECKING([ut_host in struct utmpx])
287 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
288 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
289 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
290 [su_cv_func_ut_host_in_utmpx=yes],
291 [su_cv_func_ut_host_in_utmpx=no])])
292 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
293 if test $su_cv_func_ut_host_in_utmpx = yes; then
294 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
295 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
299 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
301 AC_SYS_POSIX_TERMIOS()
302 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
304 if test $ac_cv_sys_posix_termios = yes; then
305 gl_ADD_PROG([optional_bin_progs], [stty])
307 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
308 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
309 [AC_EGREP_CPP([yes], [#include <termios.h>
312 #endif], su_cv_sys_termios_needs_xopen_source=no,
313 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
317 #endif], su_cv_sys_termios_needs_xopen_source=yes,
318 su_cv_sys_termios_needs_xopen_source=no))])
319 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
320 test $su_cv_sys_termios_needs_xopen_source = yes &&
321 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
323 AC_MSG_CHECKING([c_line in struct termios])
324 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
325 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
326 #define _XOPEN_SOURCE
328 #include <sys/types.h>
329 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
330 [su_cv_sys_c_line_in_termios=yes],
331 [su_cv_sys_c_line_in_termios=no])])
332 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
333 test $su_cv_sys_c_line_in_termios = yes \
334 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
337 # FIXME: note that this macro appears above, too.
338 # I'm leaving it here for now. This whole thing needs to be modernized...
341 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
343 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
344 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
345 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
346 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
347 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
348 #ifdef WINSIZE_IN_PTEM
349 # include <sys/stream.h>
350 # include <sys/ptem.h>
352 #include <sys/ioctl.h>
354 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
355 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
356 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
357 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
359 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
360 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
361 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
365 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
367 #include <signal.h>])
372 # Build df only if there's a point to it.
373 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
374 gl_ADD_PROG([optional_bin_progs], [df])
377 # Limit stdbuf to ELF systems with GCC
378 AC_MSG_CHECKING([whether this is an ELF system])
379 AC_EGREP_CPP([yes], [#if __ELF__
381 #endif], [elf_sys=yes], [elf_sys=no])
382 AC_MSG_RESULT([$elf_sys])
383 if test "$elf_sys" = "yes" && \
384 test "$GCC" = "yes"; then
385 gl_ADD_PROG([optional_bin_progs], [stdbuf])
388 ############################################################################
389 mk="$srcdir/src/Makefile.am"
390 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
391 # in $mk but don't expand the variable references.
392 # Append each literal name to $optional_bin_progs.
394 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
395 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
396 | tr -s '\\015\\012\\\\' ' '`; do
397 gl_ADD_PROG([optional_bin_progs], $gl_i)
400 # As above, extract literal names from the definition of $(no_install__progs)
401 # in $mk but don't expand the variable references.
403 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
404 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
405 | tr -s '\\015\\012\\\\' ' '`
406 # Remove any trailing space.
407 no_install_progs_default=`echo "$t"|sed 's/ $//'`
409 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
410 # of default-not-installed programs, "arch hostname su", must appear in two
411 # places: in this file below, and in $mk. Using "$no_install_progs_default"
412 # below cannot work. And we can't substitute the names into $mk because
413 # automake needs the literals, too.
414 # The compromise is to ensure that the space-separated list extracted
415 # above matches the literal 2nd argument below.
416 c="$srcdir/configure.ac"
417 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
418 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
421 $no_install_progs_default) ;;
422 *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
423 does not match the list of default-not-installed programs
424 ($no_install_progs_default) also recorded in $mk]],
428 # Given the name of a variable containing a space-separated list of
429 # install-by-default programs and the actual list do-not-install-by-default
430 # programs, modify the former variable to reflect any "do-install" and
431 # "don't-install" requests.
432 # I.e., add any program name specified via --enable-install-program=..., and
433 # remove any program name specified via --enable-no-install-program=...
434 # Note how the second argument below is a literal, with "," separators.
435 # That is required due to the way the macro works, and since the
436 # corresponding ./configure option argument is comma-separated on input.
437 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
439 # Now that we know which programs will actually be built up, figure out
440 # which optional helper progs should be compiled.
441 optional_pkglib_progs=
442 case " $optional_bin_progs " in
443 *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
446 # Set INSTALL_SU if su installation has been requested via
447 # --enable-install-program=su.
448 AC_SUBST([INSTALL_SU])
449 case " $optional_bin_progs " in
450 *' su '*) INSTALL_SU=yes ;;
454 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
456 # Change "ginstall.1" to "install.1" in $MAN.
457 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
458 | tr '\015\012' ' '; echo`
460 # Remove [.1, since writing a portable rule for it in man/Makefile.am
461 # is not practical. The sed LHS below uses the autoconf quadrigraph
463 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
465 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
466 AC_SUBST([OPTIONAL_BIN_PROGS])
467 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
468 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
469 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
470 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
472 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
474 # Arrange to rerun configure whenever the file, src/Makefile.am,
475 # containing the list of program names changes.
476 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
477 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
478 ############################################################################
480 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
481 # translatable strings, we must use need-formatstring-macros here.
482 AM_GNU_GETTEXT([external], [need-formatstring-macros])
483 AM_GNU_GETTEXT_VERSION([0.18.1])
485 # For a test of uniq: it uses the $LOCALE_FR envvar.
496 gnulib-tests/Makefile