maint: use gnulib's gettext-h, not the gettext module
[coreutils.git] / configure.ac
blob3c4681c570b9b3af237968efbb2e5f638da037f5
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-2011 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.64])
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 no-dist-gzip 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 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
60 # ------------------------------------------------
61 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
62 # Otherwise, run RUN-IF-NOT-FOUND.
63 AC_DEFUN([gl_GCC_VERSION_IFELSE],
64   [AC_PREPROC_IFELSE(
65     [AC_LANG_PROGRAM(
66       [[
67 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
68 /* ok */
69 #else
70 # error "your version of gcc is older than $1.$2"
71 #endif
72       ]]),
73     ], [$3], [$4])
74   ]
77 if test "$gl_gcc_warnings" = yes; then
78   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
79   AC_SUBST([WERROR_CFLAGS])
81   nw=
82   # This, $nw, is the list of warnings we disable.
83   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
84   nw="$nw -Waggregate-return"       # anachronistic
85   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
86   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
87   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
88   nw="$nw -Wtraditional"            # Warns on #elif which we use often
89   nw="$nw -Wcast-qual"              # Too many warnings for now
90   nw="$nw -Wconversion"             # Too many warnings for now
91   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
92   nw="$nw -Wsign-conversion"        # Too many warnings for now
93   nw="$nw -Wtraditional-conversion" # Too many warnings for now
94   nw="$nw -Wunreachable-code"       # Too many warnings for now
95   nw="$nw -Wpadded"                 # Our structs are not padded
96   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
97   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
98   nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
99   nw="$nw -Wvla"                    # warnings in gettext.h
100   nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
101   nw="$nw -Wswitch-enum"            # Too many warnings for now
102   nw="$nw -Wswitch-default"         # Too many warnings for now
103   nw="$nw -Wstack-protector"        # not worth working around
104   # things I might fix soon:
105   nw="$nw -Wfloat-equal"            # sort.c, seq.c
106   nw="$nw -Wmissing-format-attribute" # copy.c
107   nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
108   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
110   # Using -Wstrict-overflow is a pain, but the alternative is worse.
111   # For an example, see the code that provoked this report:
112   # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
113   # Code like that still infloops with gcc-4.6.0 and -O2.  Scary indeed.
115   gl_MANYWARN_ALL_GCC([ws])
116   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
117   for w in $ws; do
118     gl_WARN_ADD([$w])
119   done
120   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
121   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
122   gl_WARN_ADD([-Wsuggest-attribute=const])
123   gl_WARN_ADD([-Wsuggest-attribute=noreturn])
124   gl_WARN_ADD([-Wno-format-nonliteral])
125   gl_WARN_ADD([-Wno-unsuffixed-float-constants])
127   # Enable this warning only with gcc-4.7 and newer.  With 4.6.1 20110824,
128   # it suggests test.c's advance function may be pure, even though it
129   # increments a global variable.  Oops.
130   # Normally we'd write code to test for the precise failure, but that
131   # requires a relatively large input to make gcc exhibit the failure.
132   gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
134   # In spite of excluding -Wlogical-op above, it is enabled, as of
135   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
136   gl_WARN_ADD([-Wno-logical-op])
138   gl_WARN_ADD([-fdiagnostics-show-option])
139   gl_WARN_ADD([-funit-at-a-time])
141   AC_SUBST([WARN_CFLAGS])
143   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
144   AC_DEFINE([_FORTIFY_SOURCE], [2],
145     [enable compile-time and run-time bounds-checking, and some warnings])
146   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
148   # We use a slightly smaller set of warning options for lib/.
149   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
150   nw=
151   nw="$nw -Wstrict-overflow"
152   nw="$nw -Wuninitialized"
153   nw="$nw -Wunused-macros"
154   nw="$nw -Wmissing-prototypes"
155   nw="$nw -Wold-style-definition"
156   # FIXME: it may be easy to remove this, since it affects only one file:
157   # the snprintf call at ftoastr.c:132.
158   nw="$nw -Wdouble-promotion"
159   # FIXME: remove/reenable the following two, once gnulib is adjusted.
160   nw="$nw -Wsuggest-attribute=const"
161   nw="$nw -Wsuggest-attribute=pure"
162   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
163   AC_SUBST([GNULIB_WARN_CFLAGS])
165   # For gnulib-tests, the set is slightly smaller still.
166   nw=
167   nw="$nw -Wstrict-prototypes"
168   gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
169                          [$GNULIB_WARN_CFLAGS], [$nw])
170   AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
173 AC_FUNC_FORK
175 optional_bin_progs=
176 AC_CHECK_FUNCS([chroot],
177         gl_ADD_PROG([optional_bin_progs], [chroot]))
178 AC_CHECK_FUNCS([gethostid],
179         gl_ADD_PROG([optional_bin_progs], [hostid]))
181 gl_WINSIZE_IN_PTEM
183 AC_MSG_CHECKING([whether localtime caches TZ])
184 AC_CACHE_VAL([utils_cv_localtime_cache],
185 [if test x$ac_cv_func_tzset = xyes; then
186 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
187 #if STDC_HEADERS
188 # include <stdlib.h>
189 #endif
190 extern char **environ;
191 void unset_TZ (void)
193   char **from, **to;
194   for (to = from = environ; (*to = *from); from++)
195     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
196       to++;
198 int main()
200   time_t now = time ((time_t *) 0);
201   int hour_GMT0, hour_unset;
202   if (putenv ("TZ=GMT0") != 0)
203     return 1;
204   hour_GMT0 = localtime (&now)->tm_hour;
205   unset_TZ ();
206   hour_unset = localtime (&now)->tm_hour;
207   if (putenv ("TZ=PST8") != 0)
208     return 1;
209   if (localtime (&now)->tm_hour == hour_GMT0)
210     return 1;
211   unset_TZ ();
212   if (localtime (&now)->tm_hour != hour_unset)
213     return 1;
214   return 0;
215 }]])],
216 [utils_cv_localtime_cache=no],
217 [utils_cv_localtime_cache=yes],
218 [# If we have tzset, assume the worst when cross-compiling.
219 utils_cv_localtime_cache=yes])
220 else
221         # If we lack tzset, report that localtime does not cache TZ,
222         # since we can't invalidate the cache if we don't have tzset.
223         utils_cv_localtime_cache=no
224 fi])dnl
225 AC_MSG_RESULT([$utils_cv_localtime_cache])
226 if test $utils_cv_localtime_cache = yes; then
227   AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
230 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
231 AC_CHECK_FUNCS([initgroups])
232 if test $ac_cv_func_initgroups = no; then
233   AC_CHECK_LIB([os], [initgroups])
236 AC_CHECK_FUNCS([syslog])
237 if test $ac_cv_func_syslog = no; then
238   # syslog is not in the default libraries.  See if it's in some other.
239   for lib in bsd socket inet; do
240     AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
241       LIBS="$LIBS -l$lib"; break])
242   done
245 AC_CACHE_CHECK([for 3-argument setpriority function],
246   [utils_cv_func_setpriority],
247   [AC_LINK_IFELSE(
248     [AC_LANG_PROGRAM(
249        [[#include <sys/time.h>
250          #include <sys/resource.h>
251        ]],
252        [[setpriority (0, 0, 0);]])],
253     [utils_cv_func_setpriority=yes],
254     [utils_cv_func_setpriority=no])])
255 if test $utils_cv_func_setpriority = no; then
256   AC_CHECK_FUNCS([nice])
258 case $utils_cv_func_setpriority,$ac_cv_func_nice in
259 *yes*)
260   gl_ADD_PROG([optional_bin_progs], [nice])
261 esac
263 AC_DEFUN([coreutils_DUMMY_1],
265   AC_REQUIRE([gl_READUTMP])
266   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
267     gl_ADD_PROG([optional_bin_progs], [who])
268     gl_ADD_PROG([optional_bin_progs], [users])
269     gl_ADD_PROG([optional_bin_progs], [pinky])
270   fi
272 coreutils_DUMMY_1
274 AC_MSG_CHECKING([ut_host in struct utmp])
275 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
276 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
277 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
278   [su_cv_func_ut_host_in_utmp=yes],
279   [su_cv_func_ut_host_in_utmp=no])])
280 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
281 if test $su_cv_func_ut_host_in_utmp = yes; then
282   have_ut_host=1
283   AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
286 if test -z "$have_ut_host"; then
287   AC_MSG_CHECKING([ut_host in struct utmpx])
288   AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
289   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
290 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
291     [su_cv_func_ut_host_in_utmpx=yes],
292     [su_cv_func_ut_host_in_utmpx=no])])
293   AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
294   if test $su_cv_func_ut_host_in_utmpx = yes; then
295     AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
296     AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
297   fi
300 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
302 AC_SYS_POSIX_TERMIOS()
303 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
305 if test $ac_cv_sys_posix_termios = yes; then
306   gl_ADD_PROG([optional_bin_progs], [stty])
308   AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
309   AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
310   [AC_EGREP_CPP([yes], [#include <termios.h>
311 #ifdef IUCLC
313 #endif], su_cv_sys_termios_needs_xopen_source=no,
314    AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
315 #include <termios.h>
316 #ifdef IUCLC
318 #endif], su_cv_sys_termios_needs_xopen_source=yes,
319    su_cv_sys_termios_needs_xopen_source=no))])
320   AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
321   test $su_cv_sys_termios_needs_xopen_source = yes &&
322     AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
324   AC_MSG_CHECKING([c_line in struct termios])
325   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
326   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
327 #define _XOPEN_SOURCE
328 #endif
329 #include <sys/types.h>
330 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
331     [su_cv_sys_c_line_in_termios=yes],
332     [su_cv_sys_c_line_in_termios=no])])
333   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
334   test $su_cv_sys_c_line_in_termios = yes \
335     && AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
338 # FIXME: note that this macro appears above, too.
339 # I'm leaving it here for now.  This whole thing needs to be modernized...
340 gl_WINSIZE_IN_PTEM
342 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
344 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
345    test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
346   AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
347   AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
348   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
349 #ifdef WINSIZE_IN_PTEM
350 # include <sys/stream.h>
351 # include <sys/ptem.h>
352 #endif
353 #include <sys/ioctl.h>
354 #include <sys/tty.h>
355 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
356     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
357     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
358   AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
360   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
361       && AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
362                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
365 # For src/kill.c.
366 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
367   [AC_INCLUDES_DEFAULT
368 #include <signal.h>])
370 cu_LIB_CHECK
371 cu_GMP
373 # Build df only if there's a point to it.
374 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
375   gl_ADD_PROG([optional_bin_progs], [df])
378 # Limit stdbuf to ELF systems with GCC
379 AC_MSG_CHECKING([whether this is an ELF system])
380 AC_EGREP_CPP([yes], [#if __ELF__
382 #endif], [elf_sys=yes], [elf_sys=no])
383 AC_MSG_RESULT([$elf_sys])
384 if test "$elf_sys" = "yes" && \
385    test "$GCC" = "yes"; then
386   gl_ADD_PROG([optional_bin_progs], [stdbuf])
389 ############################################################################
390 mk="$srcdir/src/Makefile.am"
391 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
392 # in $mk but don't expand the variable references.
393 # Append each literal name to $optional_bin_progs.
394 v=EXTRA_PROGRAMS
395 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
396     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
397     | tr -s '\\015\\012\\\\' '   '`; do
398   gl_ADD_PROG([optional_bin_progs], $gl_i)
399 done
401 # As above, extract literal names from the definition of $(no_install__progs)
402 # in $mk but don't expand the variable references.
403 v=no_install__progs
404 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
405     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
406     | tr -s '\\015\\012\\\\' '   '`
407 # Remove any trailing space.
408 no_install_progs_default=`echo "$t"|sed 's/ $//'`
410 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
411 # of default-not-installed programs, "arch hostname su", must appear in two
412 # places: in this file below, and in $mk.  Using "$no_install_progs_default"
413 # below cannot work.  And we can't substitute the names into $mk because
414 # automake needs the literals, too.
415 # The compromise is to ensure that the space-separated list extracted
416 # above matches the literal 2nd argument below.
417 c="$srcdir/configure.ac"
418 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
419 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
420 }' $c`
421 case $t in
422   $no_install_progs_default) ;;
423   *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
424                    does not match the list of default-not-installed programs
425                    ($no_install_progs_default) also recorded in $mk]],
426                    1) ;;
427 esac
429 # Given the name of a variable containing a space-separated list of
430 # install-by-default programs and the actual list do-not-install-by-default
431 # programs, modify the former variable to reflect any "do-install" and
432 # "don't-install" requests.
433 # I.e., add any program name specified via --enable-install-program=..., and
434 # remove any program name specified via --enable-no-install-program=...
435 # Note how the second argument below is a literal, with "," separators.
436 # That is required due to the way the macro works, and since the
437 # corresponding ./configure option argument is comma-separated on input.
438 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
440 # Now that we know which programs will actually be built up, figure out
441 # which optional helper progs should be compiled.
442 optional_pkglib_progs=
443 case " $optional_bin_progs " in
444   *' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
445 esac
447 # Set INSTALL_SU if su installation has been requested via
448 # --enable-install-program=su.
449 AC_SUBST([INSTALL_SU])
450 case " $optional_bin_progs " in
451   *' su '*) INSTALL_SU=yes ;;
452   *)        INSTALL_SU=no ;;
453 esac
455 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
457 # Change "ginstall.1" to "install.1" in $MAN.
458 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
459   | tr '\015\012' '  '; echo`
461 # Remove [.1, since writing a portable rule for it in man/Makefile.am
462 # is not practical.  The sed LHS below uses the autoconf quadrigraph
463 # representing '['.
464 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
466 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
467 AC_SUBST([OPTIONAL_BIN_PROGS])
468 OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
469 AC_SUBST([OPTIONAL_PKGLIB_PROGS])
470 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
471 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
473 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
475 # Arrange to rerun configure whenever the file, src/Makefile.am,
476 # containing the list of program names changes.
477 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
478 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
479 ############################################################################
481 # As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
482 # translatable strings, we must use need-formatstring-macros here.
483 AM_GNU_GETTEXT([external], [need-formatstring-macros])
484 AM_GNU_GETTEXT_VERSION([0.18.1])
486 # For a test of uniq: it uses the $LOCALE_FR envvar.
487 gt_LOCALE_FR
489 AC_CONFIG_FILES(
490   Makefile
491   doc/Makefile
492   lib/Makefile
493   man/Makefile
494   po/Makefile.in
495   src/Makefile
496   tests/Makefile
497   gnulib-tests/Makefile
498   )
499 AC_OUTPUT