2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-2008 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.10a dist-xz])
40 AC_PROG_GCC_TRADITIONAL
47 AC_ARG_ENABLE([gcc-warnings],
48 [AS_HELP_STRING([--enable-gcc-warnings],
49 [turn on lots of GCC warnings (not recommended)])],
52 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
54 gl_gcc_warnings=$enableval],
58 if test "$gl_gcc_warnings" = yes; then
59 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
60 AC_SUBST([WERROR_CFLAGS])
62 gl_WARN_ADD([-Wextra])
63 gl_WARN_ADD([-Wshadow])
64 gl_WARN_ADD([-Wno-sign-compare])
65 gl_WARN_ADD([-Wformat])
66 gl_WARN_ADD([-Wformat-security])
67 gl_WARN_ADD([-Wcast-align])
68 gl_WARN_ADD([-Wpointer-arith])
69 gl_WARN_ADD([-Wwrite-strings])
70 gl_WARN_ADD([-Wbad-function-cast])
71 gl_WARN_ADD([-Wmissing-declarations])
72 gl_WARN_ADD([-Wmissing-prototypes])
73 gl_WARN_ADD([-Wstrict-prototypes])
74 AC_SUBST([WARN_CFLAGS])
75 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
76 AC_DEFINE([_FORTIFY_SOURCE], [2],
77 [enable compile-time and run-time bounds-checking, and some warnings])
83 AC_CHECK_FUNCS([uname],
84 gl_ADD_PROG([optional_bin_progs], [uname]))
85 AC_CHECK_FUNCS([chroot],
86 gl_ADD_PROG([optional_bin_progs], [chroot]))
87 AC_CHECK_FUNCS([gethostid],
88 gl_ADD_PROG([optional_bin_progs], [hostid]))
92 AC_MSG_CHECKING([whether localtime caches TZ])
93 AC_CACHE_VAL([utils_cv_localtime_cache],
94 [if test x$ac_cv_func_tzset = xyes; then
95 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
99 extern char **environ;
103 for (to = from = environ; (*to = *from); from++)
104 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
109 time_t now = time ((time_t *) 0);
110 int hour_GMT0, hour_unset;
111 if (putenv ("TZ=GMT0") != 0)
113 hour_GMT0 = localtime (&now)->tm_hour;
115 hour_unset = localtime (&now)->tm_hour;
116 if (putenv ("TZ=PST8") != 0)
118 if (localtime (&now)->tm_hour == hour_GMT0)
121 if (localtime (&now)->tm_hour != hour_unset)
125 [utils_cv_localtime_cache=no],
126 [utils_cv_localtime_cache=yes],
127 [# If we have tzset, assume the worst when cross-compiling.
128 utils_cv_localtime_cache=yes])
130 # If we lack tzset, report that localtime does not cache TZ,
131 # since we can't invalidate the cache if we don't have tzset.
132 utils_cv_localtime_cache=no
134 AC_MSG_RESULT([$utils_cv_localtime_cache])
135 if test $utils_cv_localtime_cache = yes; then
136 AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
139 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
140 AC_CHECK_FUNCS([initgroups])
141 if test $ac_cv_func_initgroups = no; then
142 AC_CHECK_LIB([os], [initgroups])
145 AC_CHECK_FUNCS([syslog])
146 if test $ac_cv_func_syslog = no; then
147 # syslog is not in the default libraries. See if it's in some other.
148 for lib in bsd socket inet; do
149 AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
150 LIBS="$LIBS -l$lib"; break])
154 AC_CACHE_CHECK([for 3-argument setpriority function],
155 [utils_cv_func_setpriority],
158 [[#include <sys/time.h>
159 #include <sys/resource.h>
161 [[setpriority (0, 0, 0);]])],
162 [utils_cv_func_setpriority=yes],
163 [utils_cv_func_setpriority=no])])
164 if test $utils_cv_func_setpriority = no; then
165 AC_CHECK_FUNCS([nice])
167 case $utils_cv_func_setpriority,$ac_cv_func_nice in
169 gl_ADD_PROG([optional_bin_progs], [nice])
172 AC_DEFUN([coreutils_DUMMY_1],
174 AC_REQUIRE([gl_READUTMP])
175 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
176 gl_ADD_PROG([optional_bin_progs], [who])
177 gl_ADD_PROG([optional_bin_progs], [users])
178 gl_ADD_PROG([optional_bin_progs], [pinky])
183 AC_MSG_CHECKING([ut_host in struct utmp])
184 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
185 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
186 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
187 [su_cv_func_ut_host_in_utmp=yes],
188 [su_cv_func_ut_host_in_utmp=no])])
189 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
190 if test $su_cv_func_ut_host_in_utmp = yes; then
192 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
195 if test -z "$have_ut_host"; then
196 AC_MSG_CHECKING([ut_host in struct utmpx])
197 AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
198 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
199 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
200 [su_cv_func_ut_host_in_utmpx=yes],
201 [su_cv_func_ut_host_in_utmpx=no])])
202 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
203 if test $su_cv_func_ut_host_in_utmpx = yes; then
204 AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
205 AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
209 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
211 AC_SYS_POSIX_TERMIOS()
212 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
214 if test $ac_cv_sys_posix_termios = yes; then
215 gl_ADD_PROG([optional_bin_progs], [stty])
217 AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
218 AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
219 [AC_EGREP_CPP([yes], [#include <termios.h>
222 #endif], su_cv_sys_termios_needs_xopen_source=no,
223 AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
227 #endif], su_cv_sys_termios_needs_xopen_source=yes,
228 su_cv_sys_termios_needs_xopen_source=no))])
229 AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
230 test $su_cv_sys_termios_needs_xopen_source = yes &&
231 AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
233 AC_MSG_CHECKING([c_line in struct termios])
234 AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
235 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
236 #define _XOPEN_SOURCE
238 #include <sys/types.h>
239 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
240 [su_cv_sys_c_line_in_termios=yes],
241 [su_cv_sys_c_line_in_termios=no])])
242 AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
243 test $su_cv_sys_c_line_in_termios = yes \
244 && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
247 # FIXME: note that this macro appears above, too.
248 # I'm leaving it here for now. This whole thing needs to be modernized...
251 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
253 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
254 test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
255 AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
256 AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
257 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
258 #ifdef WINSIZE_IN_PTEM
259 # include <sys/stream.h>
260 # include <sys/ptem.h>
262 #include <sys/ioctl.h>
264 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
265 [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
266 [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
267 AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
269 test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
270 && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
271 [Define if your system defines TIOCGWINSZ in sys/pty.h.])
275 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
277 #include <signal.h>])
282 # Build df only if there's a point to it.
283 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
284 gl_ADD_PROG([optional_bin_progs], [df])
287 ############################################################################
288 mk="$srcdir/src/Makefile.am"
289 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
290 # in $mk but don't expand the variable references.
291 # Append each literal name to $optional_bin_progs.
293 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
294 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
295 | tr -s '\\015\\012\\\\' ' '`; do
296 gl_ADD_PROG([optional_bin_progs], $gl_i)
299 # As above, extract literal names from the definition of $(no_install__progs)
300 # in $mk but don't expand the variable references.
302 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
303 | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
304 | tr -s '\\015\\012\\\\' ' '`
305 # Remove any trailing space.
306 no_install_progs_default=`echo "$t"|sed 's/ $//'`
308 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
309 # of default-not-installed programs, "arch hostname su", must appear in two
310 # places: in this file below, and in $mk. Using "$no_install_progs_default"
311 # below cannot work. And we can't substitute the names into $mk because
312 # automake needs the literals, too.
313 # The compromise is to ensure that the space-separated list extracted
314 # above matches the literal 2nd argument below.
315 c="$srcdir/configure.ac"
316 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
317 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
320 $no_install_progs_default) ;;
321 *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
322 does not match the list of default-not-installed programs
323 ($no_install_progs_default) also recorded in $mk]],
327 # Given the name of a variable containing a space-separated list of
328 # install-by-default programs and the actual list do-not-install-by-default
329 # programs, modify the former variable to reflect any "do-install" and
330 # "don't-install" requests.
331 # I.e., add any program name specified via --enable-install-program=..., and
332 # remove any program name specified via --enable-no-install-program=...
333 # Note how the second argument below is a literal, with "," separators.
334 # That is required due to the way the macro works, and since the
335 # corresponding ./configure option argument is comma-separated on input.
336 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
338 # Set INSTALL_SU if su installation has been requested via
339 # --enable-install-program=su.
340 AC_SUBST([INSTALL_SU])
341 case " $optional_bin_progs " in
342 *' su '*) INSTALL_SU=yes ;;
346 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
348 # Change ginstall.1 to "install.h" in $MAN.
349 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
350 | tr '\015\012' ' '; echo`
352 # Remove [.1, since writing a portable rule for it in man/Makefile.am
353 # is not practical. The sed LHS below uses the autoconf quadrigraph
355 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
357 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
358 AC_SUBST([OPTIONAL_BIN_PROGS])
359 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
360 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
362 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
364 # Arrange to rerun configure whenever the file, src/Makefile.am,
365 # containing the list of program names changes.
366 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
367 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
368 ############################################################################
370 AM_GNU_GETTEXT([external], [need-formatstring-macros])
371 AM_GNU_GETTEXT_VERSION([0.15])
373 # For a test of uniq: it uses the $LOCALE_FR envvar.
384 gnulib-tests/Makefile