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