cp, mv, touch: fix file time manipulation on Solaris 10
[coreutils.git] / configure.ac
blob4ac30e8a1464e23c1e12ad1ee5eae655759949f2
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-2010 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.
21 AC_PREREQ([2.62])
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 dist-xz color-tests parallel-tests])
36 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
38 AC_PROG_CC_STDC
39 AM_PROG_CC_C_O
40 AC_PROG_CPP
41 AC_PROG_GCC_TRADITIONAL
42 AC_PROG_RANLIB
43 AC_PROG_LN_S
44 gl_EARLY
45 gl_INIT
46 coreutils_MACROS
48 AC_ARG_ENABLE([gcc-warnings],
49   [AS_HELP_STRING([--enable-gcc-warnings],
50                   [turn on lots of GCC warnings (for developers)])],
51   [case $enableval in
52      yes|no) ;;
53      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
54    esac
55    gl_gcc_warnings=$enableval],
56   [gl_gcc_warnings=no]
59 if test "$gl_gcc_warnings" = yes; then
60   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
61   AC_SUBST([WERROR_CFLAGS])
63   nw=
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   nw="$nw -Wstack-protector"        # not worth working around
86   # things I might fix soon:
87   nw="$nw -Wfloat-equal"            # sort.c, seq.c
88   nw="$nw -Wmissing-format-attribute" # copy.c
89   nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
90   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
91   nw="$nw -Wstrict-overflow"        # expr.c, pr.c, tr.c, factor.c
92   # ?? -Wstrict-overflow
94   gl_MANYWARN_ALL_GCC([ws])
95   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
96   for w in $ws; do
97     gl_WARN_ADD([$w])
98   done
99   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
100   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
101   gl_WARN_ADD([-Wno-pointer-sign])     # Too many warnings for now
102   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
104   # In spite of excluding -Wlogical-op above, it is enabled, as of
105   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
106   gl_WARN_ADD([-Wno-logical-op])
108   gl_WARN_ADD([-fdiagnostics-show-option])
109   gl_WARN_ADD([-funit-at-a-time])
111   AC_SUBST([WARN_CFLAGS])
113   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
114   AC_DEFINE([_FORTIFY_SOURCE], [2],
115     [enable compile-time and run-time bounds-checking, and some warnings])
116   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
118   # We use a slightly smaller set of warning options for lib/.
119   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
120   nw=
121   nw="$nw -Wuninitialized"
122   nw="$nw -Wunused-macros"
123   nw="$nw -Wmissing-prototypes"
124   nw="$nw -Wold-style-definition"
125   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
126   AC_SUBST([GNULIB_WARN_CFLAGS])
128   # For gnulib-tests, the set is slightly smaller still.
129   nw=
130   nw="$nw -Wstrict-prototypes"
131   gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
132                          [$GNULIB_WARN_CFLAGS], [$nw])
133   AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
136 AC_FUNC_FORK
138 optional_bin_progs=
139 AC_CHECK_FUNCS([chroot],
140         gl_ADD_PROG([optional_bin_progs], [chroot]))
141 AC_CHECK_FUNCS([gethostid],
142         gl_ADD_PROG([optional_bin_progs], [hostid]))
144 gl_WINSIZE_IN_PTEM
146 AC_MSG_CHECKING([whether localtime caches TZ])
147 AC_CACHE_VAL([utils_cv_localtime_cache],
148 [if test x$ac_cv_func_tzset = xyes; then
149 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
150 #if STDC_HEADERS
151 # include <stdlib.h>
152 #endif
153 extern char **environ;
154 void unset_TZ (void)
156   char **from, **to;
157   for (to = from = environ; (*to = *from); from++)
158     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
159       to++;
161 int main()
163   time_t now = time ((time_t *) 0);
164   int hour_GMT0, hour_unset;
165   if (putenv ("TZ=GMT0") != 0)
166     exit (1);
167   hour_GMT0 = localtime (&now)->tm_hour;
168   unset_TZ ();
169   hour_unset = localtime (&now)->tm_hour;
170   if (putenv ("TZ=PST8") != 0)
171     exit (1);
172   if (localtime (&now)->tm_hour == hour_GMT0)
173     exit (1);
174   unset_TZ ();
175   if (localtime (&now)->tm_hour != hour_unset)
176     exit (1);
177   exit (0);
178 }]])],
179 [utils_cv_localtime_cache=no],
180 [utils_cv_localtime_cache=yes],
181 [# If we have tzset, assume the worst when cross-compiling.
182 utils_cv_localtime_cache=yes])
183 else
184         # If we lack tzset, report that localtime does not cache TZ,
185         # since we can't invalidate the cache if we don't have tzset.
186         utils_cv_localtime_cache=no
187 fi])dnl
188 AC_MSG_RESULT([$utils_cv_localtime_cache])
189 if test $utils_cv_localtime_cache = yes; then
190   AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
193 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
194 AC_CHECK_FUNCS([initgroups])
195 if test $ac_cv_func_initgroups = no; then
196   AC_CHECK_LIB([os], [initgroups])
199 AC_CHECK_FUNCS([syslog])
200 if test $ac_cv_func_syslog = no; then
201   # syslog is not in the default libraries.  See if it's in some other.
202   for lib in bsd socket inet; do
203     AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
204       LIBS="$LIBS -l$lib"; break])
205   done
208 AC_CACHE_CHECK([for 3-argument setpriority function],
209   [utils_cv_func_setpriority],
210   [AC_LINK_IFELSE(
211     [AC_LANG_PROGRAM(
212        [[#include <sys/time.h>
213          #include <sys/resource.h>
214        ]],
215        [[setpriority (0, 0, 0);]])],
216     [utils_cv_func_setpriority=yes],
217     [utils_cv_func_setpriority=no])])
218 if test $utils_cv_func_setpriority = no; then
219   AC_CHECK_FUNCS([nice])
221 case $utils_cv_func_setpriority,$ac_cv_func_nice in
222 *yes*)
223   gl_ADD_PROG([optional_bin_progs], [nice])
224 esac
226 AC_DEFUN([coreutils_DUMMY_1],
228   AC_REQUIRE([gl_READUTMP])
229   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
230     gl_ADD_PROG([optional_bin_progs], [who])
231     gl_ADD_PROG([optional_bin_progs], [users])
232     gl_ADD_PROG([optional_bin_progs], [pinky])
233   fi
235 coreutils_DUMMY_1
237 AC_MSG_CHECKING([ut_host in struct utmp])
238 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
239 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
240 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
241   [su_cv_func_ut_host_in_utmp=yes],
242   [su_cv_func_ut_host_in_utmp=no])])
243 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
244 if test $su_cv_func_ut_host_in_utmp = yes; then
245   have_ut_host=1
246   AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
249 if test -z "$have_ut_host"; then
250   AC_MSG_CHECKING([ut_host in struct utmpx])
251   AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
252   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
253 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
254     [su_cv_func_ut_host_in_utmpx=yes],
255     [su_cv_func_ut_host_in_utmpx=no])])
256   AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
257   if test $su_cv_func_ut_host_in_utmpx = yes; then
258     AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
259     AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
260   fi
263 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
265 AC_SYS_POSIX_TERMIOS()
266 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
268 if test $ac_cv_sys_posix_termios = yes; then
269   gl_ADD_PROG([optional_bin_progs], [stty])
271   AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
272   AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
273   [AC_EGREP_CPP([yes], [#include <termios.h>
274 #ifdef IUCLC
276 #endif], su_cv_sys_termios_needs_xopen_source=no,
277    AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
278 #include <termios.h>
279 #ifdef IUCLC
281 #endif], su_cv_sys_termios_needs_xopen_source=yes,
282    su_cv_sys_termios_needs_xopen_source=no))])
283   AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
284   test $su_cv_sys_termios_needs_xopen_source = yes &&
285     AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
287   AC_MSG_CHECKING([c_line in struct termios])
288   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
289   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
290 #define _XOPEN_SOURCE
291 #endif
292 #include <sys/types.h>
293 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
294     [su_cv_sys_c_line_in_termios=yes],
295     [su_cv_sys_c_line_in_termios=no])])
296   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
297   test $su_cv_sys_c_line_in_termios = yes \
298     && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
301 # FIXME: note that this macro appears above, too.
302 # I'm leaving it here for now.  This whole thing needs to be modernized...
303 gl_WINSIZE_IN_PTEM
305 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
307 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
308    test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
309   AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
310   AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
311   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
312 #ifdef WINSIZE_IN_PTEM
313 # include <sys/stream.h>
314 # include <sys/ptem.h>
315 #endif
316 #include <sys/ioctl.h>
317 #include <sys/tty.h>
318 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
319     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
320     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
321   AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
323   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
324       && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
325                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
328 # For src/kill.c.
329 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
330   [AC_INCLUDES_DEFAULT
331 #include <signal.h>])
333 cu_LIB_CHECK
334 cu_GMP
336 # Build df only if there's a point to it.
337 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
338   gl_ADD_PROG([optional_bin_progs], [df])
341 # Limit stdbuf to ELF systems with GCC
342 AC_MSG_CHECKING([whether this is an ELF system])
343 AC_EGREP_CPP([yes], [#if __ELF__
345 #endif], [elf_sys=yes], [elf_sys=no])
346 AC_MSG_RESULT([$elf_sys])
347 if test "$elf_sys" = "yes" && \
348    test "$GCC" = "yes"; then
349   gl_ADD_PROG([optional_bin_progs], [stdbuf])
352 ############################################################################
353 mk="$srcdir/src/Makefile.am"
354 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
355 # in $mk but don't expand the variable references.
356 # Append each literal name to $optional_bin_progs.
357 v=EXTRA_PROGRAMS
358 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
359     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
360     | tr -s '\\015\\012\\\\' '   '`; do
361   gl_ADD_PROG([optional_bin_progs], $gl_i)
362 done
364 # As above, extract literal names from the definition of $(no_install__progs)
365 # in $mk but don't expand the variable references.
366 v=no_install__progs
367 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
368     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
369     | tr -s '\\015\\012\\\\' '   '`
370 # Remove any trailing space.
371 no_install_progs_default=`echo "$t"|sed 's/ $//'`
373 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
374 # of default-not-installed programs, "arch hostname su", must appear in two
375 # places: in this file below, and in $mk.  Using "$no_install_progs_default"
376 # below cannot work.  And we can't substitute the names into $mk because
377 # automake needs the literals, too.
378 # The compromise is to ensure that the space-separated list extracted
379 # above matches the literal 2nd argument below.
380 c="$srcdir/configure.ac"
381 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
382 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
383 }' $c`
384 case $t in
385   $no_install_progs_default) ;;
386   *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
387                    does not match the list of default-not-installed programs
388                    ($no_install_progs_default) also recorded in $mk]],
389                    1) ;;
390 esac
392 # Given the name of a variable containing a space-separated list of
393 # install-by-default programs and the actual list do-not-install-by-default
394 # programs, modify the former variable to reflect any "do-install" and
395 # "don't-install" requests.
396 # I.e., add any program name specified via --enable-install-program=..., and
397 # remove any program name specified via --enable-no-install-program=...
398 # Note how the second argument below is a literal, with "," separators.
399 # That is required due to the way the macro works, and since the
400 # corresponding ./configure option argument is comma-separated on input.
401 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
403 # Now that we know which programs will actually be built up, figure out
404 # which optional helper progs should be compiled.
405 optional_pkglib_progs=
406 case " $optional_bin_progs " in
407   *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
408 esac
410 # Set INSTALL_SU if su installation has been requested via
411 # --enable-install-program=su.
412 AC_SUBST([INSTALL_SU])
413 case " $optional_bin_progs " in
414   *' su '*) INSTALL_SU=yes ;;
415   *)        INSTALL_SU=no ;;
416 esac
418 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
420 # Change ginstall.1 to "install.h" in $MAN.
421 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
422   | tr '\015\012' '  '; echo`
424 # Remove [.1, since writing a portable rule for it in man/Makefile.am
425 # is not practical.  The sed LHS below uses the autoconf quadrigraph
426 # representing '['.
427 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
429 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
430 AC_SUBST([OPTIONAL_BIN_PROGS])
431 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
432 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
433 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
434 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
436 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
438 # Arrange to rerun configure whenever the file, src/Makefile.am,
439 # containing the list of program names changes.
440 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
441 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
442 ############################################################################
444 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
445 # translatable strings, we must use need-formatstring-macros here.
446 AM_GNU_GETTEXT([external], [need-formatstring-macros])
447 AM_GNU_GETTEXT_VERSION([0.18])
449 # For a test of uniq: it uses the $LOCALE_FR envvar.
450 gt_LOCALE_FR
452 AC_CONFIG_FILES(
453   Makefile
454   doc/Makefile
455   lib/Makefile
456   man/Makefile
457   po/Makefile.in
458   src/Makefile
459   tests/Makefile
460   gnulib-tests/Makefile
461   )
462 AC_OUTPUT