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