tests: adjust the new, very expensive rm test to be less expensive
[platform/upstream/coreutils.git] / configure.ac
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # Copyright (C) 1991, 1993-2011 Free Software Foundation, Inc.
5
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.
10
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.
15
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/>.
18
19 dnl Written by Jim Meyering.
20
21 AC_PREREQ([2.64])
22
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])
29
30 AC_CONFIG_SRCDIR([src/ls.c])
31
32 AC_CONFIG_AUX_DIR([build-aux])
33 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
34
35 AM_INIT_AUTOMAKE([1.11.1 dist-xz color-tests parallel-tests])
36 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
37
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
47
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]
57 )
58
59 if test "$gl_gcc_warnings" = yes; then
60   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
61   AC_SUBST([WERROR_CFLAGS])
62
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
92   # Using -Wstrict-overflow is a pain, but the alternative is worse.
93   # For an example, see the code that provoked this report:
94   # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
95   # Code like that still infloops with gcc-4.6.0 and -O2.  Scary indeed.
96
97   gl_MANYWARN_ALL_GCC([ws])
98   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
99   for w in $ws; do
100     gl_WARN_ADD([$w])
101   done
102   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
103   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
104   gl_WARN_ADD([-Wsuggest-attribute=const])
105   gl_WARN_ADD([-Wsuggest-attribute=pure])
106   gl_WARN_ADD([-Wsuggest-attribute=noreturn])
107
108   # In spite of excluding -Wlogical-op above, it is enabled, as of
109   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
110   gl_WARN_ADD([-Wno-logical-op])
111
112   gl_WARN_ADD([-fdiagnostics-show-option])
113   gl_WARN_ADD([-funit-at-a-time])
114
115   AC_SUBST([WARN_CFLAGS])
116
117   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
118   AC_DEFINE([_FORTIFY_SOURCE], [2],
119     [enable compile-time and run-time bounds-checking, and some warnings])
120   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
121
122   # We use a slightly smaller set of warning options for lib/.
123   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
124   nw=
125   nw="$nw -Wstrict-overflow"
126   nw="$nw -Wuninitialized"
127   nw="$nw -Wunused-macros"
128   nw="$nw -Wmissing-prototypes"
129   nw="$nw -Wold-style-definition"
130   # FIXME: remove/reenable the following two, once gnulib is adjusted.
131   nw="$nw -Wsuggest-attribute=const"
132   nw="$nw -Wsuggest-attribute=pure"
133   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
134   AC_SUBST([GNULIB_WARN_CFLAGS])
135
136   # For gnulib-tests, the set is slightly smaller still.
137   nw=
138   nw="$nw -Wstrict-prototypes"
139   gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
140                          [$GNULIB_WARN_CFLAGS], [$nw])
141   AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
142 fi
143
144 AC_FUNC_FORK
145
146 optional_bin_progs=
147 AC_CHECK_FUNCS([chroot],
148         gl_ADD_PROG([optional_bin_progs], [chroot]))
149 AC_CHECK_FUNCS([gethostid],
150         gl_ADD_PROG([optional_bin_progs], [hostid]))
151
152 gl_WINSIZE_IN_PTEM
153
154 AC_MSG_CHECKING([whether localtime caches TZ])
155 AC_CACHE_VAL([utils_cv_localtime_cache],
156 [if test x$ac_cv_func_tzset = xyes; then
157 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
158 #if STDC_HEADERS
159 # include <stdlib.h>
160 #endif
161 extern char **environ;
162 void unset_TZ (void)
163 {
164   char **from, **to;
165   for (to = from = environ; (*to = *from); from++)
166     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
167       to++;
168 }
169 int main()
170 {
171   time_t now = time ((time_t *) 0);
172   int hour_GMT0, hour_unset;
173   if (putenv ("TZ=GMT0") != 0)
174     return 1;
175   hour_GMT0 = localtime (&now)->tm_hour;
176   unset_TZ ();
177   hour_unset = localtime (&now)->tm_hour;
178   if (putenv ("TZ=PST8") != 0)
179     return 1;
180   if (localtime (&now)->tm_hour == hour_GMT0)
181     return 1;
182   unset_TZ ();
183   if (localtime (&now)->tm_hour != hour_unset)
184     return 1;
185   return 0;
186 }]])],
187 [utils_cv_localtime_cache=no],
188 [utils_cv_localtime_cache=yes],
189 [# If we have tzset, assume the worst when cross-compiling.
190 utils_cv_localtime_cache=yes])
191 else
192         # If we lack tzset, report that localtime does not cache TZ,
193         # since we can't invalidate the cache if we don't have tzset.
194         utils_cv_localtime_cache=no
195 fi])dnl
196 AC_MSG_RESULT([$utils_cv_localtime_cache])
197 if test $utils_cv_localtime_cache = yes; then
198   AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
199 fi
200
201 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
202 AC_CHECK_FUNCS([initgroups])
203 if test $ac_cv_func_initgroups = no; then
204   AC_CHECK_LIB([os], [initgroups])
205 fi
206
207 AC_CHECK_FUNCS([syslog])
208 if test $ac_cv_func_syslog = no; then
209   # syslog is not in the default libraries.  See if it's in some other.
210   for lib in bsd socket inet; do
211     AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
212       LIBS="$LIBS -l$lib"; break])
213   done
214 fi
215
216 AC_CACHE_CHECK([for 3-argument setpriority function],
217   [utils_cv_func_setpriority],
218   [AC_LINK_IFELSE(
219     [AC_LANG_PROGRAM(
220        [[#include <sys/time.h>
221          #include <sys/resource.h>
222        ]],
223        [[setpriority (0, 0, 0);]])],
224     [utils_cv_func_setpriority=yes],
225     [utils_cv_func_setpriority=no])])
226 if test $utils_cv_func_setpriority = no; then
227   AC_CHECK_FUNCS([nice])
228 fi
229 case $utils_cv_func_setpriority,$ac_cv_func_nice in
230 *yes*)
231   gl_ADD_PROG([optional_bin_progs], [nice])
232 esac
233
234 AC_DEFUN([coreutils_DUMMY_1],
235 [
236   AC_REQUIRE([gl_READUTMP])
237   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
238     gl_ADD_PROG([optional_bin_progs], [who])
239     gl_ADD_PROG([optional_bin_progs], [users])
240     gl_ADD_PROG([optional_bin_progs], [pinky])
241   fi
242 ])
243 coreutils_DUMMY_1
244
245 AC_MSG_CHECKING([ut_host in struct utmp])
246 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
247 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
248 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
249   [su_cv_func_ut_host_in_utmp=yes],
250   [su_cv_func_ut_host_in_utmp=no])])
251 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
252 if test $su_cv_func_ut_host_in_utmp = yes; then
253   have_ut_host=1
254   AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
255 fi
256
257 if test -z "$have_ut_host"; then
258   AC_MSG_CHECKING([ut_host in struct utmpx])
259   AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
260   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
261 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
262     [su_cv_func_ut_host_in_utmpx=yes],
263     [su_cv_func_ut_host_in_utmpx=no])])
264   AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
265   if test $su_cv_func_ut_host_in_utmpx = yes; then
266     AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
267     AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
268   fi
269 fi
270
271 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
272
273 AC_SYS_POSIX_TERMIOS()
274 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
275
276 if test $ac_cv_sys_posix_termios = yes; then
277   gl_ADD_PROG([optional_bin_progs], [stty])
278
279   AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
280   AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
281   [AC_EGREP_CPP([yes], [#include <termios.h>
282 #ifdef IUCLC
283 yes
284 #endif], su_cv_sys_termios_needs_xopen_source=no,
285    AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
286 #include <termios.h>
287 #ifdef IUCLC
288 yes
289 #endif], su_cv_sys_termios_needs_xopen_source=yes,
290    su_cv_sys_termios_needs_xopen_source=no))])
291   AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
292   test $su_cv_sys_termios_needs_xopen_source = yes &&
293     AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
294
295   AC_MSG_CHECKING([c_line in struct termios])
296   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
297   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
298 #define _XOPEN_SOURCE
299 #endif
300 #include <sys/types.h>
301 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
302     [su_cv_sys_c_line_in_termios=yes],
303     [su_cv_sys_c_line_in_termios=no])])
304   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
305   test $su_cv_sys_c_line_in_termios = yes \
306     && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
307 fi
308
309 # FIXME: note that this macro appears above, too.
310 # I'm leaving it here for now.  This whole thing needs to be modernized...
311 gl_WINSIZE_IN_PTEM
312
313 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
314
315 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
316    test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
317   AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
318   AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
319   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
320 #ifdef WINSIZE_IN_PTEM
321 # include <sys/stream.h>
322 # include <sys/ptem.h>
323 #endif
324 #include <sys/ioctl.h>
325 #include <sys/tty.h>
326 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
327     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
328     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
329   AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
330
331   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
332       && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
333                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
334 fi
335
336 # For src/kill.c.
337 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
338   [AC_INCLUDES_DEFAULT
339 #include <signal.h>])
340
341 cu_LIB_CHECK
342 cu_GMP
343
344 # Build df only if there's a point to it.
345 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
346   gl_ADD_PROG([optional_bin_progs], [df])
347 fi
348
349 # Limit stdbuf to ELF systems with GCC
350 AC_MSG_CHECKING([whether this is an ELF system])
351 AC_EGREP_CPP([yes], [#if __ELF__
352 yes
353 #endif], [elf_sys=yes], [elf_sys=no])
354 AC_MSG_RESULT([$elf_sys])
355 if test "$elf_sys" = "yes" && \
356    test "$GCC" = "yes"; then
357   gl_ADD_PROG([optional_bin_progs], [stdbuf])
358 fi
359
360 ############################################################################
361 mk="$srcdir/src/Makefile.am"
362 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
363 # in $mk but don't expand the variable references.
364 # Append each literal name to $optional_bin_progs.
365 v=EXTRA_PROGRAMS
366 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
367     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
368     | tr -s '\\015\\012\\\\' '   '`; do
369   gl_ADD_PROG([optional_bin_progs], $gl_i)
370 done
371
372 # As above, extract literal names from the definition of $(no_install__progs)
373 # in $mk but don't expand the variable references.
374 v=no_install__progs
375 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
376     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
377     | tr -s '\\015\\012\\\\' '   '`
378 # Remove any trailing space.
379 no_install_progs_default=`echo "$t"|sed 's/ $//'`
380
381 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
382 # of default-not-installed programs, "arch hostname su", must appear in two
383 # places: in this file below, and in $mk.  Using "$no_install_progs_default"
384 # below cannot work.  And we can't substitute the names into $mk because
385 # automake needs the literals, too.
386 # The compromise is to ensure that the space-separated list extracted
387 # above matches the literal 2nd argument below.
388 c="$srcdir/configure.ac"
389 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
390 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
391 }' $c`
392 case $t in
393   $no_install_progs_default) ;;
394   *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
395                    does not match the list of default-not-installed programs
396                    ($no_install_progs_default) also recorded in $mk]],
397                    1) ;;
398 esac
399
400 # Given the name of a variable containing a space-separated list of
401 # install-by-default programs and the actual list do-not-install-by-default
402 # programs, modify the former variable to reflect any "do-install" and
403 # "don't-install" requests.
404 # I.e., add any program name specified via --enable-install-program=..., and
405 # remove any program name specified via --enable-no-install-program=...
406 # Note how the second argument below is a literal, with "," separators.
407 # That is required due to the way the macro works, and since the
408 # corresponding ./configure option argument is comma-separated on input.
409 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
410
411 # Now that we know which programs will actually be built up, figure out
412 # which optional helper progs should be compiled.
413 optional_pkglib_progs=
414 case " $optional_bin_progs " in
415   *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
416 esac
417
418 # Set INSTALL_SU if su installation has been requested via
419 # --enable-install-program=su.
420 AC_SUBST([INSTALL_SU])
421 case " $optional_bin_progs " in
422   *' su '*) INSTALL_SU=yes ;;
423   *)        INSTALL_SU=no ;;
424 esac
425
426 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
427
428 # Change "ginstall.1" to "install.1" in $MAN.
429 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
430   | tr '\015\012' '  '; echo`
431
432 # Remove [.1, since writing a portable rule for it in man/Makefile.am
433 # is not practical.  The sed LHS below uses the autoconf quadrigraph
434 # representing '['.
435 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
436
437 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
438 AC_SUBST([OPTIONAL_BIN_PROGS])
439 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
440 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
441 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
442 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
443
444 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
445
446 # Arrange to rerun configure whenever the file, src/Makefile.am,
447 # containing the list of program names changes.
448 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
449 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
450 ############################################################################
451
452 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
453 # translatable strings, we must use need-formatstring-macros here.
454 AM_GNU_GETTEXT([external], [need-formatstring-macros])
455 AM_GNU_GETTEXT_VERSION([0.18.1])
456
457 # For a test of uniq: it uses the $LOCALE_FR envvar.
458 gt_LOCALE_FR
459
460 AC_CONFIG_FILES(
461   Makefile
462   doc/Makefile
463   lib/Makefile
464   man/Makefile
465   po/Makefile.in
466   src/Makefile
467   tests/Makefile
468   gnulib-tests/Makefile
469   )
470 AC_OUTPUT