2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-2009 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 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 if test "$gl_gcc_warnings" = yes; then
60 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
61 AC_SUBST([WERROR_CFLAGS])
64 # This, $nw, is the list of warnings we disable.
65 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
66 nw="$nw -Waggregate-return" # anachronistic
67 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
68 nw="$nw -Wc++-compat" # We don't care about C++ compilers
69 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
70 nw="$nw -Wtraditional" # Warns on #elif which we use often
71 nw="$nw -Wcast-qual" # Too many warnings for now
72 nw="$nw -Wconversion" # Too many warnings for now
73 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
74 nw="$nw -Wsign-conversion" # Too many warnings for now
75 nw="$nw -Wtraditional-conversion" # Too many warnings for now
76 nw="$nw -Wunreachable-code" # Too many warnings for now
77 nw="$nw -Wpadded" # Our structs are not padded
78 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
79 nw="$nw -Wlogical-op" # any use of fwrite provokes this
80 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
81 nw="$nw -Wvla" # warnings in gettext.h
82 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
83 nw="$nw -Wswitch-enum" # Too many warnings for now
84 nw="$nw -Wswitch-default" # Too many warnings for now
85 # things I might fix soon:
86 nw="$nw -Wfloat-equal" # sort.c, seq.c
87 nw="$nw -Wmissing-format-attribute" # copy.c
88 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
89 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
90 nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
91 # ?? -Wstrict-overflow
93 gl_MANYWARN_ALL_GCC([ws])
94 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
98 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
99 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
100 gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
101 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
103 # In spite of excluding -Wlogical-op above, it is enabled, as of
104 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
105 gl_WARN_ADD([-Wno-logical-op])
107 gl_WARN_ADD([-fdiagnostics-show-option])
109 AC_SUBST([WARN_CFLAGS])
111 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
112 AC_DEFINE([_FORTIFY_SOURCE], [2],
113 [enable compile-time and run-time bounds-checking, and some warnings])
114 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
120 AC_CHECK_FUNCS([uname],
121 gl_ADD_PROG([optional_bin_progs], [uname]))
122 AC_CHECK_FUNCS([chroot],
123 gl_ADD_PROG([optional_bin_progs], [chroot]))
124 AC_CHECK_FUNCS([gethostid],
125 gl_ADD_PROG([optional_bin_progs], [hostid]))
129 AC_MSG_CHECKING([whether localtime caches TZ])
130 AC_CACHE_VAL([utils_cv_localtime_cache],
131 [if test x$ac_cv_func_tzset = xyes; then
132 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
136 extern char **environ;
140 for (to = from = environ; (*to = *from); from++)
141 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
146 time_t now = time ((time_t *) 0);
147 int hour_GMT0, hour_unset;
148 if (putenv ("TZ=GMT0") != 0)
150 hour_GMT0 = localtime (&now)->tm_hour;
152 hour_unset = localtime (&now)->tm_hour;
153 if (putenv ("TZ=PST8") != 0)
155 if (localtime (&now)->tm_hour == hour_GMT0)
158 if (localtime (&now)->tm_hour != hour_unset)
162 [utils_cv_localtime_cache=no],
163 [utils_cv_localtime_cache=yes],
164 [# If we have tzset, assume the worst when cross-compiling.
165 utils_cv_localtime_cache=yes])
167 # If we lack tzset, report that localtime does not cache TZ,
168 # since we can't invalidate the cache if we don't have tzset.
169 utils_cv_localtime_cache=no
171 AC_MSG_RESULT([$utils_cv_localtime_cache])
172 if test $utils_cv_localtime_cache = yes; then
173 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
176 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
177 AC_CHECK_FUNCS([initgroups])
178 if test $ac_cv_func_initgroups = no; then
179 AC_CHECK_LIB([os], [initgroups])
182 AC_CHECK_FUNCS([syslog])
183 if test $ac_cv_func_syslog = no; then
184 # syslog is not in the default libraries. See if it's in some other.
185 for lib in bsd socket inet; do
186 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
187 LIBS="$LIBS -l$lib"; break])
191 AC_CACHE_CHECK([for 3-argument setpriority function],
192 [utils_cv_func_setpriority],
195 [[#include <sys/time.h>
196 #include <sys/resource.h>
198 [[setpriority (0, 0, 0);]])],
199 [utils_cv_func_setpriority=yes],
200 [utils_cv_func_setpriority=no])])
201 if test $utils_cv_func_setpriority = no; then
202 AC_CHECK_FUNCS([nice])
204 case $utils_cv_func_setpriority,$ac_cv_func_nice in
206 gl_ADD_PROG([optional_bin_progs], [nice])
209 AC_DEFUN([coreutils_DUMMY_1],
211 AC_REQUIRE([gl_READUTMP])
212 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
213 gl_ADD_PROG([optional_bin_progs], [who])
214 gl_ADD_PROG([optional_bin_progs], [users])
215 gl_ADD_PROG([optional_bin_progs], [pinky])
220 AC_MSG_CHECKING([ut_host in struct utmp])
221 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
222 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
223 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
224 [su_cv_func_ut_host_in_utmp=yes],
225 [su_cv_func_ut_host_in_utmp=no])])
226 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
227 if test $su_cv_func_ut_host_in_utmp = yes; then
229 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
232 if test -z "$have_ut_host"; then
233 AC_MSG_CHECKING([ut_host in struct utmpx])
234 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
235 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
236 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
237 [su_cv_func_ut_host_in_utmpx=yes],
238 [su_cv_func_ut_host_in_utmpx=no])])
239 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
240 if test $su_cv_func_ut_host_in_utmpx = yes; then
241 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
242 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
246 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
248 AC_SYS_POSIX_TERMIOS()
249 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
251 if test $ac_cv_sys_posix_termios = yes; then
252 gl_ADD_PROG([optional_bin_progs], [stty])
254 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
255 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
256 [AC_EGREP_CPP([yes], [#include <termios.h>
259 #endif], su_cv_sys_termios_needs_xopen_source=no,
260 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
264 #endif], su_cv_sys_termios_needs_xopen_source=yes,
265 su_cv_sys_termios_needs_xopen_source=no))])
266 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
267 test $su_cv_sys_termios_needs_xopen_source = yes &&
268 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
270 AC_MSG_CHECKING([c_line in struct termios])
271 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
272 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
273 #define _XOPEN_SOURCE
275 #include <sys/types.h>
276 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
277 [su_cv_sys_c_line_in_termios=yes],
278 [su_cv_sys_c_line_in_termios=no])])
279 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
280 test $su_cv_sys_c_line_in_termios = yes \
281 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
284 # FIXME: note that this macro appears above, too.
285 # I'm leaving it here for now. This whole thing needs to be modernized...
288 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
290 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
291 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
292 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
293 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
294 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
295 #ifdef WINSIZE_IN_PTEM
296 # include <sys/stream.h>
297 # include <sys/ptem.h>
299 #include <sys/ioctl.h>
301 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
302 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
303 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
304 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
306 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
307 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
308 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
312 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
314 #include <signal.h>])
319 # Build df only if there's a point to it.
320 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
321 gl_ADD_PROG([optional_bin_progs], [df])
324 ############################################################################
325 mk="$srcdir/src/Makefile.am"
326 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
327 # in $mk but don't expand the variable references.
328 # Append each literal name to $optional_bin_progs.
330 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
331 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
332 | tr -s '\\015\\012\\\\' ' '`; do
333 gl_ADD_PROG([optional_bin_progs], $gl_i)
336 # As above, extract literal names from the definition of $(no_install__progs)
337 # in $mk but don't expand the variable references.
339 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
340 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
341 | tr -s '\\015\\012\\\\' ' '`
342 # Remove any trailing space.
343 no_install_progs_default=`echo "$t"|sed 's/ $//'`
345 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
346 # of default-not-installed programs, "arch hostname su", must appear in two
347 # places: in this file below, and in $mk. Using "$no_install_progs_default"
348 # below cannot work. And we can't substitute the names into $mk because
349 # automake needs the literals, too.
350 # The compromise is to ensure that the space-separated list extracted
351 # above matches the literal 2nd argument below.
352 c="$srcdir/configure.ac"
353 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
354 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
357 $no_install_progs_default) ;;
358 *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
359 does not match the list of default-not-installed programs
360 ($no_install_progs_default) also recorded in $mk]],
364 # Given the name of a variable containing a space-separated list of
365 # install-by-default programs and the actual list do-not-install-by-default
366 # programs, modify the former variable to reflect any "do-install" and
367 # "don't-install" requests.
368 # I.e., add any program name specified via --enable-install-program=..., and
369 # remove any program name specified via --enable-no-install-program=...
370 # Note how the second argument below is a literal, with "," separators.
371 # That is required due to the way the macro works, and since the
372 # corresponding ./configure option argument is comma-separated on input.
373 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
375 # Set INSTALL_SU if su installation has been requested via
376 # --enable-install-program=su.
377 AC_SUBST([INSTALL_SU])
378 case " $optional_bin_progs " in
379 *' su '*) INSTALL_SU=yes ;;
383 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
385 # Change ginstall.1 to "install.h" in $MAN.
386 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
387 | tr '\015\012' ' '; echo`
389 # Remove [.1, since writing a portable rule for it in man/Makefile.am
390 # is not practical. The sed LHS below uses the autoconf quadrigraph
392 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
394 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
395 AC_SUBST([OPTIONAL_BIN_PROGS])
396 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
397 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
399 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
401 # Arrange to rerun configure whenever the file, src/Makefile.am,
402 # containing the list of program names changes.
403 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
404 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
405 ############################################################################
407 AM_GNU_GETTEXT([external], [need-formatstring-macros])
408 AM_GNU_GETTEXT_VERSION([0.15])
410 # For a test of uniq: it uses the $LOCALE_FR envvar.
421 gnulib-tests/Makefile