(readdir_ignoring_dotdirs): Move function to system.h, renaming it. Update uses.
[platform/upstream/coreutils.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2 AC_INIT([GNU coreutils],[5.3.0],[bug-coreutils@gnu.org])
3 AC_CONFIG_SRCDIR(src/ls.c)
4
5 AC_CONFIG_AUX_DIR(config)
6 AC_CONFIG_HEADERS([config.h:config.hin])
7
8 AM_INIT_AUTOMAKE([1.8.3 gnits dist-bzip2])
9
10 gl_DEFAULT_POSIX2_VERSION
11 gl_USE_SYSTEM_EXTENSIONS
12 gl_PERL
13 AC_PROG_CC
14 AC_PROG_CPP
15 AC_PROG_GCC_TRADITIONAL
16 AC_PROG_RANLIB
17 AC_PROG_LN_S
18 AC_CANONICAL_HOST
19
20
21 AC_CHECK_FUNCS(uname,
22         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uname\$(EXEEXT)"
23         MAN="$MAN uname.1")
24 AC_CHECK_FUNCS(chroot,
25         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS chroot\$(EXEEXT)"
26         MAN="$MAN chroot.1")
27 AC_CHECK_FUNCS(gethostid,
28         OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS hostid\$(EXEEXT)"
29         MAN="$MAN hostid.1")
30
31 gl_MACROS
32
33 AC_HEADER_TIOCGWINSZ()
34 gl_WINSIZE_IN_PTEM
35
36 AC_MSG_CHECKING(whether localtime caches TZ)
37 AC_CACHE_VAL(utils_cv_localtime_cache,
38 [if test x$ac_cv_func_tzset = xyes; then
39 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
40 #if STDC_HEADERS
41 # include <stdlib.h>
42 #endif
43 extern char **environ;
44 unset_TZ ()
45 {
46   char **from, **to;
47   for (to = from = environ; (*to = *from); from++)
48     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
49       to++;
50 }
51 main()
52 {
53   time_t now = time ((time_t *) 0);
54   int hour_GMT0, hour_unset;
55   if (putenv ("TZ=GMT0") != 0)
56     exit (1);
57   hour_GMT0 = localtime (&now)->tm_hour;
58   unset_TZ ();
59   hour_unset = localtime (&now)->tm_hour;
60   if (putenv ("TZ=PST8") != 0)
61     exit (1);
62   if (localtime (&now)->tm_hour == hour_GMT0)
63     exit (1);
64   unset_TZ ();
65   if (localtime (&now)->tm_hour != hour_unset)
66     exit (1);
67   exit (0);
68 }]])],
69 [utils_cv_localtime_cache=no],
70 [utils_cv_localtime_cache=yes],
71 [# If we have tzset, assume the worst when cross-compiling.
72 utils_cv_localtime_cache=yes])
73 else
74         # If we lack tzset, report that localtime does not cache TZ,
75         # since we can't invalidate the cache if we don't have tzset.
76         utils_cv_localtime_cache=no
77 fi])dnl
78 AC_MSG_RESULT($utils_cv_localtime_cache)
79 if test $utils_cv_localtime_cache = yes; then
80   AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
81 fi
82
83 # SCO-ODT-3.0 is reported to need -los to link programs using initgroups
84 AC_CHECK_FUNCS(initgroups)
85 if test $ac_cv_func_initgroups = no; then
86   AC_CHECK_LIB(os, initgroups)
87 fi
88
89 AC_CHECK_FUNCS(syslog)
90 if test $ac_cv_func_syslog = no; then
91   # syslog is not in the default libraries.  See if it's in some other.
92   for lib in bsd socket inet; do
93     AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
94       LIBS="$LIBS -l$lib"; break])
95   done
96 fi
97
98 AC_MSG_CHECKING(for 3-argument setpriority function)
99 AC_CACHE_VAL(utils_cv_func_setpriority,
100 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>
101   #include <sys/resource.h>]], [[setpriority(0, 0, 0);]])],
102   [utils_cv_func_setpriority=yes],
103   [utils_cv_func_setpriority=no])])
104 AC_MSG_RESULT($utils_cv_func_setpriority)
105 if test $utils_cv_func_setpriority = yes; then
106   OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS nice\$(EXEEXT)"
107   MAN="$MAN nice.1"
108 else
109   AC_MSG_CHECKING(for nice function)
110   AC_CACHE_VAL(utils_cv_func_nice,
111     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[nice();]])],
112                     [utils_cv_func_nice=yes],
113                     [utils_cv_func_nice=no])])
114   AC_MSG_RESULT($utils_cv_func_nice)
115   if test $utils_cv_func_nice = yes; then
116     AC_DEFINE(NICE_PRIORITY, 1, [FIXME])
117     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS nice\$(EXEEXT)"
118     MAN="$MAN nice.1"
119   fi
120 fi
121
122 AC_DEFUN([coreutils_DUMMY_1],
123 [
124   AC_REQUIRE([gl_READUTMP])
125   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
126     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS pinky\$(EXEEXT)"
127     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS users\$(EXEEXT)"
128     OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS who\$(EXEEXT)"
129     MAN="$MAN pinky.1 users.1 who.1"
130   fi
131 ])
132 coreutils_DUMMY_1
133
134 AC_MSG_CHECKING(ut_host in struct utmp)
135 AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
136 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
137 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],
138   [su_cv_func_ut_host_in_utmp=yes],
139   [su_cv_func_ut_host_in_utmp=no])])
140 AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
141 if test $su_cv_func_ut_host_in_utmp = yes; then
142   have_ut_host=1
143   AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
144 fi
145
146 if test -z "$have_ut_host"; then
147   AC_MSG_CHECKING(ut_host in struct utmpx)
148   AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
149   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
150 #include <utmpx.h>]], [[struct utmpx ut; ut.ut_host;]])],
151     [su_cv_func_ut_host_in_utmpx=yes],
152     [su_cv_func_ut_host_in_utmpx=no])])
153   AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
154   if test $su_cv_func_ut_host_in_utmpx = yes; then
155     AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
156     AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
157   fi
158 fi
159
160 GNULIB_BOOT_TIME(
161   [OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uptime\$(EXEEXT)"
162   MAN="$MAN uptime.1"])
163
164 AC_SYS_POSIX_TERMIOS()
165 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
166
167 if test $ac_cv_sys_posix_termios = yes; then
168   OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS stty\$(EXEEXT)" MAN="$MAN stty.1"
169
170   AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
171   AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
172   [AC_EGREP_CPP(yes, [#include <termios.h>
173 #ifdef IUCLC
174 yes
175 #endif], su_cv_sys_termios_needs_xopen_source=no,
176    AC_EGREP_CPP(yes, [#define _XOPEN_SOURCE
177 #include <termios.h>
178 #ifdef IUCLC
179 yes
180 #endif], su_cv_sys_termios_needs_xopen_source=yes,
181    su_cv_sys_termios_needs_xopen_source=no))])
182   AC_MSG_RESULT($su_cv_sys_termios_needs_xopen_source)
183   test $su_cv_sys_termios_needs_xopen_source = yes &&
184     AC_DEFINE(TERMIOS_NEEDS_XOPEN_SOURCE, 1, [FIXME])
185
186   AC_MSG_CHECKING(c_line in struct termios)
187   AC_CACHE_VAL(su_cv_sys_c_line_in_termios,
188   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
189 #define _XOPEN_SOURCE
190 #endif
191 #include <sys/types.h>
192 #include <termios.h>]], [[struct termios t; t.c_line;]])],
193     [su_cv_sys_c_line_in_termios=yes],
194     [su_cv_sys_c_line_in_termios=no])])
195   AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
196   test $su_cv_sys_c_line_in_termios = yes \
197     && AC_DEFINE(HAVE_C_LINE, 1, [FIXME])
198 fi
199
200 # FIXME: note that this macro appears above, too.
201 # I'm leaving it here for now.  This whole thing needs to be modernized...
202 gl_WINSIZE_IN_PTEM
203
204 gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
205
206 if test $jm_cv_sys_tiocgwinsz_needs_termios_h = no && \
207    test $jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
208   AC_MSG_CHECKING(TIOCGWINSZ in sys/pty.h)
209   AC_CACHE_VAL(su_cv_sys_tiocgwinsz_in_sys_pty_h,
210   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
211 #ifdef WINSIZE_IN_PTEM
212 # include <sys/stream.h>
213 # include <sys/ptem.h>
214 #endif
215 #include <sys/ioctl.h>
216 #include <sys/tty.h>
217 #include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
218     [su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
219     [su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
220   AC_MSG_RESULT($su_cv_sys_tiocgwinsz_in_sys_pty_h)
221
222   test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
223       && AC_DEFINE(GWINSZ_IN_SYS_PTY, 1,
224                    [Define if your system defines TIOCGWINSZ in sys/pty.h.])
225 fi
226
227 # For src/kill.c.
228 AC_CHECK_DECLS([strtoimax])
229 AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
230   [AC_INCLUDES_DEFAULT
231 #include <signal.h>])
232
233 gl_LIB_CHECK
234
235 AM_GNU_GETTEXT([external], [need-ngettext])
236 AM_GNU_GETTEXT_VERSION(0.13.1)
237
238 AC_CONFIG_FILES(
239   Makefile
240   doc/Makefile
241   lib/Makefile
242   man/Makefile
243   po/Makefile.in
244   src/Makefile
245   tests/Makefile
246   tests/basename/Makefile
247   tests/chgrp/Makefile
248   tests/chmod/Makefile
249   tests/chown/Makefile
250   tests/cp/Makefile
251   tests/cut/Makefile
252   tests/date/Makefile
253   tests/dd/Makefile
254   tests/dircolors/Makefile
255   tests/du/Makefile
256   tests/expr/Makefile
257   tests/factor/Makefile
258   tests/fmt/Makefile
259   tests/head/Makefile
260   tests/install/Makefile
261   tests/join/Makefile
262   tests/ln/Makefile
263   tests/ls-2/Makefile
264   tests/ls/Makefile
265   tests/md5sum/Makefile
266   tests/misc/Makefile
267   tests/mkdir/Makefile
268   tests/mv/Makefile
269   tests/od/Makefile
270   tests/pr/Makefile
271   tests/rm/Makefile
272   tests/rmdir/Makefile
273   tests/seq/Makefile
274   tests/sha1sum/Makefile
275   tests/shred/Makefile
276   tests/sort/Makefile
277   tests/stty/Makefile
278   tests/sum/Makefile
279   tests/tac/Makefile
280   tests/tail-2/Makefile
281   tests/tail/Makefile
282   tests/test/Makefile
283   tests/touch/Makefile
284   tests/tr/Makefile
285   tests/tsort/Makefile
286   tests/unexpand/Makefile
287   tests/uniq/Makefile
288   tests/wc/Makefile
289   )
290 AC_OUTPUT