Avoid a shell syntax error, when building with an inadequate Perl.
[coreutils.git] / configure.ac
blob66f079b408aed7bda9e1e3006586b32919c352fa
1 # -*- autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1991, 1993-2006 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 2, or (at your option)
9 # 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, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 dnl Written by Jim Meyering.
22 AC_PREREQ(2.61)
23 AC_INIT([GNU coreutils],[6.7-dirty],[bug-coreutils@gnu.org])
24 AC_CONFIG_SRCDIR(src/ls.c)
26 AC_CONFIG_AUX_DIR(build-aux)
27 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
29 AB_INIT()
30 AM_INIT_AUTOMAKE([1.10 gnits dist-bzip2])
32 AC_PROG_CC_STDC
33 AM_PROG_CC_C_O
34 AC_PROG_CPP
35 AC_PROG_GCC_TRADITIONAL
36 AC_PROG_RANLIB
37 AC_PROG_LN_S
38 gl_EARLY
39 gl_INIT
40 coreutils_MACROS
42 AC_FUNC_FORK
44 AC_CHECK_FUNCS(uname,
45         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uname\$(EXEEXT)"
46         MAN="$MAN uname.1")
47 AC_CHECK_FUNCS(chroot,
48         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS chroot\$(EXEEXT)"
49         MAN="$MAN chroot.1")
50 AC_CHECK_FUNCS(gethostid,
51         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS hostid\$(EXEEXT)"
52         MAN="$MAN hostid.1")
54 gl_WINSIZE_IN_PTEM
56 AC_MSG_CHECKING(whether localtime caches TZ)
57 AC_CACHE_VAL(utils_cv_localtime_cache,
58 [if test x$ac_cv_func_tzset = xyes; then
59 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
60 #if STDC_HEADERS
61 # include <stdlib.h>
62 #endif
63 extern char **environ;
64 void unset_TZ (void)
66   char **from, **to;
67   for (to = from = environ; (*to = *from); from++)
68     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
69       to++;
71 int main()
73   time_t now = time ((time_t *) 0);
74   int hour_GMT0, hour_unset;
75   if (putenv ("TZ=GMT0") != 0)
76     exit (1);
77   hour_GMT0 = localtime (&now)->tm_hour;
78   unset_TZ ();
79   hour_unset = localtime (&now)->tm_hour;
80   if (putenv ("TZ=PST8") != 0)
81     exit (1);
82   if (localtime (&now)->tm_hour == hour_GMT0)
83     exit (1);
84   unset_TZ ();
85   if (localtime (&now)->tm_hour != hour_unset)
86     exit (1);
87   exit (0);
88 }]])],
89 [utils_cv_localtime_cache=no],
90 [utils_cv_localtime_cache=yes],
91 [# If we have tzset, assume the worst when cross-compiling.
92 utils_cv_localtime_cache=yes])
93 else
94         # If we lack tzset, report that localtime does not cache TZ,
95         # since we can't invalidate the cache if we don't have tzset.
96         utils_cv_localtime_cache=no
97 fi])dnl
98 AC_MSG_RESULT($utils_cv_localtime_cache)
99 if test $utils_cv_localtime_cache = yes; then
100   AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
103 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
104 AC_CHECK_FUNCS(initgroups)
105 if test $ac_cv_func_initgroups = no; then
106   AC_CHECK_LIB(os, initgroups)
109 AC_CHECK_FUNCS(syslog)
110 if test $ac_cv_func_syslog = no; then
111   # syslog is not in the default libraries.  See if it's in some other.
112   for lib in bsd socket inet; do
113     AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
114       LIBS="$LIBS -l$lib"; break])
115   done
118 AC_CACHE_CHECK([for 3-argument setpriority function],
119   [utils_cv_func_setpriority],
120   [AC_LINK_IFELSE(
121     [AC_LANG_PROGRAM(
122        [[#include <sys/time.h>
123          #include <sys/resource.h>
124        ]],
125        [[setpriority (0, 0, 0);]])],
126     [utils_cv_func_setpriority=yes],
127     [utils_cv_func_setpriority=no])])
128 if test $utils_cv_func_setpriority = no; then
129   AC_CHECK_FUNCS([nice])
131 case $utils_cv_func_setpriority,$ac_cv_func_nice in
132 *yes*)
133   OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS nice\$(EXEEXT)"
134   MAN="$MAN nice.1";;
135 esac
137 AC_DEFUN([coreutils_DUMMY_1],
139   AC_REQUIRE([gl_READUTMP])
140   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
141     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS pinky\$(EXEEXT)"
142     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS users\$(EXEEXT)"
143     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS who\$(EXEEXT)"
144     MAN="$MAN pinky.1 users.1 who.1"
145   fi
147 coreutils_DUMMY_1
149 AC_MSG_CHECKING(ut_host in struct utmp)
150 AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
151 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
152 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
153   [su_cv_func_ut_host_in_utmp=yes],
154   [su_cv_func_ut_host_in_utmp=no])])
155 AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
156 if test $su_cv_func_ut_host_in_utmp = yes; then
157   have_ut_host=1
158   AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
161 if test -z "$have_ut_host"; then
162   AC_MSG_CHECKING(ut_host in struct utmpx)
163   AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
164   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
165 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
166     [su_cv_func_ut_host_in_utmpx=yes],
167     [su_cv_func_ut_host_in_utmpx=no])])
168   AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
169   if test $su_cv_func_ut_host_in_utmpx = yes; then
170     AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
171     AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
172   fi
175 GNULIB_BOOT_TIME(
176   [OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uptime\$(EXEEXT)"
177   MAN="$MAN uptime.1"])
179 AC_SYS_POSIX_TERMIOS()
180 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
182 if test $ac_cv_sys_posix_termios = yes; then
183   OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS stty\$(EXEEXT)" MAN="$MAN stty.1"
185   AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
186   AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
187   [AC_EGREP_CPP(yes, [#include <termios.h>
188 #ifdef IUCLC
190 #endif], su_cv_sys_termios_needs_xopen_source=no,
191    AC_EGREP_CPP(yes, [#define _XOPEN_SOURCE
192 #include <termios.h>
193 #ifdef IUCLC
195 #endif], su_cv_sys_termios_needs_xopen_source=yes,
196    su_cv_sys_termios_needs_xopen_source=no))])
197   AC_MSG_RESULT($su_cv_sys_termios_needs_xopen_source)
198   test $su_cv_sys_termios_needs_xopen_source = yes &&
199     AC_DEFINE(TERMIOS_NEEDS_XOPEN_SOURCE, 1, [FIXME])
201   AC_MSG_CHECKING(c_line in struct termios)
202   AC_CACHE_VAL(su_cv_sys_c_line_in_termios,
203   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
204 #define _XOPEN_SOURCE
205 #endif
206 #include <sys/types.h>
207 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
208     [su_cv_sys_c_line_in_termios=yes],
209     [su_cv_sys_c_line_in_termios=no])])
210   AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
211   test $su_cv_sys_c_line_in_termios = yes \
212     && AC_DEFINE(HAVE_C_LINE, 1, [FIXME])
215 # FIXME: note that this macro appears above, too.
216 # I'm leaving it here for now.  This whole thing needs to be modernized...
217 gl_WINSIZE_IN_PTEM
219 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
221 if test $jm_cv_sys_tiocgwinsz_needs_termios_h = no && \
222    test $jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
223   AC_MSG_CHECKING(TIOCGWINSZ in sys/pty.h)
224   AC_CACHE_VAL(su_cv_sys_tiocgwinsz_in_sys_pty_h,
225   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
226 #ifdef WINSIZE_IN_PTEM
227 # include <sys/stream.h>
228 # include <sys/ptem.h>
229 #endif
230 #include <sys/ioctl.h>
231 #include <sys/tty.h>
232 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
233     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
234     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
235   AC_MSG_RESULT($su_cv_sys_tiocgwinsz_in_sys_pty_h)
237   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
238       && AC_DEFINE(GWINSZ_IN_SYS_PTY, 1,
239                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
242 # For src/kill.c.
243 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
244   [AC_INCLUDES_DEFAULT
245 #include <signal.h>])
247 # For src/kill.c and src/printf.c.
248 AC_CHECK_DECLS([strtoimax, strtoumax])
250 cu_LIB_CHECK
252 AM_GNU_GETTEXT([external], [need-formatstring-macros])
253 AM_GNU_GETTEXT_VERSION([0.15])
255 AC_CONFIG_FILES(
256   Makefile
257   doc/Makefile
258   lib/Makefile
259   man/Makefile
260   po/Makefile.in
261   src/Makefile
262   tests/Makefile
263   tests/chgrp/Makefile
264   tests/chmod/Makefile
265   tests/chown/Makefile
266   tests/cp/Makefile
267   tests/cut/Makefile
268   tests/dd/Makefile
269   tests/dircolors/Makefile
270   tests/du/Makefile
271   tests/expr/Makefile
272   tests/factor/Makefile
273   tests/fmt/Makefile
274   tests/head/Makefile
275   tests/install/Makefile
276   tests/join/Makefile
277   tests/ln/Makefile
278   tests/ls-2/Makefile
279   tests/ls/Makefile
280   tests/md5sum/Makefile
281   tests/misc/Makefile
282   tests/mkdir/Makefile
283   tests/mv/Makefile
284   tests/od/Makefile
285   tests/pr/Makefile
286   tests/readlink/Makefile
287   tests/rm/Makefile
288   tests/rmdir/Makefile
289   tests/seq/Makefile
290   tests/sha1sum/Makefile
291   tests/shred/Makefile
292   tests/sort/Makefile
293   tests/stty/Makefile
294   tests/sum/Makefile
295   tests/tac/Makefile
296   tests/tail-2/Makefile
297   tests/tail/Makefile
298   tests/tee/Makefile
299   tests/test/Makefile
300   tests/touch/Makefile
301   tests/tr/Makefile
302   tests/tsort/Makefile
303   tests/unexpand/Makefile
304   tests/uniq/Makefile
305   tests/wc/Makefile
306   )
307 AC_OUTPUT