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