.
[platform/upstream/coreutils.git] / aclocal.m4
1 # generated automatically by aclocal 1.7.5 -*- Autoconf -*-
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 # Do all the work for Automake.                            -*- Autoconf -*-
15
16 # This macro actually does too much some checks are only needed if
17 # your package does certain things.  But this isn't really a big deal.
18
19 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
20 # Free Software Foundation, Inc.
21
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License as published by
24 # the Free Software Foundation; either version 2, or (at your option)
25 # any later version.
26
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30 # GNU General Public License for more details.
31
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write to the Free Software
34 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
35 # 02111-1307, USA.
36
37 # serial 10
38
39 AC_PREREQ([2.54])
40
41 # Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
42 # the ones we care about.
43 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
44
45 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
46 # AM_INIT_AUTOMAKE([OPTIONS])
47 # -----------------------------------------------
48 # The call with PACKAGE and VERSION arguments is the old style
49 # call (pre autoconf-2.50), which is being phased out.  PACKAGE
50 # and VERSION should now be passed to AC_INIT and removed from
51 # the call to AM_INIT_AUTOMAKE.
52 # We support both call styles for the transition.  After
53 # the next Automake release, Autoconf can make the AC_INIT
54 # arguments mandatory, and then we can depend on a new Autoconf
55 # release and drop the old call support.
56 AC_DEFUN([AM_INIT_AUTOMAKE],
57 [AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
58  AC_REQUIRE([AC_PROG_INSTALL])dnl
59 # test to see if srcdir already configured
60 if test "`cd $srcdir && pwd`" != "`pwd`" &&
61    test -f $srcdir/config.status; then
62   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
63 fi
64
65 # test whether we have cygpath
66 if test -z "$CYGPATH_W"; then
67   if (cygpath --version) >/dev/null 2>/dev/null; then
68     CYGPATH_W='cygpath -w'
69   else
70     CYGPATH_W=echo
71   fi
72 fi
73 AC_SUBST([CYGPATH_W])
74
75 # Define the identity of the package.
76 dnl Distinguish between old-style and new-style calls.
77 m4_ifval([$2],
78 [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
79  AC_SUBST([PACKAGE], [$1])dnl
80  AC_SUBST([VERSION], [$2])],
81 [_AM_SET_OPTIONS([$1])dnl
82  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
83  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
84
85 _AM_IF_OPTION([no-define],,
86 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
87  AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
88
89 # Some tools Automake needs.
90 AC_REQUIRE([AM_SANITY_CHECK])dnl
91 AC_REQUIRE([AC_ARG_PROGRAM])dnl
92 AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
93 AM_MISSING_PROG(AUTOCONF, autoconf)
94 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
95 AM_MISSING_PROG(AUTOHEADER, autoheader)
96 AM_MISSING_PROG(MAKEINFO, makeinfo)
97 AM_MISSING_PROG(AMTAR, tar)
98 AM_PROG_INSTALL_SH
99 AM_PROG_INSTALL_STRIP
100 # We need awk for the "check" target.  The system "awk" is bad on
101 # some platforms.
102 AC_REQUIRE([AC_PROG_AWK])dnl
103 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
104 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
105
106 _AM_IF_OPTION([no-dependencies],,
107 [AC_PROVIDE_IFELSE([AC_PROG_CC],
108                   [_AM_DEPENDENCIES(CC)],
109                   [define([AC_PROG_CC],
110                           defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
111 AC_PROVIDE_IFELSE([AC_PROG_CXX],
112                   [_AM_DEPENDENCIES(CXX)],
113                   [define([AC_PROG_CXX],
114                           defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
115 ])
116 ])
117
118
119 # When config.status generates a header, we must update the stamp-h file.
120 # This file resides in the same directory as the config header
121 # that is generated.  The stamp files are numbered to have different names.
122
123 # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
124 # loop where config.status creates the headers, so we can generate
125 # our stamp files there.
126 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
127 [# Compute $1's index in $config_headers.
128 _am_stamp_count=1
129 for _am_header in $config_headers :; do
130   case $_am_header in
131     $1 | $1:* )
132       break ;;
133     * )
134       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
135   esac
136 done
137 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
138
139 # Copyright 2002  Free Software Foundation, Inc.
140
141 # This program is free software; you can redistribute it and/or modify
142 # it under the terms of the GNU General Public License as published by
143 # the Free Software Foundation; either version 2, or (at your option)
144 # any later version.
145
146 # This program is distributed in the hope that it will be useful,
147 # but WITHOUT ANY WARRANTY; without even the implied warranty of
148 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
149 # GNU General Public License for more details.
150
151 # You should have received a copy of the GNU General Public License
152 # along with this program; if not, write to the Free Software
153 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
154
155 # AM_AUTOMAKE_VERSION(VERSION)
156 # ----------------------------
157 # Automake X.Y traces this macro to ensure aclocal.m4 has been
158 # generated from the m4 files accompanying Automake X.Y.
159 AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
160
161 # AM_SET_CURRENT_AUTOMAKE_VERSION
162 # -------------------------------
163 # Call AM_AUTOMAKE_VERSION so it can be traced.
164 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
165 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
166          [AM_AUTOMAKE_VERSION([1.7.5])])
167
168 # Helper functions for option handling.                    -*- Autoconf -*-
169
170 # Copyright 2001, 2002  Free Software Foundation, Inc.
171
172 # This program is free software; you can redistribute it and/or modify
173 # it under the terms of the GNU General Public License as published by
174 # the Free Software Foundation; either version 2, or (at your option)
175 # any later version.
176
177 # This program is distributed in the hope that it will be useful,
178 # but WITHOUT ANY WARRANTY; without even the implied warranty of
179 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
180 # GNU General Public License for more details.
181
182 # You should have received a copy of the GNU General Public License
183 # along with this program; if not, write to the Free Software
184 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
185 # 02111-1307, USA.
186
187 # serial 2
188
189 # _AM_MANGLE_OPTION(NAME)
190 # -----------------------
191 AC_DEFUN([_AM_MANGLE_OPTION],
192 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
193
194 # _AM_SET_OPTION(NAME)
195 # ------------------------------
196 # Set option NAME.  Presently that only means defining a flag for this option.
197 AC_DEFUN([_AM_SET_OPTION],
198 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
199
200 # _AM_SET_OPTIONS(OPTIONS)
201 # ----------------------------------
202 # OPTIONS is a space-separated list of Automake options.
203 AC_DEFUN([_AM_SET_OPTIONS],
204 [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
205
206 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
207 # -------------------------------------------
208 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
209 AC_DEFUN([_AM_IF_OPTION],
210 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
211
212 #
213 # Check to make sure that the build environment is sane.
214 #
215
216 # Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
217
218 # This program is free software; you can redistribute it and/or modify
219 # it under the terms of the GNU General Public License as published by
220 # the Free Software Foundation; either version 2, or (at your option)
221 # any later version.
222
223 # This program is distributed in the hope that it will be useful,
224 # but WITHOUT ANY WARRANTY; without even the implied warranty of
225 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
226 # GNU General Public License for more details.
227
228 # You should have received a copy of the GNU General Public License
229 # along with this program; if not, write to the Free Software
230 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
231 # 02111-1307, USA.
232
233 # serial 3
234
235 # AM_SANITY_CHECK
236 # ---------------
237 AC_DEFUN([AM_SANITY_CHECK],
238 [AC_MSG_CHECKING([whether build environment is sane])
239 # Just in case
240 sleep 1
241 echo timestamp > conftest.file
242 # Do `set' in a subshell so we don't clobber the current shell's
243 # arguments.  Must try -L first in case configure is actually a
244 # symlink; some systems play weird games with the mod time of symlinks
245 # (eg FreeBSD returns the mod time of the symlink's containing
246 # directory).
247 if (
248    set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
249    if test "$[*]" = "X"; then
250       # -L didn't work.
251       set X `ls -t $srcdir/configure conftest.file`
252    fi
253    rm -f conftest.file
254    if test "$[*]" != "X $srcdir/configure conftest.file" \
255       && test "$[*]" != "X conftest.file $srcdir/configure"; then
256
257       # If neither matched, then we have a broken ls.  This can happen
258       # if, for instance, CONFIG_SHELL is bash and it inherits a
259       # broken ls alias from the environment.  This has actually
260       # happened.  Such a system could not be considered "sane".
261       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
262 alias in your environment])
263    fi
264
265    test "$[2]" = conftest.file
266    )
267 then
268    # Ok.
269    :
270 else
271    AC_MSG_ERROR([newly created file is older than distributed files!
272 Check your system clock])
273 fi
274 AC_MSG_RESULT(yes)])
275
276 #  -*- Autoconf -*-
277
278
279 # Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
280
281 # This program is free software; you can redistribute it and/or modify
282 # it under the terms of the GNU General Public License as published by
283 # the Free Software Foundation; either version 2, or (at your option)
284 # any later version.
285
286 # This program is distributed in the hope that it will be useful,
287 # but WITHOUT ANY WARRANTY; without even the implied warranty of
288 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
289 # GNU General Public License for more details.
290
291 # You should have received a copy of the GNU General Public License
292 # along with this program; if not, write to the Free Software
293 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
294 # 02111-1307, USA.
295
296 # serial 3
297
298 # AM_MISSING_PROG(NAME, PROGRAM)
299 # ------------------------------
300 AC_DEFUN([AM_MISSING_PROG],
301 [AC_REQUIRE([AM_MISSING_HAS_RUN])
302 $1=${$1-"${am_missing_run}$2"}
303 AC_SUBST($1)])
304
305
306 # AM_MISSING_HAS_RUN
307 # ------------------
308 # Define MISSING if not defined so far and test if it supports --run.
309 # If it does, set am_missing_run to use it, otherwise, to nothing.
310 AC_DEFUN([AM_MISSING_HAS_RUN],
311 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
312 test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
313 # Use eval to expand $SHELL
314 if eval "$MISSING --run true"; then
315   am_missing_run="$MISSING --run "
316 else
317   am_missing_run=
318   AC_MSG_WARN([`missing' script is too old or missing])
319 fi
320 ])
321
322 # AM_AUX_DIR_EXPAND
323
324 # Copyright 2001 Free Software Foundation, Inc.
325
326 # This program is free software; you can redistribute it and/or modify
327 # it under the terms of the GNU General Public License as published by
328 # the Free Software Foundation; either version 2, or (at your option)
329 # any later version.
330
331 # This program is distributed in the hope that it will be useful,
332 # but WITHOUT ANY WARRANTY; without even the implied warranty of
333 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
334 # GNU General Public License for more details.
335
336 # You should have received a copy of the GNU General Public License
337 # along with this program; if not, write to the Free Software
338 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
339 # 02111-1307, USA.
340
341 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
342 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
343 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
344 #
345 # Of course, Automake must honor this variable whenever it calls a
346 # tool from the auxiliary directory.  The problem is that $srcdir (and
347 # therefore $ac_aux_dir as well) can be either absolute or relative,
348 # depending on how configure is run.  This is pretty annoying, since
349 # it makes $ac_aux_dir quite unusable in subdirectories: in the top
350 # source directory, any form will work fine, but in subdirectories a
351 # relative path needs to be adjusted first.
352 #
353 # $ac_aux_dir/missing
354 #    fails when called from a subdirectory if $ac_aux_dir is relative
355 # $top_srcdir/$ac_aux_dir/missing
356 #    fails if $ac_aux_dir is absolute,
357 #    fails when called from a subdirectory in a VPATH build with
358 #          a relative $ac_aux_dir
359 #
360 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
361 # are both prefixed by $srcdir.  In an in-source build this is usually
362 # harmless because $srcdir is `.', but things will broke when you
363 # start a VPATH build or use an absolute $srcdir.
364 #
365 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
366 # iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
367 #   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
368 # and then we would define $MISSING as
369 #   MISSING="\${SHELL} $am_aux_dir/missing"
370 # This will work as long as MISSING is not called from configure, because
371 # unfortunately $(top_srcdir) has no meaning in configure.
372 # However there are other variables, like CC, which are often used in
373 # configure, and could therefore not use this "fixed" $ac_aux_dir.
374 #
375 # Another solution, used here, is to always expand $ac_aux_dir to an
376 # absolute PATH.  The drawback is that using absolute paths prevent a
377 # configured tree to be moved without reconfiguration.
378
379 # Rely on autoconf to set up CDPATH properly.
380 AC_PREREQ([2.50])
381
382 AC_DEFUN([AM_AUX_DIR_EXPAND], [
383 # expand $ac_aux_dir to an absolute path
384 am_aux_dir=`cd $ac_aux_dir && pwd`
385 ])
386
387 # AM_PROG_INSTALL_SH
388 # ------------------
389 # Define $install_sh.
390
391 # Copyright 2001 Free Software Foundation, Inc.
392
393 # This program is free software; you can redistribute it and/or modify
394 # it under the terms of the GNU General Public License as published by
395 # the Free Software Foundation; either version 2, or (at your option)
396 # any later version.
397
398 # This program is distributed in the hope that it will be useful,
399 # but WITHOUT ANY WARRANTY; without even the implied warranty of
400 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
401 # GNU General Public License for more details.
402
403 # You should have received a copy of the GNU General Public License
404 # along with this program; if not, write to the Free Software
405 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
406 # 02111-1307, USA.
407
408 AC_DEFUN([AM_PROG_INSTALL_SH],
409 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
410 install_sh=${install_sh-"$am_aux_dir/install-sh"}
411 AC_SUBST(install_sh)])
412
413 # AM_PROG_INSTALL_STRIP
414
415 # Copyright 2001 Free Software Foundation, Inc.
416
417 # This program is free software; you can redistribute it and/or modify
418 # it under the terms of the GNU General Public License as published by
419 # the Free Software Foundation; either version 2, or (at your option)
420 # any later version.
421
422 # This program is distributed in the hope that it will be useful,
423 # but WITHOUT ANY WARRANTY; without even the implied warranty of
424 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
425 # GNU General Public License for more details.
426
427 # You should have received a copy of the GNU General Public License
428 # along with this program; if not, write to the Free Software
429 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
430 # 02111-1307, USA.
431
432 # One issue with vendor `install' (even GNU) is that you can't
433 # specify the program used to strip binaries.  This is especially
434 # annoying in cross-compiling environments, where the build's strip
435 # is unlikely to handle the host's binaries.
436 # Fortunately install-sh will honor a STRIPPROG variable, so we
437 # always use install-sh in `make install-strip', and initialize
438 # STRIPPROG with the value of the STRIP variable (set by the user).
439 AC_DEFUN([AM_PROG_INSTALL_STRIP],
440 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
441 # Installed binaries are usually stripped using `strip' when the user
442 # run `make install-strip'.  However `strip' might not be the right
443 # tool to use in cross-compilation environments, therefore Automake
444 # will honor the `STRIP' environment variable to overrule this program.
445 dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
446 if test "$cross_compiling" != no; then
447   AC_CHECK_TOOL([STRIP], [strip], :)
448 fi
449 INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
450 AC_SUBST([INSTALL_STRIP_PROGRAM])])
451
452 #                                                          -*- Autoconf -*-
453 # Copyright (C) 2003  Free Software Foundation, Inc.
454
455 # This program is free software; you can redistribute it and/or modify
456 # it under the terms of the GNU General Public License as published by
457 # the Free Software Foundation; either version 2, or (at your option)
458 # any later version.
459
460 # This program is distributed in the hope that it will be useful,
461 # but WITHOUT ANY WARRANTY; without even the implied warranty of
462 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
463 # GNU General Public License for more details.
464
465 # You should have received a copy of the GNU General Public License
466 # along with this program; if not, write to the Free Software
467 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
468 # 02111-1307, USA.
469
470 # serial 1
471
472 # Check whether the underlying file-system supports filenames
473 # with a leading dot.  For instance MS-DOS doesn't.
474 AC_DEFUN([AM_SET_LEADING_DOT],
475 [rm -rf .tst 2>/dev/null
476 mkdir .tst 2>/dev/null
477 if test -d .tst; then
478   am__leading_dot=.
479 else
480   am__leading_dot=_
481 fi
482 rmdir .tst 2>/dev/null
483 AC_SUBST([am__leading_dot])])
484
485 # serial 5                                              -*- Autoconf -*-
486
487 # Copyright (C) 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
488
489 # This program is free software; you can redistribute it and/or modify
490 # it under the terms of the GNU General Public License as published by
491 # the Free Software Foundation; either version 2, or (at your option)
492 # any later version.
493
494 # This program is distributed in the hope that it will be useful,
495 # but WITHOUT ANY WARRANTY; without even the implied warranty of
496 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
497 # GNU General Public License for more details.
498
499 # You should have received a copy of the GNU General Public License
500 # along with this program; if not, write to the Free Software
501 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
502 # 02111-1307, USA.
503
504
505 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
506 # written in clear, in which case automake, when reading aclocal.m4,
507 # will think it sees a *use*, and therefore will trigger all it's
508 # C support machinery.  Also note that it means that autoscan, seeing
509 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
510
511
512
513 # _AM_DEPENDENCIES(NAME)
514 # ----------------------
515 # See how the compiler implements dependency checking.
516 # NAME is "CC", "CXX", "GCJ", or "OBJC".
517 # We try a few techniques and use that to set a single cache variable.
518 #
519 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
520 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
521 # dependency, and given that the user is not expected to run this macro,
522 # just rely on AC_PROG_CC.
523 AC_DEFUN([_AM_DEPENDENCIES],
524 [AC_REQUIRE([AM_SET_DEPDIR])dnl
525 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
526 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
527 AC_REQUIRE([AM_DEP_TRACK])dnl
528
529 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
530        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
531        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
532        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
533                    [depcc="$$1"   am_compiler_list=])
534
535 AC_CACHE_CHECK([dependency style of $depcc],
536                [am_cv_$1_dependencies_compiler_type],
537 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
538   # We make a subdir and do the tests there.  Otherwise we can end up
539   # making bogus files that we don't know about and never remove.  For
540   # instance it was reported that on HP-UX the gcc test will end up
541   # making a dummy file named `D' -- because `-MD' means `put the output
542   # in D'.
543   mkdir conftest.dir
544   # Copy depcomp to subdir because otherwise we won't find it if we're
545   # using a relative directory.
546   cp "$am_depcomp" conftest.dir
547   cd conftest.dir
548
549   am_cv_$1_dependencies_compiler_type=none
550   if test "$am_compiler_list" = ""; then
551      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
552   fi
553   for depmode in $am_compiler_list; do
554     # We need to recreate these files for each test, as the compiler may
555     # overwrite some of them when testing with obscure command lines.
556     # This happens at least with the AIX C compiler.
557     echo '#include "conftest.h"' > conftest.c
558     echo 'int i;' > conftest.h
559     echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
560
561     case $depmode in
562     nosideeffect)
563       # after this tag, mechanisms are not by side-effect, so they'll
564       # only be used when explicitly requested
565       if test "x$enable_dependency_tracking" = xyes; then
566         continue
567       else
568         break
569       fi
570       ;;
571     none) break ;;
572     esac
573     # We check with `-c' and `-o' for the sake of the "dashmstdout"
574     # mode.  It turns out that the SunPro C++ compiler does not properly
575     # handle `-M -o', and we need to detect this.
576     if depmode=$depmode \
577        source=conftest.c object=conftest.o \
578        depfile=conftest.Po tmpdepfile=conftest.TPo \
579        $SHELL ./depcomp $depcc -c -o conftest.o conftest.c \
580          >/dev/null 2>conftest.err &&
581        grep conftest.h conftest.Po > /dev/null 2>&1 &&
582        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
583       # icc doesn't choke on unknown options, it will just issue warnings
584       # (even with -Werror).  So we grep stderr for any message
585       # that says an option was ignored.
586       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
587         am_cv_$1_dependencies_compiler_type=$depmode
588         break
589       fi
590     fi
591   done
592
593   cd ..
594   rm -rf conftest.dir
595 else
596   am_cv_$1_dependencies_compiler_type=none
597 fi
598 ])
599 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
600 AM_CONDITIONAL([am__fastdep$1], [
601   test "x$enable_dependency_tracking" != xno \
602   && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
603 ])
604
605
606 # AM_SET_DEPDIR
607 # -------------
608 # Choose a directory name for dependency files.
609 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
610 AC_DEFUN([AM_SET_DEPDIR],
611 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
612 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
613 ])
614
615
616 # AM_DEP_TRACK
617 # ------------
618 AC_DEFUN([AM_DEP_TRACK],
619 [AC_ARG_ENABLE(dependency-tracking,
620 [  --disable-dependency-tracking Speeds up one-time builds
621   --enable-dependency-tracking  Do not reject slow dependency extractors])
622 if test "x$enable_dependency_tracking" != xno; then
623   am_depcomp="$ac_aux_dir/depcomp"
624   AMDEPBACKSLASH='\'
625 fi
626 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
627 AC_SUBST([AMDEPBACKSLASH])
628 ])
629
630 # Generate code to set up dependency tracking.   -*- Autoconf -*-
631
632 # Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
633
634 # This program is free software; you can redistribute it and/or modify
635 # it under the terms of the GNU General Public License as published by
636 # the Free Software Foundation; either version 2, or (at your option)
637 # any later version.
638
639 # This program is distributed in the hope that it will be useful,
640 # but WITHOUT ANY WARRANTY; without even the implied warranty of
641 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
642 # GNU General Public License for more details.
643
644 # You should have received a copy of the GNU General Public License
645 # along with this program; if not, write to the Free Software
646 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
647 # 02111-1307, USA.
648
649 #serial 2
650
651 # _AM_OUTPUT_DEPENDENCY_COMMANDS
652 # ------------------------------
653 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
654 [for mf in $CONFIG_FILES; do
655   # Strip MF so we end up with the name of the file.
656   mf=`echo "$mf" | sed -e 's/:.*$//'`
657   # Check whether this is an Automake generated Makefile or not.
658   # We used to match only the files named `Makefile.in', but
659   # some people rename them; so instead we look at the file content.
660   # Grep'ing the first line is not enough: some people post-process
661   # each Makefile.in and add a new line on top of each file to say so.
662   # So let's grep whole file.
663   if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
664     dirpart=`AS_DIRNAME("$mf")`
665   else
666     continue
667   fi
668   grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
669   # Extract the definition of DEP_FILES from the Makefile without
670   # running `make'.
671   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
672   test -z "$DEPDIR" && continue
673   # When using ansi2knr, U may be empty or an underscore; expand it
674   U=`sed -n -e '/^U = / s///p' < "$mf"`
675   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
676   # We invoke sed twice because it is the simplest approach to
677   # changing $(DEPDIR) to its actual value in the expansion.
678   for file in `sed -n -e '
679     /^DEP_FILES = .*\\\\$/ {
680       s/^DEP_FILES = //
681       :loop
682         s/\\\\$//
683         p
684         n
685         /\\\\$/ b loop
686       p
687     }
688     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
689        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
690     # Make sure the directory exists.
691     test -f "$dirpart/$file" && continue
692     fdir=`AS_DIRNAME(["$file"])`
693     AS_MKDIR_P([$dirpart/$fdir])
694     # echo "creating $dirpart/$file"
695     echo '# dummy' > "$dirpart/$file"
696   done
697 done
698 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
699
700
701 # AM_OUTPUT_DEPENDENCY_COMMANDS
702 # -----------------------------
703 # This macro should only be invoked once -- use via AC_REQUIRE.
704 #
705 # This code is only required when automatic dependency tracking
706 # is enabled.  FIXME.  This creates each `.P' file that we will
707 # need in order to bootstrap the dependency handling code.
708 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
709 [AC_CONFIG_COMMANDS([depfiles],
710      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
711      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
712 ])
713
714 # Check to see how 'make' treats includes.      -*- Autoconf -*-
715
716 # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
717
718 # This program is free software; you can redistribute it and/or modify
719 # it under the terms of the GNU General Public License as published by
720 # the Free Software Foundation; either version 2, or (at your option)
721 # any later version.
722
723 # This program is distributed in the hope that it will be useful,
724 # but WITHOUT ANY WARRANTY; without even the implied warranty of
725 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
726 # GNU General Public License for more details.
727
728 # You should have received a copy of the GNU General Public License
729 # along with this program; if not, write to the Free Software
730 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
731 # 02111-1307, USA.
732
733 # serial 2
734
735 # AM_MAKE_INCLUDE()
736 # -----------------
737 # Check to see how make treats includes.
738 AC_DEFUN([AM_MAKE_INCLUDE],
739 [am_make=${MAKE-make}
740 cat > confinc << 'END'
741 am__doit:
742         @echo done
743 .PHONY: am__doit
744 END
745 # If we don't find an include directive, just comment out the code.
746 AC_MSG_CHECKING([for style of include used by $am_make])
747 am__include="#"
748 am__quote=
749 _am_result=none
750 # First try GNU make style include.
751 echo "include confinc" > confmf
752 # We grep out `Entering directory' and `Leaving directory'
753 # messages which can occur if `w' ends up in MAKEFLAGS.
754 # In particular we don't look at `^make:' because GNU make might
755 # be invoked under some other name (usually "gmake"), in which
756 # case it prints its new name instead of `make'.
757 if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
758    am__include=include
759    am__quote=
760    _am_result=GNU
761 fi
762 # Now try BSD make style include.
763 if test "$am__include" = "#"; then
764    echo '.include "confinc"' > confmf
765    if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
766       am__include=.include
767       am__quote="\""
768       _am_result=BSD
769    fi
770 fi
771 AC_SUBST([am__include])
772 AC_SUBST([am__quote])
773 AC_MSG_RESULT([$_am_result])
774 rm -f confinc confmf
775 ])
776
777 # AM_CONDITIONAL                                              -*- Autoconf -*-
778
779 # Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
780
781 # This program is free software; you can redistribute it and/or modify
782 # it under the terms of the GNU General Public License as published by
783 # the Free Software Foundation; either version 2, or (at your option)
784 # any later version.
785
786 # This program is distributed in the hope that it will be useful,
787 # but WITHOUT ANY WARRANTY; without even the implied warranty of
788 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
789 # GNU General Public License for more details.
790
791 # You should have received a copy of the GNU General Public License
792 # along with this program; if not, write to the Free Software
793 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
794 # 02111-1307, USA.
795
796 # serial 5
797
798 AC_PREREQ(2.52)
799
800 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
801 # -------------------------------------
802 # Define a conditional.
803 AC_DEFUN([AM_CONDITIONAL],
804 [ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
805         [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
806 AC_SUBST([$1_TRUE])
807 AC_SUBST([$1_FALSE])
808 if $2; then
809   $1_TRUE=
810   $1_FALSE='#'
811 else
812   $1_TRUE='#'
813   $1_FALSE=
814 fi
815 AC_CONFIG_COMMANDS_PRE(
816 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
817   AC_MSG_ERROR([conditional "$1" was never defined.
818 Usually this means the macro was only invoked conditionally.])
819 fi])])
820
821 #serial 5
822
823 dnl From Jim Meyering.
824 dnl Find a new-enough version of Perl.
825 dnl
826
827 AC_DEFUN([jm_PERL],
828 [
829   dnl FIXME: don't hard-code 5.003
830   dnl FIXME: should we cache the result?
831   AC_MSG_CHECKING([for perl5.003 or newer])
832   if test "${PERL+set}" = set; then
833     # `PERL' is set in the user's environment.
834     candidate_perl_names="$PERL"
835     perl_specified=yes
836   else
837     candidate_perl_names='perl perl5'
838     perl_specified=no
839   fi
840
841   found=no
842   AC_SUBST(PERL)
843   PERL="$am_missing_run perl"
844   for perl in $candidate_perl_names; do
845     # Run test in a subshell; some versions of sh will print an error if
846     # an executable is not found, even if stderr is redirected.
847     if ( $perl -e 'require 5.003; use File::Compare' ) > /dev/null 2>&1; then
848       PERL=$perl
849       found=yes
850       break
851     fi
852   done
853
854   AC_MSG_RESULT($found)
855   test $found = no && AC_MSG_WARN([
856 WARNING: You don't seem to have perl5.003 or newer installed, or you lack
857          a usable version of the Perl File::Compare module.  As a result,
858          you may be unable to run a few tests or to regenerate certain
859          files if you modify the sources from which they are derived.
860 ] )
861 ])
862
863 #serial 65   -*- autoconf -*-
864
865 m4_undefine([AC_LANG_SOURCE(C)])
866 dnl The following is identical to the definition in c.m4
867 dnl from the autoconf cvs repository on 2003-03-07.
868 dnl FIXME: remove this code once we upgrade to autoconf-2.58.
869
870 # We can't use '#line $LINENO "configure"' here, since
871 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
872 # rejects $LINENO greater than 32767, and some configure scripts
873 # are longer than 32767 lines.
874 m4_define([AC_LANG_SOURCE(C)],
875 [/* confdefs.h.  */
876 _ACEOF
877 cat confdefs.h >>conftest.$ac_ext
878 cat >>conftest.$ac_ext <<_ACEOF
879 /* end confdefs.h.  */
880 $1])
881
882
883 dnl Misc type-related macros for fileutils, sh-utils, textutils.
884
885 AC_DEFUN([jm_MACROS],
886 [
887   AC_PREREQ(2.57)
888
889   GNU_PACKAGE="GNU $PACKAGE"
890   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
891     [The concatenation of the strings `GNU ', and PACKAGE.])
892   AC_SUBST(GNU_PACKAGE)
893
894   AM_MISSING_PROG(HELP2MAN, help2man)
895   AC_SUBST(OPTIONAL_BIN_PROGS)
896   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
897   AC_SUBST(MAN)
898   AC_SUBST(DF_PROG)
899
900   dnl This macro actually runs replacement code.  See isc-posix.m4.
901   AC_REQUIRE([AC_ISC_POSIX])dnl
902
903   jm_CHECK_ALL_TYPES
904   jm_INCLUDED_REGEX([lib/regex.c])
905
906   AC_REQUIRE([UTILS_HOST_OS])
907   AC_REQUIRE([UTILS_FUNC_MKDIR_TRAILING_SLASH])
908   AC_REQUIRE([jm_BISON])
909   AC_REQUIRE([jm_ASSERT])
910   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
911   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
912   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
913   AC_REQUIRE([jm_CHECK_DECLS])
914
915   AC_REQUIRE([jm_PREREQ])
916
917   AC_REQUIRE([UTILS_FUNC_DIRFD])
918   AC_REQUIRE([AC_FUNC_ACL])
919   AC_REQUIRE([AC_FUNC_FTW])
920   AC_REQUIRE([jm_FUNC_LCHOWN])
921   AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
922   AC_REQUIRE([jm_FUNC_CHOWN])
923   AC_REQUIRE([jm_FUNC_MKTIME])
924   AC_REQUIRE([jm_FUNC_LSTAT])
925   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
926   AC_REQUIRE([jm_FUNC_STAT])
927   AC_REQUIRE([AC_FUNC_REALLOC])
928   AC_REQUIRE([AC_FUNC_MALLOC])
929   AC_REQUIRE([AC_FUNC_STRERROR_R])
930   AC_REQUIRE([jm_FUNC_NANOSLEEP])
931   AC_REQUIRE([jm_FUNC_MEMCMP])
932   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
933   AC_REQUIRE([AC_FUNC_FNMATCH_GNU])
934   AC_REQUIRE([jm_FUNC_GROUP_MEMBER])
935   AC_REQUIRE([jm_FUNC_PUTENV])
936   AC_REQUIRE([jm_AFS])
937   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
938   AC_REQUIRE([jm_AC_PREREQ_XSTRTOIMAX])
939   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
940   AC_REQUIRE([AC_FUNC_ERROR_AT_LINE])
941   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
942   AC_REQUIRE([jm_FUNC_MKTIME])
943   AC_REQUIRE([jm_FUNC_FPENDING])
944
945   # This is for od and stat, and any other program that
946   # uses the PRI.MAX macros from inttypes.h.
947   AC_REQUIRE([gt_INTTYPES_PRI])
948
949   AC_REQUIRE([jm_FUNC_GETGROUPS])
950
951   AC_REQUIRE([AC_FUNC_FSEEKO])
952   AC_REQUIRE([AC_FUNC_VPRINTF])
953   AC_REQUIRE([AC_FUNC_ALLOCA])
954   AC_REQUIRE([gl_FUNC_ALLOCA])
955
956   AC_CONFIG_LIBOBJ_DIR([lib])
957   AC_FUNC_GETLOADAVG
958
959   AC_REQUIRE([jm_SYS_PROC_UPTIME])
960   AC_REQUIRE([jm_FUNC_FTRUNCATE])
961   AC_REQUIRE([vb_FUNC_RENAME])
962
963   AC_REPLACE_FUNCS(strcasecmp strncasecmp)
964   AC_REPLACE_FUNCS(dup2)
965   AC_REPLACE_FUNCS(gethostname getusershell)
966   AC_REPLACE_FUNCS(sig2str)
967   AC_REPLACE_FUNCS(strcspn stpcpy strstr strtol strtoul)
968   AC_REPLACE_FUNCS(strpbrk)
969   AC_REPLACE_FUNCS(euidaccess memcmp rmdir rpmatch strndup strverscmp)
970   AC_REPLACE_FUNCS(atexit)
971   AC_REPLACE_FUNCS(getpass)
972
973   # raise is used by at least sort and ls.
974   AC_REPLACE_FUNCS(raise)
975
976   dnl used by e.g. intl/*domain.c and lib/canon-host.c
977   AC_REPLACE_FUNCS(strdup)
978
979   AC_REPLACE_FUNCS(memchr memcpy memmove memrchr memset)
980   AC_CHECK_FUNCS(getpagesize)
981
982   AC_REQUIRE([UTILS_FUNC_MKSTEMP])
983
984   # By default, argmatch should fail calling usage (1).
985   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
986             [Define to the function xargmatch calls on failures.])
987   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
988             [Define to the declaration of the xargmatch failure function.])
989
990   dnl Used to define SETVBUF in sys2.h.
991   dnl This evokes the following warning from autoconf:
992   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
993   AC_FUNC_SETVBUF_REVERSED
994
995   # used by sleep and shred
996   # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
997   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
998
999   # Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
1000   # programs in the package would end up linked with that potentially-shared
1001   # library, inducing unnecessary run-time overhead.
1002   fetish_saved_libs=$LIBS
1003     AC_SEARCH_LIBS(clock_gettime, [rt posix4],
1004                    [LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
1005     AC_SUBST(LIB_CLOCK_GETTIME)
1006     AC_CHECK_FUNCS(clock_gettime clock_settime)
1007   LIBS=$fetish_saved_libs
1008   AC_CHECK_FUNCS(gettimeofday)
1009   AC_FUNC_GETTIMEOFDAY_CLOBBER
1010
1011   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
1012   AC_REQUIRE([jm_FUNC_UTIME])
1013   AC_REQUIRE([gl_FUNC_VASPRINTF])
1014   AC_REQUIRE([gl_FUNC_VASNPRINTF])
1015
1016   AC_CHECK_FUNCS( \
1017     bcopy \
1018     endgrent \
1019     endpwent \
1020     fchdir \
1021     fdatasync \
1022     ftime \
1023     ftruncate \
1024     getcwd \
1025     gethrtime \
1026     getmntinfo \
1027     hasmntopt \
1028     isascii \
1029     iswspace \
1030     lchown \
1031     listmntent \
1032     localeconv \
1033     memcpy \
1034     mempcpy \
1035     mkfifo \
1036     realpath \
1037     sethostname \
1038     strchr \
1039     strerror \
1040     strrchr \
1041     sysctl \
1042     sysinfo \
1043     wcrtomb \
1044     tzset \
1045   )
1046
1047   # for test.c
1048   AC_CHECK_FUNCS(setreuid setregid)
1049
1050   AM_FUNC_GETLINE
1051   if test $am_cv_func_working_getline != yes; then
1052     AC_CHECK_FUNCS(getdelim)
1053   fi
1054   AC_FUNC_OBSTACK
1055
1056   AC_FUNC_STRTOD
1057   AC_REQUIRE([UTILS_SYS_OPEN_MAX])
1058   AC_REQUIRE([GL_FUNC_GETCWD_PATH_MAX])
1059   AC_REQUIRE([GL_FUNC_READDIR])
1060
1061   # See if linking `seq' requires -lm.
1062   # It does on nearly every system.  The single exception (so far) is
1063   # BeOS which has all the math functions in the normal runtime library
1064   # and doesn't have a separate math library.
1065
1066   AC_SUBST(SEQ_LIBM)
1067   ac_seq_body='
1068      static double x, y;
1069      x = floor (x);
1070      x = rint (x);
1071      x = modf (x, &y);'
1072   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
1073     [ac_seq_save_LIBS="$LIBS"
1074      LIBS="$LIBS -lm"
1075      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
1076      LIBS="$ac_seq_save_LIBS"
1077     ])
1078
1079   AM_LANGINFO_CODESET
1080   jm_GLIBC21
1081   AM_ICONV
1082   jm_FUNC_UNLINK_BUSY_TEXT
1083
1084   # These tests are for df.
1085   jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
1086   jm_FSTYPENAME
1087   jm_FILE_SYSTEM_USAGE([space=yes], [space=no])
1088   if test $list_mounted_fs = yes && test $space = yes; then
1089     DF_PROG='df$(EXEEXT)'
1090     AC_LIBOBJ(fsusage)
1091     AC_LIBOBJ(mountlist)
1092   fi
1093   AC_REQUIRE([jm_AC_DOS])
1094   AC_REQUIRE([AC_FUNC_CANONICALIZE_FILE_NAME])
1095
1096   # If any of these functions don't exist (e.g. DJGPP 2.03),
1097   # use the corresponding stub.
1098   AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
1099   AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])
1100   AC_CHECK_FUNC([lstat], , [AC_LIBOBJ(lstat-stub)])
1101   AC_CHECK_FUNC([readlink], , [AC_LIBOBJ(readlink-stub)])
1102   AC_REQUIRE([AM_STDBOOL_H])
1103
1104 ])
1105
1106 # These tests must be run before any use of AC_CHECK_TYPE,
1107 # because that macro compiles code that tests e.g., HAVE_UNISTD_H.
1108 # See the definition of ac_includes_default in `configure'.
1109 AC_DEFUN([jm_CHECK_ALL_HEADERS],
1110 [
1111   AC_CHECK_HEADERS( \
1112     errno.h  \
1113     fcntl.h \
1114     float.h \
1115     hurd.h \
1116     limits.h \
1117     memory.h \
1118     mntent.h \
1119     mnttab.h \
1120     netdb.h \
1121     paths.h \
1122     stdlib.h \
1123     stddef.h \
1124     stdint.h \
1125     string.h \
1126     sys/filsys.h \
1127     sys/fs/s5param.h \
1128     sys/fs_types.h \
1129     sys/fstyp.h \
1130     sys/ioctl.h \
1131     sys/mntent.h \
1132     sys/mount.h \
1133     sys/param.h \
1134     sys/resource.h \
1135     sys/socket.h \
1136     sys/statfs.h \
1137     sys/statvfs.h \
1138     sys/sysctl.h \
1139     sys/systeminfo.h \
1140     sys/time.h \
1141     sys/timeb.h \
1142     sys/vfs.h \
1143     sys/wait.h \
1144     syslog.h \
1145     termios.h \
1146     unistd.h \
1147     utime.h \
1148     values.h \
1149   )
1150 ])
1151
1152 # This macro must be invoked before any tests that run the compiler.
1153 AC_DEFUN([jm_CHECK_ALL_TYPES],
1154 [
1155   dnl This test must come as early as possible after the compiler configuration
1156   dnl tests, because the choice of the file model can (in principle) affect
1157   dnl whether functions and headers are available, whether they work, etc.
1158   AC_REQUIRE([AC_SYS_LARGEFILE])
1159
1160   dnl This test must precede tests of compiler characteristics like
1161   dnl that for the inline keyword, since it may change the degree to
1162   dnl which the compiler supports such features.
1163   AC_REQUIRE([AM_C_PROTOTYPES])
1164
1165   dnl Checks for typedefs, structures, and compiler characteristics.
1166   AC_REQUIRE([AC_C_BIGENDIAN])
1167   AC_REQUIRE([AC_C_CONST])
1168   AC_REQUIRE([AC_C_VOLATILE])
1169   AC_REQUIRE([AC_C_INLINE])
1170   AC_REQUIRE([AC_C_LONG_DOUBLE])
1171
1172   AC_REQUIRE([jm_CHECK_ALL_HEADERS])
1173   AC_REQUIRE([AC_HEADER_DIRENT])
1174   AC_REQUIRE([AC_HEADER_STDC])
1175   AC_CHECK_MEMBERS(
1176     [struct stat.st_author,
1177      struct stat.st_blksize],,,
1178     [$ac_includes_default
1179 #include <sys/stat.h>
1180   ])
1181   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
1182
1183   AC_REQUIRE([AC_STRUCT_TM])
1184   AC_REQUIRE([AC_STRUCT_TIMEZONE])
1185   AC_REQUIRE([AC_HEADER_STAT])
1186   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
1187   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
1188   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
1189
1190   AC_REQUIRE([AC_TYPE_GETGROUPS])
1191   AC_REQUIRE([AC_TYPE_MODE_T])
1192   AC_REQUIRE([AC_TYPE_OFF_T])
1193   AC_REQUIRE([AC_TYPE_PID_T])
1194   AC_REQUIRE([AC_TYPE_SIGNAL])
1195   AC_REQUIRE([AC_TYPE_SIZE_T])
1196   AC_REQUIRE([AC_TYPE_UID_T])
1197   AC_CHECK_TYPE(ino_t, unsigned long)
1198
1199   dnl This relies on the fact that autoconf 2.14a's implementation of
1200   dnl AC_CHECK_TYPE checks includes unistd.h.
1201   AC_CHECK_TYPE(ssize_t, int)
1202   AC_CHECK_TYPE(major_t, unsigned int)
1203   AC_CHECK_TYPE(minor_t, unsigned int)
1204
1205   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
1206   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1207
1208   AC_REQUIRE([AC_HEADER_MAJOR])
1209   AC_REQUIRE([AC_HEADER_DIRENT])
1210
1211 ])
1212
1213 # isc-posix.m4 serial 2 (gettext-0.11.2)
1214 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
1215 dnl This file is free software, distributed under the terms of the GNU
1216 dnl General Public License.  As a special exception to the GNU General
1217 dnl Public License, this file may be distributed as part of a program
1218 dnl that contains a configuration script generated by Autoconf, under
1219 dnl the same distribution terms as the rest of that program.
1220
1221 # This file is not needed with autoconf-2.53 and newer.  Remove it in 2005.
1222
1223 # This test replaces the one in autoconf.
1224 # Currently this macro should have the same name as the autoconf macro
1225 # because gettext's gettext.m4 (distributed in the automake package)
1226 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
1227 # give these diagnostics:
1228 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
1229 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
1230
1231 undefine([AC_ISC_POSIX])
1232
1233 AC_DEFUN([AC_ISC_POSIX],
1234   [
1235     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
1236     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
1237   ]
1238 )
1239
1240 #serial 15
1241
1242 dnl Initially derived from code in GNU grep.
1243 dnl Mostly written by Jim Meyering.
1244
1245 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
1246 dnl
1247 AC_DEFUN([jm_INCLUDED_REGEX],
1248   [
1249     dnl Even packages that don't use regex.c can use this macro.
1250     dnl Of course, for them it doesn't do anything.
1251
1252     # Assume we'll default to using the included regex.c.
1253     ac_use_included_regex=yes
1254
1255     # However, if the system regex support is good enough that it passes the
1256     # the following run test, then default to *not* using the included regex.c.
1257     # If cross compiling, assume the test would fail and use the included
1258     # regex.c.  The first failing regular expression is from `Spencer ere
1259     # test #75' in grep-2.3.
1260     AC_CACHE_CHECK([for working re_compile_pattern],
1261                    jm_cv_func_working_re_compile_pattern,
1262       AC_TRY_RUN(
1263 [#include <stdio.h>
1264 #include <string.h>
1265 #include <regex.h>
1266           int
1267           main ()
1268           {
1269             static struct re_pattern_buffer regex;
1270             const char *s;
1271             struct re_registers regs;
1272             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
1273             memset (&regex, 0, sizeof (regex));
1274             [s = re_compile_pattern ("a[[:@:>@:]]b\n", 9, &regex);]
1275             /* This should fail with _Invalid character class name_ error.  */
1276             if (!s)
1277               exit (1);
1278
1279             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
1280             memset (&regex, 0, sizeof (regex));
1281             s = re_compile_pattern ("{1", 2, &regex);
1282
1283             if (s)
1284               exit (1);
1285
1286             /* The following example is derived from a problem report
1287                against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */
1288             memset (&regex, 0, sizeof (regex));
1289             s = re_compile_pattern ("[[anù]]*n", 7, &regex);
1290             if (s)
1291               exit (1);
1292
1293             /* This should match, but doesn't for e.g. glibc-2.2.1.  */
1294             if (re_match (&regex, "an", 2, 0, &regs) != 2)
1295               exit (1);
1296
1297             memset (&regex, 0, sizeof (regex));
1298             s = re_compile_pattern ("x", 1, &regex);
1299             if (s)
1300               exit (1);
1301
1302             /* The version of regex.c in e.g. GNU libc-2.2.93 didn't
1303                work with a negative RANGE argument.  */
1304             if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
1305               exit (1);
1306
1307             exit (0);
1308           }
1309         ],
1310                jm_cv_func_working_re_compile_pattern=yes,
1311                jm_cv_func_working_re_compile_pattern=no,
1312                dnl When crosscompiling, assume it's broken.
1313                jm_cv_func_working_re_compile_pattern=no))
1314     if test $jm_cv_func_working_re_compile_pattern = yes; then
1315       ac_use_included_regex=no
1316     fi
1317
1318     test -n "$1" || AC_MSG_ERROR([missing argument])
1319     m4_syscmd([test -f $1])
1320     ifelse(m4_sysval, 0,
1321       [
1322         AC_ARG_WITH(included-regex,
1323         [  --without-included-regex don't compile regex; this is the default on
1324                           systems with version 2 of the GNU C library
1325                           (use with caution on other system)],
1326                     jm_with_regex=$withval,
1327                     jm_with_regex=$ac_use_included_regex)
1328         if test "$jm_with_regex" = yes; then
1329           AC_LIBOBJ(regex)
1330           jm_PREREQ_REGEX
1331         fi
1332       ],
1333     )
1334   ]
1335 )
1336
1337 # Prerequisites of lib/regex.c.
1338 AC_DEFUN([jm_PREREQ_REGEX],
1339 [
1340   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1341   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1342   dnl to get them.
1343
1344   dnl Persuade glibc <string.h> to declare mempcpy().
1345   AC_REQUIRE([AC_GNU_SOURCE])
1346
1347   AC_REQUIRE([ACX_C_RESTRICT])
1348   AC_REQUIRE([AC_FUNC_ALLOCA])
1349   AC_REQUIRE([AC_HEADER_STDC])
1350   AC_CHECK_HEADERS_ONCE(limits.h string.h wchar.h wctype.h)
1351   AC_CHECK_FUNCS_ONCE(isascii mempcpy)
1352   AC_CHECK_FUNCS(btowc)
1353 ])
1354
1355 #serial 1001
1356 dnl based on acx_restrict.m4, from the GNU Autoconf Macro Archive at:
1357 dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_restrict.html
1358
1359 # Determine whether the C/C++ compiler supports the "restrict" keyword
1360 # introduced in ANSI C99, or an equivalent.  Do nothing if the compiler
1361 # accepts it.  Otherwise, if the compiler supports an equivalent (like
1362 # gcc's __restrict__) define "restrict" to be that.  Otherwise, define
1363 # "restrict" to be empty.
1364
1365 AC_DEFUN([ACX_C_RESTRICT],
1366 [AC_CACHE_CHECK([for C/C++ restrict keyword], acx_cv_c_restrict,
1367   [acx_cv_c_restrict=no
1368    # Try the official restrict keyword, then gcc's __restrict__.
1369    for acx_kw in restrict __restrict__; do
1370      AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1371       [float * $acx_kw x;])],
1372       [acx_cv_c_restrict=$acx_kw; break])
1373    done
1374   ])
1375  case $acx_cv_c_restrict in
1376    restrict) ;;
1377    no) AC_DEFINE(restrict,,
1378         [Define to equivalent of C99 restrict keyword, or to nothing if this
1379         is not supported.  Do not define if restrict is supported directly.]) ;;
1380    *)  AC_DEFINE_UNQUOTED(restrict, $acx_cv_c_restrict) ;;
1381  esac
1382 ])
1383
1384 # onceonly.m4 serial 2
1385 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
1386 dnl This file is free software, distributed under the terms of the GNU
1387 dnl General Public License.  As a special exception to the GNU General
1388 dnl Public License, this file may be distributed as part of a program
1389 dnl that contains a configuration script generated by Autoconf, under
1390 dnl the same distribution terms as the rest of that program.
1391
1392 dnl This file defines some "once only" variants of standard autoconf macros.
1393 dnl   AC_CHECK_HEADERS_ONCE         like  AC_CHECK_HEADERS
1394 dnl   AC_CHECK_FUNCS_ONCE           like  AC_CHECK_FUNCS
1395 dnl   AC_CHECK_DECLS_ONCE           like  AC_CHECK_DECLS
1396 dnl   AC_REQUIRE([AC_HEADER_STDC])  like  AC_HEADER_STDC
1397 dnl The advantage is that the check for each of the headers/functions/decls
1398 dnl will be put only once into the 'configure' file. It keeps the size of
1399 dnl the 'configure' file down, and avoids redundant output when 'configure'
1400 dnl is run.
1401 dnl The drawback is that the checks cannot be conditionalized. If you write
1402 dnl   if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
1403 dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
1404 dnl empty, and the check will be inserted before the body of the AC_DEFUNed
1405 dnl function.
1406
1407 dnl Taken from Autoconf 2.50; can be removed once we assume 2.50 or later.
1408 define([m4_quote], [[$*]])
1409
1410 # AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
1411 # AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
1412 AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
1413   :
1414   AC_FOREACH([gl_HEADER_NAME], [$1], [
1415     AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(defn([gl_HEADER_NAME]),
1416                                                  [-./], [___])), [
1417       AC_CHECK_HEADERS(gl_HEADER_NAME)
1418     ])
1419     AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
1420                                                    [-./], [___])))
1421   ])
1422 ])
1423
1424 # AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
1425 # AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
1426 AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
1427   :
1428   AC_FOREACH([gl_FUNC_NAME], [$1], [
1429     AC_DEFUN([gl_CHECK_FUNC_]defn([gl_FUNC_NAME]), [
1430       AC_CHECK_FUNCS(defn([gl_FUNC_NAME]))
1431     ])
1432     AC_REQUIRE([gl_CHECK_FUNC_]defn([gl_FUNC_NAME]))
1433   ])
1434 ])
1435
1436 # AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
1437 # AC_CHECK_DECLS(DECL1, DECL2, ...).
1438 AC_DEFUN([AC_CHECK_DECLS_ONCE], [
1439   :
1440   AC_FOREACH([gl_DECL_NAME], [$1], [
1441     AC_DEFUN([gl_CHECK_DECL_]defn([gl_DECL_NAME]), [
1442       AC_CHECK_DECLS(defn([gl_DECL_NAME]))
1443     ])
1444     AC_REQUIRE([gl_CHECK_DECL_]defn([gl_DECL_NAME]))
1445   ])
1446 ])
1447
1448 #serial 2
1449
1450 dnl From Paul Eggert.
1451
1452 # Define HOST_OPERATING_SYSTEM to a name for the host operating system.
1453 AC_DEFUN([UTILS_HOST_OS],
1454 [
1455   AC_CACHE_CHECK([host operating system],
1456     utils_cv_host_operating_system,
1457
1458     [[case $host_os in
1459
1460        # These operating system names do not use the default heuristic below.
1461        # They are in reverse order, so that more-specific prefixes come first.
1462        winnt*)          os='Windows NT';;
1463        vos*)            os='VOS';;
1464        sysv*)           os='Unix System V';;
1465        superux*)        os='SUPER-UX';;
1466        sunos*)          os='SunOS';;
1467        stop*)           os='STOP';;
1468        sco*)            os='SCO Unix';;
1469        riscos*)         os='RISC OS';;
1470        riscix*)         os='RISCiX';;
1471        qnx*)            os='QNX';;
1472        pw32*)           os='PW32';;
1473        ptx*)            os='ptx';;
1474        plan9*)          os='Plan 9';;
1475        osf*)            os='Tru64';;
1476        os2*)            os='OS/2';;
1477        openbsd*)        os='OpenBSD';;
1478        nsk*)            os='NonStop Kernel';;
1479        nonstopux*)      os='NonStop-UX';;
1480        netbsd*)         os='NetBSD';;
1481        msdosdjgpp*)     os='DJGPP';;
1482        mpeix*)          os='MPE/iX';;
1483        mint*)           os='MiNT';;
1484        mingw*)          os='MinGW';;
1485        lynxos*)         os='LynxOS';;
1486        linux*)          os='GNU/Linux';;
1487        hpux*)           os='HP-UX';;
1488        hiux*)           os='HI-UX';;
1489        gnu*)            os='GNU';;
1490        freebsd*-gnu*)   os='GNU/FreeBSD';;
1491        freebsd*)        os='FreeBSD';;
1492        dgux*)           os='DG/UX';;
1493        bsdi*)           os='BSD/OS';;
1494        bsd*)            os='BSD';;
1495        beos*)           os='BeOS';;
1496        aux*)            os='A/UX';;
1497        atheos*)         os='AtheOS';;
1498        amigaos*)        os='Amiga OS';;
1499        aix*)            os='AIX';;
1500
1501        # The default heuristic takes the initial alphabetic string
1502        # from $host_os, but capitalizes its first letter.
1503        [A-Za-z]*)
1504          os=`
1505            expr "X$host_os" : 'X\([A-Za-z]\)' | tr '[a-z]' '[A-Z]'
1506          ``
1507            expr "X$host_os" : 'X.\([A-Za-z]*\)'
1508          `
1509          ;;
1510
1511        # If $host_os does not start with an alphabetic string, use it unchanged.
1512        *)
1513          os=$host_os;;
1514      esac
1515      utils_cv_host_operating_system=$os]])
1516   AC_DEFINE_UNQUOTED(HOST_OPERATING_SYSTEM,
1517     "$utils_cv_host_operating_system",
1518     [The host operating system.])
1519 ])
1520
1521 #serial 1
1522
1523 # On some systems, mkdir ("foo/", 0700) fails because of the trailing slash.
1524 # On such systems, arrange to use a wrapper function that removes any
1525 # trailing slashes.
1526 AC_DEFUN([UTILS_FUNC_MKDIR_TRAILING_SLASH],
1527 [dnl
1528   AC_CACHE_CHECK([whether mkdir fails due to a trailing slash],
1529     utils_cv_func_mkdir_trailing_slash_bug,
1530     [
1531       # Arrange for deletion of the temporary directory this test might create.
1532       ac_clean_files="$ac_clean_files confdir-slash"
1533       AC_TRY_RUN([
1534 #       include <sys/types.h>
1535 #       include <sys/stat.h>
1536 #       include <stdlib.h>
1537         int main ()
1538         {
1539           rmdir ("confdir-slash");
1540           exit (mkdir ("confdir-slash/", 0700));
1541         }
1542         ],
1543       utils_cv_func_mkdir_trailing_slash_bug=no,
1544       utils_cv_func_mkdir_trailing_slash_bug=yes,
1545       utils_cv_func_mkdir_trailing_slash_bug=yes
1546       )
1547     ]
1548   )
1549
1550   if test $utils_cv_func_mkdir_trailing_slash_bug = yes; then
1551     AC_LIBOBJ(mkdir)
1552     AC_DEFINE(mkdir, rpl_mkdir,
1553       [Define to rpl_mkdir if the replacement function should be used.])
1554   fi
1555 ])
1556
1557 #serial 2
1558
1559 AC_DEFUN([jm_BISON],
1560 [
1561   # getdate.y works with bison only.
1562   : ${YACC='bison -y'}
1563   AC_SUBST(YACC)
1564 ])
1565
1566 #serial 3
1567 dnl based on code from Eleftherios Gkioulekas
1568
1569 AC_DEFUN([jm_ASSERT],
1570 [
1571   AC_MSG_CHECKING(whether to enable assertions)
1572   AC_ARG_ENABLE(assert,
1573         [  --disable-assert        turn off assertions],
1574         [ AC_MSG_RESULT(no)
1575           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
1576         [ AC_MSG_RESULT(yes) ]
1577                )
1578 ])
1579
1580 #serial 4
1581
1582 dnl From Jim Meyering
1583
1584 dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
1585 dnl usually in <utime.h>.
1586 dnl Some systems have utime.h but don't declare the struct anywhere.
1587
1588 AC_DEFUN([jm_CHECK_TYPE_STRUCT_UTIMBUF],
1589 [
1590   AC_CHECK_HEADERS(utime.h)
1591   AC_REQUIRE([AC_HEADER_TIME])
1592   AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf,
1593     [AC_TRY_COMPILE(
1594       [
1595 #ifdef TIME_WITH_SYS_TIME
1596 # include <sys/time.h>
1597 # include <time.h>
1598 #else
1599 # ifdef HAVE_SYS_TIME_H
1600 #  include <sys/time.h>
1601 # else
1602 #  include <time.h>
1603 # endif
1604 #endif
1605 #ifdef HAVE_UTIME_H
1606 # include <utime.h>
1607 #endif
1608       ],
1609       [static struct utimbuf x; x.actime = x.modtime;],
1610       fu_cv_sys_struct_utimbuf=yes,
1611       fu_cv_sys_struct_utimbuf=no)
1612     ])
1613
1614   if test $fu_cv_sys_struct_utimbuf = yes; then
1615     AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1,
1616 [Define if struct utimbuf is declared -- usually in <utime.h>.
1617    Some systems have utime.h but don't declare the struct anywhere. ])
1618   fi
1619 ])
1620
1621 #serial 5
1622
1623 dnl From Jim Meyering.
1624 dnl
1625 dnl Check whether struct dirent has a member named d_type.
1626 dnl
1627
1628 AC_DEFUN([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
1629   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
1630    AC_CACHE_CHECK([for d_type member in directory struct],
1631                   jm_cv_struct_dirent_d_type,
1632      [AC_TRY_LINK(dnl
1633        [
1634 #include <sys/types.h>
1635 #ifdef HAVE_DIRENT_H
1636 # include <dirent.h>
1637 #else /* not HAVE_DIRENT_H */
1638 # define dirent direct
1639 # ifdef HAVE_SYS_NDIR_H
1640 #  include <sys/ndir.h>
1641 # endif /* HAVE_SYS_NDIR_H */
1642 # ifdef HAVE_SYS_DIR_H
1643 #  include <sys/dir.h>
1644 # endif /* HAVE_SYS_DIR_H */
1645 # ifdef HAVE_NDIR_H
1646 #  include <ndir.h>
1647 # endif /* HAVE_NDIR_H */
1648 #endif /* HAVE_DIRENT_H */
1649        ],
1650        [struct dirent dp; dp.d_type = 0;],
1651
1652        jm_cv_struct_dirent_d_type=yes,
1653        jm_cv_struct_dirent_d_type=no)
1654      ]
1655    )
1656    if test $jm_cv_struct_dirent_d_type = yes; then
1657      AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
1658   [Define if there is a member named d_type in the struct describing
1659    directory headers.])
1660    fi
1661   ]
1662 )
1663
1664 #serial 4
1665
1666 dnl From Jim Meyering.
1667 dnl
1668 dnl Check whether struct dirent has a member named d_ino.
1669 dnl
1670
1671 AC_DEFUN([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO],
1672   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
1673    AC_CACHE_CHECK([for d_ino member in directory struct],
1674                   jm_cv_struct_dirent_d_ino,
1675      [AC_TRY_LINK(dnl
1676        [
1677 #include <sys/types.h>
1678 #ifdef HAVE_DIRENT_H
1679 # include <dirent.h>
1680 #else /* not HAVE_DIRENT_H */
1681 # define dirent direct
1682 # ifdef HAVE_SYS_NDIR_H
1683 #  include <sys/ndir.h>
1684 # endif /* HAVE_SYS_NDIR_H */
1685 # ifdef HAVE_SYS_DIR_H
1686 #  include <sys/dir.h>
1687 # endif /* HAVE_SYS_DIR_H */
1688 # ifdef HAVE_NDIR_H
1689 #  include <ndir.h>
1690 # endif /* HAVE_NDIR_H */
1691 #endif /* HAVE_DIRENT_H */
1692        ],
1693        [struct dirent dp; dp.d_ino = 0;],
1694
1695        jm_cv_struct_dirent_d_ino=yes,
1696        jm_cv_struct_dirent_d_ino=no)
1697      ]
1698    )
1699    if test $jm_cv_struct_dirent_d_ino = yes; then
1700      AC_DEFINE(D_INO_IN_DIRENT, 1,
1701   [Define if there is a member named d_ino in the struct describing
1702    directory headers.])
1703    fi
1704   ]
1705 )
1706
1707 #serial 19
1708
1709 dnl This is just a wrapper function to encapsulate this kludge.
1710 dnl Putting it in a separate file like this helps share it between
1711 dnl different packages.
1712 AC_DEFUN([jm_CHECK_DECLS],
1713 [
1714   AC_REQUIRE([_jm_DECL_HEADERS])
1715   AC_REQUIRE([AC_HEADER_TIME])
1716   headers='
1717 #include <stdio.h>
1718 #if HAVE_STRING_H
1719 # if !STDC_HEADERS && HAVE_MEMORY_H
1720 #  include <memory.h>
1721 # endif
1722 # include <string.h>
1723 #else
1724 # if HAVE_STRINGS_H
1725 #  include <strings.h>
1726 # endif
1727 #endif
1728 #if HAVE_STDLIB_H
1729 # include <stdlib.h>
1730 #endif
1731 #if HAVE_UNISTD_H
1732 # include <unistd.h>
1733 #endif
1734
1735 #include <sys/types.h>
1736 #if TIME_WITH_SYS_TIME
1737 # include <sys/time.h>
1738 # include <time.h>
1739 #else
1740 # if HAVE_SYS_TIME_H
1741 #  include <sys/time.h>
1742 # else
1743 #  include <time.h>
1744 # endif
1745 #endif
1746
1747 #if HAVE_UTMP_H
1748 # include <utmp.h>
1749 #endif
1750
1751 #if HAVE_GRP_H
1752 # include <grp.h>
1753 #endif
1754
1755 #if HAVE_PWD_H
1756 # include <pwd.h>
1757 #endif
1758 '
1759
1760   AC_CHECK_DECLS([
1761     euidaccess,
1762     free,
1763     getenv,
1764     geteuid,
1765     getgrgid,
1766     getlogin,
1767     getpwuid,
1768     getuid,
1769     getutent,
1770     lseek,
1771     malloc,
1772     memchr,
1773     memrchr,
1774     nanosleep,
1775     realloc,
1776     stpcpy,
1777     strndup,
1778     strnlen,
1779     strstr,
1780     strtoul,
1781     strtoull,
1782     ttyname], , , $headers)
1783 ])
1784
1785 dnl FIXME: when autoconf has support for it.
1786 dnl This is a little helper so we can require these header checks.
1787 AC_DEFUN([_jm_DECL_HEADERS],
1788 [
1789   AC_REQUIRE([AC_HEADER_STDC])
1790   AC_CHECK_HEADERS(grp.h memory.h pwd.h string.h strings.h stdlib.h \
1791                    unistd.h sys/time.h utmp.h utmpx.h)
1792 ])
1793
1794 #serial 33
1795
1796 dnl We use jm_ for non Autoconf macros.
1797 m4_pattern_forbid([^jm_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
1798 m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
1799
1800 # These are the prerequisite macros for files in the lib/
1801 # directory of the coreutils package.
1802
1803 AC_DEFUN([jm_PREREQ],
1804 [
1805   AC_REQUIRE([jm_PREREQ_ADDEXT])
1806
1807   # We don't yet use c-stack.c.
1808   # AC_REQUIRE([jm_PREREQ_C_STACK])
1809
1810   AC_REQUIRE([jm_PREREQ_CANON_HOST])
1811   AC_REQUIRE([jm_PREREQ_DIRNAME])
1812   AC_REQUIRE([jm_PREREQ_ERROR])
1813   AC_REQUIRE([jm_PREREQ_EXCLUDE])
1814   AC_REQUIRE([jm_PREREQ_GETPAGESIZE])
1815   AC_REQUIRE([jm_PREREQ_HARD_LOCALE])
1816   AC_REQUIRE([jm_PREREQ_HASH])
1817   AC_REQUIRE([gl_HUMAN])
1818   AC_REQUIRE([jm_PREREQ_MBSWIDTH])
1819   AC_REQUIRE([jm_PREREQ_MEMCHR])
1820   AC_REQUIRE([jm_PREREQ_PHYSMEM])
1821   AC_REQUIRE([jm_PREREQ_POSIXVER])
1822   AC_REQUIRE([jm_PREREQ_QUOTEARG])
1823   AC_REQUIRE([jm_PREREQ_READUTMP])
1824   AC_REQUIRE([jm_PREREQ_STAT])
1825   AC_REQUIRE([jm_PREREQ_STRNLEN])
1826   AC_REQUIRE([jm_PREREQ_TEMPNAME]) # called by mkstemp
1827   AC_REQUIRE([jm_PREREQ_XGETCWD])
1828   AC_REQUIRE([jm_PREREQ_XREADLINK])
1829 ])
1830
1831 AC_DEFUN([jm_PREREQ_ADDEXT],
1832 [
1833   dnl For addext.c.
1834   AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
1835   AC_CHECK_FUNCS(pathconf)
1836   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1837 ])
1838
1839 AC_DEFUN([jm_PREREQ_CANON_HOST],
1840 [
1841   dnl Add any libraries as early as possible.
1842   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1843   dnl so we have to add -lnsl to LIBS before checking for that function.
1844   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1845
1846   dnl These come from -lnsl on Solaris5.5.1.
1847   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1848
1849   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1850                    netinet/in.h arpa/inet.h)
1851 ])
1852
1853 AC_DEFUN([jm_PREREQ_DIRNAME],
1854 [
1855   AC_REQUIRE([AC_HEADER_STDC])
1856   AC_CHECK_HEADERS(string.h)
1857 ])
1858
1859 AC_DEFUN([jm_PREREQ_EXCLUDE],
1860 [
1861   AC_REQUIRE([AC_FUNC_FNMATCH_GNU])
1862   AC_REQUIRE([AC_HEADER_STDBOOL])
1863 ])
1864
1865 AC_DEFUN([jm_PREREQ_GETPAGESIZE],
1866 [
1867   AC_CHECK_FUNCS(getpagesize)
1868   AC_CHECK_HEADERS(OS.h unistd.h)
1869 ])
1870
1871 AC_DEFUN([jm_PREREQ_HARD_LOCALE],
1872 [
1873   AC_CHECK_HEADERS(locale.h stdlib.h string.h)
1874   AC_CHECK_FUNCS(setlocale)
1875   AC_REQUIRE([AM_C_PROTOTYPES])
1876 ])
1877
1878 AC_DEFUN([jm_PREREQ_HASH],
1879 [
1880   AC_CHECK_HEADERS(stdlib.h)
1881   AC_REQUIRE([AC_HEADER_STDBOOL])
1882   AC_REQUIRE([jm_CHECK_DECLS])
1883 ])
1884
1885 AC_DEFUN([jm_PREREQ_MEMCHR],
1886 [
1887   AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h)
1888 ])
1889
1890 # Check for the external symbol, _system_configuration,
1891 # a struct with member `physmem'.
1892 AC_DEFUN([gl_SYS__SYSTEM_CONFIGURATION],
1893   [AC_CACHE_CHECK(for external symbol _system_configuration,
1894                   gl_cv_var__system_configuration,
1895     [AC_LINK_IFELSE([AC_LANG_PROGRAM(
1896                       [[#include <sys/systemcfg.h>
1897                       ]],
1898                       [double x = _system_configuration.physmem;])],
1899       [gl_cv_var__system_configuration=yes],
1900       [gl_cv_var__system_configuration=no])])
1901
1902     if test $gl_cv_var__system_configuration = yes; then
1903       AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
1904                 [Define to 1 if you have the external variable,
1905                 _system_configuration with a member named physmem.])
1906     fi
1907   ]
1908 )
1909
1910 AC_DEFUN([jm_PREREQ_PHYSMEM],
1911 [
1912   AC_CHECK_HEADERS([unistd.h sys/pstat.h sys/sysmp.h sys/sysinfo.h \
1913     machine/hal_sysinfo.h sys/table.h sys/param.h sys/sysctl.h \
1914     sys/systemcfg.h])
1915   AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp getsysinfo sysctl table)
1916
1917   AC_REQUIRE([gl_SYS__SYSTEM_CONFIGURATION])
1918 ])
1919
1920 AC_DEFUN([jm_PREREQ_POSIXVER],
1921 [
1922   AC_CHECK_HEADERS(unistd.h)
1923   AC_CHECK_DECLS([getenv])
1924 ])
1925
1926 AC_DEFUN([jm_PREREQ_QUOTEARG],
1927 [
1928   AC_CHECK_FUNCS(isascii iswprint)
1929   AC_REQUIRE([jm_FUNC_MBRTOWC])
1930   AC_REQUIRE([jm_FUNC_MEMCMP])
1931   AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
1932   AC_REQUIRE([AC_HEADER_STDC])
1933   AC_REQUIRE([AC_C_BACKSLASH_A])
1934   AC_REQUIRE([AC_TYPE_MBSTATE_T])
1935   AC_REQUIRE([AM_C_PROTOTYPES])
1936 ])
1937
1938 AC_DEFUN([jm_PREREQ_READUTMP],
1939 [
1940   AC_REQUIRE([AC_HEADER_STDC])
1941   AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
1942   AC_CHECK_FUNCS(utmpname)
1943   AC_CHECK_FUNCS(utmpxname)
1944   AC_REQUIRE([AM_C_PROTOTYPES])
1945
1946   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
1947     utmp_includes="\
1948 $ac_includes_default
1949 #ifdef HAVE_UTMPX_H
1950 # include <utmpx.h>
1951 #endif
1952 #ifdef HAVE_UTMP_H
1953 # include <utmp.h>
1954 #endif
1955 "
1956     AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
1957     AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
1958     AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
1959     AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
1960     AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
1961     AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
1962     AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
1963     AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
1964     AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
1965     AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
1966
1967     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
1968     AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_exit],,,[$utmp_includes])
1969     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
1970     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
1971
1972     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
1973     AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_termination],,,[$utmp_includes])
1974     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
1975     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
1976     AC_LIBOBJ(readutmp)
1977   fi
1978 ])
1979
1980 AC_DEFUN([jm_PREREQ_STAT],
1981 [
1982   AC_CHECK_HEADERS(sys/sysmacros.h sys/statvfs.h sys/vfs.h inttypes.h)
1983   AC_CHECK_HEADERS(sys/param.h sys/mount.h)
1984   AC_CHECK_FUNCS(statvfs)
1985
1986   # For `struct statfs' on Ultrix 4.4.
1987   AC_CHECK_HEADERS(netinet/in.h nfs/nfs_clnt.h nfs/vfs.h)
1988
1989   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
1990
1991   statxfs_includes="\
1992 $ac_includes_default
1993 #if HAVE_SYS_STATVFS_H
1994 # include <sys/statvfs.h>
1995 #endif
1996 #if HAVE_SYS_VFS_H
1997 # include <sys/vfs.h>
1998 #endif
1999 #if !HAVE_SYS_STATVFS_H && !HAVE_SYS_VFS_H
2000 # if HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
2001 /* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
2002 #  include <sys/param.h>
2003 #  include <sys/mount.h>
2004 # elif HAVE_NETINET_IN_H && HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
2005 /* Ultrix 4.4 needs these for the declaration of struct statfs.  */
2006 #  include <netinet/in.h>
2007 #  include <nfs/nfs_clnt.h>
2008 #  include <nfs/vfs.h>
2009 # endif
2010 #endif
2011 "
2012   AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes])
2013   AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes])
2014   AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes])
2015   AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes])
2016   AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes])
2017   AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes])
2018   AC_CHECK_MEMBERS([struct statvfs.f_fsid.__val],,,[$statxfs_includes])
2019   AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
2020   AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
2021   AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
2022   AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
2023 ])
2024
2025 AC_DEFUN([jm_PREREQ_STRNLEN],
2026 [
2027   AC_REQUIRE([AC_FUNC_STRNLEN])
2028   AC_REQUIRE([AC_HEADER_STDC])
2029   AC_CHECK_HEADERS(memory.h)
2030   AC_CHECK_DECLS([memchr])
2031
2032   # This is necessary because automake-1.6.1 doesn't understand
2033   # that the above use of AC_FUNC_STRNLEN means we may have to use
2034   # lib/strnlen.c.
2035   test $ac_cv_func_strnlen_working = yes \
2036     && AC_LIBOBJ(strnlen)
2037 ])
2038
2039 AC_DEFUN([jm_PREREQ_TEMPNAME],
2040 [
2041   AC_REQUIRE([AC_HEADER_STDC])
2042   AC_REQUIRE([AC_HEADER_STAT])
2043   AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h)
2044   AC_CHECK_FUNCS(__secure_getenv gettimeofday)
2045   AC_CHECK_DECLS([getenv])
2046   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
2047 ])
2048
2049 AC_DEFUN([jm_PREREQ_XGETCWD],
2050 [
2051   AC_REQUIRE([AC_C_PROTOTYPES])
2052   AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h)
2053   AC_CHECK_FUNCS(getcwd)
2054   AC_REQUIRE([AC_FUNC_GETCWD_NULL])
2055 ])
2056
2057 AC_DEFUN([jm_PREREQ_XREADLINK],
2058 [
2059   AC_REQUIRE([AC_C_PROTOTYPES])
2060   AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h)
2061 ])
2062
2063 #serial 5
2064
2065 dnl FIXME: put these prerequisite-only *.m4 files in a separate
2066 dnl directory -- otherwise, they'll conflict with existing files.
2067
2068 dnl These are the prerequisite macros for GNU's error.c file.
2069 AC_DEFUN([jm_PREREQ_ERROR],
2070 [
2071   AC_CHECK_FUNCS(strerror vprintf doprnt)
2072   AC_CHECK_DECLS([strerror])
2073   AC_CHECK_HEADERS([libintl.h])
2074   AC_FUNC_STRERROR_R
2075   AC_HEADER_STDC
2076 ])
2077
2078 # human.m4 serial 3
2079 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2080 dnl This file is free software, distributed under the terms of the GNU
2081 dnl General Public License.  As a special exception to the GNU General
2082 dnl Public License, this file may be distributed as part of a program
2083 dnl that contains a configuration script generated by Autoconf, under
2084 dnl the same distribution terms as the rest of that program.
2085
2086 AC_DEFUN([gl_HUMAN],
2087 [
2088   dnl Prerequisites of lib/human.h.
2089   AC_REQUIRE([AM_STDBOOL_H])
2090   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
2091
2092   dnl Prerequisites of lib/human.c.
2093   AC_CHECK_HEADERS_ONCE(locale.h stdlib.h string.h)
2094   AC_CHECK_DECLS_ONCE(getenv)
2095   AC_CHECK_FUNCS_ONCE(localeconv)
2096 ])
2097
2098 # Check for stdbool.h that conforms to C99.
2099
2100 # Copyright (C) 2002-2003 Free Software Foundation, Inc.
2101
2102 # This program is free software; you can redistribute it and/or modify
2103 # it under the terms of the GNU General Public License as published by
2104 # the Free Software Foundation; either version 2, or (at your option)
2105 # any later version.
2106
2107 # This program is distributed in the hope that it will be useful,
2108 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2109 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2110 # GNU General Public License for more details.
2111
2112 # You should have received a copy of the GNU General Public License
2113 # along with this program; if not, write to the Free Software
2114 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2115 # 02111-1307, USA.
2116
2117 # Prepare for substituting <stdbool.h> if it is not supported.
2118
2119 AC_DEFUN([AM_STDBOOL_H],
2120 [
2121   AC_REQUIRE([AC_HEADER_STDBOOL])
2122
2123   # Define two additional variables used in the Makefile substitution.
2124
2125   if test "$ac_cv_header_stdbool_h" = yes; then
2126     STDBOOL_H=''
2127   else
2128     STDBOOL_H='stdbool.h'
2129   fi
2130   AC_SUBST([STDBOOL_H])
2131
2132   if test "$ac_cv_type__Bool" = yes; then
2133     HAVE__BOOL=1
2134   else
2135     HAVE__BOOL=0
2136   fi
2137   AC_SUBST([HAVE__BOOL])
2138 ])
2139
2140 # This macro is only needed in autoconf <= 2.54.  Newer versions of autoconf
2141 # have this macro built-in.
2142
2143 AC_DEFUN([AC_HEADER_STDBOOL],
2144   [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
2145      [ac_cv_header_stdbool_h],
2146      [AC_TRY_COMPILE(
2147         [
2148           #include <stdbool.h>
2149           #ifndef bool
2150            "error: bool is not defined"
2151           #endif
2152           #ifndef false
2153            "error: false is not defined"
2154           #endif
2155           #if false
2156            "error: false is not 0"
2157           #endif
2158           #ifndef true
2159            "error: false is not defined"
2160           #endif
2161           #if true != 1
2162            "error: true is not 1"
2163           #endif
2164           #ifndef __bool_true_false_are_defined
2165            "error: __bool_true_false_are_defined is not defined"
2166           #endif
2167
2168           struct s { _Bool s: 1; _Bool t; } s;
2169
2170           char a[true == 1 ? 1 : -1];
2171           char b[false == 0 ? 1 : -1];
2172           char c[__bool_true_false_are_defined == 1 ? 1 : -1];
2173           char d[(bool) -0.5 == true ? 1 : -1];
2174           bool e = &s;
2175           char f[(_Bool) -0.0 == false ? 1 : -1];
2176           char g[true];
2177           char h[sizeof (_Bool)];
2178           char i[sizeof s.t];
2179         ],
2180         [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
2181         [ac_cv_header_stdbool_h=yes],
2182         [ac_cv_header_stdbool_h=no])])
2183    AC_CHECK_TYPES([_Bool])
2184    if test $ac_cv_header_stdbool_h = yes; then
2185      AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
2186    fi])
2187
2188 # uintmax_t.m4 serial 7 (gettext-0.12)
2189 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
2190 dnl This file is free software, distributed under the terms of the GNU
2191 dnl General Public License.  As a special exception to the GNU General
2192 dnl Public License, this file may be distributed as part of a program
2193 dnl that contains a configuration script generated by Autoconf, under
2194 dnl the same distribution terms as the rest of that program.
2195
2196 dnl From Paul Eggert.
2197
2198 AC_PREREQ(2.13)
2199
2200 # Define uintmax_t to 'unsigned long' or 'unsigned long long'
2201 # if it is not already defined in <stdint.h> or <inttypes.h>.
2202
2203 AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
2204 [
2205   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2206   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
2207   if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
2208     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2209     test $ac_cv_type_unsigned_long_long = yes \
2210       && ac_type='unsigned long long' \
2211       || ac_type='unsigned long'
2212     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2213       [Define to unsigned long or unsigned long long
2214        if <stdint.h> and <inttypes.h> don't define.])
2215   else
2216     AC_DEFINE(HAVE_UINTMAX_T, 1,
2217       [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
2218   fi
2219 ])
2220
2221 # inttypes_h.m4 serial 5 (gettext-0.12)
2222 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
2223 dnl This file is free software, distributed under the terms of the GNU
2224 dnl General Public License.  As a special exception to the GNU General
2225 dnl Public License, this file may be distributed as part of a program
2226 dnl that contains a configuration script generated by Autoconf, under
2227 dnl the same distribution terms as the rest of that program.
2228
2229 dnl From Paul Eggert.
2230
2231 # Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
2232 # doesn't clash with <sys/types.h>, and declares uintmax_t.
2233
2234 AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
2235 [
2236   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
2237   [AC_TRY_COMPILE(
2238     [#include <sys/types.h>
2239 #include <inttypes.h>],
2240     [uintmax_t i = (uintmax_t) -1;],
2241     jm_ac_cv_header_inttypes_h=yes,
2242     jm_ac_cv_header_inttypes_h=no)])
2243   if test $jm_ac_cv_header_inttypes_h = yes; then
2244     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
2245       [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
2246        and declares uintmax_t. ])
2247   fi
2248 ])
2249
2250 # stdint_h.m4 serial 3 (gettext-0.12)
2251 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
2252 dnl This file is free software, distributed under the terms of the GNU
2253 dnl General Public License.  As a special exception to the GNU General
2254 dnl Public License, this file may be distributed as part of a program
2255 dnl that contains a configuration script generated by Autoconf, under
2256 dnl the same distribution terms as the rest of that program.
2257
2258 dnl From Paul Eggert.
2259
2260 # Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
2261 # doesn't clash with <sys/types.h>, and declares uintmax_t.
2262
2263 AC_DEFUN([jm_AC_HEADER_STDINT_H],
2264 [
2265   AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
2266   [AC_TRY_COMPILE(
2267     [#include <sys/types.h>
2268 #include <stdint.h>],
2269     [uintmax_t i = (uintmax_t) -1;],
2270     jm_ac_cv_header_stdint_h=yes,
2271     jm_ac_cv_header_stdint_h=no)])
2272   if test $jm_ac_cv_header_stdint_h = yes; then
2273     AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
2274       [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
2275        and declares uintmax_t. ])
2276   fi
2277 ])
2278
2279 #serial 2
2280
2281 dnl From Paul Eggert.
2282
2283 # Define HAVE_LONG_LONG if 'long long' works.
2284
2285 AC_DEFUN([jm_AC_TYPE_LONG_LONG],
2286 [
2287   AC_CACHE_CHECK([for long long], ac_cv_type_long_long,
2288   [AC_TRY_LINK([long long ll = 1; int i = 63;],
2289     [long long llmax = (long long) -1;
2290      return ll << i | ll >> i | llmax / ll | llmax % ll;],
2291     ac_cv_type_long_long=yes,
2292     ac_cv_type_long_long=no)])
2293   if test $ac_cv_type_long_long = yes; then
2294     AC_DEFINE(HAVE_LONG_LONG, 1,
2295       [Define if you have the long long type.])
2296   fi
2297 ])
2298
2299 # Define HAVE_UNSIGNED_LONG_LONG if 'unsigned long long' works.
2300
2301 AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG],
2302 [
2303   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
2304   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
2305     [unsigned long long ullmax = (unsigned long long) -1;
2306      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
2307     ac_cv_type_unsigned_long_long=yes,
2308     ac_cv_type_unsigned_long_long=no)])
2309   if test $ac_cv_type_unsigned_long_long = yes; then
2310     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
2311       [Define if you have the unsigned long long type.])
2312   fi
2313 ])
2314
2315 #serial 7
2316
2317 dnl autoconf tests required for use of mbswidth.c
2318 dnl From Bruno Haible.
2319
2320 AC_DEFUN([jm_PREREQ_MBSWIDTH],
2321 [
2322   AC_REQUIRE([AC_HEADER_STDC])
2323   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
2324   AC_CHECK_FUNCS(isascii iswcntrl iswprint mbsinit wcwidth)
2325   jm_FUNC_MBRTOWC
2326
2327   AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth,
2328     [AC_TRY_COMPILE([
2329 /* AIX 3.2.5 declares wcwidth in <string.h>. */
2330 #if HAVE_STRING_H
2331 # include <string.h>
2332 #endif
2333 #if HAVE_WCHAR_H
2334 # include <wchar.h>
2335 #endif
2336 ], [
2337 #ifndef wcwidth
2338   char *p = (char *) wcwidth;
2339 #endif
2340 ], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)])
2341   if test $ac_cv_have_decl_wcwidth = yes; then
2342     ac_val=1
2343   else
2344     ac_val=0
2345   fi
2346   AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val,
2347     [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.])
2348
2349   AC_TYPE_MBSTATE_T
2350 ])
2351
2352 # mbrtowc.m4 serial 4 (fileutils-4.1.3)
2353 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
2354 dnl This file is free software, distributed under the terms of the GNU
2355 dnl General Public License.  As a special exception to the GNU General
2356 dnl Public License, this file may be distributed as part of a program
2357 dnl that contains a configuration script generated by Autoconf, under
2358 dnl the same distribution terms as the rest of that program.
2359
2360 dnl From Paul Eggert
2361
2362 AC_DEFUN([jm_FUNC_MBRTOWC],
2363 [
2364   AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
2365     jm_cv_func_mbrtowc,
2366     [AC_TRY_LINK(
2367        [#include <wchar.h>],
2368        [mbstate_t state; return ! (sizeof state && mbrtowc);],
2369        jm_cv_func_mbrtowc=yes,
2370        jm_cv_func_mbrtowc=no)])
2371   if test $jm_cv_func_mbrtowc = yes; then
2372     AC_DEFINE(HAVE_MBRTOWC, 1,
2373       [Define to 1 if mbrtowc and mbstate_t are properly declared.])
2374   fi
2375 ])
2376
2377 #serial 5
2378
2379 dnl A replacement for autoconf's macro by the same name.  This version
2380 dnl uses `ac_lib' rather than `i' for the loop variable, but more importantly
2381 dnl moves the ACTION-IF-FOUND ([$]3) into the inner `if'-block so that it is
2382 dnl run only if one of the listed libraries ends up being used (and not in
2383 dnl the `none required' case.
2384 dnl I hope it's only temporary while we wait for that version to be fixed.
2385 undefine([AC_SEARCH_LIBS])
2386
2387 # AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS,
2388 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
2389 #                [OTHER-LIBRARIES])
2390 # --------------------------------------------------------
2391 # Search for a library defining FUNC, if it's not already available.
2392 AC_DEFUN([AC_SEARCH_LIBS],
2393 [
2394   AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
2395   [
2396     ac_func_search_save_LIBS=$LIBS
2397     ac_cv_search_$1=no
2398     AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1='none required'])
2399     if test "$ac_cv_search_$1" = no; then
2400       for ac_lib in $2; do
2401         LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
2402         AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="-l$ac_lib"; break])
2403       done
2404     fi
2405     LIBS=$ac_func_search_save_LIBS
2406   ])
2407
2408   if test "$ac_cv_search_$1" = no; then :
2409     $4
2410   else
2411     if test "$ac_cv_search_$1" = 'none required'; then :
2412       $4
2413     else
2414       LIBS="$ac_cv_search_$1 $LIBS"
2415       $3
2416     fi
2417   fi
2418 ])
2419
2420
2421 # Copyright 1996, 1997, 1998, 2000, 2001, 2002  Free Software Foundation, Inc.
2422
2423 # This program is free software; you can redistribute it and/or modify
2424 # it under the terms of the GNU General Public License as published by
2425 # the Free Software Foundation; either version 2, or (at your option)
2426 # any later version.
2427
2428 # This program is distributed in the hope that it will be useful,
2429 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2430 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2431 # GNU General Public License for more details.
2432
2433 # You should have received a copy of the GNU General Public License
2434 # along with this program; if not, write to the Free Software
2435 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2436 # 02111-1307, USA.
2437
2438 # serial 2
2439
2440 AC_DEFUN([AM_C_PROTOTYPES],
2441 [AC_REQUIRE([AM_PROG_CC_STDC])
2442 AC_REQUIRE([AC_PROG_CPP])
2443 AC_MSG_CHECKING([for function prototypes])
2444 if test "$am_cv_prog_cc_stdc" != no; then
2445   AC_MSG_RESULT(yes)
2446   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
2447   U= ANSI2KNR=
2448 else
2449   AC_MSG_RESULT(no)
2450   U=_ ANSI2KNR=./ansi2knr
2451 fi
2452 # Ensure some checks needed by ansi2knr itself.
2453 AC_HEADER_STDC
2454 AC_CHECK_HEADERS(string.h)
2455 AC_SUBST(U)dnl
2456 AC_SUBST(ANSI2KNR)dnl
2457 ])
2458
2459 AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
2460
2461
2462 # Copyright 1996, 1997, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
2463
2464 # This program is free software; you can redistribute it and/or modify
2465 # it under the terms of the GNU General Public License as published by
2466 # the Free Software Foundation; either version 2, or (at your option)
2467 # any later version.
2468
2469 # This program is distributed in the hope that it will be useful,
2470 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2471 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2472 # GNU General Public License for more details.
2473
2474 # You should have received a copy of the GNU General Public License
2475 # along with this program; if not, write to the Free Software
2476 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2477 # 02111-1307, USA.
2478
2479 # serial 2
2480
2481 # @defmac AC_PROG_CC_STDC
2482 # @maindex PROG_CC_STDC
2483 # @ovindex CC
2484 # If the C compiler in not in ANSI C mode by default, try to add an option
2485 # to output variable @code{CC} to make it so.  This macro tries various
2486 # options that select ANSI C on some system or another.  It considers the
2487 # compiler to be in ANSI C mode if it handles function prototypes correctly.
2488 #
2489 # If you use this macro, you should check after calling it whether the C
2490 # compiler has been set to accept ANSI C; if not, the shell variable
2491 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
2492 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
2493 # program @code{ansi2knr}, which comes with Ghostscript.
2494 # @end defmac
2495
2496 AC_DEFUN([AM_PROG_CC_STDC],
2497 [AC_REQUIRE([AC_PROG_CC])
2498 AC_BEFORE([$0], [AC_C_INLINE])
2499 AC_BEFORE([$0], [AC_C_CONST])
2500 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
2501 dnl a magic option to avoid problems with ANSI preprocessor commands
2502 dnl like #elif.
2503 dnl FIXME: can't do this because then AC_AIX won't work due to a
2504 dnl circular dependency.
2505 dnl AC_BEFORE([$0], [AC_PROG_CPP])
2506 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
2507 AC_CACHE_VAL(am_cv_prog_cc_stdc,
2508 [am_cv_prog_cc_stdc=no
2509 ac_save_CC="$CC"
2510 # Don't try gcc -ansi; that turns off useful extensions and
2511 # breaks some systems' header files.
2512 # AIX                   -qlanglvl=ansi
2513 # Ultrix and OSF/1      -std1
2514 # HP-UX 10.20 and later -Ae
2515 # HP-UX older versions  -Aa -D_HPUX_SOURCE
2516 # SVR4                  -Xc -D__EXTENSIONS__
2517 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
2518 do
2519   CC="$ac_save_CC $ac_arg"
2520   AC_TRY_COMPILE(
2521 [#include <stdarg.h>
2522 #include <stdio.h>
2523 #include <sys/types.h>
2524 #include <sys/stat.h>
2525 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
2526 struct buf { int x; };
2527 FILE * (*rcsopen) (struct buf *, struct stat *, int);
2528 static char *e (p, i)
2529      char **p;
2530      int i;
2531 {
2532   return p[i];
2533 }
2534 static char *f (char * (*g) (char **, int), char **p, ...)
2535 {
2536   char *s;
2537   va_list v;
2538   va_start (v,p);
2539   s = g (p, va_arg (v,int));
2540   va_end (v);
2541   return s;
2542 }
2543 int test (int i, double x);
2544 struct s1 {int (*f) (int a);};
2545 struct s2 {int (*f) (double a);};
2546 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
2547 int argc;
2548 char **argv;
2549 ], [
2550 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
2551 ],
2552 [am_cv_prog_cc_stdc="$ac_arg"; break])
2553 done
2554 CC="$ac_save_CC"
2555 ])
2556 if test -z "$am_cv_prog_cc_stdc"; then
2557   AC_MSG_RESULT([none needed])
2558 else
2559   AC_MSG_RESULT([$am_cv_prog_cc_stdc])
2560 fi
2561 case "x$am_cv_prog_cc_stdc" in
2562   x|xno) ;;
2563   *) CC="$CC $am_cv_prog_cc_stdc" ;;
2564 esac
2565 ])
2566
2567 AU_DEFUN([fp_PROG_CC_STDC], [AM_PROG_CC_STDC])
2568
2569 #serial 7
2570
2571 AC_DEFUN([jm_FUNC_MEMCMP],
2572 [AC_REQUIRE([AC_FUNC_MEMCMP])dnl
2573  if test $ac_cv_func_memcmp_working = no; then
2574    AC_DEFINE(memcmp, rpl_memcmp,
2575      [Define to rpl_memcmp if the replacement function should be used.])
2576  fi
2577 ])
2578
2579 # getcwd.m4 - check whether getcwd (NULL, 0) allocates memory for result
2580
2581 # Copyright 2001 Free Software Foundation, Inc.
2582
2583 # This program is free software; you can redistribute it and/or modify
2584 # it under the terms of the GNU General Public License as published by
2585 # the Free Software Foundation; either version 2, or (at your option)
2586 # any later version.
2587
2588 # This program is distributed in the hope that it will be useful,
2589 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2590 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2591 # GNU General Public License for more details.
2592
2593 # You should have received a copy of the GNU General Public License
2594 # along with this program; if not, write to the Free Software Foundation,
2595 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2596
2597 # Written by Paul Eggert.
2598
2599 AC_DEFUN([AC_FUNC_GETCWD_NULL],
2600   [AC_CHECK_HEADERS(stdlib.h unistd.h)
2601    AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
2602      [ac_cv_func_getcwd_null],
2603      [AC_TRY_RUN(
2604         [
2605 #        ifdef HAVE_STDLIB_H
2606 #         include <stdlib.h>
2607 #        endif
2608 #        ifdef HAVE_UNISTD_H
2609 #         include <unistd.h>
2610 #        endif
2611 #        ifndef getcwd
2612          char *getcwd ();
2613 #        endif
2614          int
2615          main ()
2616          {
2617            if (chdir ("/") != 0)
2618              exit (1);
2619            else
2620              {
2621                char *f = getcwd (NULL, 0);
2622                exit (! (f && f[0] == '/' && !f[1]));
2623              }
2624          }],
2625         [ac_cv_func_getcwd_null=yes],
2626         [ac_cv_func_getcwd_null=no],
2627         [ac_cv_func_getcwd_null=no])])
2628    if test $ac_cv_func_getcwd_null = yes; then
2629      AC_DEFINE(HAVE_GETCWD_NULL, 1,
2630                [Define if getcwd (NULL, 0) allocates memory for result.])
2631    fi])
2632
2633 #serial 6
2634
2635 dnl Find out how to get the file descriptor associated with an open DIR*.
2636 dnl From Jim Meyering
2637
2638 AC_DEFUN([UTILS_FUNC_DIRFD],
2639 [
2640   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
2641   AC_REQUIRE([AC_PROG_CPP])
2642   AC_REQUIRE([AC_PROG_EGREP])
2643
2644   AC_HEADER_DIRENT
2645   dirfd_headers='
2646 #if HAVE_DIRENT_H
2647 # include <dirent.h>
2648 #else /* not HAVE_DIRENT_H */
2649 # define dirent direct
2650 # if HAVE_SYS_NDIR_H
2651 #  include <sys/ndir.h>
2652 # endif /* HAVE_SYS_NDIR_H */
2653 # if HAVE_SYS_DIR_H
2654 #  include <sys/dir.h>
2655 # endif /* HAVE_SYS_DIR_H */
2656 # if HAVE_NDIR_H
2657 #  include <ndir.h>
2658 # endif /* HAVE_NDIR_H */
2659 #endif /* HAVE_DIRENT_H */
2660 '
2661   AC_CHECK_FUNCS(dirfd)
2662   AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
2663
2664   AC_CACHE_CHECK([whether dirfd is a macro],
2665     jm_cv_func_dirfd_macro,
2666     [AC_EGREP_CPP([dirent_header_defines_dirfd], [$dirfd_headers
2667 #ifdef dirfd
2668  dirent_header_defines_dirfd
2669 #endif],
2670        jm_cv_func_dirfd_macro=yes,
2671        jm_cv_func_dirfd_macro=no)])
2672
2673   # Use the replacement only if we have no function, macro,
2674   # or declaration with that name.
2675   if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$jm_cv_func_dirfd_macro \
2676       = no,no,no; then
2677     AC_REPLACE_FUNCS([dirfd])
2678     AC_CACHE_CHECK(
2679               [how to get the file descriptor associated with an open DIR*],
2680                    gl_cv_sys_dir_fd_member_name,
2681       [
2682         dirfd_save_CFLAGS=$CFLAGS
2683         for ac_expr in d_fd dd_fd; do
2684
2685           CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
2686           AC_TRY_COMPILE(
2687             [$dirfd_headers
2688             ],
2689             [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;],
2690             dir_fd_found=yes
2691           )
2692           CFLAGS=$dirfd_save_CFLAGS
2693           test "$dir_fd_found" = yes && break
2694         done
2695         test "$dir_fd_found" = yes || ac_expr=no_such_member
2696
2697         gl_cv_sys_dir_fd_member_name=$ac_expr
2698       ]
2699     )
2700     if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
2701       AC_DEFINE_UNQUOTED(DIR_FD_MEMBER_NAME,
2702         $gl_cv_sys_dir_fd_member_name,
2703         [the name of the file descriptor member of DIR])
2704     fi
2705     AH_VERBATIM(DIR_TO_FD,
2706                 [#ifdef DIR_FD_MEMBER_NAME
2707 # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
2708 #else
2709 # define DIR_TO_FD(Dir_p) -1
2710 #endif
2711 ]
2712     )
2713   fi
2714 ])
2715
2716 # acl.m4 - check for access control list (ACL) primitives
2717
2718 # Copyright (C) 2002 Free Software Foundation, Inc.
2719
2720 # This program is free software; you can redistribute it and/or modify
2721 # it under the terms of the GNU General Public License as published by
2722 # the Free Software Foundation; either version 2, or (at your option)
2723 # any later version.
2724
2725 # This program is distributed in the hope that it will be useful,
2726 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2727 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2728 # GNU General Public License for more details.
2729
2730 # You should have received a copy of the GNU General Public License
2731 # along with this program; if not, write to the Free Software Foundation,
2732 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2733
2734 # Written by Paul Eggert.
2735
2736 AC_DEFUN([AC_FUNC_ACL],
2737   [AC_CHECK_HEADERS(sys/acl.h)
2738    AC_CHECK_FUNCS(acl)])
2739
2740 #serial 2
2741 # Use the replacement ftw.c if the one in the C library is inadequate or buggy.
2742 # For now, we always use the code in lib/ because libc doesn't have the FTW_DCH
2743 # or FTW_DCHP that we need.  Arrange to use lib/ftw.h.  And since that
2744 # implementation uses tsearch.c/tdestroy, add tsearch.o to the list of
2745 # objects and arrange to use lib/search.h if necessary.
2746 # From Jim Meyering
2747
2748 AC_DEFUN([AC_FUNC_FTW],
2749 [
2750   # prerequisites
2751   AC_REQUIRE([AC_HEADER_STAT])
2752   AC_REQUIRE([jm_FUNC_LSTAT])
2753   AC_REQUIRE([AC_HEADER_DIRENT])
2754   AC_CHECK_HEADERS(sys/param.h)
2755   AC_CHECK_DECLS([stpcpy])
2756
2757   # In the event that we have to use the replacement ftw.c,
2758   # see if we'll also need the replacement tsearch.c.
2759   AC_CHECK_FUNC([tdestroy], , [need_tdestroy=1])
2760
2761   AC_CACHE_CHECK([for ftw/FTW_CHDIR that informs callback of failed chdir],
2762                  ac_cv_func_ftw_working,
2763   [
2764   # The following test would fail prior to glibc-2.3.2, because `depth'
2765   # would be 2 rather than 4.  Of course, now that we require FTW_DCH
2766   # and FTW_DCHP, this test fails even with GNU libc's fixed ftw.
2767   mkdir -p conftest.dir/a/b/c
2768   AC_RUN_IFELSE([AC_LANG_SOURCE([[
2769 #include <string.h>
2770 #include <stdlib.h>
2771 #include <ftw.h>
2772
2773 static char *_f[] = { "conftest.dir", "conftest.dir/a",
2774                       "conftest.dir/a/b", "conftest.dir/a/b/c" };
2775 static char **p = _f;
2776 static int depth;
2777
2778 static int
2779 cb (const char *file, const struct stat *sb, int file_type, struct FTW *info)
2780 {
2781   if (strcmp (file, *p++) != 0)
2782     exit (1);
2783   ++depth;
2784   return 0;
2785 }
2786
2787 int
2788 main ()
2789 {
2790   /* Require these symbols, too.  */
2791   int d1 = FTW_DCH;
2792   int d2 = FTW_DCHP;
2793
2794   int err = nftw ("conftest.dir", cb, 30, FTW_PHYS | FTW_MOUNT | FTW_CHDIR);
2795   exit ((err == 0 && depth == 4) ? 0 : 1);
2796 }
2797 ]])],
2798                [ac_cv_func_ftw_working=yes],
2799                [ac_cv_func_ftw_working=no],
2800                [ac_cv_func_ftw_working=no])])
2801   rm -rf conftest.dir
2802   if test $ac_cv_func_ftw_working = no; then
2803     AC_LIBOBJ([ftw])
2804     AC_CONFIG_LINKS([$ac_config_libobj_dir/ftw.h:$ac_config_libobj_dir/ftw_.h])
2805     # Add tsearch.o IFF we have to use the replacement ftw.c.
2806     if test -n "$need_tdestroy"; then
2807       AC_LIBOBJ([tsearch])
2808       # Link search.h to search_.h if we use the replacement tsearch.c.
2809       AC_CONFIG_LINKS(
2810         [$ac_config_libobj_dir/search.h:$ac_config_libobj_dir/search_.h])
2811     fi
2812   fi
2813 ])# AC_FUNC_FTW
2814
2815 #serial 7
2816
2817 dnl From Jim Meyering.
2818 dnl Determine whether lstat has the bug that it succeeds when given the
2819 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
2820 dnl (as of 1998-11-01) do this.
2821 dnl
2822 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
2823 dnl compile the wrapper function.
2824 dnl
2825
2826 AC_DEFUN([jm_FUNC_LSTAT],
2827 [
2828  AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
2829  AC_CACHE_CHECK([whether lstat accepts an empty string],
2830   jm_cv_func_lstat_empty_string_bug,
2831   [AC_TRY_RUN([
2832 #   include <sys/types.h>
2833 #   include <sys/stat.h>
2834
2835     int
2836     main ()
2837     {
2838       struct stat sbuf;
2839       exit (lstat ("", &sbuf) ? 1 : 0);
2840     }
2841           ],
2842          jm_cv_func_lstat_empty_string_bug=yes,
2843          jm_cv_func_lstat_empty_string_bug=no,
2844          dnl When crosscompiling, assume lstat is broken.
2845          jm_cv_func_lstat_empty_string_bug=yes)
2846   ])
2847   if test $jm_cv_func_lstat_empty_string_bug = yes; then
2848     AC_LIBOBJ(lstat)
2849     AC_DEFINE(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
2850 [Define if lstat has the bug that it succeeds when given the zero-length
2851    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
2852    do this. ])
2853   fi
2854 ])
2855
2856 #serial 2
2857
2858 dnl From Jim Meyering.
2859 dnl Provide lchown on systems that lack it.
2860
2861 AC_DEFUN([jm_FUNC_LCHOWN],
2862 [
2863   AC_REQUIRE([AC_TYPE_UID_T])
2864   AC_REPLACE_FUNCS(lchown)
2865 ])
2866
2867 #serial 3
2868
2869 # When rmdir fails because the specified directory is not empty, it sets
2870 # errno to some value, usually ENOTEMPTY.  However, on some AIX systems,
2871 # ENOTEMPTY is mistakenly defined to be EEXIST.  To work around this, and
2872 # in general, to avoid depending on the use of any particular symbol, this
2873 # test runs a test to determine the actual numeric value.
2874 AC_DEFUN([fetish_FUNC_RMDIR_NOTEMPTY],
2875 [dnl
2876   AC_CACHE_CHECK([for rmdir-not-empty errno value],
2877     fetish_cv_func_rmdir_errno_not_empty,
2878     [
2879       # Arrange for deletion of the temporary directory this test creates.
2880       ac_clean_files="$ac_clean_files confdir2"
2881       mkdir confdir2; : > confdir2/file
2882       AC_TRY_RUN([
2883 #include <stdio.h>
2884 #include <errno.h>
2885 #ifndef errno
2886 extern int errno;
2887 #endif
2888         int main ()
2889         {
2890           FILE *s;
2891           int val;
2892           rmdir ("confdir2");
2893           val = errno;
2894           s = fopen ("confdir2/errno", "w");
2895           fprintf (s, "%d\n", val);
2896           exit (0);
2897         }
2898         ],
2899       fetish_cv_func_rmdir_errno_not_empty=`cat confdir2/errno`,
2900       fetish_cv_func_rmdir_errno_not_empty='configure error in rmdir-errno.m4',
2901       fetish_cv_func_rmdir_errno_not_empty=ENOTEMPTY
2902       )
2903     ]
2904   )
2905
2906   AC_DEFINE_UNQUOTED([RMDIR_ERRNO_NOT_EMPTY],
2907     $fetish_cv_func_rmdir_errno_not_empty,
2908     [the value to which errno is set when rmdir fails on a nonempty directory])
2909 ])
2910
2911 #serial 7
2912
2913 dnl From Jim Meyering.
2914 dnl Determine whether chown accepts arguments of -1 for uid and gid.
2915 dnl If it doesn't, arrange to use the replacement function.
2916 dnl
2917
2918 AC_DEFUN([jm_FUNC_CHOWN],
2919 [AC_REQUIRE([AC_TYPE_UID_T])dnl
2920  test -z "$ac_cv_header_unistd_h" \
2921    && AC_CHECK_HEADERS(unistd.h)
2922  AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
2923   [AC_TRY_RUN([
2924 #   include <sys/types.h>
2925 #   include <sys/stat.h>
2926 #   include <fcntl.h>
2927 #   ifdef HAVE_UNISTD_H
2928 #    include <unistd.h>
2929 #   endif
2930
2931     int
2932     main ()
2933     {
2934       char *f = "conftest.chown";
2935       struct stat before, after;
2936
2937       if (creat (f, 0600) < 0)
2938         exit (1);
2939       if (stat (f, &before) < 0)
2940         exit (1);
2941       if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
2942         exit (1);
2943       if (stat (f, &after) < 0)
2944         exit (1);
2945       exit ((before.st_uid == after.st_uid
2946              && before.st_gid == after.st_gid) ? 0 : 1);
2947     }
2948               ],
2949              jm_cv_func_working_chown=yes,
2950              jm_cv_func_working_chown=no,
2951              dnl When crosscompiling, assume chown is broken.
2952              jm_cv_func_working_chown=no)
2953   ])
2954   if test $jm_cv_func_working_chown = no; then
2955     AC_LIBOBJ(chown)
2956     AC_DEFINE(chown, rpl_chown,
2957       [Define to rpl_chown if the replacement function should be used.])
2958   fi
2959 ])
2960
2961 #serial 8
2962
2963 dnl From Jim Meyering.
2964 dnl A wrapper around AC_FUNC_MKTIME.
2965
2966 AC_DEFUN([jm_FUNC_MKTIME],
2967 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
2968
2969  dnl mktime.c uses localtime_r if it exists.  Check for it.
2970  AC_CHECK_FUNCS(localtime_r)
2971
2972  if test $ac_cv_func_working_mktime = no; then
2973    AC_DEFINE(mktime, rpl_mktime,
2974     [Define to rpl_mktime if the replacement function should be used.])
2975  fi
2976 ])
2977
2978 # mktime.m4 serial 2
2979 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2980 dnl This file is free software, distributed under the terms of the GNU
2981 dnl General Public License.  As a special exception to the GNU General
2982 dnl Public License, this file may be distributed as part of a program
2983 dnl that contains a configuration script generated by Autoconf, under
2984 dnl the same distribution terms as the rest of that program.
2985
2986 dnl From Jim Meyering.
2987
2988 # Redefine AC_FUNC_MKTIME, to fix a bug in Autoconf 2.57 and earlier.
2989 # This redefinition can be removed once a new version of Autoconf comes out.
2990 # The redefinition is taken from
2991 # <http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/autoconf/autoconf/lib/autoconf/functions.m4?rev=1.78>.
2992 # AC_FUNC_MKTIME
2993 # --------------
2994 AC_DEFUN([AC_FUNC_MKTIME],
2995 [AC_REQUIRE([AC_HEADER_TIME])dnl
2996 AC_CHECK_HEADERS(stdlib.h sys/time.h unistd.h)
2997 AC_CHECK_FUNCS(alarm)
2998 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
2999 [AC_RUN_IFELSE([AC_LANG_SOURCE(
3000 [[/* Test program from Paul Eggert and Tony Leneis.  */
3001 #if TIME_WITH_SYS_TIME
3002 # include <sys/time.h>
3003 # include <time.h>
3004 #else
3005 # if HAVE_SYS_TIME_H
3006 #  include <sys/time.h>
3007 # else
3008 #  include <time.h>
3009 # endif
3010 #endif
3011
3012 #if HAVE_STDLIB_H
3013 # include <stdlib.h>
3014 #endif
3015
3016 #if HAVE_UNISTD_H
3017 # include <unistd.h>
3018 #endif
3019
3020 #if !HAVE_ALARM
3021 # define alarm(X) /* empty */
3022 #endif
3023
3024 /* Work around redefinition to rpl_putenv by other config tests.  */
3025 #undef putenv
3026
3027 static time_t time_t_max;
3028 static time_t time_t_min;
3029
3030 /* Values we'll use to set the TZ environment variable.  */
3031 static char *tz_strings[] = {
3032   (char *) 0, "TZ=GMT0", "TZ=JST-9",
3033   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
3034 };
3035 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
3036
3037 /* Fail if mktime fails to convert a date in the spring-forward gap.
3038    Based on a problem report from Andreas Jaeger.  */
3039 static void
3040 spring_forward_gap ()
3041 {
3042   /* glibc (up to about 1998-10-07) failed this test. */
3043   struct tm tm;
3044
3045   /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
3046      instead of "TZ=America/Vancouver" in order to detect the bug even
3047      on systems that don't support the Olson extension, or don't have the
3048      full zoneinfo tables installed.  */
3049   putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
3050
3051   tm.tm_year = 98;
3052   tm.tm_mon = 3;
3053   tm.tm_mday = 5;
3054   tm.tm_hour = 2;
3055   tm.tm_min = 0;
3056   tm.tm_sec = 0;
3057   tm.tm_isdst = -1;
3058   if (mktime (&tm) == (time_t)-1)
3059     exit (1);
3060 }
3061
3062 static void
3063 mktime_test1 (now)
3064      time_t now;
3065 {
3066   struct tm *lt;
3067   if ((lt = localtime (&now)) && mktime (lt) != now)
3068     exit (1);
3069 }
3070
3071 static void
3072 mktime_test (now)
3073      time_t now;
3074 {
3075   mktime_test1 (now);
3076   mktime_test1 ((time_t) (time_t_max - now));
3077   mktime_test1 ((time_t) (time_t_min + now));
3078 }
3079
3080 static void
3081 irix_6_4_bug ()
3082 {
3083   /* Based on code from Ariel Faigon.  */
3084   struct tm tm;
3085   tm.tm_year = 96;
3086   tm.tm_mon = 3;
3087   tm.tm_mday = 0;
3088   tm.tm_hour = 0;
3089   tm.tm_min = 0;
3090   tm.tm_sec = 0;
3091   tm.tm_isdst = -1;
3092   mktime (&tm);
3093   if (tm.tm_mon != 2 || tm.tm_mday != 31)
3094     exit (1);
3095 }
3096
3097 static void
3098 bigtime_test (j)
3099      int j;
3100 {
3101   struct tm tm;
3102   time_t now;
3103   tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
3104   now = mktime (&tm);
3105   if (now != (time_t) -1)
3106     {
3107       struct tm *lt = localtime (&now);
3108       if (! (lt
3109              && lt->tm_year == tm.tm_year
3110              && lt->tm_mon == tm.tm_mon
3111              && lt->tm_mday == tm.tm_mday
3112              && lt->tm_hour == tm.tm_hour
3113              && lt->tm_min == tm.tm_min
3114              && lt->tm_sec == tm.tm_sec
3115              && lt->tm_yday == tm.tm_yday
3116              && lt->tm_wday == tm.tm_wday
3117              && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
3118                   == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
3119         exit (1);
3120     }
3121 }
3122
3123 int
3124 main ()
3125 {
3126   time_t t, delta;
3127   int i, j;
3128
3129   /* This test makes some buggy mktime implementations loop.
3130      Give up after 60 seconds; a mktime slower than that
3131      isn't worth using anyway.  */
3132   alarm (60);
3133
3134   for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
3135     continue;
3136   time_t_max--;
3137   if ((time_t) -1 < 0)
3138     for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
3139       continue;
3140   delta = time_t_max / 997; /* a suitable prime number */
3141   for (i = 0; i < N_STRINGS; i++)
3142     {
3143       if (tz_strings[i])
3144         putenv (tz_strings[i]);
3145
3146       for (t = 0; t <= time_t_max - delta; t += delta)
3147         mktime_test (t);
3148       mktime_test ((time_t) 1);
3149       mktime_test ((time_t) (60 * 60));
3150       mktime_test ((time_t) (60 * 60 * 24));
3151
3152       for (j = 1; 0 < j; j *= 2)
3153         bigtime_test (j);
3154       bigtime_test (j - 1);
3155     }
3156   irix_6_4_bug ();
3157   spring_forward_gap ();
3158   exit (0);
3159 }]])],
3160                [ac_cv_func_working_mktime=yes],
3161                [ac_cv_func_working_mktime=no],
3162                [ac_cv_func_working_mktime=no])])
3163 if test $ac_cv_func_working_mktime = no; then
3164   AC_LIBOBJ([mktime])
3165 fi
3166 ])# AC_FUNC_MKTIME
3167
3168 AC_DEFUN([gl_FUNC_MKTIME],
3169 [
3170   AC_REQUIRE([AC_FUNC_MKTIME])
3171   if test $ac_cv_func_working_mktime = no; then
3172     AC_DEFINE(mktime, rpl_mktime,
3173       [Define to rpl_mktime if the replacement function should be used.])
3174     gl_PREREQ_MKTIME
3175   fi
3176 ])
3177
3178 # Prerequisites of lib/mktime.c.
3179 AC_DEFUN([gl_PREREQ_MKTIME], [
3180   AC_REQUIRE([AC_HEADER_STDC])
3181   AC_CHECK_HEADERS_ONCE(limits.h)
3182 ])
3183
3184 #serial 7
3185
3186 dnl From Jim Meyering.
3187 dnl Determine whether stat has the bug that it succeeds when given the
3188 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
3189 dnl (as of 1998-11-01) do this.
3190 dnl
3191 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
3192 dnl compile the wrapper function.
3193 dnl
3194
3195 AC_DEFUN([jm_FUNC_STAT],
3196 [
3197  AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
3198  AC_CACHE_CHECK([whether stat accepts an empty string],
3199   jm_cv_func_stat_empty_string_bug,
3200   [AC_TRY_RUN([
3201 #   include <sys/types.h>
3202 #   include <sys/stat.h>
3203
3204     int
3205     main ()
3206     {
3207       struct stat sbuf;
3208       exit (stat ("", &sbuf) ? 1 : 0);
3209     }
3210           ],
3211          jm_cv_func_stat_empty_string_bug=yes,
3212          jm_cv_func_stat_empty_string_bug=no,
3213          dnl When crosscompiling, assume stat is broken.
3214          jm_cv_func_stat_empty_string_bug=yes)
3215   ])
3216   if test $jm_cv_func_stat_empty_string_bug = yes; then
3217     AC_LIBOBJ(stat)
3218     AC_DEFINE(HAVE_STAT_EMPTY_STRING_BUG, 1,
3219 [Define if stat has the bug that it succeeds when given the zero-length
3220    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
3221    do this. ])
3222   fi
3223 ])
3224
3225 #serial 8
3226
3227 dnl From Jim Meyering.
3228 dnl Check for the nanosleep function.
3229 dnl If not found, use the supplied replacement.
3230 dnl
3231
3232 AC_DEFUN([jm_FUNC_NANOSLEEP],
3233 [
3234  nanosleep_save_libs=$LIBS
3235
3236  # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
3237  # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
3238  AC_SEARCH_LIBS(nanosleep, [rt posix4], [LIB_NANOSLEEP=$ac_cv_search_nanosleep])
3239  AC_SUBST(LIB_NANOSLEEP)
3240
3241  AC_CACHE_CHECK([whether nanosleep works],
3242   jm_cv_func_nanosleep_works,
3243   [
3244    AC_REQUIRE([AC_HEADER_TIME])
3245    AC_TRY_RUN([
3246 #   if TIME_WITH_SYS_TIME
3247 #    include <sys/time.h>
3248 #    include <time.h>
3249 #   else
3250 #    if HAVE_SYS_TIME_H
3251 #     include <sys/time.h>
3252 #    else
3253 #     include <time.h>
3254 #    endif
3255 #   endif
3256
3257     int
3258     main ()
3259     {
3260       struct timespec ts_sleep, ts_remaining;
3261       ts_sleep.tv_sec = 0;
3262       ts_sleep.tv_nsec = 1;
3263       exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
3264     }
3265           ],
3266          jm_cv_func_nanosleep_works=yes,
3267          jm_cv_func_nanosleep_works=no,
3268          dnl When crosscompiling, assume the worst.
3269          jm_cv_func_nanosleep_works=no)
3270   ])
3271   if test $jm_cv_func_nanosleep_works = no; then
3272     AC_LIBOBJ(nanosleep)
3273     AC_DEFINE(nanosleep, rpl_nanosleep,
3274       [Define to rpl_nanosleep if the replacement function should be used.])
3275   fi
3276
3277  LIBS=$nanosleep_save_libs
3278 ])
3279
3280 #serial 7 -*- autoconf -*-
3281
3282 dnl From Jim Meyering.
3283 dnl
3284 dnl See if the glibc *_unlocked I/O macros are available.
3285 dnl Use only those *_unlocked macros that are declared.
3286 dnl
3287
3288 AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO],
3289   [AC_CHECK_DECLS(
3290      [clearerr_unlocked, feof_unlocked, ferror_unlocked,
3291       fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked,
3292       fread_unlocked, fwrite_unlocked, getc_unlocked,
3293       getchar_unlocked, putc_unlocked, putchar_unlocked])])
3294
3295 #serial 3
3296
3297 dnl Written by Jim Meyering
3298
3299 AC_DEFUN([jm_FUNC_GROUP_MEMBER],
3300   [
3301     dnl Do this replacement check manually because I want the hyphen
3302     dnl (not the underscore) in the filename.
3303     AC_CHECK_FUNC(group_member, , [AC_LIBOBJ(group-member)])
3304   ]
3305 )
3306
3307 #serial 5
3308
3309 dnl From Jim Meyering.
3310 dnl
3311 dnl Check whether putenv ("FOO") removes FOO from the environment.
3312 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
3313 dnl
3314
3315 AC_DEFUN([jm_FUNC_PUTENV],
3316 [AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
3317   [AC_TRY_RUN([
3318     int
3319     main ()
3320     {
3321       /* Put it in env.  */
3322       if (putenv ("CONFTEST_putenv=val"))
3323         exit (1);
3324
3325       /* Try to remove it.  */
3326       if (putenv ("CONFTEST_putenv"))
3327         exit (1);
3328
3329       /* Make sure it was deleted.  */
3330       if (getenv ("CONFTEST_putenv") != 0)
3331         exit (1);
3332
3333       exit (0);
3334     }
3335               ],
3336              jm_cv_func_svid_putenv=yes,
3337              jm_cv_func_svid_putenv=no,
3338              dnl When crosscompiling, assume putenv is broken.
3339              jm_cv_func_svid_putenv=no)
3340   ])
3341   if test $jm_cv_func_svid_putenv = no; then
3342     AC_LIBOBJ(putenv)
3343     AC_DEFINE(putenv, rpl_putenv,
3344       [Define to rpl_putenv if the replacement function should be used.])
3345   fi
3346 ])
3347
3348 #serial 5
3349
3350 AC_DEFUN([jm_AFS],
3351   [
3352     AC_MSG_CHECKING(for AFS)
3353     if test -d /afs; then
3354       AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
3355       ac_result=yes
3356     else
3357       ac_result=no
3358     fi
3359     AC_MSG_RESULT($ac_result)
3360   ])
3361
3362 #serial 4
3363
3364 # autoconf tests required for use of xstrtoumax.c
3365
3366 AC_DEFUN([jm_AC_PREREQ_XSTRTOUMAX],
3367 [
3368   AC_REQUIRE([jm_AC_TYPE_INTMAX_T])
3369   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
3370   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
3371   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
3372   AC_CHECK_DECLS([strtol, strtoul, strtoull, strtoimax, strtoumax])
3373   AC_CHECK_HEADERS(limits.h stdlib.h inttypes.h)
3374
3375   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
3376     jm_cv_func_strtoumax_macro,
3377     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
3378 #ifdef strtoumax
3379  inttypes_h_defines_strtoumax
3380 #endif],
3381       jm_cv_func_strtoumax_macro=yes,
3382       jm_cv_func_strtoumax_macro=no))
3383
3384   if test "$jm_cv_func_strtoumax_macro" != yes; then
3385     AC_REPLACE_FUNCS(strtoumax)
3386   fi
3387
3388   dnl Only the replacement strtoumax invokes strtoul and strtoull,
3389   dnl so we need the replacements only if strtoumax does not exist.
3390   case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
3391     no,no)
3392       AC_REPLACE_FUNCS(strtoul)
3393
3394       dnl We don't need (and can't compile) the replacement strtoull
3395       dnl unless the type `unsigned long long' exists.
3396       if test "$ac_cv_type_unsigned_long_long" = yes; then
3397         AC_REPLACE_FUNCS(strtoull)
3398       fi
3399       ;;
3400   esac
3401 ])
3402
3403 # intmax_t.m4 serial 1
3404 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
3405 dnl This file is free software, distributed under the terms of the GNU
3406 dnl General Public License.  As a special exception to the GNU General
3407 dnl Public License, this file may be distributed as part of a program
3408 dnl that contains a configuration script generated by Autoconf, under
3409 dnl the same distribution terms as the rest of that program.
3410
3411 dnl From Paul Eggert.
3412
3413 AC_PREREQ(2.13)
3414
3415 # Define intmax_t to 'long' or 'long long'
3416 # if it is not already defined in <stdint.h> or <inttypes.h>.
3417
3418 AC_DEFUN([jm_AC_TYPE_INTMAX_T],
3419 [
3420   dnl For simplicity, we assume that a header file defines 'intmax_t' if and
3421   dnl only if it defines 'uintmax_t'.
3422   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
3423   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
3424   if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
3425     AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
3426     test $ac_cv_type_long_long = yes \
3427       && ac_type='long long' \
3428       || ac_type='long'
3429     AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
3430      [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
3431   else
3432     AC_DEFINE(HAVE_INTMAX_T, 1,
3433       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
3434   fi
3435 ])
3436
3437 dnl An alternative would be to explicitly test for 'intmax_t'.
3438
3439 AC_DEFUN([gt_AC_TYPE_INTMAX_T],
3440 [
3441   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
3442   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
3443   AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
3444     [AC_TRY_COMPILE([
3445 #include <stddef.h>
3446 #include <stdlib.h>
3447 #if HAVE_STDINT_H_WITH_UINTMAX
3448 #include <stdint.h>
3449 #endif
3450 #if HAVE_INTTYPES_H_WITH_UINTMAX
3451 #include <inttypes.h>
3452 #endif
3453 ], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
3454   if test $gt_cv_c_intmax_t = yes; then
3455     AC_DEFINE(HAVE_INTMAX_T, 1,
3456       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
3457   else
3458     AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
3459     test $ac_cv_type_long_long = yes \
3460       && ac_type='long long' \
3461       || ac_type='long'
3462     AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
3463      [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
3464   fi
3465 ])
3466
3467 #serial 2
3468 dnl Cloned from xstrtoumax.m4.  Keep these files in sync.
3469
3470 # autoconf tests required for use of xstrtoimax.c
3471
3472 AC_DEFUN([jm_AC_PREREQ_XSTRTOIMAX],
3473 [
3474   AC_REQUIRE([jm_AC_TYPE_INTMAX_T])
3475   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
3476   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
3477   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
3478   AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoimax, strtoumax])
3479   AC_CHECK_HEADERS(limits.h stdlib.h inttypes.h)
3480
3481   AC_CACHE_CHECK([whether <inttypes.h> defines strtoimax as a macro],
3482     jm_cv_func_strtoimax_macro,
3483     AC_EGREP_CPP([inttypes_h_defines_strtoimax], [#include <inttypes.h>
3484 #ifdef strtoimax
3485  inttypes_h_defines_strtoimax
3486 #endif],
3487       jm_cv_func_strtoimax_macro=yes,
3488       jm_cv_func_strtoimax_macro=no))
3489
3490   if test "$jm_cv_func_strtoimax_macro" != yes; then
3491     AC_REPLACE_FUNCS(strtoimax)
3492   fi
3493
3494   dnl Only the replacement strtoimax invokes strtol and strtoll,
3495   dnl so we need the replacements only if strtoimax does not exist.
3496   case "$jm_cv_func_strtoimax_macro,$ac_cv_func_strtoimax" in
3497     no,no)
3498       AC_REPLACE_FUNCS(strtol)
3499
3500       dnl We don't need (and can't compile) the replacement strtoll
3501       dnl unless the type `long long' exists.
3502       if test "$ac_cv_type_long_long" = yes; then
3503         AC_REPLACE_FUNCS(strtoll)
3504       fi
3505       ;;
3506   esac
3507 ])
3508
3509 #serial 3
3510 dnl Run a program to determine whether whether link(2) follows symlinks.
3511 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
3512
3513 AC_DEFUN([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK],
3514 [dnl
3515   AC_CACHE_CHECK(
3516     [whether link(2) dereferences a symlink specified with a trailing slash],
3517                  jm_ac_cv_func_link_follows_symlink,
3518   [
3519     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
3520     dnl the appropriate framework.
3521     test -z "$ac_cv_header_unistd_h" \
3522       && AC_CHECK_HEADERS(unistd.h)
3523
3524     # Create a regular file.
3525     echo > conftest.file
3526     AC_TRY_RUN(
3527       [
3528 #       include <sys/types.h>
3529 #       include <sys/stat.h>
3530 #       ifdef HAVE_UNISTD_H
3531 #        include <unistd.h>
3532 #       endif
3533
3534 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
3535           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
3536            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
3537
3538         int
3539         main ()
3540         {
3541           const char *file = "conftest.file";
3542           const char *sym = "conftest.sym";
3543           const char *hard = "conftest.hard";
3544           struct stat sb_file, sb_hard;
3545
3546           /* Create a symlink to the regular file. */
3547           if (symlink (file, sym))
3548             abort ();
3549
3550           /* Create a hard link to that symlink.  */
3551           if (link (sym, hard))
3552             abort ();
3553
3554           if (lstat (hard, &sb_hard))
3555             abort ();
3556           if (lstat (file, &sb_file))
3557             abort ();
3558
3559           /* If the dev/inode of hard and file are the same, then
3560              the link call followed the symlink.  */
3561           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
3562         }
3563       ],
3564       jm_ac_cv_func_link_follows_symlink=yes,
3565       jm_ac_cv_func_link_follows_symlink=no,
3566       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
3567     )
3568   ])
3569   if test $jm_ac_cv_func_link_follows_symlink = yes; then
3570     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
3571       [Define if `link(2)' dereferences symbolic links.])
3572   fi
3573 ])
3574
3575 #serial 20
3576
3577 dnl This macro is intended to be used solely in this file.
3578 dnl These are the prerequisite macros for GNU's strftime.c replacement.
3579 AC_DEFUN([_jm_STRFTIME_PREREQS],
3580 [
3581  dnl strftime.c uses the underyling system strftime if it exists.
3582  AC_FUNC_STRFTIME
3583
3584  AC_CHECK_HEADERS_ONCE(limits.h)
3585  AC_CHECK_FUNCS_ONCE(memcpy mempcpy)
3586  AC_CHECK_FUNCS(tzset memset)
3587
3588  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
3589  AC_STRUCT_TIMEZONE
3590
3591  AC_CHECK_FUNCS(mblen mbrlen)
3592  AC_TYPE_MBSTATE_T
3593
3594  AC_REQUIRE([gl_TM_GMTOFF])
3595  AC_REQUIRE([gl_FUNC_TZSET_CLOBBER])
3596 ])
3597
3598 dnl From Jim Meyering.
3599 dnl
3600 AC_DEFUN([jm_FUNC_GNU_STRFTIME],
3601 [AC_REQUIRE([AC_HEADER_TIME])dnl
3602
3603  _jm_STRFTIME_PREREQS
3604
3605  AC_REQUIRE([AC_C_CONST])dnl
3606  AC_REQUIRE([AC_HEADER_STDC])dnl
3607  AC_CHECK_HEADERS_ONCE(sys/time.h)
3608  AC_DEFINE([my_strftime], [nstrftime],
3609    [Define to the name of the strftime replacement function.])
3610 ])
3611
3612 AC_DEFUN([jm_FUNC_STRFTIME],
3613 [
3614   _jm_STRFTIME_PREREQS
3615 ])
3616
3617 # tm_gmtoff.m4 serial 1
3618 dnl Copyright (C) 2002 Free Software Foundation, Inc.
3619 dnl This file is free software, distributed under the terms of the GNU
3620 dnl General Public License.  As a special exception to the GNU General
3621 dnl Public License, this file may be distributed as part of a program
3622 dnl that contains a configuration script generated by Autoconf, under
3623 dnl the same distribution terms as the rest of that program.
3624
3625 AC_DEFUN([gl_TM_GMTOFF],
3626 [
3627  AC_CHECK_MEMBER([struct tm.tm_gmtoff],
3628                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
3629                             [Define if struct tm has the tm_gmtoff member.])],
3630                  ,
3631                  [#include <time.h>])
3632 ])
3633
3634 #serial 1
3635 # See if we have a working tzset function.
3636 # If so, arrange to compile the wrapper function.
3637 # For at least Solaris 2.5.1 and 2.6, this is necessary
3638 # because tzset can clobber the contents of the buffer
3639 # used by localtime.
3640
3641 # Written by Paul Eggert and Jim Meyering.
3642
3643 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
3644 [
3645   AC_REQUIRE([AC_HEADER_TIME])
3646   AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
3647                  gl_cv_func_tzset_clobber,
3648   [
3649   AC_RUN_IFELSE([AC_LANG_SOURCE([[
3650 #if TIME_WITH_SYS_TIME
3651 # include <sys/time.h>
3652 # include <time.h>
3653 #else
3654 # if HAVE_SYS_TIME_H
3655 #  include <sys/time.h>
3656 # else
3657 #  include <time.h>
3658 # endif
3659 #endif
3660 #include <stdlib.h>
3661
3662 int
3663 main ()
3664 {
3665   time_t t1 = 853958121;
3666   struct tm *p, s;
3667   putenv ("TZ=GMT0");
3668   p = localtime (&t1);
3669   s = *p;
3670   putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
3671   tzset ();
3672   exit (p->tm_year != s.tm_year
3673         || p->tm_mon != s.tm_mon
3674         || p->tm_mday != s.tm_mday
3675         || p->tm_hour != s.tm_hour
3676         || p->tm_min != s.tm_min
3677         || p->tm_sec != s.tm_sec);
3678 }
3679   ]])],
3680        [gl_cv_func_tzset_clobber=no],
3681        [gl_cv_func_tzset_clobber=yes],
3682        [gl_cv_func_tzset_clobber=yes])])
3683
3684   AC_DEFINE(HAVE_RUN_TZSET_TEST, 1,
3685     [Define to 1 if you have run the test for working tzset.])
3686
3687   if test $gl_cv_func_tzset_clobber = yes; then
3688     # Caution: the following few lines should be the same
3689     # as those in gettimeofday.m4.
3690     AC_LIBOBJ(gettimeofday)
3691     AC_DEFINE(gmtime, rpl_gmtime,
3692       [Define to rpl_gmtime if the replacement function should be used.])
3693     AC_DEFINE(localtime, rpl_localtime,
3694       [Define to rpl_localtime if the replacement function should be used.])
3695
3696     AC_DEFINE(tzset, rpl_tzset,
3697       [Define to rpl_tzset if the wrapper function should be used.])
3698     AC_DEFINE(TZSET_CLOBBERS_LOCALTIME_BUFFER, 1,
3699       [Define if tzset clobbers localtime's static buffer.])
3700   fi
3701 ])
3702
3703 #serial 3
3704
3705 dnl From Jim Meyering
3706 dnl Using code from emacs, based on suggestions from Paul Eggert
3707 dnl and Ulrich Drepper.
3708
3709 dnl Find out how to determine the number of pending output bytes on a stream.
3710 dnl glibc (2.1.93 and newer) and Solaris provide __fpending.  On other systems,
3711 dnl we have to grub around in the FILE struct.
3712
3713 AC_DEFUN([jm_FUNC_FPENDING],
3714 [
3715   AC_CHECK_HEADERS(stdio_ext.h)
3716   AC_REPLACE_FUNCS([__fpending])
3717   fp_headers='
3718 #     if HAVE_STDIO_EXT_H
3719 #      include <stdio_ext.h>
3720 #     endif
3721 '
3722   AC_CHECK_DECLS([__fpending], , , $fp_headers)
3723   if test $ac_cv_func___fpending = no; then
3724     AC_CACHE_CHECK(
3725               [how to determine the number of pending output bytes on a stream],
3726                    ac_cv_sys_pending_output_n_bytes,
3727       [
3728         for ac_expr in                                          \
3729                                                                 \
3730             '# glibc2'                                          \
3731             'fp->_IO_write_ptr - fp->_IO_write_base'            \
3732                                                                 \
3733             '# traditional Unix'                                \
3734             'fp->_ptr - fp->_base'                              \
3735                                                                 \
3736             '# BSD'                                             \
3737             'fp->_p - fp->_bf._base'                            \
3738                                                                 \
3739             '# SCO, Unixware'                                   \
3740             'fp->__ptr - fp->__base'                            \
3741                                                                 \
3742             '# old glibc?'                                      \
3743             'fp->__bufp - fp->__buffer'                         \
3744                                                                 \
3745             '# old glibc iostream?'                             \
3746             'fp->_pptr - fp->_pbase'                            \
3747                                                                 \
3748             '# VMS'                                             \
3749             '(*fp)->_ptr - (*fp)->_base'                        \
3750                                                                 \
3751             '# e.g., DGUX R4.11; the info is not available'     \
3752             1                                                   \
3753             ; do
3754
3755           # Skip each embedded comment.
3756           case "$ac_expr" in '#'*) continue;; esac
3757
3758           AC_TRY_COMPILE(
3759             [#include <stdio.h>
3760             ],
3761             [FILE *fp = stdin; (void) ($ac_expr);],
3762             fp_done=yes
3763           )
3764           test "$fp_done" = yes && break
3765         done
3766
3767         ac_cv_sys_pending_output_n_bytes=$ac_expr
3768       ]
3769     )
3770     AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
3771       $ac_cv_sys_pending_output_n_bytes,
3772       [the number of pending output bytes on stream `fp'])
3773   fi
3774 ])
3775
3776 # inttypes-pri.m4 serial 1001 (based on gettext-0.11.4's `serial 1')
3777 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
3778 dnl This file is free software, distributed under the terms of the GNU
3779 dnl General Public License.  As a special exception to the GNU General
3780 dnl Public License, this file may be distributed as part of a program
3781 dnl that contains a configuration script generated by Autoconf, under
3782 dnl the same distribution terms as the rest of that program.
3783
3784 dnl From Bruno Haible.
3785
3786 # Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
3787 # macros to non-string values.  This is the case on AIX 4.3.3.
3788
3789 AC_DEFUN([gt_INTTYPES_PRI],
3790 [
3791   # autoconf-2.52 has a proper check for inttypes.h.
3792   AC_PREREQ(2.52)
3793
3794   if test $ac_cv_header_inttypes_h = yes; then
3795     AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
3796       gt_cv_inttypes_pri_broken,
3797       [
3798         AC_TRY_COMPILE([#include <inttypes.h>
3799 #ifdef PRId32
3800 char *p = PRId32;
3801 #endif
3802 ], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes)
3803       ])
3804   fi
3805   if test "$gt_cv_inttypes_pri_broken" = yes; then
3806     AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
3807       [Define if <inttypes.h> exists and defines unusable PRI* macros.])
3808   fi
3809 ])
3810
3811 #serial 7
3812
3813 dnl From Jim Meyering.
3814 dnl A wrapper around AC_FUNC_GETGROUPS.
3815
3816 AC_DEFUN([jm_FUNC_GETGROUPS],
3817 [AC_REQUIRE([AC_FUNC_GETGROUPS])dnl
3818   if test $ac_cv_func_getgroups_works = no; then
3819     AC_LIBOBJ(getgroups)
3820     AC_DEFINE(getgroups, rpl_getgroups,
3821       [Define as rpl_getgroups if getgroups doesn't work right.])
3822   fi
3823   test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"
3824 ])
3825
3826 # alloca.m4 serial 2 (gettext-0.12)
3827 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
3828 dnl This file is free software, distributed under the terms of the GNU
3829 dnl General Public License.  As a special exception to the GNU General
3830 dnl Public License, this file may be distributed as part of a program
3831 dnl that contains a configuration script generated by Autoconf, under
3832 dnl the same distribution terms as the rest of that program.
3833
3834 AC_DEFUN([gl_FUNC_ALLOCA],
3835 [
3836   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
3837   AC_REQUIRE([AC_PROG_CPP])
3838   AC_REQUIRE([AC_PROG_EGREP])
3839
3840   AC_REQUIRE([AC_FUNC_ALLOCA])
3841   if test $ac_cv_func_alloca_works = no; then
3842     gl_PREREQ_ALLOCA
3843   fi
3844
3845   # Define an additional variable used in the Makefile substitution.
3846
3847   AC_EGREP_CPP([Need own alloca], [
3848 #if defined __GNUC__ || defined _MSC_VER || !HAVE_ALLOCA_H
3849   Need own alloca
3850 #endif
3851     ],
3852     ALLOCA_H=alloca.h,
3853     ALLOCA_H=)
3854   AC_SUBST([ALLOCA_H])
3855 ])
3856
3857 # Prerequisites of lib/alloca.c.
3858 # STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
3859 AC_DEFUN([gl_PREREQ_ALLOCA], [
3860   AC_CHECK_HEADERS_ONCE(stdlib.h string.h)
3861 ])
3862
3863 #serial 5
3864
3865 AC_PREREQ(2.13)
3866
3867 AC_DEFUN([jm_SYS_PROC_UPTIME],
3868 [ dnl Require AC_PROG_CC to see if we're cross compiling.
3869   AC_REQUIRE([AC_PROG_CC])
3870   AC_CACHE_CHECK([for /proc/uptime], jm_cv_have_proc_uptime,
3871   [jm_cv_have_proc_uptime=no
3872     test -f /proc/uptime \
3873       && test "$cross_compiling" = no \
3874       && cat < /proc/uptime >/dev/null 2>/dev/null \
3875       && jm_cv_have_proc_uptime=yes])
3876   if test $jm_cv_have_proc_uptime = yes; then
3877     AC_DEFINE(HAVE_PROC_UPTIME, 1,
3878               [  Define if your system has the /proc/uptime special file.])
3879   fi
3880 ])
3881
3882 #serial 4
3883
3884 # See if we need to emulate a missing ftruncate function using fcntl or chsize.
3885
3886 AC_DEFUN([jm_FUNC_FTRUNCATE],
3887 [
3888   AC_CHECK_FUNCS(ftruncate, , [ftruncate_missing=yes])
3889
3890   if test "$ftruncate_missing" = yes; then
3891     AC_CHECK_HEADERS([unistd.h])
3892     AC_CHECK_FUNCS([chsize])
3893     AC_LIBOBJ(ftruncate)
3894   fi
3895 ])
3896
3897 #serial 3
3898
3899 dnl From Volker Borchert.
3900 dnl Determine whether rename works for source paths with a trailing slash.
3901 dnl The rename from SunOS 4.1.1_U1 doesn't.
3902 dnl
3903 dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
3904 dnl to compile the wrapper function.
3905 dnl
3906
3907 AC_DEFUN([vb_FUNC_RENAME],
3908 [
3909  AC_CACHE_CHECK([whether rename is broken],
3910   vb_cv_func_rename_trailing_slash_bug,
3911   [
3912     rm -rf conftest.d1 conftest.d2
3913     mkdir conftest.d1 ||
3914       AC_MSG_ERROR([cannot create temporary directory])
3915     AC_TRY_RUN([
3916 #       include <stdio.h>
3917         int
3918         main ()
3919         {
3920           exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
3921         }
3922       ],
3923       vb_cv_func_rename_trailing_slash_bug=no,
3924       vb_cv_func_rename_trailing_slash_bug=yes,
3925       dnl When crosscompiling, assume rename is broken.
3926       vb_cv_func_rename_trailing_slash_bug=yes)
3927
3928       rm -rf conftest.d1 conftest.d2
3929   ])
3930   if test $vb_cv_func_rename_trailing_slash_bug = yes; then
3931     AC_LIBOBJ(rename)
3932     AC_DEFINE(RENAME_TRAILING_SLASH_BUG, 1,
3933 [Define if rename does not work for source paths with a trailing slash,
3934    like the one from SunOS 4.1.1_U1.])
3935   fi
3936 ])
3937
3938 #serial 1
3939
3940 # On some systems (e.g., HPUX-10.20, SunOS4.1.4, solaris2.5.1), mkstemp has the
3941 # silly limit that it can create no more than 26 files from a given template.
3942 # Other systems lack mkstemp altogether.  On either type of system, arrange
3943 # to use the replacement function.
3944 AC_DEFUN([UTILS_FUNC_MKSTEMP],
3945 [dnl
3946   AC_REPLACE_FUNCS(mkstemp)
3947   if test $ac_cv_func_mkstemp = no; then
3948     utils_cv_func_mkstemp_limitations=yes
3949   else
3950     AC_CACHE_CHECK([for mkstemp limitations],
3951       utils_cv_func_mkstemp_limitations,
3952       [
3953         AC_TRY_RUN([
3954 #         include <stdlib.h>
3955           int main ()
3956           {
3957             int i;
3958             for (i = 0; i < 30; i++)
3959               {
3960                 char template[] = "conftestXXXXXX";
3961                 int fd = mkstemp (template);
3962                 if (fd == -1)
3963                   exit (1);
3964                 close (fd);
3965               }
3966             exit (0);
3967           }
3968           ],
3969         utils_cv_func_mkstemp_limitations=no,
3970         utils_cv_func_mkstemp_limitations=yes,
3971         utils_cv_func_mkstemp_limitations=yes
3972         )
3973       ]
3974     )
3975   fi
3976
3977   if test $utils_cv_func_mkstemp_limitations = yes; then
3978     AC_LIBOBJ(mkstemp)
3979     AC_LIBOBJ(tempname)
3980     AC_DEFINE(mkstemp, rpl_mkstemp,
3981       [Define to rpl_mkstemp if the replacement function should be used.])
3982   fi
3983 ])
3984
3985 #serial 2
3986
3987 dnl From Jim Meyering.
3988 dnl
3989 dnl See if gettimeofday clobbers the static buffer that localtime uses
3990 dnl for it's return value.  The gettimeofday function from Mac OS X 10.0.4,
3991 dnl i.e. Darwin 1.3.7 has this problem.
3992 dnl
3993 dnl If it does, then arrange to use gettimeofday and localtime only via
3994 dnl the wrapper functions that work around the problem.
3995
3996 AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER],
3997 [
3998  AC_REQUIRE([AC_HEADER_TIME])
3999  AC_CHECK_HEADERS(string.h stdlib.h)
4000  AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
4001   jm_cv_func_gettimeofday_clobber,
4002   [AC_TRY_RUN([
4003 #include <stdio.h>
4004 #if HAVE_STRING_H
4005 # include <string.h>
4006 #endif
4007
4008 #if TIME_WITH_SYS_TIME
4009 # include <sys/time.h>
4010 # include <time.h>
4011 #else
4012 # if HAVE_SYS_TIME_H
4013 #  include <sys/time.h>
4014 # else
4015 #  include <time.h>
4016 # endif
4017 #endif
4018
4019 #if HAVE_STDLIB_H
4020 # include <stdlib.h>
4021 #endif
4022
4023 int
4024 main ()
4025 {
4026   time_t t = 0;
4027   struct tm *lt;
4028   struct tm saved_lt;
4029   struct timeval tv;
4030   lt = localtime (&t);
4031   saved_lt = *lt;
4032   gettimeofday (&tv, NULL);
4033   if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0)
4034     exit (1);
4035
4036   exit (0);
4037 }
4038           ],
4039          jm_cv_func_gettimeofday_clobber=no,
4040          jm_cv_func_gettimeofday_clobber=yes,
4041          dnl When crosscompiling, assume it is broken.
4042          jm_cv_func_gettimeofday_clobber=yes)
4043   ])
4044   if test $jm_cv_func_gettimeofday_clobber = yes; then
4045     # Caution: the following few lines should be the same
4046     # as those in gettimeofday.m4.
4047     AC_LIBOBJ(gettimeofday)
4048     AC_DEFINE(gmtime, rpl_gmtime,
4049       [Define to rpl_gmtime if the replacement function should be used.])
4050     AC_DEFINE(localtime, rpl_localtime,
4051       [Define to rpl_localtime if the replacement function should be used.])
4052
4053     AC_DEFINE(gettimeofday, rpl_gettimeofday,
4054       [Define to rpl_gettimeofday if the replacement function should be used.])
4055     AC_DEFINE(GETTIMEOFDAY_CLOBBERS_LOCALTIME_BUFFER, 1,
4056       [Define if gettimeofday clobbers localtime's static buffer.])
4057   fi
4058 ])
4059
4060 #serial 3
4061
4062 dnl From Jim Meyering
4063 dnl Replace the utime function on systems that need it.
4064
4065 dnl FIXME
4066
4067 AC_DEFUN([jm_FUNC_UTIME],
4068 [
4069   AC_CHECK_HEADERS(utime.h)
4070   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
4071   AC_REQUIRE([AC_FUNC_UTIME_NULL])
4072
4073   if test $ac_cv_func_utime_null = no; then
4074     jm_FUNC_UTIMES_NULL
4075     AC_REPLACE_FUNCS(utime)
4076   fi
4077 ])
4078
4079 #serial 4
4080
4081 dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL,
4082 dnl then do case-insensitive s/utime/utimes/.
4083
4084 AC_DEFUN([jm_FUNC_UTIMES_NULL],
4085 [AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
4086 [rm -f conftest.data; > conftest.data
4087 AC_TRY_RUN([
4088 /* In case stat has been defined to rpl_stat, undef it here.  */
4089 #undef stat
4090 #include <sys/types.h>
4091 #include <sys/stat.h>
4092 main() {
4093 struct stat s, t;
4094 exit(!(stat ("conftest.data", &s) == 0
4095        && utimes("conftest.data", (long *)0) == 0
4096        && stat("conftest.data", &t) == 0
4097        && t.st_mtime >= s.st_mtime
4098        && t.st_mtime - s.st_mtime < 120));
4099 }],
4100   ac_cv_func_utimes_null=yes,
4101   ac_cv_func_utimes_null=no,
4102   ac_cv_func_utimes_null=no)
4103 rm -f core core.* *.core])
4104
4105     if test $ac_cv_func_utimes_null = yes; then
4106       AC_DEFINE(HAVE_UTIMES_NULL, 1,
4107                 [Define if utimes accepts a null argument])
4108     fi
4109   ]
4110 )
4111
4112 # vasprintf.m4 serial 1
4113 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
4114 dnl This file is free software, distributed under the terms of the GNU
4115 dnl General Public License.  As a special exception to the GNU General
4116 dnl Public License, this file may be distributed as part of a program
4117 dnl that contains a configuration script generated by Autoconf, under
4118 dnl the same distribution terms as the rest of that program.
4119
4120 AC_DEFUN([gl_FUNC_VASPRINTF],
4121 [
4122   AC_REPLACE_FUNCS(vasprintf)
4123   if test $ac_cv_func_vasprintf = no; then
4124     AC_LIBOBJ(asprintf)
4125     gl_PREREQ_VASPRINTF
4126     gl_PREREQ_ASPRINTF
4127   fi
4128 ])
4129
4130 # Prerequisites of lib/vasprintf.c.
4131 AC_DEFUN([gl_PREREQ_VASPRINTF],
4132 [
4133 ])
4134
4135 # Prerequisites of lib/asprintf.c.
4136 AC_DEFUN([gl_PREREQ_ASPRINTF],
4137 [
4138 ])
4139
4140 # vasnprintf.m4 serial 1
4141 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
4142 dnl This file is free software, distributed under the terms of the GNU
4143 dnl General Public License.  As a special exception to the GNU General
4144 dnl Public License, this file may be distributed as part of a program
4145 dnl that contains a configuration script generated by Autoconf, under
4146 dnl the same distribution terms as the rest of that program.
4147
4148 AC_DEFUN([gl_FUNC_VASNPRINTF],
4149 [
4150   AC_REPLACE_FUNCS(vasnprintf)
4151   if test $ac_cv_func_vasnprintf = no; then
4152     AC_LIBOBJ(printf-args)
4153     AC_LIBOBJ(printf-parse)
4154     AC_LIBOBJ(asnprintf)
4155     gl_PREREQ_PRINTF_ARGS
4156     gl_PREREQ_PRINTF_PARSE
4157     gl_PREREQ_VASNPRINTF
4158     gl_PREREQ_ASNPRINTF
4159   fi
4160 ])
4161
4162 # Prequisites of lib/printf-args.h, lib/printf-args.c.
4163 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
4164 [
4165   AC_REQUIRE([bh_C_SIGNED])
4166   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
4167   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
4168   AC_REQUIRE([gt_TYPE_WCHAR_T])
4169   AC_REQUIRE([gt_TYPE_WINT_T])
4170 ])
4171
4172 # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
4173 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
4174 [
4175   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
4176   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
4177   AC_REQUIRE([gt_TYPE_WCHAR_T])
4178   AC_REQUIRE([gt_TYPE_WINT_T])
4179   AC_REQUIRE([AC_TYPE_SIZE_T])
4180   AC_CHECK_TYPES(ptrdiff_t)
4181   AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
4182 ])
4183
4184 # Prerequisites of lib/vasnprintf.c.
4185 AC_DEFUN([gl_PREREQ_VASNPRINTF],
4186 [
4187   AC_REQUIRE([AC_FUNC_ALLOCA])
4188   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
4189   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
4190   AC_REQUIRE([gt_TYPE_WCHAR_T])
4191   AC_REQUIRE([gt_TYPE_WINT_T])
4192   AC_CHECK_FUNCS(snprintf)
4193 ])
4194
4195 # Prerequisites of lib/asnprintf.c.
4196 AC_DEFUN([gl_PREREQ_ASNPRINTF],
4197 [
4198 ])
4199
4200 # signed.m4 serial 1 (gettext-0.10.40)
4201 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
4202 dnl This file is free software, distributed under the terms of the GNU
4203 dnl General Public License.  As a special exception to the GNU General
4204 dnl Public License, this file may be distributed as part of a program
4205 dnl that contains a configuration script generated by Autoconf, under
4206 dnl the same distribution terms as the rest of that program.
4207
4208 dnl From Bruno Haible.
4209
4210 AC_DEFUN([bh_C_SIGNED],
4211 [
4212   AC_CACHE_CHECK([for signed], bh_cv_c_signed,
4213    [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)])
4214   if test $bh_cv_c_signed = no; then
4215     AC_DEFINE(signed, ,
4216               [Define to empty if the C compiler doesn't support this keyword.])
4217   fi
4218 ])
4219
4220 # longdouble.m4 serial 1 (gettext-0.12)
4221 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
4222 dnl This file is free software, distributed under the terms of the GNU
4223 dnl General Public License.  As a special exception to the GNU General
4224 dnl Public License, this file may be distributed as part of a program
4225 dnl that contains a configuration script generated by Autoconf, under
4226 dnl the same distribution terms as the rest of that program.
4227
4228 dnl From Bruno Haible.
4229 dnl Test whether the compiler supports the 'long double' type.
4230 dnl Prerequisite: AC_PROG_CC
4231
4232 AC_DEFUN([gt_TYPE_LONGDOUBLE],
4233 [
4234   AC_CACHE_CHECK([for long double], gt_cv_c_long_double,
4235     [if test "$GCC" = yes; then
4236        gt_cv_c_long_double=yes
4237      else
4238        AC_TRY_COMPILE([
4239          /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
4240          long double foo = 0.0;
4241          /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
4242          int array [2*(sizeof(long double) >= sizeof(double)) - 1];
4243          ], ,
4244          gt_cv_c_long_double=yes, gt_cv_c_long_double=no)
4245      fi])
4246   if test $gt_cv_c_long_double = yes; then
4247     AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.])
4248   fi
4249 ])
4250
4251 # wchar_t.m4 serial 1 (gettext-0.12)
4252 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
4253 dnl This file is free software, distributed under the terms of the GNU
4254 dnl General Public License.  As a special exception to the GNU General
4255 dnl Public License, this file may be distributed as part of a program
4256 dnl that contains a configuration script generated by Autoconf, under
4257 dnl the same distribution terms as the rest of that program.
4258
4259 dnl From Bruno Haible.
4260 dnl Test whether <stddef.h> has the 'wchar_t' type.
4261 dnl Prerequisite: AC_PROG_CC
4262
4263 AC_DEFUN([gt_TYPE_WCHAR_T],
4264 [
4265   AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t,
4266     [AC_TRY_COMPILE([#include <stddef.h>
4267        wchar_t foo = (wchar_t)'\0';], ,
4268        gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)])
4269   if test $gt_cv_c_wchar_t = yes; then
4270     AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.])
4271   fi
4272 ])
4273
4274 # wint_t.m4 serial 1 (gettext-0.12)
4275 dnl Copyright (C) 2003 Free Software Foundation, Inc.
4276 dnl This file is free software, distributed under the terms of the GNU
4277 dnl General Public License.  As a special exception to the GNU General
4278 dnl Public License, this file may be distributed as part of a program
4279 dnl that contains a configuration script generated by Autoconf, under
4280 dnl the same distribution terms as the rest of that program.
4281
4282 dnl From Bruno Haible.
4283 dnl Test whether <wchar.h> has the 'wint_t' type.
4284 dnl Prerequisite: AC_PROG_CC
4285
4286 AC_DEFUN([gt_TYPE_WINT_T],
4287 [
4288   AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
4289     [AC_TRY_COMPILE([#include <wchar.h>
4290        wint_t foo = (wchar_t)'\0';], ,
4291        gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
4292   if test $gt_cv_c_wint_t = yes; then
4293     AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
4294   fi
4295 ])
4296
4297 #serial 5
4298
4299 dnl See if there's a working, system-supplied version of the getline function.
4300 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
4301 dnl have a function by that name in -linet that doesn't have anything
4302 dnl to do with the function we need.
4303 AC_DEFUN([AM_FUNC_GETLINE],
4304 [dnl
4305   am_getline_needs_run_time_check=no
4306   AC_CHECK_FUNC(getline,
4307                 dnl Found it in some library.  Verify that it works.
4308                 am_getline_needs_run_time_check=yes,
4309                 am_cv_func_working_getline=no)
4310   if test $am_getline_needs_run_time_check = yes; then
4311     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
4312     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
4313     AC_TRY_RUN([
4314 #    include <stdio.h>
4315 #    include <sys/types.h>
4316 #    include <string.h>
4317     int main ()
4318     { /* Based on a test program from Karl Heuer.  */
4319       char *line = NULL;
4320       size_t siz = 0;
4321       int len;
4322       FILE *in = fopen ("./conftest.data", "r");
4323       if (!in)
4324         return 1;
4325       len = getline (&line, &siz, in);
4326       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
4327     }
4328     ], am_cv_func_working_getline=yes dnl The library version works.
4329     , am_cv_func_working_getline=no dnl The library version does NOT work.
4330     , am_cv_func_working_getline=no dnl We're cross compiling.
4331     )])
4332   fi
4333
4334   if test $am_cv_func_working_getline = no; then
4335     AC_LIBOBJ(getline)
4336   fi
4337 ])
4338
4339 #serial 1
4340 # Determine approximately how many files may be open simultaneously
4341 # in one process.  This is approximate, since while running this test,
4342 # the configure script already has a few files open.
4343 # From Jim Meyering
4344
4345 AC_DEFUN([UTILS_SYS_OPEN_MAX],
4346 [
4347   AC_CACHE_CHECK([determine how many files may be open simultaneously],
4348                  utils_cv_sys_open_max,
4349   [
4350   AC_RUN_IFELSE([AC_LANG_SOURCE([[
4351 #include <stdio.h>
4352 #include <stdlib.h>
4353 #include <unistd.h>
4354     int
4355     main ()
4356     {
4357       FILE *result = fopen ("conftest.omax", "w");
4358       int i = 1;
4359       /* Impose an arbitrary limit, in case some system has no
4360          effective limit on the number of simultaneously open files.  */
4361       while (i < 30000)
4362         {
4363           FILE *s = fopen ("conftest.op", "w");
4364           if (!s)
4365             break;
4366           ++i;
4367         }
4368       fprintf (result, "%d\n", i);
4369       exit (fclose (result) == EOF);
4370     }
4371   ]])],
4372        [utils_cv_sys_open_max=`cat conftest.omax`],
4373        [utils_cv_sys_open_max='internal error in open-max.m4'],
4374        [utils_cv_sys_open_max='cross compiling run-test in open-max.m4'])])
4375
4376   AC_DEFINE_UNQUOTED([UTILS_OPEN_MAX],
4377     $utils_cv_sys_open_max,
4378     [the maximum number of simultaneously open files per process])
4379 ])
4380
4381 #serial 4
4382 # Check whether getcwd has the bug that it succeeds for a working directory
4383 # longer than PATH_MAX, yet returns a truncated directory name.
4384 # If so, arrange to compile the wrapper function.
4385
4386 # This is necessary for at least GNU libc on linux-2.4.19 and 2.4.20.
4387 # I've heard that this is due to a Linux kernel bug, and that it has
4388 # been fixed between 2.4.21-pre3 and 2.4.21-pre4.  */
4389
4390 # From Jim Meyering
4391
4392 AC_DEFUN([GL_FUNC_GETCWD_PATH_MAX],
4393 [
4394   AC_CHECK_DECLS([getcwd])
4395   AC_CACHE_CHECK([whether getcwd properly handles paths longer than PATH_MAX],
4396                  gl_cv_func_getcwd_vs_path_max,
4397   [
4398   # Arrange for deletion of the temporary directory this test creates.
4399   ac_clean_files="$ac_clean_files confdir3"
4400   AC_RUN_IFELSE([AC_LANG_SOURCE([[
4401 #include <stdlib.h>
4402 #include <unistd.h>
4403 #include <string.h>
4404 #include <limits.h>
4405 #include <sys/stat.h>
4406 #include <sys/types.h>
4407
4408 /* Don't get link errors because mkdir is redefined to rpl_mkdir.  */
4409 #undef mkdir
4410
4411 #ifndef CHAR_BIT
4412 # define CHAR_BIT 8
4413 #endif
4414
4415 /* The extra casts work around common compiler bugs.  */
4416 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
4417 /* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
4418    It is necessary at least when t == time_t.  */
4419 #define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
4420                               ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
4421 #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
4422
4423 #ifndef INT_MAX
4424 # define INT_MAX TYPE_MAXIMUM (int)
4425 #endif
4426
4427 /* The length of this name must be 8.  */
4428 #define DIR_NAME "confdir3"
4429
4430 int
4431 main ()
4432 {
4433 #ifndef PATH_MAX
4434   /* The Hurd doesn't define this, so getcwd can't exhibit the bug --
4435      at least not on a local file system.  And if we were to start worrying
4436      about remote file systems, we'd have to enable the wrapper function
4437      all of the time, just to be safe.  That's not worth the cost.  */
4438   exit (0);
4439 #elif INT_MAX - 9 <= PATH_MAX
4440   /* The '9', above, comes from strlen (DIR_NAME) + 1.  */
4441   /* FIXME: Assuming there's a system for which this is true,
4442      this should be done in a compile test.  */
4443   exit (0);
4444 #else
4445   char buf[PATH_MAX + 20];
4446   char *cwd = getcwd (buf, PATH_MAX);
4447   size_t cwd_len;
4448   int fail = 0;
4449   size_t n_chdirs = 0;
4450
4451   if (cwd == NULL)
4452     exit (1);
4453
4454   cwd_len = strlen (cwd);
4455
4456   while (1)
4457     {
4458       char *c;
4459       size_t len;
4460
4461       cwd_len += 1 + strlen (DIR_NAME);
4462       /* If mkdir or chdir fails, be pessimistic and consider that
4463          as a failure, too.  */
4464       if (mkdir (DIR_NAME, 0700) < 0 || chdir (DIR_NAME) < 0)
4465         {
4466           fail = 1;
4467           break;
4468         }
4469       if ((c = getcwd (buf, PATH_MAX)) == NULL)
4470         {
4471           /* This allows any failure to indicate there is no bug.
4472              FIXME: check errno?  */
4473           break;
4474         }
4475       if ((len = strlen (c)) != cwd_len)
4476         {
4477           fail = 1;
4478           break;
4479         }
4480       ++n_chdirs;
4481       if (PATH_MAX < len)
4482         break;
4483     }
4484
4485   /* Leaving behind such a deep directory is not polite.
4486      So clean up here, right away, even though the driving
4487      shell script would also clean up.  */
4488   {
4489     size_t i;
4490
4491     /* Unlink first, in case the chdir failed.  */
4492     unlink (DIR_NAME);
4493     for (i = 0; i <= n_chdirs; i++)
4494       {
4495         if (chdir ("..") < 0)
4496           break;
4497         rmdir (DIR_NAME);
4498       }
4499   }
4500
4501   exit (fail);
4502 #endif
4503 }
4504   ]])],
4505        [gl_cv_func_getcwd_vs_path_max=yes],
4506        [gl_cv_func_getcwd_vs_path_max=no],
4507        [gl_cv_func_getcwd_vs_path_max=no])])
4508
4509   if test $gl_cv_func_getcwd_vs_path_max = yes; then
4510     AC_LIBOBJ(getcwd)
4511     AC_DEFINE(getcwd, rpl_getcwd,
4512       [Define to rpl_getcwd if the wrapper function should be used.])
4513   fi
4514 ])
4515
4516 #serial 5
4517
4518 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
4519 dnl to test whether a NULL return value really means there are no more files
4520 dnl in the directory.
4521 dnl
4522 dnl And the rm from coreutils-5.0 exposes a similar problem when there
4523 dnl are 338 or more files in a directory on a Darwin-6.5 system
4524 dnl
4525 dnl Detect the problem by creating a directory containing 500 files (254 not
4526 dnl counting . and .. is the minimum for SunOS, 338 for Darwin) and see
4527 dnl if a loop doing `readdir; unlink' removes all of them.
4528 dnl
4529 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
4530
4531 dnl Written by Jim Meyering.
4532
4533 AC_DEFUN([GL_FUNC_READDIR],
4534 [dnl
4535 AC_REQUIRE([AC_HEADER_DIRENT])
4536 AC_CHECK_HEADERS(string.h)
4537 AC_CACHE_CHECK([for working readdir], gl_cv_func_working_readdir,
4538   [dnl
4539   # Arrange for deletion of the temporary directory this test creates, in
4540   # case the test itself fails to delete everything -- as happens on Sunos.
4541   ac_clean_files="$ac_clean_files conf-dir"
4542
4543   AC_TRY_RUN(
4544 [#   include <stdio.h>
4545 #   include <sys/types.h>
4546 #   if HAVE_STRING_H
4547 #    include <string.h>
4548 #   endif
4549
4550 #   ifdef HAVE_DIRENT_H
4551 #    include <dirent.h>
4552 #    define NLENGTH(direct) (strlen((direct)->d_name))
4553 #   else /* not HAVE_DIRENT_H */
4554 #    define dirent direct
4555 #    define NLENGTH(direct) ((direct)->d_namlen)
4556 #    ifdef HAVE_SYS_NDIR_H
4557 #     include <sys/ndir.h>
4558 #    endif /* HAVE_SYS_NDIR_H */
4559 #    ifdef HAVE_SYS_DIR_H
4560 #     include <sys/dir.h>
4561 #    endif /* HAVE_SYS_DIR_H */
4562 #    ifdef HAVE_NDIR_H
4563 #     include <ndir.h>
4564 #    endif /* HAVE_NDIR_H */
4565 #   endif /* HAVE_DIRENT_H */
4566
4567 #   define DOT_OR_DOTDOT(Basename) \
4568      (Basename[0] == '.' && (Basename[1] == '\0' \
4569                              || (Basename[1] == '.' && Basename[2] == '\0')))
4570
4571 /* Don't try to use replacement mkdir; it wouldn't resolve at link time.  */
4572 #   undef mkdir
4573
4574     static void
4575     create_N_file_dir (const char *dir, size_t n_files)
4576     {
4577       unsigned int i;
4578
4579       if (mkdir (dir, 0700))
4580         abort ();
4581       if (chdir (dir))
4582         abort ();
4583
4584       for (i = 0; i < n_files; i++)
4585         {
4586           char file_name[4];
4587           FILE *out;
4588
4589           sprintf (file_name, "%03d", i);
4590           out = fopen (file_name, "w");
4591           if (!out)
4592             abort ();
4593           if (fclose (out) == EOF)
4594             abort ();
4595         }
4596
4597       if (chdir (".."))
4598         abort ();
4599     }
4600
4601     static void
4602     remove_dir (const char *dir)
4603     {
4604       DIR *dirp;
4605
4606       if (chdir (dir))
4607         abort ();
4608
4609       dirp = opendir (".");
4610       if (dirp == NULL)
4611         abort ();
4612
4613       while (1)
4614         {
4615           struct dirent *dp = readdir (dirp);
4616           if (dp == NULL)
4617             break;
4618
4619           if (DOT_OR_DOTDOT (dp->d_name))
4620             continue;
4621
4622           if (unlink (dp->d_name))
4623             abort ();
4624         }
4625       closedir (dirp);
4626
4627       if (chdir (".."))
4628         abort ();
4629
4630       if (rmdir (dir))
4631         exit (1);
4632     }
4633
4634     int
4635     main ()
4636     {
4637       const char *dir = "conf-dir";
4638       create_N_file_dir (dir, 500);
4639       remove_dir (dir);
4640       exit (0);
4641     }],
4642   gl_cv_func_working_readdir=yes,
4643   gl_cv_func_working_readdir=no,
4644   gl_cv_func_working_readdir=no)])
4645
4646   if test $gl_cv_func_working_readdir = yes; then
4647     AC_DEFINE(HAVE_WORKING_READDIR, 1,
4648 [Define if readdir is found to work properly in some unusual cases. ])
4649   fi
4650 ])
4651
4652 # codeset.m4 serial AM1 (gettext-0.10.40)
4653 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
4654 dnl This file is free software, distributed under the terms of the GNU
4655 dnl General Public License.  As a special exception to the GNU General
4656 dnl Public License, this file may be distributed as part of a program
4657 dnl that contains a configuration script generated by Autoconf, under
4658 dnl the same distribution terms as the rest of that program.
4659
4660 dnl From Bruno Haible.
4661
4662 AC_DEFUN([AM_LANGINFO_CODESET],
4663 [
4664   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
4665     [AC_TRY_LINK([#include <langinfo.h>],
4666       [char* cs = nl_langinfo(CODESET);],
4667       am_cv_langinfo_codeset=yes,
4668       am_cv_langinfo_codeset=no)
4669     ])
4670   if test $am_cv_langinfo_codeset = yes; then
4671     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
4672       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
4673   fi
4674 ])
4675
4676 # glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
4677 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
4678 dnl This file is free software, distributed under the terms of the GNU
4679 dnl General Public License.  As a special exception to the GNU General
4680 dnl Public License, this file may be distributed as part of a program
4681 dnl that contains a configuration script generated by Autoconf, under
4682 dnl the same distribution terms as the rest of that program.
4683
4684 # Test for the GNU C Library, version 2.1 or newer.
4685 # From Bruno Haible.
4686
4687 AC_DEFUN([jm_GLIBC21],
4688   [
4689     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
4690       ac_cv_gnu_library_2_1,
4691       [AC_EGREP_CPP([Lucky GNU user],
4692         [
4693 #include <features.h>
4694 #ifdef __GNU_LIBRARY__
4695  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
4696   Lucky GNU user
4697  #endif
4698 #endif
4699         ],
4700         ac_cv_gnu_library_2_1=yes,
4701         ac_cv_gnu_library_2_1=no)
4702       ]
4703     )
4704     AC_SUBST(GLIBC21)
4705     GLIBC21="$ac_cv_gnu_library_2_1"
4706   ]
4707 )
4708
4709 # iconv.m4 serial AM4 (gettext-0.11.3)
4710 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
4711 dnl This file is free software, distributed under the terms of the GNU
4712 dnl General Public License.  As a special exception to the GNU General
4713 dnl Public License, this file may be distributed as part of a program
4714 dnl that contains a configuration script generated by Autoconf, under
4715 dnl the same distribution terms as the rest of that program.
4716
4717 dnl From Bruno Haible.
4718
4719 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
4720 [
4721   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
4722   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
4723   AC_REQUIRE([AC_LIB_RPATH])
4724
4725   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
4726   dnl accordingly.
4727   AC_LIB_LINKFLAGS_BODY([iconv])
4728 ])
4729
4730 AC_DEFUN([AM_ICONV_LINK],
4731 [
4732   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
4733   dnl those with the standalone portable GNU libiconv installed).
4734
4735   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
4736   dnl accordingly.
4737   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
4738
4739   dnl Add $INCICONV to CPPFLAGS before performing the following checks,
4740   dnl because if the user has installed libiconv and not disabled its use
4741   dnl via --without-libiconv-prefix, he wants to use it. The first
4742   dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
4743   am_save_CPPFLAGS="$CPPFLAGS"
4744   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
4745
4746   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
4747     am_cv_func_iconv="no, consider installing GNU libiconv"
4748     am_cv_lib_iconv=no
4749     AC_TRY_LINK([#include <stdlib.h>
4750 #include <iconv.h>],
4751       [iconv_t cd = iconv_open("","");
4752        iconv(cd,NULL,NULL,NULL,NULL);
4753        iconv_close(cd);],
4754       am_cv_func_iconv=yes)
4755     if test "$am_cv_func_iconv" != yes; then
4756       am_save_LIBS="$LIBS"
4757       LIBS="$LIBS $LIBICONV"
4758       AC_TRY_LINK([#include <stdlib.h>
4759 #include <iconv.h>],
4760         [iconv_t cd = iconv_open("","");
4761          iconv(cd,NULL,NULL,NULL,NULL);
4762          iconv_close(cd);],
4763         am_cv_lib_iconv=yes
4764         am_cv_func_iconv=yes)
4765       LIBS="$am_save_LIBS"
4766     fi
4767   ])
4768   if test "$am_cv_func_iconv" = yes; then
4769     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
4770   fi
4771   if test "$am_cv_lib_iconv" = yes; then
4772     AC_MSG_CHECKING([how to link with libiconv])
4773     AC_MSG_RESULT([$LIBICONV])
4774   else
4775     dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
4776     dnl either.
4777     CPPFLAGS="$am_save_CPPFLAGS"
4778     LIBICONV=
4779     LTLIBICONV=
4780   fi
4781   AC_SUBST(LIBICONV)
4782   AC_SUBST(LTLIBICONV)
4783 ])
4784
4785 AC_DEFUN([AM_ICONV],
4786 [
4787   AM_ICONV_LINK
4788   if test "$am_cv_func_iconv" = yes; then
4789     AC_MSG_CHECKING([for iconv declaration])
4790     AC_CACHE_VAL(am_cv_proto_iconv, [
4791       AC_TRY_COMPILE([
4792 #include <stdlib.h>
4793 #include <iconv.h>
4794 extern
4795 #ifdef __cplusplus
4796 "C"
4797 #endif
4798 #if defined(__STDC__) || defined(__cplusplus)
4799 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
4800 #else
4801 size_t iconv();
4802 #endif
4803 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
4804       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
4805     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
4806     AC_MSG_RESULT([$]{ac_t:-
4807          }[$]am_cv_proto_iconv)
4808     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
4809       [Define as const if the declaration of iconv() needs const.])
4810   fi
4811 ])
4812
4813 # lib-prefix.m4 serial 1 (gettext-0.11)
4814 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
4815 dnl This file is free software, distributed under the terms of the GNU
4816 dnl General Public License.  As a special exception to the GNU General
4817 dnl Public License, this file may be distributed as part of a program
4818 dnl that contains a configuration script generated by Autoconf, under
4819 dnl the same distribution terms as the rest of that program.
4820
4821 dnl From Bruno Haible.
4822
4823 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
4824 dnl to access previously installed libraries. The basic assumption is that
4825 dnl a user will want packages to use other packages he previously installed
4826 dnl with the same --prefix option.
4827 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
4828 dnl libraries, but is otherwise very convenient.
4829 AC_DEFUN([AC_LIB_PREFIX],
4830 [
4831   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
4832   AC_REQUIRE([AC_PROG_CC])
4833   AC_REQUIRE([AC_CANONICAL_HOST])
4834   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
4835   dnl By default, look in $includedir and $libdir.
4836   use_additional=yes
4837   AC_LIB_WITH_FINAL_PREFIX([
4838     eval additional_includedir=\"$includedir\"
4839     eval additional_libdir=\"$libdir\"
4840   ])
4841   AC_ARG_WITH([lib-prefix],
4842 [  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
4843   --without-lib-prefix    don't search for libraries in includedir and libdir],
4844 [
4845     if test "X$withval" = "Xno"; then
4846       use_additional=no
4847     else
4848       if test "X$withval" = "X"; then
4849         AC_LIB_WITH_FINAL_PREFIX([
4850           eval additional_includedir=\"$includedir\"
4851           eval additional_libdir=\"$libdir\"
4852         ])
4853       else
4854         additional_includedir="$withval/include"
4855         additional_libdir="$withval/lib"
4856       fi
4857     fi
4858 ])
4859   if test $use_additional = yes; then
4860     dnl Potentially add $additional_includedir to $CPPFLAGS.
4861     dnl But don't add it
4862     dnl   1. if it's the standard /usr/include,
4863     dnl   2. if it's already present in $CPPFLAGS,
4864     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
4865     dnl   4. if it doesn't exist as a directory.
4866     if test "X$additional_includedir" != "X/usr/include"; then
4867       haveit=
4868       for x in $CPPFLAGS; do
4869         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
4870         if test "X$x" = "X-I$additional_includedir"; then
4871           haveit=yes
4872           break
4873         fi
4874       done
4875       if test -z "$haveit"; then
4876         if test "X$additional_includedir" = "X/usr/local/include"; then
4877           if test -n "$GCC"; then
4878             case $host_os in
4879               linux*) haveit=yes;;
4880             esac
4881           fi
4882         fi
4883         if test -z "$haveit"; then
4884           if test -d "$additional_includedir"; then
4885             dnl Really add $additional_includedir to $CPPFLAGS.
4886             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
4887           fi
4888         fi
4889       fi
4890     fi
4891     dnl Potentially add $additional_libdir to $LDFLAGS.
4892     dnl But don't add it
4893     dnl   1. if it's the standard /usr/lib,
4894     dnl   2. if it's already present in $LDFLAGS,
4895     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
4896     dnl   4. if it doesn't exist as a directory.
4897     if test "X$additional_libdir" != "X/usr/lib"; then
4898       haveit=
4899       for x in $LDFLAGS; do
4900         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
4901         if test "X$x" = "X-L$additional_libdir"; then
4902           haveit=yes
4903           break
4904         fi
4905       done
4906       if test -z "$haveit"; then
4907         if test "X$additional_libdir" = "X/usr/local/lib"; then
4908           if test -n "$GCC"; then
4909             case $host_os in
4910               linux*) haveit=yes;;
4911             esac
4912           fi
4913         fi
4914         if test -z "$haveit"; then
4915           if test -d "$additional_libdir"; then
4916             dnl Really add $additional_libdir to $LDFLAGS.
4917             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
4918           fi
4919         fi
4920       fi
4921     fi
4922   fi
4923 ])
4924
4925 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
4926 dnl acl_final_exec_prefix, containing the values to which $prefix and
4927 dnl $exec_prefix will expand at the end of the configure script.
4928 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
4929 [
4930   dnl Unfortunately, prefix and exec_prefix get only finally determined
4931   dnl at the end of configure.
4932   if test "X$prefix" = "XNONE"; then
4933     acl_final_prefix="$ac_default_prefix"
4934   else
4935     acl_final_prefix="$prefix"
4936   fi
4937   if test "X$exec_prefix" = "XNONE"; then
4938     acl_final_exec_prefix='${prefix}'
4939   else
4940     acl_final_exec_prefix="$exec_prefix"
4941   fi
4942   acl_save_prefix="$prefix"
4943   prefix="$acl_final_prefix"
4944   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
4945   prefix="$acl_save_prefix"
4946 ])
4947
4948 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
4949 dnl variables prefix and exec_prefix bound to the values they will have
4950 dnl at the end of the configure script.
4951 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
4952 [
4953   acl_save_prefix="$prefix"
4954   prefix="$acl_final_prefix"
4955   acl_save_exec_prefix="$exec_prefix"
4956   exec_prefix="$acl_final_exec_prefix"
4957   $1
4958   exec_prefix="$acl_save_exec_prefix"
4959   prefix="$acl_save_prefix"
4960 ])
4961
4962 # lib-link.m4 serial 3 (gettext-0.11.3)
4963 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
4964 dnl This file is free software, distributed under the terms of the GNU
4965 dnl General Public License.  As a special exception to the GNU General
4966 dnl Public License, this file may be distributed as part of a program
4967 dnl that contains a configuration script generated by Autoconf, under
4968 dnl the same distribution terms as the rest of that program.
4969
4970 dnl From Bruno Haible.
4971
4972 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
4973 dnl the libraries corresponding to explicit and implicit dependencies.
4974 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
4975 dnl augments the CPPFLAGS variable.
4976 AC_DEFUN([AC_LIB_LINKFLAGS],
4977 [
4978   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
4979   AC_REQUIRE([AC_LIB_RPATH])
4980   define([Name],[translit([$1],[./-], [___])])
4981   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
4982                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
4983   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
4984     AC_LIB_LINKFLAGS_BODY([$1], [$2])
4985     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
4986     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
4987     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
4988   ])
4989   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
4990   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
4991   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
4992   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
4993   AC_SUBST([LIB]NAME)
4994   AC_SUBST([LTLIB]NAME)
4995   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
4996   dnl results of this search when this library appears as a dependency.
4997   HAVE_LIB[]NAME=yes
4998   undefine([Name])
4999   undefine([NAME])
5000 ])
5001
5002 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
5003 dnl searches for libname and the libraries corresponding to explicit and
5004 dnl implicit dependencies, together with the specified include files and
5005 dnl the ability to compile and link the specified testcode. If found, it
5006 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
5007 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
5008 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
5009 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
5010 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
5011 [
5012   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
5013   AC_REQUIRE([AC_LIB_RPATH])
5014   define([Name],[translit([$1],[./-], [___])])
5015   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
5016                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
5017
5018   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
5019   dnl accordingly.
5020   AC_LIB_LINKFLAGS_BODY([$1], [$2])
5021
5022   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
5023   dnl because if the user has installed lib[]Name and not disabled its use
5024   dnl via --without-lib[]Name-prefix, he wants to use it.
5025   ac_save_CPPFLAGS="$CPPFLAGS"
5026   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
5027
5028   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
5029     ac_save_LIBS="$LIBS"
5030     LIBS="$LIBS $LIB[]NAME"
5031     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
5032     LIBS="$ac_save_LIBS"
5033   ])
5034   if test "$ac_cv_lib[]Name" = yes; then
5035     HAVE_LIB[]NAME=yes
5036     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
5037     AC_MSG_CHECKING([how to link with lib[]$1])
5038     AC_MSG_RESULT([$LIB[]NAME])
5039   else
5040     HAVE_LIB[]NAME=no
5041     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
5042     dnl $INC[]NAME either.
5043     CPPFLAGS="$ac_save_CPPFLAGS"
5044     LIB[]NAME=
5045     LTLIB[]NAME=
5046   fi
5047   AC_SUBST([HAVE_LIB]NAME)
5048   AC_SUBST([LIB]NAME)
5049   AC_SUBST([LTLIB]NAME)
5050   undefine([Name])
5051   undefine([NAME])
5052 ])
5053
5054 dnl Determine the platform dependent parameters needed to use rpath:
5055 dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
5056 dnl hardcode_direct, hardcode_minus_L,
5057 dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec.
5058 AC_DEFUN([AC_LIB_RPATH],
5059 [
5060   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
5061   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
5062   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
5063   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
5064   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
5065     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
5066     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
5067     . ./conftest.sh
5068     rm -f ./conftest.sh
5069     acl_cv_rpath=done
5070   ])
5071   wl="$acl_cv_wl"
5072   libext="$acl_cv_libext"
5073   shlibext="$acl_cv_shlibext"
5074   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
5075   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
5076   hardcode_direct="$acl_cv_hardcode_direct"
5077   hardcode_minus_L="$acl_cv_hardcode_minus_L"
5078   sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec"
5079   sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec"
5080   dnl Determine whether the user wants rpath handling at all.
5081   AC_ARG_ENABLE(rpath,
5082     [  --disable-rpath         do not hardcode runtime library paths],
5083     :, enable_rpath=yes)
5084 ])
5085
5086 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
5087 dnl the libraries corresponding to explicit and implicit dependencies.
5088 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
5089 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
5090 [
5091   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
5092                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
5093   dnl By default, look in $includedir and $libdir.
5094   use_additional=yes
5095   AC_LIB_WITH_FINAL_PREFIX([
5096     eval additional_includedir=\"$includedir\"
5097     eval additional_libdir=\"$libdir\"
5098   ])
5099   AC_ARG_WITH([lib$1-prefix],
5100 [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
5101   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
5102 [
5103     if test "X$withval" = "Xno"; then
5104       use_additional=no
5105     else
5106       if test "X$withval" = "X"; then
5107         AC_LIB_WITH_FINAL_PREFIX([
5108           eval additional_includedir=\"$includedir\"
5109           eval additional_libdir=\"$libdir\"
5110         ])
5111       else
5112         additional_includedir="$withval/include"
5113         additional_libdir="$withval/lib"
5114       fi
5115     fi
5116 ])
5117   dnl Search the library and its dependencies in $additional_libdir and
5118   dnl $LDFLAGS. Using breadth-first-seach.
5119   LIB[]NAME=
5120   LTLIB[]NAME=
5121   INC[]NAME=
5122   rpathdirs=
5123   ltrpathdirs=
5124   names_already_handled=
5125   names_next_round='$1 $2'
5126   while test -n "$names_next_round"; do
5127     names_this_round="$names_next_round"
5128     names_next_round=
5129     for name in $names_this_round; do
5130       already_handled=
5131       for n in $names_already_handled; do
5132         if test "$n" = "$name"; then
5133           already_handled=yes
5134           break
5135         fi
5136       done
5137       if test -z "$already_handled"; then
5138         names_already_handled="$names_already_handled $name"
5139         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
5140         dnl or AC_LIB_HAVE_LINKFLAGS call.
5141         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
5142         eval value=\"\$HAVE_LIB$uppername\"
5143         if test -n "$value"; then
5144           if test "$value" = yes; then
5145             eval value=\"\$LIB$uppername\"
5146             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
5147             eval value=\"\$LTLIB$uppername\"
5148             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
5149           else
5150             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
5151             dnl that this library doesn't exist. So just drop it.
5152             :
5153           fi
5154         else
5155           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
5156           dnl and the already constructed $LIBNAME/$LTLIBNAME.
5157           found_dir=
5158           found_la=
5159           found_so=
5160           found_a=
5161           if test $use_additional = yes; then
5162             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
5163               found_dir="$additional_libdir"
5164               found_so="$additional_libdir/lib$name.$shlibext"
5165               if test -f "$additional_libdir/lib$name.la"; then
5166                 found_la="$additional_libdir/lib$name.la"
5167               fi
5168             else
5169               if test -f "$additional_libdir/lib$name.$libext"; then
5170                 found_dir="$additional_libdir"
5171                 found_a="$additional_libdir/lib$name.$libext"
5172                 if test -f "$additional_libdir/lib$name.la"; then
5173                   found_la="$additional_libdir/lib$name.la"
5174                 fi
5175               fi
5176             fi
5177           fi
5178           if test "X$found_dir" = "X"; then
5179             for x in $LDFLAGS $LTLIB[]NAME; do
5180               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5181               case "$x" in
5182                 -L*)
5183                   dir=`echo "X$x" | sed -e 's/^X-L//'`
5184                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
5185                     found_dir="$dir"
5186                     found_so="$dir/lib$name.$shlibext"
5187                     if test -f "$dir/lib$name.la"; then
5188                       found_la="$dir/lib$name.la"
5189                     fi
5190                   else
5191                     if test -f "$dir/lib$name.$libext"; then
5192                       found_dir="$dir"
5193                       found_a="$dir/lib$name.$libext"
5194                       if test -f "$dir/lib$name.la"; then
5195                         found_la="$dir/lib$name.la"
5196                       fi
5197                     fi
5198                   fi
5199                   ;;
5200               esac
5201               if test "X$found_dir" != "X"; then
5202                 break
5203               fi
5204             done
5205           fi
5206           if test "X$found_dir" != "X"; then
5207             dnl Found the library.
5208             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
5209             if test "X$found_so" != "X"; then
5210               dnl Linking with a shared library. We attempt to hardcode its
5211               dnl directory into the executable's runpath, unless it's the
5212               dnl standard /usr/lib.
5213               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
5214                 dnl No hardcoding is needed.
5215                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
5216               else
5217                 dnl Use an explicit option to hardcode DIR into the resulting
5218                 dnl binary.
5219                 dnl Potentially add DIR to ltrpathdirs.
5220                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
5221                 haveit=
5222                 for x in $ltrpathdirs; do
5223                   if test "X$x" = "X$found_dir"; then
5224                     haveit=yes
5225                     break
5226                   fi
5227                 done
5228                 if test -z "$haveit"; then
5229                   ltrpathdirs="$ltrpathdirs $found_dir"
5230                 fi
5231                 dnl The hardcoding into $LIBNAME is system dependent.
5232                 if test "$hardcode_direct" = yes; then
5233                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
5234                   dnl resulting binary.
5235                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
5236                 else
5237                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
5238                     dnl Use an explicit option to hardcode DIR into the resulting
5239                     dnl binary.
5240                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
5241                     dnl Potentially add DIR to rpathdirs.
5242                     dnl The rpathdirs will be appended to $LIBNAME at the end.
5243                     haveit=
5244                     for x in $rpathdirs; do
5245                       if test "X$x" = "X$found_dir"; then
5246                         haveit=yes
5247                         break
5248                       fi
5249                     done
5250                     if test -z "$haveit"; then
5251                       rpathdirs="$rpathdirs $found_dir"
5252                     fi
5253                   else
5254                     dnl Rely on "-L$found_dir".
5255                     dnl But don't add it if it's already contained in the LDFLAGS
5256                     dnl or the already constructed $LIBNAME
5257                     haveit=
5258                     for x in $LDFLAGS $LIB[]NAME; do
5259                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5260                       if test "X$x" = "X-L$found_dir"; then
5261                         haveit=yes
5262                         break
5263                       fi
5264                     done
5265                     if test -z "$haveit"; then
5266                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
5267                     fi
5268                     if test "$hardcode_minus_L" != no; then
5269                       dnl FIXME: Not sure whether we should use
5270                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
5271                       dnl here.
5272                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
5273                     else
5274                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
5275                       dnl here, because this doesn't fit in flags passed to the
5276                       dnl compiler. So give up. No hardcoding. This affects only
5277                       dnl very old systems.
5278                       dnl FIXME: Not sure whether we should use
5279                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
5280                       dnl here.
5281                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
5282                     fi
5283                   fi
5284                 fi
5285               fi
5286             else
5287               if test "X$found_a" != "X"; then
5288                 dnl Linking with a static library.
5289                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
5290               else
5291                 dnl We shouldn't come here, but anyway it's good to have a
5292                 dnl fallback.
5293                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
5294               fi
5295             fi
5296             dnl Assume the include files are nearby.
5297             additional_includedir=
5298             case "$found_dir" in
5299               */lib | */lib/)
5300                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
5301                 additional_includedir="$basedir/include"
5302                 ;;
5303             esac
5304             if test "X$additional_includedir" != "X"; then
5305               dnl Potentially add $additional_includedir to $INCNAME.
5306               dnl But don't add it
5307               dnl   1. if it's the standard /usr/include,
5308               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
5309               dnl   3. if it's already present in $CPPFLAGS or the already
5310               dnl      constructed $INCNAME,
5311               dnl   4. if it doesn't exist as a directory.
5312               if test "X$additional_includedir" != "X/usr/include"; then
5313                 haveit=
5314                 if test "X$additional_includedir" = "X/usr/local/include"; then
5315                   if test -n "$GCC"; then
5316                     case $host_os in
5317                       linux*) haveit=yes;;
5318                     esac
5319                   fi
5320                 fi
5321                 if test -z "$haveit"; then
5322                   for x in $CPPFLAGS $INC[]NAME; do
5323                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5324                     if test "X$x" = "X-I$additional_includedir"; then
5325                       haveit=yes
5326                       break
5327                     fi
5328                   done
5329                   if test -z "$haveit"; then
5330                     if test -d "$additional_includedir"; then
5331                       dnl Really add $additional_includedir to $INCNAME.
5332                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
5333                     fi
5334                   fi
5335                 fi
5336               fi
5337             fi
5338             dnl Look for dependencies.
5339             if test -n "$found_la"; then
5340               dnl Read the .la file. It defines the variables
5341               dnl dlname, library_names, old_library, dependency_libs, current,
5342               dnl age, revision, installed, dlopen, dlpreopen, libdir.
5343               save_libdir="$libdir"
5344               case "$found_la" in
5345                 */* | *\\*) . "$found_la" ;;
5346                 *) . "./$found_la" ;;
5347               esac
5348               libdir="$save_libdir"
5349               dnl We use only dependency_libs.
5350               for dep in $dependency_libs; do
5351                 case "$dep" in
5352                   -L*)
5353                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
5354                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
5355                     dnl But don't add it
5356                     dnl   1. if it's the standard /usr/lib,
5357                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
5358                     dnl   3. if it's already present in $LDFLAGS or the already
5359                     dnl      constructed $LIBNAME,
5360                     dnl   4. if it doesn't exist as a directory.
5361                     if test "X$additional_libdir" != "X/usr/lib"; then
5362                       haveit=
5363                       if test "X$additional_libdir" = "X/usr/local/lib"; then
5364                         if test -n "$GCC"; then
5365                           case $host_os in
5366                             linux*) haveit=yes;;
5367                           esac
5368                         fi
5369                       fi
5370                       if test -z "$haveit"; then
5371                         haveit=
5372                         for x in $LDFLAGS $LIB[]NAME; do
5373                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5374                           if test "X$x" = "X-L$additional_libdir"; then
5375                             haveit=yes
5376                             break
5377                           fi
5378                         done
5379                         if test -z "$haveit"; then
5380                           if test -d "$additional_libdir"; then
5381                             dnl Really add $additional_libdir to $LIBNAME.
5382                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
5383                           fi
5384                         fi
5385                         haveit=
5386                         for x in $LDFLAGS $LTLIB[]NAME; do
5387                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5388                           if test "X$x" = "X-L$additional_libdir"; then
5389                             haveit=yes
5390                             break
5391                           fi
5392                         done
5393                         if test -z "$haveit"; then
5394                           if test -d "$additional_libdir"; then
5395                             dnl Really add $additional_libdir to $LTLIBNAME.
5396                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
5397                           fi
5398                         fi
5399                       fi
5400                     fi
5401                     ;;
5402                   -R*)
5403                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
5404                     if test "$enable_rpath" != no; then
5405                       dnl Potentially add DIR to rpathdirs.
5406                       dnl The rpathdirs will be appended to $LIBNAME at the end.
5407                       haveit=
5408                       for x in $rpathdirs; do
5409                         if test "X$x" = "X$dir"; then
5410                           haveit=yes
5411                           break
5412                         fi
5413                       done
5414                       if test -z "$haveit"; then
5415                         rpathdirs="$rpathdirs $dir"
5416                       fi
5417                       dnl Potentially add DIR to ltrpathdirs.
5418                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
5419                       haveit=
5420                       for x in $ltrpathdirs; do
5421                         if test "X$x" = "X$dir"; then
5422                           haveit=yes
5423                           break
5424                         fi
5425                       done
5426                       if test -z "$haveit"; then
5427                         ltrpathdirs="$ltrpathdirs $dir"
5428                       fi
5429                     fi
5430                     ;;
5431                   -l*)
5432                     dnl Handle this in the next round.
5433                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
5434                     ;;
5435                   *.la)
5436                     dnl Handle this in the next round. Throw away the .la's
5437                     dnl directory; it is already contained in a preceding -L
5438                     dnl option.
5439                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
5440                     ;;
5441                   *)
5442                     dnl Most likely an immediate library name.
5443                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
5444                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
5445                     ;;
5446                 esac
5447               done
5448             fi
5449           else
5450             dnl Didn't find the library; assume it is in the system directories
5451             dnl known to the linker and runtime loader. (All the system
5452             dnl directories known to the linker should also be known to the
5453             dnl runtime loader, otherwise the system is severely misconfigured.)
5454             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
5455             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
5456           fi
5457         fi
5458       fi
5459     done
5460   done
5461   if test "X$rpathdirs" != "X"; then
5462     if test -n "$hardcode_libdir_separator"; then
5463       dnl Weird platform: only the last -rpath option counts, the user must
5464       dnl pass all path elements in one option. We can arrange that for a
5465       dnl single library, but not when more than one $LIBNAMEs are used.
5466       alldirs=
5467       for found_dir in $rpathdirs; do
5468         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
5469       done
5470       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
5471       acl_save_libdir="$libdir"
5472       libdir="$alldirs"
5473       eval flag=\"$hardcode_libdir_flag_spec\"
5474       libdir="$acl_save_libdir"
5475       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
5476     else
5477       dnl The -rpath options are cumulative.
5478       for found_dir in $rpathdirs; do
5479         acl_save_libdir="$libdir"
5480         libdir="$found_dir"
5481         eval flag=\"$hardcode_libdir_flag_spec\"
5482         libdir="$acl_save_libdir"
5483         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
5484       done
5485     fi
5486   fi
5487   if test "X$ltrpathdirs" != "X"; then
5488     dnl When using libtool, the option that works for both libraries and
5489     dnl executables is -R. The -R options are cumulative.
5490     for found_dir in $ltrpathdirs; do
5491       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
5492     done
5493   fi
5494 ])
5495
5496 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
5497 dnl unless already present in VAR.
5498 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
5499 dnl contains two or three consecutive elements that belong together.
5500 AC_DEFUN([AC_LIB_APPENDTOVAR],
5501 [
5502   for element in [$2]; do
5503     haveit=
5504     for x in $[$1]; do
5505       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5506       if test "X$x" = "X$element"; then
5507         haveit=yes
5508         break
5509       fi
5510     done
5511     if test -z "$haveit"; then
5512       [$1]="${[$1]}${[$1]:+ }$element"
5513     fi
5514   done
5515 ])
5516
5517 # lib-ld.m4 serial 2
5518 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
5519 dnl This file is free software, distributed under the terms of the GNU
5520 dnl General Public License.  As a special exception to the GNU General
5521 dnl Public License, this file may be distributed as part of a program
5522 dnl that contains a configuration script generated by Autoconf, under
5523 dnl the same distribution terms as the rest of that program.
5524
5525 dnl Subroutines of libtool.m4,
5526 dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
5527 dnl with libtool.m4.
5528
5529 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
5530 AC_DEFUN([AC_LIB_PROG_LD_GNU],
5531 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
5532 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
5533 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
5534   acl_cv_prog_gnu_ld=yes
5535 else
5536   acl_cv_prog_gnu_ld=no
5537 fi])
5538 with_gnu_ld=$acl_cv_prog_gnu_ld
5539 ])
5540
5541 dnl From libtool-1.4. Sets the variable LD.
5542 AC_DEFUN([AC_LIB_PROG_LD],
5543 [AC_ARG_WITH(gnu-ld,
5544 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
5545 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
5546 AC_REQUIRE([AC_PROG_CC])dnl
5547 AC_REQUIRE([AC_CANONICAL_HOST])dnl
5548 ac_prog=ld
5549 if test "$GCC" = yes; then
5550   # Check if gcc -print-prog-name=ld gives a path.
5551   AC_MSG_CHECKING([for ld used by GCC])
5552   case $host in
5553   *-*-mingw*)
5554     # gcc leaves a trailing carriage return which upsets mingw
5555     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
5556   *)
5557     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
5558   esac
5559   case $ac_prog in
5560     # Accept absolute paths.
5561     [[\\/]* | [A-Za-z]:[\\/]*)]
5562       [re_direlt='/[^/][^/]*/\.\./']
5563       # Canonicalize the path of ld
5564       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
5565       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
5566         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
5567       done
5568       test -z "$LD" && LD="$ac_prog"
5569       ;;
5570   "")
5571     # If it fails, then pretend we aren't using GCC.
5572     ac_prog=ld
5573     ;;
5574   *)
5575     # If it is relative, then search for the first ld in PATH.
5576     with_gnu_ld=unknown
5577     ;;
5578   esac
5579 elif test "$with_gnu_ld" = yes; then
5580   AC_MSG_CHECKING([for GNU ld])
5581 else
5582   AC_MSG_CHECKING([for non-GNU ld])
5583 fi
5584 AC_CACHE_VAL(acl_cv_path_LD,
5585 [if test -z "$LD"; then
5586   IFS="${IFS=    }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
5587   for ac_dir in $PATH; do
5588     test -z "$ac_dir" && ac_dir=.
5589     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
5590       acl_cv_path_LD="$ac_dir/$ac_prog"
5591       # Check to see if the program is GNU ld.  I'd rather use --version,
5592       # but apparently some GNU ld's only accept -v.
5593       # Break only if it was the GNU/non-GNU ld that we prefer.
5594       if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
5595         test "$with_gnu_ld" != no && break
5596       else
5597         test "$with_gnu_ld" != yes && break
5598       fi
5599     fi
5600   done
5601   IFS="$ac_save_ifs"
5602 else
5603   acl_cv_path_LD="$LD" # Let the user override the test with a path.
5604 fi])
5605 LD="$acl_cv_path_LD"
5606 if test -n "$LD"; then
5607   AC_MSG_RESULT($LD)
5608 else
5609   AC_MSG_RESULT(no)
5610 fi
5611 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
5612 AC_LIB_PROG_LD_GNU
5613 ])
5614
5615 #serial 6
5616
5617 dnl From J. David Anglin.
5618
5619 dnl HPUX and other systems can't unlink shared text that is being executed.
5620
5621 AC_DEFUN([jm_FUNC_UNLINK_BUSY_TEXT],
5622 [dnl
5623   AC_CACHE_CHECK([whether a running program can be unlinked],
5624     jm_cv_func_unlink_busy_text,
5625     [
5626       AC_TRY_RUN([
5627         main (argc, argv)
5628           int argc;
5629           char **argv;
5630         {
5631           if (!argc)
5632             exit (-1);
5633           exit (unlink (argv[0]));
5634         }
5635         ],
5636       jm_cv_func_unlink_busy_text=yes,
5637       jm_cv_func_unlink_busy_text=no,
5638       jm_cv_func_unlink_busy_text=no
5639       )
5640     ]
5641   )
5642
5643   if test $jm_cv_func_unlink_busy_text = no; then
5644     INSTALL=$ac_install_sh
5645   fi
5646 ])
5647
5648 #serial 12
5649
5650 dnl From Jim Meyering.
5651 dnl
5652 dnl This is not pretty.  I've just taken the autoconf code and wrapped
5653 dnl it in an AC_DEFUN.
5654 dnl
5655
5656 # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
5657 AC_DEFUN([jm_LIST_MOUNTED_FILESYSTEMS],
5658   [
5659 AC_CHECK_FUNCS(listmntent getmntinfo)
5660 AC_CHECK_HEADERS(mntent.h sys/param.h sys/ucred.h sys/mount.h sys/fs_types.h)
5661     getfsstat_includes="\
5662 $ac_includes_default
5663 #if HAVE_SYS_PARAM_H
5664 # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
5665 #endif
5666 #if HAVE_SYS_UCRED_H
5667 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
5668 #endif
5669 #if HAVE_SYS_MOUNT_H
5670 # include <sys/mount.h>
5671 #endif
5672 #if HAVE_SYS_FS_TYPES_H
5673 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
5674 #endif
5675 "
5676 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
5677
5678 # Determine how to get the list of mounted filesystems.
5679 ac_list_mounted_fs=
5680
5681 # If the getmntent function is available but not in the standard library,
5682 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
5683 AC_FUNC_GETMNTENT
5684
5685 # This test must precede the ones for getmntent because Unicos-9 is
5686 # reported to have the getmntent function, but its support is incompatible
5687 # with other getmntent implementations.
5688
5689 # NOTE: Normally, I wouldn't use a check for system type as I've done for
5690 # `CRAY' below since that goes against the whole autoconf philosophy.  But
5691 # I think there is too great a chance that some non-Cray system has a
5692 # function named listmntent to risk the false positive.
5693
5694 if test -z "$ac_list_mounted_fs"; then
5695   # Cray UNICOS 9
5696   AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
5697   AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
5698     [fu_cv_sys_mounted_cray_listmntent=no
5699       AC_EGREP_CPP(yes,
5700         [#ifdef _CRAY
5701 yes
5702 #endif
5703         ], [test $ac_cv_func_listmntent = yes \
5704             && fu_cv_sys_mounted_cray_listmntent=yes]
5705       )
5706     ]
5707   )
5708   AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
5709   if test $fu_cv_sys_mounted_cray_listmntent = yes; then
5710     ac_list_mounted_fs=found
5711     AC_DEFINE(MOUNTED_LISTMNTENT, 1,
5712       [Define if there is a function named listmntent that can be used to
5713    list all mounted filesystems. (UNICOS)])
5714   fi
5715 fi
5716
5717 if test -z "$ac_list_mounted_fs"; then
5718   # AIX.
5719   AC_MSG_CHECKING([for mntctl function and struct vmount])
5720   AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
5721   [AC_TRY_CPP([#include <fshelp.h>],
5722     fu_cv_sys_mounted_vmount=yes,
5723     fu_cv_sys_mounted_vmount=no)])
5724   AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
5725   if test $fu_cv_sys_mounted_vmount = yes; then
5726     ac_list_mounted_fs=found
5727     AC_DEFINE(MOUNTED_VMOUNT, 1,
5728         [Define if there is a function named mntctl that can be used to read
5729    the list of mounted filesystems, and there is a system header file
5730    that declares `struct vmount.'  (AIX)])
5731   fi
5732 fi
5733
5734 if test $ac_cv_func_getmntent = yes; then
5735
5736   # This system has the getmntent function.
5737   # Determine whether it's the one-argument variant or the two-argument one.
5738
5739   if test -z "$ac_list_mounted_fs"; then
5740     # 4.3BSD, SunOS, HP-UX, Dynix, Irix
5741     AC_MSG_CHECKING([for one-argument getmntent function])
5742     AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
5743                  [AC_TRY_COMPILE([
5744 /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
5745 #include <stdio.h>
5746
5747 #include <mntent.h>
5748 #if !defined MOUNTED
5749 # if defined _PATH_MOUNTED      /* GNU libc  */
5750 #  define MOUNTED _PATH_MOUNTED
5751 # endif
5752 # if defined MNT_MNTTAB /* HP-UX.  */
5753 #  define MOUNTED MNT_MNTTAB
5754 # endif
5755 # if defined MNTTABNAME /* Dynix.  */
5756 #  define MOUNTED MNTTABNAME
5757 # endif
5758 #endif
5759 ],
5760                     [ struct mntent *mnt = 0; char *table = MOUNTED; ],
5761                     fu_cv_sys_mounted_getmntent1=yes,
5762                     fu_cv_sys_mounted_getmntent1=no)])
5763     AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
5764     if test $fu_cv_sys_mounted_getmntent1 = yes; then
5765       ac_list_mounted_fs=found
5766       AC_DEFINE(MOUNTED_GETMNTENT1, 1,
5767   [Define if there is a function named getmntent for reading the list
5768    of mounted filesystems, and that function takes a single argument.
5769    (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
5770     fi
5771   fi
5772
5773   if test -z "$ac_list_mounted_fs"; then
5774     # SVR4
5775     AC_MSG_CHECKING([for two-argument getmntent function])
5776     AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
5777     [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
5778       fu_cv_sys_mounted_getmntent2=yes,
5779       fu_cv_sys_mounted_getmntent2=no)])
5780     AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
5781     if test $fu_cv_sys_mounted_getmntent2 = yes; then
5782       ac_list_mounted_fs=found
5783       AC_DEFINE(MOUNTED_GETMNTENT2, 1,
5784   [Define if there is a function named getmntent for reading the list of
5785    mounted filesystems, and that function takes two arguments.  (SVR4)])
5786     fi
5787   fi
5788
5789 fi
5790
5791 if test -z "$ac_list_mounted_fs"; then
5792   # DEC Alpha running OSF/1, and Apple Darwin 1.3.
5793   # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
5794
5795   AC_MSG_CHECKING([for getfsstat function])
5796   AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
5797   [AC_TRY_LINK([
5798 #include <sys/types.h>
5799 #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
5800 # define FS_TYPE(Ent) ((Ent).f_fstypename)
5801 #else
5802 # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
5803 #endif
5804 ]$getfsstat_includes
5805 ,
5806   [struct statfs *stats;
5807    int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
5808    char *t = FS_TYPE (*stats); ],
5809     fu_cv_sys_mounted_getfsstat=yes,
5810     fu_cv_sys_mounted_getfsstat=no)])
5811   AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
5812   if test $fu_cv_sys_mounted_getfsstat = yes; then
5813     ac_list_mounted_fs=found
5814     AC_DEFINE(MOUNTED_GETFSSTAT, 1,
5815               [Define if there is a function named getfsstat for reading the
5816    list of mounted filesystems.  (DEC Alpha running OSF/1)])
5817   fi
5818 fi
5819
5820 if test -z "$ac_list_mounted_fs"; then
5821   # SVR3
5822   AC_MSG_CHECKING([for FIXME existence of three headers])
5823   AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
5824     [AC_TRY_CPP([
5825 #include <sys/statfs.h>
5826 #include <sys/fstyp.h>
5827 #include <mnttab.h>],
5828                 fu_cv_sys_mounted_fread_fstyp=yes,
5829                 fu_cv_sys_mounted_fread_fstyp=no)])
5830   AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
5831   if test $fu_cv_sys_mounted_fread_fstyp = yes; then
5832     ac_list_mounted_fs=found
5833     AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
5834 [Define if (like SVR2) there is no specific function for reading the
5835    list of mounted filesystems, and your system has these header files:
5836    <sys/fstyp.h> and <sys/statfs.h>.  (SVR3)])
5837   fi
5838 fi
5839
5840 if test -z "$ac_list_mounted_fs"; then
5841   # 4.4BSD and DEC OSF/1.
5842   AC_MSG_CHECKING([for getmntinfo function])
5843   AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
5844     [
5845       test "$ac_cv_func_getmntinfo" = yes \
5846           && fu_cv_sys_mounted_getmntinfo=yes \
5847           || fu_cv_sys_mounted_getmntinfo=no
5848     ])
5849   AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
5850   if test $fu_cv_sys_mounted_getmntinfo = yes; then
5851     ac_list_mounted_fs=found
5852     AC_DEFINE(MOUNTED_GETMNTINFO, 1,
5853               [Define if there is a function named getmntinfo for reading the
5854    list of mounted filesystems.  (4.4BSD, Darwin)])
5855   fi
5856 fi
5857
5858 if test -z "$ac_list_mounted_fs"; then
5859   # Ultrix
5860   AC_MSG_CHECKING([for getmnt function])
5861   AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
5862     [AC_TRY_CPP([
5863 #include <sys/fs_types.h>
5864 #include <sys/mount.h>],
5865                 fu_cv_sys_mounted_getmnt=yes,
5866                 fu_cv_sys_mounted_getmnt=no)])
5867   AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
5868   if test $fu_cv_sys_mounted_getmnt = yes; then
5869     ac_list_mounted_fs=found
5870     AC_DEFINE(MOUNTED_GETMNT, 1,
5871       [Define if there is a function named getmnt for reading the list of
5872    mounted filesystems.  (Ultrix)])
5873   fi
5874 fi
5875
5876 if test -z "$ac_list_mounted_fs"; then
5877   # BeOS
5878   AC_CHECK_FUNCS(next_dev fs_stat_dev)
5879   AC_CHECK_HEADERS(fs_info.h)
5880   AC_MSG_CHECKING([for BEOS mounted file system support functions])
5881   if test $ac_cv_header_fs_info_h = yes \
5882       && test $ac_cv_func_next_dev = yes \
5883         && test $ac_cv_func_fs_stat_dev = yes; then
5884     fu_result=yes
5885   else
5886     fu_result=no
5887   fi
5888   AC_MSG_RESULT($fu_result)
5889   if test $fu_result = yes; then
5890     ac_list_mounted_fs=found
5891     AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
5892       [Define if there are functions named next_dev and fs_stat_dev for
5893    reading the list of mounted filesystems.  (BeOS)])
5894   fi
5895 fi
5896
5897 if test -z "$ac_list_mounted_fs"; then
5898   # SVR2
5899   AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
5900   AC_CACHE_VAL(fu_cv_sys_mounted_fread,
5901     [AC_TRY_CPP([#include <mnttab.h>],
5902                 fu_cv_sys_mounted_fread=yes,
5903                 fu_cv_sys_mounted_fread=no)])
5904   AC_MSG_RESULT($fu_cv_sys_mounted_fread)
5905   if test $fu_cv_sys_mounted_fread = yes; then
5906     ac_list_mounted_fs=found
5907     AC_DEFINE(MOUNTED_FREAD, 1,
5908               [Define if there is no specific function for reading the list of
5909    mounted filesystems.  fread will be used to read /etc/mnttab.  (SVR2) ])
5910   fi
5911 fi
5912
5913 if test -z "$ac_list_mounted_fs"; then
5914   AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
5915   # FIXME -- no need to abort building the whole package
5916   # Can't build mountlist.c or anything that needs its functions
5917 fi
5918
5919 AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
5920
5921   ])
5922
5923 #serial 3
5924
5925 dnl From Jim Meyering.
5926 dnl
5927 dnl See if struct statfs has the f_fstypename member.
5928 dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
5929 dnl
5930
5931 AC_DEFUN([jm_FSTYPENAME],
5932   [
5933     AC_CACHE_CHECK([for f_fstypename in struct statfs],
5934                    fu_cv_sys_f_fstypename_in_statfs,
5935       [
5936         AC_TRY_COMPILE(
5937           [
5938 #include <sys/param.h>
5939 #include <sys/types.h>
5940 #include <sys/mount.h>
5941           ],
5942           [struct statfs s; int i = sizeof s.f_fstypename;],
5943           fu_cv_sys_f_fstypename_in_statfs=yes,
5944           fu_cv_sys_f_fstypename_in_statfs=no
5945         )
5946       ]
5947     )
5948
5949     if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
5950       AC_DEFINE(HAVE_F_FSTYPENAME_IN_STATFS, 1,
5951                 [Define if struct statfs has the f_fstypename member.])
5952     fi
5953   ]
5954 )
5955
5956 #serial 9
5957
5958 # From fileutils/configure.in
5959
5960 # Try to determine how a program can obtain filesystem usage information.
5961 # If successful, define the appropriate symbol (see fsusage.c) and
5962 # execute ACTION-IF-FOUND.  Otherwise, execute ACTION-IF-NOT-FOUND.
5963 #
5964 # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
5965
5966 AC_DEFUN([jm_FILE_SYSTEM_USAGE],
5967 [
5968
5969 echo "checking how to get filesystem space usage..."
5970 ac_fsusage_space=no
5971
5972 # Perform only the link test since it seems there are no variants of the
5973 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
5974 # because that got a false positive on SCO OSR5.  Adding the declaration
5975 # of a `struct statvfs' causes this test to fail (as it should) on such
5976 # systems.  That system is reported to work fine with STAT_STATFS4 which
5977 # is what it gets when this test fails.
5978 if test $ac_fsusage_space = no; then
5979   # SVR4
5980   AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
5981                  [AC_TRY_LINK([#include <sys/types.h>
5982 #ifdef __GLIBC__
5983 Do not use statvfs on systems with GNU libc, because that function stats
5984 all preceding entries in /proc/mounts, and that makes df hang if even
5985 one of the corresponding file systems is hard-mounted, but not available.
5986 #endif
5987 #include <sys/statvfs.h>],
5988                               [struct statvfs fsd; statvfs (0, &fsd);],
5989                               fu_cv_sys_stat_statvfs=yes,
5990                               fu_cv_sys_stat_statvfs=no)])
5991   if test $fu_cv_sys_stat_statvfs = yes; then
5992     ac_fsusage_space=yes
5993     AC_DEFINE(STAT_STATVFS, 1,
5994               [  Define if there is a function named statvfs.  (SVR4)])
5995   fi
5996 fi
5997
5998 if test $ac_fsusage_space = no; then
5999   # DEC Alpha running OSF/1
6000   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
6001   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
6002   [AC_TRY_RUN([
6003 #include <sys/param.h>
6004 #include <sys/types.h>
6005 #include <sys/mount.h>
6006   main ()
6007   {
6008     struct statfs fsd;
6009     fsd.f_fsize = 0;
6010     exit (statfs (".", &fsd, sizeof (struct statfs)));
6011   }],
6012   fu_cv_sys_stat_statfs3_osf1=yes,
6013   fu_cv_sys_stat_statfs3_osf1=no,
6014   fu_cv_sys_stat_statfs3_osf1=no)])
6015   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
6016   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
6017     ac_fsusage_space=yes
6018     AC_DEFINE(STAT_STATFS3_OSF1, 1,
6019               [   Define if  statfs takes 3 args.  (DEC Alpha running OSF/1)])
6020   fi
6021 fi
6022
6023 if test $ac_fsusage_space = no; then
6024 # AIX
6025   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
6026 member (AIX, 4.3BSD)])
6027   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
6028   [AC_TRY_RUN([
6029 #ifdef HAVE_SYS_PARAM_H
6030 #include <sys/param.h>
6031 #endif
6032 #ifdef HAVE_SYS_MOUNT_H
6033 #include <sys/mount.h>
6034 #endif
6035 #ifdef HAVE_SYS_VFS_H
6036 #include <sys/vfs.h>
6037 #endif
6038   main ()
6039   {
6040   struct statfs fsd;
6041   fsd.f_bsize = 0;
6042   exit (statfs (".", &fsd));
6043   }],
6044   fu_cv_sys_stat_statfs2_bsize=yes,
6045   fu_cv_sys_stat_statfs2_bsize=no,
6046   fu_cv_sys_stat_statfs2_bsize=no)])
6047   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
6048   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
6049     ac_fsusage_space=yes
6050     AC_DEFINE(STAT_STATFS2_BSIZE, 1,
6051 [  Define if statfs takes 2 args and struct statfs has a field named f_bsize.
6052    (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
6053   fi
6054 fi
6055
6056 if test $ac_fsusage_space = no; then
6057 # SVR3
6058   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
6059   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
6060   [AC_TRY_RUN([#include <sys/types.h>
6061 #include <sys/statfs.h>
6062   main ()
6063   {
6064   struct statfs fsd;
6065   exit (statfs (".", &fsd, sizeof fsd, 0));
6066   }],
6067     fu_cv_sys_stat_statfs4=yes,
6068     fu_cv_sys_stat_statfs4=no,
6069     fu_cv_sys_stat_statfs4=no)])
6070   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
6071   if test $fu_cv_sys_stat_statfs4 = yes; then
6072     ac_fsusage_space=yes
6073     AC_DEFINE(STAT_STATFS4, 1,
6074               [  Define if statfs takes 4 args.  (SVR3, Dynix, Irix, Dolphin)])
6075   fi
6076 fi
6077
6078 if test $ac_fsusage_space = no; then
6079 # 4.4BSD and NetBSD
6080   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
6081 member (4.4BSD and NetBSD)])
6082   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
6083   [AC_TRY_RUN([#include <sys/types.h>
6084 #ifdef HAVE_SYS_PARAM_H
6085 #include <sys/param.h>
6086 #endif
6087 #ifdef HAVE_SYS_MOUNT_H
6088 #include <sys/mount.h>
6089 #endif
6090   main ()
6091   {
6092   struct statfs fsd;
6093   fsd.f_fsize = 0;
6094   exit (statfs (".", &fsd));
6095   }],
6096   fu_cv_sys_stat_statfs2_fsize=yes,
6097   fu_cv_sys_stat_statfs2_fsize=no,
6098   fu_cv_sys_stat_statfs2_fsize=no)])
6099   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
6100   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
6101     ac_fsusage_space=yes
6102     AC_DEFINE(STAT_STATFS2_FSIZE, 1,
6103 [  Define if statfs takes 2 args and struct statfs has a field named f_fsize.
6104    (4.4BSD, NetBSD)])
6105   fi
6106 fi
6107
6108 if test $ac_fsusage_space = no; then
6109   # Ultrix
6110   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
6111   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
6112   [AC_TRY_RUN([#include <sys/types.h>
6113 #ifdef HAVE_SYS_PARAM_H
6114 #include <sys/param.h>
6115 #endif
6116 #ifdef HAVE_SYS_MOUNT_H
6117 #include <sys/mount.h>
6118 #endif
6119 #ifdef HAVE_SYS_FS_TYPES_H
6120 #include <sys/fs_types.h>
6121 #endif
6122   main ()
6123   {
6124   struct fs_data fsd;
6125   /* Ultrix's statfs returns 1 for success,
6126      0 for not mounted, -1 for failure.  */
6127   exit (statfs (".", &fsd) != 1);
6128   }],
6129   fu_cv_sys_stat_fs_data=yes,
6130   fu_cv_sys_stat_fs_data=no,
6131   fu_cv_sys_stat_fs_data=no)])
6132   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
6133   if test $fu_cv_sys_stat_fs_data = yes; then
6134     ac_fsusage_space=yes
6135     AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
6136 [  Define if statfs takes 2 args and the second argument has
6137    type struct fs_data.  (Ultrix)])
6138   fi
6139 fi
6140
6141 if test $ac_fsusage_space = no; then
6142   # SVR2
6143   AC_TRY_CPP([#include <sys/filsys.h>
6144     ],
6145     AC_DEFINE(STAT_READ_FILSYS, 1,
6146       [Define if there is no specific function for reading filesystems usage
6147        information and you have the <sys/filsys.h> header file.  (SVR2)])
6148     ac_fsusage_space=yes)
6149 fi
6150
6151 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
6152
6153 ])
6154
6155 #serial 5
6156
6157 # Define some macros required for proper operation of code in lib/*.c
6158 # on MSDOS/Windows systems.
6159
6160 # From Jim Meyering.
6161
6162 AC_DEFUN([jm_AC_DOS],
6163   [
6164     AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
6165       [
6166         AC_TRY_COMPILE([],
6167         [#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__
6168 neither MSDOS nor Windows
6169 #endif],
6170         [ac_cv_win_or_dos=yes],
6171         [ac_cv_win_or_dos=no])
6172       ])
6173
6174     if test x"$ac_cv_win_or_dos" = xyes; then
6175       ac_fs_accepts_drive_letter_prefix=1
6176       ac_fs_backslash_is_file_name_separator=1
6177     else
6178       ac_fs_accepts_drive_letter_prefix=0
6179       ac_fs_backslash_is_file_name_separator=0
6180     fi
6181
6182     AH_VERBATIM(FILESYSTEM_PREFIX_LEN,
6183     [#if FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
6184 # define FILESYSTEM_PREFIX_LEN(Filename) \
6185   ((Filename)[0] && (Filename)[1] == ':' ? 2 : 0)
6186 #else
6187 # define FILESYSTEM_PREFIX_LEN(Filename) 0
6188 #endif])
6189
6190     AC_DEFINE_UNQUOTED([FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
6191       $ac_fs_accepts_drive_letter_prefix,
6192       [Define on systems for which file names may have a so-called
6193        `drive letter' prefix, define this to compute the length of that
6194        prefix, including the colon.])
6195
6196     AH_VERBATIM(ISSLASH,
6197     [#if FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
6198 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
6199 #else
6200 # define ISSLASH(C) ((C) == '/')
6201 #endif])
6202
6203     AC_DEFINE_UNQUOTED([FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
6204       $ac_fs_backslash_is_file_name_separator,
6205       [Define if the backslash character may also serve as a file name
6206        component separator.])
6207   ])
6208
6209 #serial 1
6210 AC_DEFUN([AC_FUNC_CANONICALIZE_FILE_NAME],
6211   [
6212     AC_REQUIRE([AC_HEADER_STDC])
6213     AC_CHECK_HEADERS(string.h sys/param.h stddef.h)
6214     AC_CHECK_FUNCS(resolvepath)
6215     AC_REQUIRE([AC_HEADER_STAT])
6216
6217     # This would simply be AC_REPLACE_FUNC([canonicalize_file_name])
6218     # if the function name weren't so long.  Besides, I would rather
6219     # not have underscores in file names.
6220     AC_CHECK_FUNC([canonicalize_file_name], , [AC_LIBOBJ(canonicalize)])
6221   ])
6222
6223 #serial 5
6224
6225 dnl From Paul Eggert.
6226
6227 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
6228 # if it exists.
6229
6230 AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
6231  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
6232    ac_cv_struct_st_mtim_nsec,
6233    [ac_save_CPPFLAGS="$CPPFLAGS"
6234     ac_cv_struct_st_mtim_nsec=no
6235     # tv_nsec -- the usual case
6236     # _tv_nsec -- Solaris 2.6, if
6237     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
6238     #    && !defined __EXTENSIONS__)
6239     # st__tim.tv_nsec -- UnixWare 2.1.2
6240     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
6241       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
6242       AC_TRY_COMPILE([#include <sys/types.h>
6243 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
6244         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
6245     done
6246     CPPFLAGS="$ac_save_CPPFLAGS"])
6247
6248   if test $ac_cv_struct_st_mtim_nsec != no; then
6249     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
6250       [Define to be the nanoseconds member of struct stat's st_mtim,
6251    if it exists.])
6252   fi
6253  ]
6254 )
6255
6256 #serial 3
6257
6258 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
6259
6260 AC_DEFUN([AC_STRUCT_ST_DM_MODE],
6261  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
6262    [AC_TRY_COMPILE([#include <sys/types.h>
6263 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
6264      ac_cv_struct_st_dm_mode=yes,
6265      ac_cv_struct_st_dm_mode=no)])
6266
6267   if test $ac_cv_struct_st_dm_mode = yes; then
6268     AC_DEFINE(HAVE_ST_DM_MODE, 1,
6269               [Define if struct stat has an st_dm_mode member. ])
6270   fi
6271  ]
6272 )
6273
6274 #serial 5
6275
6276 dnl From Jim Meyering
6277
6278 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
6279 dnl in time.h or sys/time.h.
6280
6281 AC_DEFUN([jm_CHECK_TYPE_STRUCT_TIMESPEC],
6282 [
6283   AC_REQUIRE([AC_HEADER_TIME])
6284   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
6285     [AC_TRY_COMPILE(
6286       [
6287 #      if TIME_WITH_SYS_TIME
6288 #       include <sys/time.h>
6289 #       include <time.h>
6290 #      else
6291 #       if HAVE_SYS_TIME_H
6292 #        include <sys/time.h>
6293 #       else
6294 #        include <time.h>
6295 #       endif
6296 #      endif
6297       ],
6298       [static struct timespec x; x.tv_sec = x.tv_nsec;],
6299       fu_cv_sys_struct_timespec=yes,
6300       fu_cv_sys_struct_timespec=no)
6301     ])
6302
6303   if test $fu_cv_sys_struct_timespec = yes; then
6304     AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
6305               [Define if struct timespec is declared in <time.h>. ])
6306   fi
6307 ])
6308
6309 #serial 6
6310 dnl From Jim Meyering and Paul Eggert.
6311 AC_DEFUN([jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
6312 [AC_REQUIRE([AC_SYS_POSIX_TERMIOS])
6313  AC_CACHE_CHECK([whether use of TIOCGWINSZ requires termios.h],
6314                 jm_cv_sys_tiocgwinsz_needs_termios_h,
6315   [jm_cv_sys_tiocgwinsz_needs_termios_h=no
6316
6317    if test $ac_cv_sys_posix_termios = yes; then
6318      AC_EGREP_CPP([yes],
6319      [#include <sys/types.h>
6320 #      include <termios.h>
6321 #      ifdef TIOCGWINSZ
6322          yes
6323 #      endif
6324      ], jm_cv_sys_tiocgwinsz_needs_termios_h=yes)
6325    fi
6326   ])
6327 ])
6328
6329 AC_DEFUN([jm_WINSIZE_IN_PTEM],
6330   [AC_REQUIRE([AC_SYS_POSIX_TERMIOS])
6331    AC_CACHE_CHECK([whether use of struct winsize requires sys/ptem.h],
6332      jm_cv_sys_struct_winsize_needs_sys_ptem_h,
6333      [jm_cv_sys_struct_winsize_needs_sys_ptem_h=yes
6334       if test $ac_cv_sys_posix_termios = yes; then
6335         AC_TRY_COMPILE([#include <termios.h>]
6336           [struct winsize x;],
6337           [jm_cv_sys_struct_winsize_needs_sys_ptem_h=no])
6338       fi
6339       if test $jm_cv_sys_struct_winsize_needs_sys_ptem_h = yes; then
6340         AC_TRY_COMPILE([#include <sys/ptem.h>],
6341           [struct winsize x;],
6342           [], [jm_cv_sys_struct_winsize_needs_sys_ptem_h=no])
6343       fi])
6344    if test $jm_cv_sys_struct_winsize_needs_sys_ptem_h = yes; then
6345      AC_DEFINE([WINSIZE_IN_PTEM], 1,
6346        [Define if sys/ptem.h is required for struct winsize.])
6347    fi])
6348
6349 # Determine whether this system has infrastructure for obtaining the boot time.
6350
6351 # GNULIB_BOOT_TIME([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
6352 * ----------------------------------------------------------
6353 AC_DEFUN([GNULIB_BOOT_TIME],
6354 [
6355   AC_CHECK_FUNCS(sysctl)
6356   AC_CHECK_HEADERS(sys/sysctl.h)
6357   AC_CACHE_CHECK(
6358     [whether we can get the system boot time],
6359     [gnulib_cv_have_boot_time],
6360     [
6361       AC_COMPILE_IFELSE(
6362        [AC_LANG_PROGRAM(
6363 [AC_INCLUDES_DEFAULT
6364 #if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
6365 # include <sys/param.h> /* needed for OpenBSD 3.0 */
6366 # include <sys/sysctl.h>
6367 #endif
6368 #ifdef HAVE_UTMPX_H
6369 # include <utmpx.h>
6370 #else
6371 # include <utmp.h>
6372 #endif
6373 ],
6374 [[
6375 #if defined BOOT_TIME || (defined CTL_KERN && defined KERN_BOOTTIME)
6376 /* your system *does* have the infrastructure to determine boot time */
6377 #else
6378 please_tell_us_how_to_determine_boot_time_on_your_system
6379 #endif
6380 ]])],
6381        gnulib_cv_have_boot_time=yes,
6382        gnulib_cv_have_boot_time=no)
6383     ])
6384   AS_IF([test $gnulib_cv_have_boot_time = yes], [$1], [$2])
6385 ])
6386
6387 #serial 4
6388
6389 AC_DEFUN([jm_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL],
6390 [AC_REQUIRE([jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H])
6391  AC_CACHE_CHECK([whether use of TIOCGWINSZ requires sys/ioctl.h],
6392                 jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h,
6393   [jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h=no
6394
6395   if test $jm_cv_sys_tiocgwinsz_needs_termios_h = no; then
6396     AC_EGREP_CPP([yes],
6397     [#include <sys/types.h>
6398 #     include <sys/ioctl.h>
6399 #     ifdef TIOCGWINSZ
6400         yes
6401 #     endif
6402     ], jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h=yes)
6403   fi
6404   ])
6405   if test $jm_cv_sys_tiocgwinsz_needs_sys_ioctl_h = yes; then
6406     AC_DEFINE(GWINSZ_IN_SYS_IOCTL, 1,
6407       [Define if your system defines TIOCGWINSZ in sys/ioctl.h.])
6408   fi
6409 ])
6410
6411 #serial 5
6412
6413 dnl Misc lib-related macros for fileutils, sh-utils, textutils.
6414
6415 AC_DEFUN([jm_LIB_CHECK],
6416 [
6417
6418   # Check for libypsec.a on Dolphin M88K machines.
6419   AC_CHECK_LIB(ypsec, main)
6420
6421   # m88k running dgux 5.4 needs this
6422   AC_CHECK_LIB(ldgc, main)
6423
6424   # Some programs need to link with -lm.  printf does if it uses
6425   # lib/strtod.c which uses pow.  And seq uses the math functions,
6426   # floor, modf, rint.  And factor uses sqrt.  And sleep uses fesetround.
6427
6428   # Save a copy of $LIBS and add $FLOOR_LIBM before these tests
6429   # Check for these math functions used by seq.
6430   ac_su_saved_lib="$LIBS"
6431   LIBS="$LIBS -lm"
6432   AC_CHECK_FUNCS(floor modf rint)
6433   LIBS="$ac_su_saved_lib"
6434
6435   AC_SUBST(SQRT_LIBM)
6436   AC_CHECK_FUNCS(sqrt)
6437   if test $ac_cv_func_sqrt = no; then
6438     AC_CHECK_LIB(m, sqrt, [SQRT_LIBM=-lm])
6439   fi
6440
6441   AC_SUBST(FESETROUND_LIBM)
6442   AC_CHECK_FUNCS(fesetround)
6443   if test $ac_cv_func_fesetround = no; then
6444     AC_CHECK_LIB(m, fesetround, [FESETROUND_LIBM=-lm])
6445   fi
6446
6447   # The -lsun library is required for YP support on Irix-4.0.5 systems.
6448   # m88k/svr3 DolphinOS systems using YP need -lypsec for id.
6449   AC_SEARCH_LIBS(yp_match, [sun ypsec])
6450
6451   # SysV needs -lsec, older versions of Linux need -lshadow for
6452   # shadow passwords.  UnixWare 7 needs -lgen.
6453   AC_SEARCH_LIBS(getspnam, [shadow sec gen])
6454
6455   AC_CHECK_HEADERS(shadow.h)
6456
6457   # Requirements for su.c.
6458   shadow_includes="\
6459 $ac_includes_default
6460 #if HAVE_SHADOW_H
6461 # include <shadow.h>
6462 #endif
6463 "
6464   AC_CHECK_MEMBERS([struct spwd.sp_pwdp],,,[$shadow_includes])
6465   AC_CHECK_FUNCS(getspnam)
6466
6467   # SCO-ODT-3.0 is reported to need -lufc for crypt.
6468   # NetBSD needs -lcrypt for crypt.
6469   ac_su_saved_lib="$LIBS"
6470   AC_SEARCH_LIBS(crypt, [ufc crypt], [LIB_CRYPT="$ac_cv_search_crypt"])
6471   LIBS="$ac_su_saved_lib"
6472   AC_SUBST(LIB_CRYPT)
6473 ])
6474
6475 # gettext.m4 serial 17 (gettext-0.11.5)
6476 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
6477 dnl This file is free software, distributed under the terms of the GNU
6478 dnl General Public License.  As a special exception to the GNU General
6479 dnl Public License, this file may be distributed as part of a program
6480 dnl that contains a configuration script generated by Autoconf, under
6481 dnl the same distribution terms as the rest of that program.
6482 dnl
6483 dnl This file can can be used in projects which are not available under
6484 dnl the GNU General Public License or the GNU Library General Public
6485 dnl License but which still want to provide support for the GNU gettext
6486 dnl functionality.
6487 dnl Please note that the actual code of the GNU gettext library is covered
6488 dnl by the GNU Library General Public License, and the rest of the GNU
6489 dnl gettext package package is covered by the GNU General Public License.
6490 dnl They are *not* in the public domain.
6491
6492 dnl Authors:
6493 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
6494 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2002.
6495
6496 dnl Macro to add for using GNU gettext.
6497
6498 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
6499 dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
6500 dnl    default (if it is not specified or empty) is 'no-libtool'.
6501 dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
6502 dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
6503 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
6504 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
6505 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
6506 dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
6507 dnl    $(top_builddir)/intl/libintl.a will be created.
6508 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
6509 dnl    implementations (in libc or libintl) without the ngettext() function
6510 dnl    will be ignored.  If NEEDSYMBOL is specified and is
6511 dnl    'need-formatstring-macros', then GNU gettext implementations that don't
6512 dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
6513 dnl INTLDIR is used to find the intl libraries.  If empty,
6514 dnl    the value `$(top_builddir)/intl/' is used.
6515 dnl
6516 dnl The result of the configuration is one of three cases:
6517 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
6518 dnl    and used.
6519 dnl    Catalog format: GNU --> install in $(datadir)
6520 dnl    Catalog extension: .mo after installation, .gmo in source tree
6521 dnl 2) GNU gettext has been found in the system's C library.
6522 dnl    Catalog format: GNU --> install in $(datadir)
6523 dnl    Catalog extension: .mo after installation, .gmo in source tree
6524 dnl 3) No internationalization, always use English msgid.
6525 dnl    Catalog format: none
6526 dnl    Catalog extension: none
6527 dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
6528 dnl The use of .gmo is historical (it was needed to avoid overwriting the
6529 dnl GNU format catalogs when building on a platform with an X/Open gettext),
6530 dnl but we keep it in order not to force irrelevant filename changes on the
6531 dnl maintainers.
6532 dnl
6533 AC_DEFUN([AM_GNU_GETTEXT],
6534 [
6535   dnl Argument checking.
6536   ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
6537     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
6538 ])])])])])
6539   ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
6540     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
6541 ])])])])
6542   define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
6543   define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
6544
6545   AC_REQUIRE([AM_PO_SUBDIRS])dnl
6546   ifelse(gt_included_intl, yes, [
6547     AC_REQUIRE([AM_INTL_SUBDIR])dnl
6548   ])
6549
6550   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
6551   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
6552   AC_REQUIRE([AC_LIB_RPATH])
6553
6554   dnl Sometimes libintl requires libiconv, so first search for libiconv.
6555   dnl Ideally we would do this search only after the
6556   dnl      if test "$USE_NLS" = "yes"; then
6557   dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
6558   dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
6559   dnl the configure script would need to contain the same shell code
6560   dnl again, outside any 'if'. There are two solutions:
6561   dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
6562   dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
6563   dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
6564   dnl documented, we avoid it.
6565   ifelse(gt_included_intl, yes, , [
6566     AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
6567   ])
6568
6569   AC_MSG_CHECKING([whether NLS is requested])
6570   dnl Default is enabled NLS
6571   AC_ARG_ENABLE(nls,
6572     [  --disable-nls           do not use Native Language Support],
6573     USE_NLS=$enableval, USE_NLS=yes)
6574   AC_MSG_RESULT($USE_NLS)
6575   AC_SUBST(USE_NLS)
6576
6577   ifelse(gt_included_intl, yes, [
6578     BUILD_INCLUDED_LIBINTL=no
6579     USE_INCLUDED_LIBINTL=no
6580   ])
6581   LIBINTL=
6582   LTLIBINTL=
6583   POSUB=
6584
6585   dnl If we use NLS figure out what method
6586   if test "$USE_NLS" = "yes"; then
6587     gt_use_preinstalled_gnugettext=no
6588     ifelse(gt_included_intl, yes, [
6589       AC_MSG_CHECKING([whether included gettext is requested])
6590       AC_ARG_WITH(included-gettext,
6591         [  --with-included-gettext use the GNU gettext library included here],
6592         nls_cv_force_use_gnu_gettext=$withval,
6593         nls_cv_force_use_gnu_gettext=no)
6594       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
6595
6596       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
6597       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
6598     ])
6599         dnl User does not insist on using GNU NLS library.  Figure out what
6600         dnl to use.  If GNU gettext is available we use this.  Else we have
6601         dnl to fall back to GNU NLS library.
6602
6603         dnl Add a version number to the cache macros.
6604         define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
6605         define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
6606         define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
6607
6608         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
6609          [AC_TRY_LINK([#include <libintl.h>
6610 ]ifelse([$2], [need-formatstring-macros],
6611 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
6612 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
6613 #endif
6614 changequote(,)dnl
6615 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
6616 changequote([,])dnl
6617 ], [])[extern int _nl_msg_cat_cntr;
6618 extern int *_nl_domain_bindings;],
6619             [bindtextdomain ("", "");
6620 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
6621             gt_cv_func_gnugettext_libc=yes,
6622             gt_cv_func_gnugettext_libc=no)])
6623
6624         if test "$gt_cv_func_gnugettext_libc" != "yes"; then
6625           dnl Sometimes libintl requires libiconv, so first search for libiconv.
6626           ifelse(gt_included_intl, yes, , [
6627             AM_ICONV_LINK
6628           ])
6629           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
6630           dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
6631           dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
6632           dnl even if libiconv doesn't exist.
6633           AC_LIB_LINKFLAGS_BODY([intl])
6634           AC_CACHE_CHECK([for GNU gettext in libintl],
6635             gt_cv_func_gnugettext_libintl,
6636            [gt_save_CPPFLAGS="$CPPFLAGS"
6637             CPPFLAGS="$CPPFLAGS $INCINTL"
6638             gt_save_LIBS="$LIBS"
6639             LIBS="$LIBS $LIBINTL"
6640             dnl Now see whether libintl exists and does not depend on libiconv.
6641             AC_TRY_LINK([#include <libintl.h>
6642 ]ifelse([$2], [need-formatstring-macros],
6643 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
6644 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
6645 #endif
6646 changequote(,)dnl
6647 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
6648 changequote([,])dnl
6649 ], [])[extern int _nl_msg_cat_cntr;
6650 extern
6651 #ifdef __cplusplus
6652 "C"
6653 #endif
6654 const char *_nl_expand_alias ();],
6655               [bindtextdomain ("", "");
6656 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
6657               gt_cv_func_gnugettext_libintl=yes,
6658               gt_cv_func_gnugettext_libintl=no)
6659             dnl Now see whether libintl exists and depends on libiconv.
6660             if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
6661               LIBS="$LIBS $LIBICONV"
6662               AC_TRY_LINK([#include <libintl.h>
6663 ]ifelse([$2], [need-formatstring-macros],
6664 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
6665 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
6666 #endif
6667 changequote(,)dnl
6668 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
6669 changequote([,])dnl
6670 ], [])[extern int _nl_msg_cat_cntr;
6671 extern
6672 #ifdef __cplusplus
6673 "C"
6674 #endif
6675 const char *_nl_expand_alias ();],
6676                 [bindtextdomain ("", "");
6677 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
6678                [LIBINTL="$LIBINTL $LIBICONV"
6679                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
6680                 gt_cv_func_gnugettext_libintl=yes
6681                ])
6682             fi
6683             CPPFLAGS="$gt_save_CPPFLAGS"
6684             LIBS="$gt_save_LIBS"])
6685         fi
6686
6687         dnl If an already present or preinstalled GNU gettext() is found,
6688         dnl use it.  But if this macro is used in GNU gettext, and GNU
6689         dnl gettext is already preinstalled in libintl, we update this
6690         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
6691         if test "$gt_cv_func_gnugettext_libc" = "yes" \
6692            || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
6693                 && test "$PACKAGE" != gettext; }; then
6694           gt_use_preinstalled_gnugettext=yes
6695         else
6696           dnl Reset the values set by searching for libintl.
6697           LIBINTL=
6698           LTLIBINTL=
6699           INCINTL=
6700         fi
6701
6702     ifelse(gt_included_intl, yes, [
6703         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
6704           dnl GNU gettext is not found in the C library.
6705           dnl Fall back on included GNU gettext library.
6706           nls_cv_use_gnu_gettext=yes
6707         fi
6708       fi
6709
6710       if test "$nls_cv_use_gnu_gettext" = "yes"; then
6711         dnl Mark actions used to generate GNU NLS library.
6712         INTLOBJS="\$(GETTOBJS)"
6713         BUILD_INCLUDED_LIBINTL=yes
6714         USE_INCLUDED_LIBINTL=yes
6715         LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
6716         LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
6717         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
6718       fi
6719
6720       if test "$gt_use_preinstalled_gnugettext" = "yes" \
6721          || test "$nls_cv_use_gnu_gettext" = "yes"; then
6722         dnl Mark actions to use GNU gettext tools.
6723         CATOBJEXT=.gmo
6724       fi
6725     ])
6726
6727     if test "$gt_use_preinstalled_gnugettext" = "yes" \
6728        || test "$nls_cv_use_gnu_gettext" = "yes"; then
6729       AC_DEFINE(ENABLE_NLS, 1,
6730         [Define to 1 if translation of program messages to the user's native language
6731    is requested.])
6732     else
6733       USE_NLS=no
6734     fi
6735   fi
6736
6737   if test "$USE_NLS" = "yes"; then
6738
6739     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
6740       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
6741         AC_MSG_CHECKING([how to link with libintl])
6742         AC_MSG_RESULT([$LIBINTL])
6743         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
6744       fi
6745
6746       dnl For backward compatibility. Some packages may be using this.
6747       AC_DEFINE(HAVE_GETTEXT, 1,
6748        [Define if the GNU gettext() function is already present or preinstalled.])
6749       AC_DEFINE(HAVE_DCGETTEXT, 1,
6750        [Define if the GNU dcgettext() function is already present or preinstalled.])
6751     fi
6752
6753     dnl We need to process the po/ directory.
6754     POSUB=po
6755   fi
6756
6757   ifelse(gt_included_intl, yes, [
6758     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
6759     dnl to 'yes' because some of the testsuite requires it.
6760     if test "$PACKAGE" = gettext; then
6761       BUILD_INCLUDED_LIBINTL=yes
6762     fi
6763
6764     dnl Make all variables we use known to autoconf.
6765     AC_SUBST(BUILD_INCLUDED_LIBINTL)
6766     AC_SUBST(USE_INCLUDED_LIBINTL)
6767     AC_SUBST(CATOBJEXT)
6768     AC_SUBST(INTLOBJS)
6769
6770     dnl For backward compatibility. Some configure.ins may be using this.
6771     nls_cv_header_intl=
6772     nls_cv_header_libgt=
6773
6774     dnl For backward compatibility. Some Makefiles may be using this.
6775     DATADIRNAME=share
6776     AC_SUBST(DATADIRNAME)
6777
6778     dnl For backward compatibility. Some Makefiles may be using this.
6779     INSTOBJEXT=.mo
6780     AC_SUBST(INSTOBJEXT)
6781
6782     dnl For backward compatibility. Some Makefiles may be using this.
6783     GENCAT=gencat
6784     AC_SUBST(GENCAT)
6785
6786     dnl Enable libtool support if the surrounding package wishes it.
6787     INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
6788     AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
6789   ])
6790
6791   dnl For backward compatibility. Some Makefiles may be using this.
6792   INTLLIBS="$LIBINTL"
6793   AC_SUBST(INTLLIBS)
6794
6795   dnl Make all documented variables known to autoconf.
6796   AC_SUBST(LIBINTL)
6797   AC_SUBST(LTLIBINTL)
6798   AC_SUBST(POSUB)
6799 ])
6800
6801
6802 dnl Checks for all prerequisites of the po subdirectory,
6803 dnl except for USE_NLS.
6804 AC_DEFUN([AM_PO_SUBDIRS],
6805 [
6806   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
6807   AC_REQUIRE([AC_PROG_INSTALL])dnl
6808   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
6809
6810   dnl Perform the following tests also if --disable-nls has been given,
6811   dnl because they are needed for "make dist" to work.
6812
6813   dnl Search for GNU msgfmt in the PATH.
6814   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
6815   dnl The second test excludes FreeBSD msgfmt.
6816   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
6817     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
6818      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
6819     :)
6820   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
6821
6822   dnl Search for GNU xgettext 0.11 or newer in the PATH.
6823   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
6824   dnl The second test excludes FreeBSD xgettext.
6825   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
6826     [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
6827      (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
6828     :)
6829   dnl Remove leftover from FreeBSD xgettext call.
6830   rm -f messages.po
6831
6832   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
6833   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
6834     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
6835
6836   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
6837   dnl Test whether we really found GNU msgfmt.
6838   if test "$GMSGFMT" != ":"; then
6839     dnl If it is no GNU msgfmt we define it as : so that the
6840     dnl Makefiles still can work.
6841     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
6842        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
6843       : ;
6844     else
6845       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
6846       AC_MSG_RESULT(
6847         [found $GMSGFMT program is not GNU msgfmt; ignore it])
6848       GMSGFMT=":"
6849     fi
6850   fi
6851
6852   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
6853   dnl Test whether we really found GNU xgettext.
6854   if test "$XGETTEXT" != ":"; then
6855     dnl If it is no GNU xgettext we define it as : so that the
6856     dnl Makefiles still can work.
6857     if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
6858        (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
6859       : ;
6860     else
6861       AC_MSG_RESULT(
6862         [found xgettext program is not GNU xgettext; ignore it])
6863       XGETTEXT=":"
6864     fi
6865     dnl Remove leftover from FreeBSD xgettext call.
6866     rm -f messages.po
6867   fi
6868
6869   AC_OUTPUT_COMMANDS([
6870     for ac_file in $CONFIG_FILES; do
6871       # Support "outfile[:infile[:infile...]]"
6872       case "$ac_file" in
6873         *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
6874       esac
6875       # PO directories have a Makefile.in generated from Makefile.in.in.
6876       case "$ac_file" in */Makefile.in)
6877         # Adjust a relative srcdir.
6878         ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
6879         ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
6880         ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
6881         # In autoconf-2.13 it is called $ac_given_srcdir.
6882         # In autoconf-2.50 it is called $srcdir.
6883         test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
6884         case "$ac_given_srcdir" in
6885           .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
6886           /*) top_srcdir="$ac_given_srcdir" ;;
6887           *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
6888         esac
6889         if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
6890           rm -f "$ac_dir/POTFILES"
6891           test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
6892           cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[    ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
6893           # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
6894           # on $ac_dir but don't depend on user-specified configuration
6895           # parameters.
6896           if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
6897             # The LINGUAS file contains the set of available languages.
6898             if test -n "$ALL_LINGUAS"; then
6899               test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
6900             fi
6901             ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
6902             # Hide the ALL_LINGUAS assigment from automake.
6903             eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
6904           fi
6905           case "$ac_given_srcdir" in
6906             .) srcdirpre= ;;
6907             *) srcdirpre='$(srcdir)/' ;;
6908           esac
6909           POFILES=
6910           GMOFILES=
6911           UPDATEPOFILES=
6912           DUMMYPOFILES=
6913           for lang in $ALL_LINGUAS; do
6914             POFILES="$POFILES $srcdirpre$lang.po"
6915             GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
6916             UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
6917             DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
6918           done
6919           # CATALOGS depends on both $ac_dir and the user's LINGUAS
6920           # environment variable.
6921           INST_LINGUAS=
6922           if test -n "$ALL_LINGUAS"; then
6923             for presentlang in $ALL_LINGUAS; do
6924               useit=no
6925               if test "%UNSET%" != "$LINGUAS"; then
6926                 desiredlanguages="$LINGUAS"
6927               else
6928                 desiredlanguages="$ALL_LINGUAS"
6929               fi
6930               for desiredlang in $desiredlanguages; do
6931                 # Use the presentlang catalog if desiredlang is
6932                 #   a. equal to presentlang, or
6933                 #   b. a variant of presentlang (because in this case,
6934                 #      presentlang can be used as a fallback for messages
6935                 #      which are not translated in the desiredlang catalog).
6936                 case "$desiredlang" in
6937                   "$presentlang"*) useit=yes;;
6938                 esac
6939               done
6940               if test $useit = yes; then
6941                 INST_LINGUAS="$INST_LINGUAS $presentlang"
6942               fi
6943             done
6944           fi
6945           CATALOGS=
6946           if test -n "$INST_LINGUAS"; then
6947             for lang in $INST_LINGUAS; do
6948               CATALOGS="$CATALOGS $lang.gmo"
6949             done
6950           fi
6951           test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
6952           sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
6953           for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
6954             if test -f "$f"; then
6955               case "$f" in
6956                 *.orig | *.bak | *~) ;;
6957                 *) cat "$f" >> "$ac_dir/Makefile" ;;
6958               esac
6959             fi
6960           done
6961         fi
6962         ;;
6963       esac
6964     done],
6965    [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
6966     # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
6967     # from automake.
6968     eval 'ALL_LINGUAS''="$ALL_LINGUAS"'
6969     # Capture the value of LINGUAS because we need it to compute CATALOGS.
6970     LINGUAS="${LINGUAS-%UNSET%}"
6971    ])
6972 ])
6973
6974
6975 dnl Checks for all prerequisites of the intl subdirectory,
6976 dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
6977 dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
6978 AC_DEFUN([AM_INTL_SUBDIR],
6979 [
6980   AC_REQUIRE([AC_PROG_INSTALL])dnl
6981   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
6982   AC_REQUIRE([AC_PROG_CC])dnl
6983   AC_REQUIRE([AC_CANONICAL_HOST])dnl
6984   AC_REQUIRE([AC_PROG_RANLIB])dnl
6985   AC_REQUIRE([AC_ISC_POSIX])dnl
6986   AC_REQUIRE([AC_HEADER_STDC])dnl
6987   AC_REQUIRE([AC_C_CONST])dnl
6988   AC_REQUIRE([AC_C_INLINE])dnl
6989   AC_REQUIRE([AC_TYPE_OFF_T])dnl
6990   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
6991   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
6992   AC_REQUIRE([AC_FUNC_MMAP])dnl
6993   AC_REQUIRE([jm_GLIBC21])dnl
6994   AC_REQUIRE([gt_INTDIV0])dnl
6995   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
6996   AC_REQUIRE([gt_INTTYPES_PRI])dnl
6997
6998   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
6999 stdlib.h string.h unistd.h sys/param.h])
7000   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
7001 geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
7002 strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
7003
7004   AM_ICONV
7005   AM_LANGINFO_CODESET
7006   if test $ac_cv_header_locale_h = yes; then
7007     AM_LC_MESSAGES
7008   fi
7009
7010   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
7011   dnl because plural.y uses bison specific features. It requires at least
7012   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
7013   dnl compile.
7014   dnl bison is only needed for the maintainer (who touches plural.y). But in
7015   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
7016   dnl the rule in general Makefile. Now, some people carelessly touch the
7017   dnl files or have a broken "make" program, hence the plural.c rule will
7018   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
7019   dnl present or too old.
7020   AC_CHECK_PROGS([INTLBISON], [bison])
7021   if test -z "$INTLBISON"; then
7022     ac_verc_fail=yes
7023   else
7024     dnl Found it, now check the version.
7025     AC_MSG_CHECKING([version of bison])
7026 changequote(<<,>>)dnl
7027     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
7028     case $ac_prog_version in
7029       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
7030       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
7031 changequote([,])dnl
7032          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
7033       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
7034     esac
7035     AC_MSG_RESULT([$ac_prog_version])
7036   fi
7037   if test $ac_verc_fail = yes; then
7038     INTLBISON=:
7039   fi
7040 ])
7041
7042
7043 AC_DEFUN([AM_MKINSTALLDIRS],
7044 [
7045   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
7046   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
7047   dnl Try to locate is.
7048   MKINSTALLDIRS=
7049   if test -n "$ac_aux_dir"; then
7050     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
7051   fi
7052   if test -z "$MKINSTALLDIRS"; then
7053     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
7054   fi
7055   AC_SUBST(MKINSTALLDIRS)
7056 ])
7057
7058
7059 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
7060 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
7061
7062 # progtest.m4 serial 3
7063 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
7064 dnl This file is free software, distributed under the terms of the GNU
7065 dnl General Public License.  As a special exception to the GNU General
7066 dnl Public License, this file may be distributed as part of a program
7067 dnl that contains a configuration script generated by Autoconf, under
7068 dnl the same distribution terms as the rest of that program.
7069 dnl
7070 dnl This file can can be used in projects which are not available under
7071 dnl the GNU General Public License or the GNU Library General Public
7072 dnl License but which still want to provide support for the GNU gettext
7073 dnl functionality.
7074 dnl Please note that the actual code of the GNU gettext library is covered
7075 dnl by the GNU Library General Public License, and the rest of the GNU
7076 dnl gettext package package is covered by the GNU General Public License.
7077 dnl They are *not* in the public domain.
7078
7079 dnl Authors:
7080 dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
7081
7082 # Search path for a program which passes the given test.
7083
7084 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
7085 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
7086 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
7087 [# Extract the first word of "$2", so it can be a program name with args.
7088 set dummy $2; ac_word=[$]2
7089 AC_MSG_CHECKING([for $ac_word])
7090 AC_CACHE_VAL(ac_cv_path_$1,
7091 [case "[$]$1" in
7092   /*)
7093   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
7094   ;;
7095   *)
7096   IFS="${IFS=    }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
7097   for ac_dir in ifelse([$5], , $PATH, [$5]); do
7098     test -z "$ac_dir" && ac_dir=.
7099     if test -f $ac_dir/$ac_word; then
7100       if [$3]; then
7101         ac_cv_path_$1="$ac_dir/$ac_word"
7102         break
7103       fi
7104     fi
7105   done
7106   IFS="$ac_save_ifs"
7107 dnl If no 4th arg is given, leave the cache variable unset,
7108 dnl so AC_PATH_PROGS will keep looking.
7109 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
7110 ])dnl
7111   ;;
7112 esac])dnl
7113 $1="$ac_cv_path_$1"
7114 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
7115   AC_MSG_RESULT([$]$1)
7116 else
7117   AC_MSG_RESULT(no)
7118 fi
7119 AC_SUBST($1)dnl
7120 ])
7121
7122 # intdiv0.m4 serial 1 (gettext-0.11.3)
7123 dnl Copyright (C) 2002 Free Software Foundation, Inc.
7124 dnl This file is free software, distributed under the terms of the GNU
7125 dnl General Public License.  As a special exception to the GNU General
7126 dnl Public License, this file may be distributed as part of a program
7127 dnl that contains a configuration script generated by Autoconf, under
7128 dnl the same distribution terms as the rest of that program.
7129
7130 dnl From Bruno Haible.
7131
7132 AC_DEFUN([gt_INTDIV0],
7133 [
7134   AC_REQUIRE([AC_PROG_CC])dnl
7135   AC_REQUIRE([AC_CANONICAL_HOST])dnl
7136
7137   AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
7138     gt_cv_int_divbyzero_sigfpe,
7139     [
7140       AC_TRY_RUN([
7141 #include <stdlib.h>
7142 #include <signal.h>
7143
7144 static void
7145 #ifdef __cplusplus
7146 sigfpe_handler (int sig)
7147 #else
7148 sigfpe_handler (sig) int sig;
7149 #endif
7150 {
7151   /* Exit with code 0 if SIGFPE, with code 1 if any other signal.  */
7152   exit (sig != SIGFPE);
7153 }
7154
7155 int x = 1;
7156 int y = 0;
7157 int z;
7158 int nan;
7159
7160 int main ()
7161 {
7162   signal (SIGFPE, sigfpe_handler);
7163 /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP.  */
7164 #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
7165   signal (SIGTRAP, sigfpe_handler);
7166 #endif
7167 /* Linux/SPARC yields signal SIGILL.  */
7168 #if defined (__sparc__) && defined (__linux__)
7169   signal (SIGILL, sigfpe_handler);
7170 #endif
7171
7172   z = x / y;
7173   nan = y / y;
7174   exit (1);
7175 }
7176 ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
7177         [
7178           # Guess based on the CPU.
7179           case "$host_cpu" in
7180             alpha* | i[34567]86 | m68k | s390*)
7181               gt_cv_int_divbyzero_sigfpe="guessing yes";;
7182             *)
7183               gt_cv_int_divbyzero_sigfpe="guessing no";;
7184           esac
7185         ])
7186     ])
7187   case "$gt_cv_int_divbyzero_sigfpe" in
7188     *yes) value=1;;
7189     *) value=0;;
7190   esac
7191   AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
7192     [Define if integer division by zero raises signal SIGFPE.])
7193 ])
7194
7195 # lcmessage.m4 serial 3 (gettext-0.11.3)
7196 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
7197 dnl This file is free software, distributed under the terms of the GNU
7198 dnl General Public License.  As a special exception to the GNU General
7199 dnl Public License, this file may be distributed as part of a program
7200 dnl that contains a configuration script generated by Autoconf, under
7201 dnl the same distribution terms as the rest of that program.
7202 dnl
7203 dnl This file can can be used in projects which are not available under
7204 dnl the GNU General Public License or the GNU Library General Public
7205 dnl License but which still want to provide support for the GNU gettext
7206 dnl functionality.
7207 dnl Please note that the actual code of the GNU gettext library is covered
7208 dnl by the GNU Library General Public License, and the rest of the GNU
7209 dnl gettext package package is covered by the GNU General Public License.
7210 dnl They are *not* in the public domain.
7211
7212 dnl Authors:
7213 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
7214
7215 # Check whether LC_MESSAGES is available in <locale.h>.
7216
7217 AC_DEFUN([AM_LC_MESSAGES],
7218 [
7219   AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
7220     [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
7221        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
7222   if test $am_cv_val_LC_MESSAGES = yes; then
7223     AC_DEFINE(HAVE_LC_MESSAGES, 1,
7224       [Define if your <locale.h> file defines LC_MESSAGES.])
7225   fi
7226 ])
7227