move wc tests from own subdir into a single script
[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-2008 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 AB_INIT()
36 AM_INIT_AUTOMAKE([1.10.1 dist-lzma])
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_FUNC_FORK
49
50 optional_bin_progs=
51 AC_CHECK_FUNCS(uname,
52         gl_ADD_PROG([optional_bin_progs], [uname]))
53 AC_CHECK_FUNCS(chroot,
54         gl_ADD_PROG([optional_bin_progs], [chroot]))
55 AC_CHECK_FUNCS(gethostid,
56         gl_ADD_PROG([optional_bin_progs], [hostid]))
57
58 gl_WINSIZE_IN_PTEM
59
60 AC_MSG_CHECKING(whether localtime caches TZ)
61 AC_CACHE_VAL(utils_cv_localtime_cache,
62 [if test x$ac_cv_func_tzset = xyes; then
63 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
64 #if STDC_HEADERS
65 # include <stdlib.h>
66 #endif
67 extern char **environ;
68 void unset_TZ (void)
69 {
70   char **from, **to;
71   for (to = from = environ; (*to = *from); from++)
72     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
73       to++;
74 }
75 int main()
76 {
77   time_t now = time ((time_t *) 0);
78   int hour_GMT0, hour_unset;
79   if (putenv ("TZ=GMT0") != 0)
80     exit (1);
81   hour_GMT0 = localtime (&now)->tm_hour;
82   unset_TZ ();
83   hour_unset = localtime (&now)->tm_hour;
84   if (putenv ("TZ=PST8") != 0)
85     exit (1);
86   if (localtime (&now)->tm_hour == hour_GMT0)
87     exit (1);
88   unset_TZ ();
89   if (localtime (&now)->tm_hour != hour_unset)
90     exit (1);
91   exit (0);
92 }]])],
93 [utils_cv_localtime_cache=no],
94 [utils_cv_localtime_cache=yes],
95 [# If we have tzset, assume the worst when cross-compiling.
96 utils_cv_localtime_cache=yes])
97 else
98         # If we lack tzset, report that localtime does not cache TZ,
99         # since we can't invalidate the cache if we don't have tzset.
100         utils_cv_localtime_cache=no
101 fi])dnl
102 AC_MSG_RESULT($utils_cv_localtime_cache)
103 if test $utils_cv_localtime_cache = yes; then
104   AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
105 fi
106
107 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
108 AC_CHECK_FUNCS(initgroups)
109 if test $ac_cv_func_initgroups = no; then
110   AC_CHECK_LIB(os, initgroups)
111 fi
112
113 AC_CHECK_FUNCS(syslog)
114 if test $ac_cv_func_syslog = no; then
115   # syslog is not in the default libraries.  See if it's in some other.
116   for lib in bsd socket inet; do
117     AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
118       LIBS="$LIBS -l$lib"; break])
119   done
120 fi
121
122 AC_CACHE_CHECK([for 3-argument setpriority function],
123   [utils_cv_func_setpriority],
124   [AC_LINK_IFELSE(
125     [AC_LANG_PROGRAM(
126        [[#include <sys/time.h>
127          #include <sys/resource.h>
128        ]],
129        [[setpriority (0, 0, 0);]])],
130     [utils_cv_func_setpriority=yes],
131     [utils_cv_func_setpriority=no])])
132 if test $utils_cv_func_setpriority = no; then
133   AC_CHECK_FUNCS([nice])
134 fi
135 case $utils_cv_func_setpriority,$ac_cv_func_nice in
136 *yes*)
137   gl_ADD_PROG([optional_bin_progs], [nice])
138 esac
139
140 AC_DEFUN([coreutils_DUMMY_1],
141 [
142   AC_REQUIRE([gl_READUTMP])
143   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
144     gl_ADD_PROG([optional_bin_progs], [who])
145     gl_ADD_PROG([optional_bin_progs], [users])
146     gl_ADD_PROG([optional_bin_progs], [pinky])
147   fi
148 ])
149 coreutils_DUMMY_1
150
151 AC_MSG_CHECKING(ut_host in struct utmp)
152 AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
153 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
154 #include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
155   [su_cv_func_ut_host_in_utmp=yes],
156   [su_cv_func_ut_host_in_utmp=no])])
157 AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
158 if test $su_cv_func_ut_host_in_utmp = yes; then
159   have_ut_host=1
160   AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
161 fi
162
163 if test -z "$have_ut_host"; then
164   AC_MSG_CHECKING(ut_host in struct utmpx)
165   AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
166   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
167 #include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
168     [su_cv_func_ut_host_in_utmpx=yes],
169     [su_cv_func_ut_host_in_utmpx=no])])
170   AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
171   if test $su_cv_func_ut_host_in_utmpx = yes; then
172     AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
173     AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
174   fi
175 fi
176
177 GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
178
179 AC_SYS_POSIX_TERMIOS()
180 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
181
182 if test $ac_cv_sys_posix_termios = yes; then
183   gl_ADD_PROG([optional_bin_progs], [stty])
184
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
189 yes
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
194 yes
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])
200
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])
213 fi
214
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
218
219 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
220
221 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
222    test $gl_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)
236
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.])
240 fi
241
242 # For src/kill.c.
243 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
244   [AC_INCLUDES_DEFAULT
245 #include <signal.h>])
246
247 cu_LIB_CHECK
248
249 # Build df only if there's a point to it.
250 if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
251   gl_ADD_PROG([optional_bin_progs], [df])
252 fi
253
254 ############################################################################
255 mk="$srcdir/src/Makefile.am"
256 # Extract all literal names from the definition of $(EXTRA_PROGRAMS)
257 # in $mk but don't expand the variable references.
258 # Append each literal name to $optional_bin_progs.
259 v=EXTRA_PROGRAMS
260 for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
261     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
262     | tr -s '\\015\\012\\\\' '  '`; do
263   gl_ADD_PROG([optional_bin_progs], $gl_i)
264 done
265
266 # As above, extract literal names from the definition of $(no_install__progs)
267 # in $mk but don't expand the variable references.
268 v=no_install__progs
269 t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
270     | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
271     | tr -s '\\015\\012\\\\' '   '`
272 # Remove any trailing space.
273 no_install_progs_default=`echo "$t"|sed 's/ $//'`
274
275 # Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
276 # of default-not-installed programs, "arch hostname su", must appear in two
277 # places: in this file below, and in $mk.  Using "$no_install_progs_default"
278 # below cannot work.  And we can't substitute the names into $mk because
279 # automake needs the literals, too.
280 # The compromise is to ensure that the space-separated list extracted
281 # above matches the literal 2nd argument below.
282 c="$srcdir/configure.ac"
283 re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
284 t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
285 }' $c`
286 case $t in
287   $no_install_progs_default) ;;
288   *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
289                    does not match the list of default-not-installed programs
290                    ($no_install_progs_default) also recorded in $mk]],
291                    1) ;;
292 esac
293
294 # Given the name of a variable containing a space-separated list of
295 # install-by-default programs and the actual list do-not-install-by-default
296 # programs, modify the former variable to reflect any "do-install" and
297 # "don't-install" requests.
298 # I.e., add any program name specified via --enable-install-program=..., and
299 # remove any program name specified via --enable-no-install-program=...
300 # Note how the second argument below is a literal, with "," separators.
301 # That is required due to the way the macro works, and since the
302 # corresponding ./configure option argument is comma-separated on input.
303 gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
304
305 # Set INSTALL_SU if su installation has been requested via
306 # --enable-install-program=su.
307 AC_SUBST([INSTALL_SU])
308 case " $optional_bin_progs " in
309   *' su '*) INSTALL_SU=yes ;;
310   *)        INSTALL_SU=no ;;
311 esac
312
313 MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
314
315 # Change ginstall.1 to "install.h" in $MAN.
316 MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
317   | tr '\015\012' ' '; echo`
318
319 # Remove [.1, since writing a portable rule for it in man/Makefile.am
320 # is not practical.  The sed LHS below uses the autoconf quadrigraph
321 # representing '['.
322 MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
323
324 OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
325 AC_SUBST([OPTIONAL_BIN_PROGS])
326 NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
327 AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
328
329 # Arrange to rerun configure whenever the file, src/Makefile.am,
330 # containing the list of program names changes.
331 CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
332 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
333 ############################################################################
334
335 AM_GNU_GETTEXT([external], [need-formatstring-macros])
336 AM_GNU_GETTEXT_VERSION([0.15])
337
338 AC_CONFIG_FILES(
339   Makefile
340   doc/Makefile
341   lib/Makefile
342   man/Makefile
343   po/Makefile.in
344   src/Makefile
345   tests/Makefile
346   gnulib-tests/Makefile
347   tests/cut/Makefile
348   tests/head/Makefile
349   tests/join/Makefile
350   tests/pr/Makefile
351   tests/sort/Makefile
352   tests/tac/Makefile
353   tests/tail/Makefile
354   tests/test/Makefile
355   tests/tr/Makefile
356   tests/uniq/Makefile
357   )
358 AC_OUTPUT