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