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