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