Change interface: make 2nd param _space_-separated, not comma-separated
[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-2007 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, or (at your option)
9 # 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, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 dnl Written by Jim Meyering.
21
22 AC_PREREQ(2.61)
23 AC_INIT([GNU coreutils],[6.9+],[bug-coreutils@gnu.org])
24 AC_CONFIG_SRCDIR(src/ls.c)
25
26 AC_CONFIG_AUX_DIR(build-aux)
27 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
28
29 AB_INIT()
30 AM_INIT_AUTOMAKE([1.10 dist-bzip2])
31
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
41
42 AC_FUNC_FORK
43
44 optional_bin_progs=
45 AC_CHECK_FUNCS(uname,
46         gl_ADD_PROG([optional_bin_progs], [uname]))
47 AC_CHECK_FUNCS(chroot,
48         gl_ADD_PROG([optional_bin_progs], [chroot]))
49 AC_CHECK_FUNCS(gethostid,
50         gl_ADD_PROG([optional_bin_progs], [hostid]))
51
52 gl_WINSIZE_IN_PTEM
53
54 AC_MSG_CHECKING(whether localtime caches TZ)
55 AC_CACHE_VAL(utils_cv_localtime_cache,
56 [if test x$ac_cv_func_tzset = xyes; then
57 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
58 #if STDC_HEADERS
59 # include <stdlib.h>
60 #endif
61 extern char **environ;
62 void unset_TZ (void)
63 {
64   char **from, **to;
65   for (to = from = environ; (*to = *from); from++)
66     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
67       to++;
68 }
69 int main()
70 {
71   time_t now = time ((time_t *) 0);
72   int hour_GMT0, hour_unset;
73   if (putenv ("TZ=GMT0") != 0)
74     exit (1);
75   hour_GMT0 = localtime (&now)->tm_hour;
76   unset_TZ ();
77   hour_unset = localtime (&now)->tm_hour;
78   if (putenv ("TZ=PST8") != 0)
79     exit (1);
80   if (localtime (&now)->tm_hour == hour_GMT0)
81     exit (1);
82   unset_TZ ();
83   if (localtime (&now)->tm_hour != hour_unset)
84     exit (1);
85   exit (0);
86 }]])],
87 [utils_cv_localtime_cache=no],
88 [utils_cv_localtime_cache=yes],
89 [# If we have tzset, assume the worst when cross-compiling.
90 utils_cv_localtime_cache=yes])
91 else
92         # If we lack tzset, report that localtime does not cache TZ,
93         # since we can't invalidate the cache if we don't have tzset.
94         utils_cv_localtime_cache=no
95 fi])dnl
96 AC_MSG_RESULT($utils_cv_localtime_cache)
97 if test $utils_cv_localtime_cache = yes; then
98   AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
99 fi
100
101 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
102 AC_CHECK_FUNCS(initgroups)
103 if test $ac_cv_func_initgroups = no; then
104   AC_CHECK_LIB(os, initgroups)
105 fi
106
107 AC_CHECK_FUNCS(syslog)
108 if test $ac_cv_func_syslog = no; then
109   # syslog is not in the default libraries.  See if it's in some other.
110   for lib in bsd socket inet; do
111     AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
112       LIBS="$LIBS -l$lib"; break])
113   done
114 fi
115
116 AC_CACHE_CHECK([for 3-argument setpriority function],
117   [utils_cv_func_setpriority],
118   [AC_LINK_IFELSE(
119     [AC_LANG_PROGRAM(
120        [[#include <sys/time.h>
121          #include <sys/resource.h>
122        ]],
123        [[setpriority (0, 0, 0);]])],
124     [utils_cv_func_setpriority=yes],
125     [utils_cv_func_setpriority=no])])
126 if test $utils_cv_func_setpriority = no; then
127   AC_CHECK_FUNCS([nice])
128 fi
129 case $utils_cv_func_setpriority,$ac_cv_func_nice in
130 *yes*)
131   gl_ADD_PROG([optional_bin_progs], [nice])
132 esac
133
134 AC_DEFUN([coreutils_DUMMY_1],
135 [
136   AC_REQUIRE([gl_READUTMP])
137   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
138     gl_ADD_PROG([optional_bin_progs], [who])
139     gl_ADD_PROG([optional_bin_progs], [users])
140     gl_ADD_PROG([optional_bin_progs], [pinky])
141   fi
142 ])
143 coreutils_DUMMY_1
144
145 AC_MSG_CHECKING(ut_host in struct utmp)
146 AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
147 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
148 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
149   [su_cv_func_ut_host_in_utmp=yes],
150   [su_cv_func_ut_host_in_utmp=no])])
151 AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
152 if test $su_cv_func_ut_host_in_utmp = yes; then
153   have_ut_host=1
154   AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
155 fi
156
157 if test -z "$have_ut_host"; then
158   AC_MSG_CHECKING(ut_host in struct utmpx)
159   AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
160   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
161 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
162     [su_cv_func_ut_host_in_utmpx=yes],
163     [su_cv_func_ut_host_in_utmpx=no])])
164   AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
165   if test $su_cv_func_ut_host_in_utmpx = yes; then
166     AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
167     AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
168   fi
169 fi
170
171 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
172
173 AC_SYS_POSIX_TERMIOS()
174 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
175
176 if test $ac_cv_sys_posix_termios = yes; then
177   gl_ADD_PROG([optional_bin_progs], [stty])
178
179   AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
180   AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
181   [AC_EGREP_CPP(yes, [#include <termios.h>
182 #ifdef IUCLC
183 yes
184 #endif], su_cv_sys_termios_needs_xopen_source=no,
185    AC_EGREP_CPP(yes, [#define _XOPEN_SOURCE
186 #include <termios.h>
187 #ifdef IUCLC
188 yes
189 #endif], su_cv_sys_termios_needs_xopen_source=yes,
190    su_cv_sys_termios_needs_xopen_source=no))])
191   AC_MSG_RESULT($su_cv_sys_termios_needs_xopen_source)
192   test $su_cv_sys_termios_needs_xopen_source = yes &&
193     AC_DEFINE(TERMIOS_NEEDS_XOPEN_SOURCE, 1, [FIXME])
194
195   AC_MSG_CHECKING(c_line in struct termios)
196   AC_CACHE_VAL(su_cv_sys_c_line_in_termios,
197   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
198 #define _XOPEN_SOURCE
199 #endif
200 #include <sys/types.h>
201 #include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
202     [su_cv_sys_c_line_in_termios=yes],
203     [su_cv_sys_c_line_in_termios=no])])
204   AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
205   test $su_cv_sys_c_line_in_termios = yes \
206     && AC_DEFINE(HAVE_C_LINE, 1, [FIXME])
207 fi
208
209 # FIXME: note that this macro appears above, too.
210 # I'm leaving it here for now.  This whole thing needs to be modernized...
211 gl_WINSIZE_IN_PTEM
212
213 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
214
215 if test $jm_cv_sys_tiocgwinsz_needs_termios_h = no && \
216    test $jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
217   AC_MSG_CHECKING(TIOCGWINSZ in sys/pty.h)
218   AC_CACHE_VAL(su_cv_sys_tiocgwinsz_in_sys_pty_h,
219   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
220 #ifdef WINSIZE_IN_PTEM
221 # include <sys/stream.h>
222 # include <sys/ptem.h>
223 #endif
224 #include <sys/ioctl.h>
225 #include <sys/tty.h>
226 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
227     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
228     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
229   AC_MSG_RESULT($su_cv_sys_tiocgwinsz_in_sys_pty_h)
230
231   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
232       && AC_DEFINE(GWINSZ_IN_SYS_PTY, 1,
233                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
234 fi
235
236 # For src/kill.c.
237 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
238   [AC_INCLUDES_DEFAULT
239 #include <signal.h>])
240
241 # For src/kill.c and src/printf.c.
242 AC_CHECK_DECLS([strtoimax, strtoumax])
243
244 cu_LIB_CHECK
245
246 # Build df only if there's a point to it.
247 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
248   gl_ADD_PROG([optional_bin_progs], [df])
249 fi
250
251 ############################################################################
252 mk="$srcdir/src/Makefile.am"
253 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
254 # in $mk but don't expand the variable references.
255 # Append each literal name to $optional_bin_progs.
256 v=EXTRA_PROGRAMS
257 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
258     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
259     | tr -s '\\012\\\\' '  '`; do
260   gl_ADD_PROG([optional_bin_progs], $gl_i)
261 done
262
263 # As above, extract literal names from the definition of $(no_install__progs)
264 # in $mk but don't expand the variable references.
265 v=no_install__progs
266 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
267     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
268     | tr -s '\\012\\\\' '  '`
269 # Remove any trailing space.
270 no_install_progs_default=`echo "$t"|sed 's/ $//'`
271
272 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the
273 # list of default-not-installed programs, "arch su", must appear in two
274 # places: in this file below, and in $mk.  Using "$no_install_progs_default"
275 # below cannot work.  And we can't substitute the names into $mk because
276 # automake needs the literals, too.
277 # The compromise is to ensure that the space-separated list extracted
278 # above matches the literal 2nd argument below.
279 c="$srcdir/configure.ac"
280 t=`sed -n '/^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])/s//\1/p' $c`
281 case $t in
282   $no_install_progs_default) ;;
283   *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
284                    does not match the list of default-not-installed programs
285                    ($no_install_progs_default) extracted also recorded in $mk]],
286                    1) ;;
287 esac
288
289 # Given the name of a variable containing a space-separated list of
290 # install-by-default programs and the actual list do-not-install-by-default
291 # programs, modify the former variable to reflect any "do-install" and
292 # "don't-install" requests.
293 # I.e., add any program name specified via --enable-install-program=..., and
294 # remove any program name specified via --enable-no-install-program=...
295 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch su])
296
297 # Set INSTALL_SU if su installation has been requested via
298 # --enable-install-program=su.
299 AC_SUBST([INSTALL_SU])
300 case " $optional_bin_progs " in
301   *' su '*) INSTALL_SU=yes ;;
302   *)        INSTALL_SU=no ;;
303 esac
304
305 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'`
306
307 # Change ginstall.1 to "install.h" in $MAN.
308 MAN=`echo "$MAN"|sed 's/\<ginstall\.1\>/install.1/'`
309
310 # Remove [.1, since writing a portable rule for it in man/Makefile.am
311 # is not practical.  The sed LHS below uses the autoconf quadrigraph
312 # representing '['.
313 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
314
315 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
316 AC_SUBST(OPTIONAL_BIN_PROGS)
317 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
318 AC_SUBST(NO_INSTALL_PROGS_DEFAULT)
319 ############################################################################
320
321 AM_GNU_GETTEXT([external], [need-formatstring-macros])
322 AM_GNU_GETTEXT_VERSION([0.15])
323
324 AC_CONFIG_FILES(
325   Makefile
326   doc/Makefile
327   lib/Makefile
328   man/Makefile
329   po/Makefile.in
330   src/Makefile
331   tests/Makefile
332   tests/chgrp/Makefile
333   tests/chmod/Makefile
334   tests/chown/Makefile
335   tests/cp/Makefile
336   tests/cut/Makefile
337   tests/dd/Makefile
338   tests/dircolors/Makefile
339   tests/du/Makefile
340   tests/expr/Makefile
341   tests/factor/Makefile
342   tests/fmt/Makefile
343   tests/head/Makefile
344   tests/install/Makefile
345   tests/join/Makefile
346   tests/ln/Makefile
347   tests/ls-2/Makefile
348   tests/ls/Makefile
349   tests/md5sum/Makefile
350   tests/misc/Makefile
351   tests/mkdir/Makefile
352   tests/mv/Makefile
353   tests/od/Makefile
354   tests/pr/Makefile
355   tests/readlink/Makefile
356   tests/rm/Makefile
357   tests/rmdir/Makefile
358   tests/seq/Makefile
359   tests/sha1sum/Makefile
360   tests/shred/Makefile
361   tests/sort/Makefile
362   tests/stty/Makefile
363   tests/sum/Makefile
364   tests/tac/Makefile
365   tests/tail-2/Makefile
366   tests/tail/Makefile
367   tests/tee/Makefile
368   tests/test/Makefile
369   tests/touch/Makefile
370   tests/tr/Makefile
371   tests/tsort/Makefile
372   tests/unexpand/Makefile
373   tests/uniq/Makefile
374   tests/wc/Makefile
375   )
376 AC_OUTPUT