*** empty log message ***
[findutils.git] / aclocal.m4
bloba3b7a1e01edebb93dd509ac2db6c906817a794ce
1 # aclocal.m4 generated automatically by aclocal 1.4f
3 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
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.
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.
14 # Like AC_CONFIG_HEADER, but automatically create stamp file.
16 # serial 3
18 # When config.status generates a header, we must update the stamp-h file.
19 # This file resides in the same directory as the config header
20 # that is generated.  We must strip everything past the first ":",
21 # and everything past the last "/".
23 AC_PREREQ([2.12])
25 AC_DEFUN([AM_CONFIG_HEADER],
26 [AC_CONFIG_HEADER([$1])
27   AC_OUTPUT_COMMANDS(
28    ifelse(patsubst([$1], [[^ ]], []),
29           [],
30           [test -z "$CONFIG_HEADERS" || echo timestamp >dnl
31            patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),
32   [am_indx=1
33   for am_file in $1; do
34     case " $CONFIG_HEADERS " in
35     *" $am_file "*)
36       echo timestamp > `echo $am_file | sed 's%:.*%%;s%[^/]*$%%'`stamp-h$am_indx
37       ;;
38     esac
39     am_indx=\`expr \$am_indx + 1\`
40   done])
43 # Do all the work for Automake.  This macro actually does too much --
44 # some checks are only needed if your package does certain things.
45 # But this isn't really a big deal.
47 # serial 5
49 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
50 # written in clear, in which case automake, when reading aclocal.m4,
51 # will think it sees a *use*, and therefore will trigger all it's
52 # C support machinery.  Also note that it means that autoscan, seeing
53 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
56 # We require 2.13 because we rely on SHELL being computed by configure.
57 AC_PREREQ([2.13])
59 # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
60 # -----------------------------------------------------------
61 # If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED.
62 # The purpose of this macro is to provide the user with a means to
63 # check macros which are provided without letting her know how the
64 # information is coded.
65 # If this macro is not defined by Autoconf, define it here.
66 ifdef([AC_PROVIDE_IFELSE],
67       [],
68       [define([AC_PROVIDE_IFELSE],
69               [ifdef([AC_PROVIDE_$1],
70                      [$2], [$3])])])
73 # AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE])
74 # ----------------------------------------------
75 AC_DEFUN([AM_INIT_AUTOMAKE],
76 [AC_REQUIRE([AC_PROG_INSTALL])dnl
77 # test to see if srcdir already configured
78 if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" &&
79    test -f $srcdir/config.status; then
80   AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first])
83 # Define the identity of the package.
84 PACKAGE=$1
85 AC_SUBST(PACKAGE)dnl
86 VERSION=$2
87 AC_SUBST(VERSION)dnl
88 ifelse([$3],,
89 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
90 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])
92 # Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
93 # the ones we care about.
94 ifdef([m4_pattern_allow],
95       [m4_pattern_allow([^AM_(C|CPP|CXX|OBJC|F|R|GCJ)FLAGS])])dnl
97 # Some tools Automake needs.
98 AC_REQUIRE([AM_SANITY_CHECK])dnl
99 AC_REQUIRE([AC_ARG_PROGRAM])dnl
100 AM_MISSING_PROG(ACLOCAL, aclocal)
101 AM_MISSING_PROG(AUTOCONF, autoconf)
102 AM_MISSING_PROG(AUTOMAKE, automake)
103 AM_MISSING_PROG(AUTOHEADER, autoheader)
104 AM_MISSING_PROG(MAKEINFO, makeinfo)
105 AM_MISSING_PROG(AMTAR, tar)
106 AM_MISSING_INSTALL_SH
107 AM_PROG_INSTALL_STRIP
108 # We need awk for the "check" target.  The system "awk" is bad on
109 # some platforms.
110 AC_REQUIRE([AC_PROG_AWK])dnl
111 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
112 AC_REQUIRE([AM_DEP_TRACK])dnl
113 AC_REQUIRE([AM_SET_DEPDIR])dnl
114 AC_PROVIDE_IFELSE([AC_PROG_][CC],
115                   [AM_DEPENDENCIES(CC)],
116                   [define([AC_PROG_][CC],
117                           defn([AC_PROG_][CC])[AM_DEPENDENCIES(CC)])])dnl
118 AC_PROVIDE_IFELSE([AC_PROG_][CXX],
119                   [AM_DEPENDENCIES(CXX)],
120                   [define([AC_PROG_][CXX],
121                           defn([AC_PROG_][CXX])[AM_DEPENDENCIES(CXX)])])dnl
125 # Check to make sure that the build environment is sane.
128 # serial 3
130 # AM_SANITY_CHECK
131 # ---------------
132 AC_DEFUN([AM_SANITY_CHECK],
133 [AC_MSG_CHECKING([whether build environment is sane])
134 # Just in case
135 sleep 1
136 echo timestamp > conftest.file
137 # Do `set' in a subshell so we don't clobber the current shell's
138 # arguments.  Must try -L first in case configure is actually a
139 # symlink; some systems play weird games with the mod time of symlinks
140 # (eg FreeBSD returns the mod time of the symlink's containing
141 # directory).
142 if (
143    set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
144    if test "$[*]" = "X"; then
145       # -L didn't work.
146       set X `ls -t $srcdir/configure conftest.file`
147    fi
148    rm -f conftest.file
149    if test "$[*]" != "X $srcdir/configure conftest.file" \
150       && test "$[*]" != "X conftest.file $srcdir/configure"; then
152       # If neither matched, then we have a broken ls.  This can happen
153       # if, for instance, CONFIG_SHELL is bash and it inherits a
154       # broken ls alias from the environment.  This has actually
155       # happened.  Such a system could not be considered "sane".
156       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
157 alias in your environment])
158    fi
160    test "$[2]" = conftest.file
161    )
162 then
163    # Ok.
164    :
165 else
166    AC_MSG_ERROR([newly created file is older than distributed files!
167 Check your system clock])
169 AC_MSG_RESULT(yes)])
172 # serial 2
174 # AM_MISSING_PROG(NAME, PROGRAM)
175 # ------------------------------
176 AC_DEFUN([AM_MISSING_PROG],
177 [AC_REQUIRE([AM_MISSING_HAS_RUN])
178 $1=${$1-"${am_missing_run}$2"}
179 AC_SUBST($1)])
182 # AM_MISSING_INSTALL_SH
183 # ---------------------
184 # Like AM_MISSING_PROG, but only looks for install-sh.
185 AC_DEFUN([AM_MISSING_INSTALL_SH],
186 [AC_REQUIRE([AM_MISSING_HAS_RUN])
187 if test -z "$install_sh"; then
188    for install_sh in "$ac_aux_dir/install-sh" \
189                      "$ac_aux_dir/install.sh" \
190                      "${am_missing_run}${ac_auxdir}/install-sh";
191    do
192      test -f "$install_sh" && break
193    done
194    # FIXME: an evil hack: we remove the SHELL invocation from
195    # install_sh because automake adds it back in.  Sigh.
196    install_sh=`echo $install_sh | sed -e 's/\${SHELL}//'`
198 AC_SUBST(install_sh)])
201 # AM_MISSING_HAS_RUN
202 # ------------------
203 # Define MISSING if not defined so far and test if it supports --run.
204 # If it does, set am_missing_run to use it, otherwise, to nothing.
205 AC_DEFUN([AM_MISSING_HAS_RUN],
206 [test x"${MISSING+set}" = xset ||
207   MISSING="\${SHELL} `CDPATH=:; cd $ac_aux_dir && pwd`/missing"
208 # Use eval to expand $SHELL
209 if eval "$MISSING --run true"; then
210   am_missing_run="$MISSING --run "
211 else
212   am_missing_run=
213   am_backtick='`'
214   AC_MSG_WARN([${am_backtick}missing' script is too old or missing])
218 # AM_AUX_DIR_EXPAND
220 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
221 # $ac_aux_dir to ${srcdir}/foo.  In other projects, it is set to `.'.
222 # Of course, Automake must honor this variable whenever it call a tool
223 # from the auxiliary directory.  The problem is that $srcdir (hence
224 # $ac_aux_dir) can be either an absolute path or a path relative to
225 # $top_srcdir or absolute, this depends on how configure is run.  This
226 # is pretty anoying since it makes $ac_aux_dir quite unusable in
227 # subdirectories: on the top source directory, any form will work
228 # fine, but in subdirectories relative pat needs to be adapted.
229 # - calling $top_srcidr/$ac_aux_dir/missing would success if $srcdir is
230 #   relative, but fail if $srcdir is absolute
231 # - conversly, calling $ax_aux_dir/missing would fail if $srcdir is
232 #   absolute, and success on relative paths.
234 # Consequently, we define and use $am_aux_dir, the "always absolute"
235 # version of $ac_aux_dir.
237 AC_DEFUN([AM_AUX_DIR_EXPAND], [
238 # expand $ac_aux_dir to an absolute path
239 am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd`
242 # One issue with vendor `install' (even GNU) is that you can't
243 # specify the program used to strip binaries.  This is especially
244 # annoying in cross-compiling environments, where the build's strip
245 # is unlikely to handle the host's binaries.
246 # Fortunately install-sh will honor a STRIPPROG variable, so we
247 # always use install-sh in `make install-strip', and initialize
248 # STRIPPROG with the value of the STRIP variable (set by the user).
249 AC_DEFUN([AM_PROG_INSTALL_STRIP],
250 [AC_REQUIRE([AM_MISSING_INSTALL_SH])dnl
251 _am_dirpart="`echo $install_sh | sed -e 's,//*[[^/]]*$,,'`"
252 INSTALL_STRIP_PROGRAM="\${SHELL} \`CDPATH=: && cd $_am_dirpart && pwd\`/install-sh -c -s"
253 AC_SUBST([INSTALL_STRIP_PROGRAM])])
255 # serial 3
257 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
258 # written in clear, in which case automake, when reading aclocal.m4,
259 # will think it sees a *use*, and therefore will trigger all it's
260 # C support machinery.  Also note that it means that autoscan, seeing
261 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
263 # AM_DEPENDENCIES(NAME)
264 # ---------------------
265 # See how the compiler implements dependency checking.
266 # NAME is "CC", "CXX" or "OBJC".
267 # We try a few techniques and use that to set a single cache variable.
268 AC_DEFUN([AM_DEPENDENCIES],
269 [AC_REQUIRE([AM_SET_DEPDIR])dnl
270 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
271 am_compiler_list=
272 ifelse([$1], CC,
273        [AC_REQUIRE([AC_PROG_][CC])dnl
274 AC_REQUIRE([AC_PROG_][CPP])
275 depcc="$CC"
276 depcpp="$CPP"],
277        [$1], CXX, [AC_REQUIRE([AC_PROG_][CXX])dnl
278 AC_REQUIRE([AC_PROG_][CXXCPP])
279 depcc="$CXX"
280 depcpp="$CXXCPP"],
281        [$1], OBJC, [am_compiler_list='gcc3 gcc'
282 depcc="$OBJC"
283 depcpp=""],
284        [$1], GCJ,  [am_compiler_list='gcc3 gcc'
285 depcc="$GCJ"
286 depcpp=""],
287        [AC_REQUIRE([AC_PROG_][$1])dnl
288 depcc="$$1"
289 depcpp=""])
291 AC_REQUIRE([AM_MAKE_INCLUDE])
292 AC_REQUIRE([AM_DEP_TRACK])
294 AC_CACHE_CHECK([dependency style of $depcc],
295                [am_cv_$1_dependencies_compiler_type],
296 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
297   # We make a subdir and do the tests there.  Otherwise we can end up
298   # making bogus files that we don't know about and never remove.  For
299   # instance it was reported that on HP-UX the gcc test will end up
300   # making a dummy file named `D' -- because `-MD' means `put the output
301   # in D'.
302   mkdir confdir
303   # Copy depcomp to subdir because otherwise we won't find it if we're
304   # using a relative directory.
305   cp "$am_depcomp" confdir
306   cd confdir
308   am_cv_$1_dependencies_compiler_type=none
309   if test "$am_compiler_list" = ""; then
310      am_compiler_list="`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`"
311   fi
312   for depmode in $am_compiler_list; do
313     # We need to recreate these files for each test, as the compiler may
314     # overwrite some of them when testing with obscure command lines.
315     # This happens at least with the AIX C compiler.
316     echo '#include "conftest.h"' > conftest.c
317     echo 'int i;' > conftest.h
319     case "$depmode" in
320     nosideeffect)
321       # after this tag, mechanisms are not by side-effect, so they'll
322       # only be used when explicitly requested
323       if test "x$enable_dependency_tracking" = xyes; then
324         continue
325       else
326         break
327       fi
328       ;;
329     none) break ;;
330     esac
331     # We check with `-c' and `-o' for the sake of the "dashmstdout"
332     # mode.  It turns out that the SunPro C++ compiler does not properly
333     # handle `-M -o', and we need to detect this.
334     if depmode="$depmode" \
335        source=conftest.c object=conftest.o \
336        depfile=conftest.Po tmpdepfile=conftest.TPo \
337        $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 &&
338        grep conftest.h conftest.Po > /dev/null 2>&1; then
339       am_cv_$1_dependencies_compiler_type="$depmode"
340       break
341     fi
342   done
344   cd ..
345   rm -rf confdir
346 else
347   am_cv_$1_dependencies_compiler_type=none
350 $1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type"
351 AC_SUBST([$1DEPMODE])
355 # AM_SET_DEPDIR
356 # -------------
357 # Choose a directory name for dependency files.
358 # This macro is AC_REQUIREd in AM_DEPENDENCIES
359 AC_DEFUN([AM_SET_DEPDIR],
360 [if test -d .deps || mkdir .deps 2> /dev/null || test -d .deps; then
361   DEPDIR=.deps
362   # We redirect because .deps might already exist and be populated.
363   # In this situation we don't want to see an error.
364   rmdir .deps > /dev/null 2>&1
365 else
366   DEPDIR=_deps
368 AC_SUBST(DEPDIR)
372 # AM_DEP_TRACK
373 # ------------
374 AC_DEFUN([AM_DEP_TRACK],
375 [AC_ARG_ENABLE(dependency-tracking,
376 [  --disable-dependency-tracking Speeds up one-time builds
377   --enable-dependency-tracking  Do not reject slow dependency extractors])
378 if test "x$enable_dependency_tracking" != xno; then
379   am_depcomp="$ac_aux_dir/depcomp"
380   AMDEPBACKSLASH='\'
382 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
383 pushdef([subst], defn([AC_SUBST]))
384 subst(AMDEPBACKSLASH)
385 popdef([subst])
388 # Generate code to set up dependency tracking.
389 # This macro should only be invoked once -- use via AC_REQUIRE.
390 # Usage:
391 # AM_OUTPUT_DEPENDENCY_COMMANDS
394 # This code is only required when automatic dependency tracking
395 # is enabled.  FIXME.  This creates each `.P' file that we will
396 # need in order to bootstrap the dependency handling code.
397 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[
398 AC_OUTPUT_COMMANDS([
399 test x"$AMDEP_TRUE" != x"" ||
400 for mf in $CONFIG_FILES; do
401   case "$mf" in
402   Makefile) dirpart=.;;
403   */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;;
404   *) continue;;
405   esac
406   grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
407   # Extract the definition of DEP_FILES from the Makefile without
408   # running `make'.
409   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
410   test -z "$DEPDIR" && continue
411   # When using ansi2knr, U may be empty or an underscore; expand it
412   U=`sed -n -e '/^U = / s///p' < "$mf"`
413   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
414   # We invoke sed twice because it is the simplest approach to
415   # changing $(DEPDIR) to its actual value in the expansion.
416   for file in `sed -n -e '
417     /^DEP_FILES = .*\\\\$/ {
418       s/^DEP_FILES = //
419       :loop
420         s/\\\\$//
421         p
422         n
423         /\\\\$/ b loop
424       p
425     }
426     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
427        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
428     # Make sure the directory exists.
429     test -f "$dirpart/$file" && continue
430     fdir=`echo "$file" | sed -e 's|/[^/]*$||'`
431     $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1
432     # echo "creating $dirpart/$file"
433     echo '# dummy' > "$dirpart/$file"
434   done
435 done
436 ], [AMDEP_TRUE="$AMDEP_TRUE"
437 ac_aux_dir="$ac_aux_dir"])])
439 # AM_MAKE_INCLUDE()
440 # -----------------
441 # Check to see how make treats includes.
442 AC_DEFUN([AM_MAKE_INCLUDE],
443 [am_make=${MAKE-make}
444 cat > confinc << 'END'
445 doit:
446         @echo done
448 # If we don't find an include directive, just comment out the code.
449 AC_MSG_CHECKING([for style of include used by $am_make])
450 _am_include='#'
451 _am_quote=
452 _am_result=none
453 # First try GNU make style include.
454 echo "include confinc" > confmf
455 # We grep out `Entering directory' and `Leaving directory'
456 # messages which can occur if `w' ends up in MAKEFLAGS.
457 # In particular we don't look at `^make:' because GNU make might
458 # be invoked under some other name (usually "gmake"), in which
459 # case it prints its new name instead of `make'.
460 if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then
461    _am_include=include
462    _am_quote=
463    _am_result=GNU
465 # Now try BSD make style include.
466 if test "$_am_include" = "#"; then
467    echo '.include "confinc"' > confmf
468    if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
469       _am_include=.include
470       _am_quote='"'
471       _am_result=BSD
472    fi
474 AC_SUBST(_am_include)
475 AC_SUBST(_am_quote)
476 AC_MSG_RESULT($_am_result)
477 rm -f confinc confmf
480 # serial 3
482 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
483 # -------------------------------------
484 # Define a conditional.
486 # FIXME: Once using 2.50, use this:
487 # m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl
488 AC_DEFUN([AM_CONDITIONAL],
489 [ifelse([$1], [TRUE],
490         [errprint(__file__:__line__: [$0: invalid condition: $1
491 ])dnl
492 m4exit(1)])dnl
493 ifelse([$1], [FALSE],
494        [errprint(__file__:__line__: [$0: invalid condition: $1
495 ])dnl
496 m4exit(1)])dnl
497 AC_SUBST([$1_TRUE])
498 AC_SUBST([$1_FALSE])
499 if $2; then
500   $1_TRUE=
501   $1_FALSE='#'
502 else
503   $1_TRUE='#'
504   $1_FALSE=
505 fi])
507 #serial 1
508 dnl This test replaces the one in autoconf.
509 dnl Currently this macro should have the same name as the autoconf macro
510 dnl because gettext's gettext.m4 (distributed in the automake package)
511 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
512 dnl give these diagnostics:
513 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
514 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
516 undefine([AC_ISC_POSIX])
517 AC_DEFUN(AC_ISC_POSIX,
518   [
519     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
520     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
521   ]
525 # serial 1
527 AC_DEFUN([AM_C_PROTOTYPES],
528 [AC_REQUIRE([AM_PROG_CC_STDC])
529 AC_REQUIRE([AC_PROG_CPP])
530 AC_MSG_CHECKING([for function prototypes])
531 if test "$am_cv_prog_cc_stdc" != no; then
532   AC_MSG_RESULT(yes)
533   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
534   U= ANSI2KNR=
535 else
536   AC_MSG_RESULT(no)
537   U=_ ANSI2KNR=./ansi2knr
539 # Ensure some checks needed by ansi2knr itself.
540 AC_HEADER_STDC
541 AC_CHECK_HEADERS(string.h)
542 AC_SUBST(U)dnl
543 AC_SUBST(ANSI2KNR)dnl
547 # serial 1
549 # @defmac AC_PROG_CC_STDC
550 # @maindex PROG_CC_STDC
551 # @ovindex CC
552 # If the C compiler in not in ANSI C mode by default, try to add an option
553 # to output variable @code{CC} to make it so.  This macro tries various
554 # options that select ANSI C on some system or another.  It considers the
555 # compiler to be in ANSI C mode if it handles function prototypes correctly.
557 # If you use this macro, you should check after calling it whether the C
558 # compiler has been set to accept ANSI C; if not, the shell variable
559 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
560 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
561 # program @code{ansi2knr}, which comes with Ghostscript.
562 # @end defmac
564 AC_DEFUN([AM_PROG_CC_STDC],
565 [AC_REQUIRE([AC_PROG_CC])
566 AC_BEFORE([$0], [AC_C_INLINE])
567 AC_BEFORE([$0], [AC_C_CONST])
568 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
569 dnl a magic option to avoid problems with ANSI preprocessor commands
570 dnl like #elif.
571 dnl FIXME: can't do this because then AC_AIX won't work due to a
572 dnl circular dependency.
573 dnl AC_BEFORE([$0], [AC_PROG_CPP])
574 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
575 AC_CACHE_VAL(am_cv_prog_cc_stdc,
576 [am_cv_prog_cc_stdc=no
577 ac_save_CC="$CC"
578 # Don't try gcc -ansi; that turns off useful extensions and
579 # breaks some systems' header files.
580 # AIX                   -qlanglvl=ansi
581 # Ultrix and OSF/1      -std1
582 # HP-UX 10.20 and later -Ae
583 # HP-UX older versions  -Aa -D_HPUX_SOURCE
584 # SVR4                  -Xc -D__EXTENSIONS__
585 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
587   CC="$ac_save_CC $ac_arg"
588   AC_TRY_COMPILE(
589 [#include <stdarg.h>
590 #include <stdio.h>
591 #include <sys/types.h>
592 #include <sys/stat.h>
593 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
594 struct buf { int x; };
595 FILE * (*rcsopen) (struct buf *, struct stat *, int);
596 static char *e (p, i)
597      char **p;
598      int i;
600   return p[i];
602 static char *f (char * (*g) (char **, int), char **p, ...)
604   char *s;
605   va_list v;
606   va_start (v,p);
607   s = g (p, va_arg (v,int));
608   va_end (v);
609   return s;
611 int test (int i, double x);
612 struct s1 {int (*f) (int a);};
613 struct s2 {int (*f) (double a);};
614 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
615 int argc;
616 char **argv;
617 ], [
618 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
620 [am_cv_prog_cc_stdc="$ac_arg"; break])
621 done
622 CC="$ac_save_CC"
624 if test -z "$am_cv_prog_cc_stdc"; then
625   AC_MSG_RESULT([none needed])
626 else
627   AC_MSG_RESULT([$am_cv_prog_cc_stdc])
629 case "x$am_cv_prog_cc_stdc" in
630   x|xno) ;;
631   *) CC="$CC $am_cv_prog_cc_stdc" ;;
632 esac
635 #serial 13, with several lines deleted for fileutils.
637 dnl Misc type-related macros for fileutils, sh-utils, textutils.
639 AC_DEFUN(jm_MACROS,
641   AC_PREREQ(2.14a)
643   GNU_PACKAGE="GNU $PACKAGE"
644   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
645     [The concatenation of the strings `GNU ', and PACKAGE.])
646   AC_SUBST(GNU_PACKAGE)
648   AC_SUBST(OPTIONAL_BIN_PROGS)
649   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
650   AC_SUBST(MAN)
651   AC_SUBST(DF_PROG)
653   dnl This macro actually runs replacement code.  See isc-posix.m4.
654   AC_REQUIRE([AC_ISC_POSIX])dnl
656   AC_CHECK_HEADERS( \
657     errno.h  \
658     fcntl.h \
659     fenv.h \
660     float.h \
661     limits.h \
662     memory.h \
663     mntent.h \
664     mnttab.h \
665     netdb.h \
666     paths.h \
667     stdlib.h \
668     stddef.h \
669     string.h \
670     sys/acl.h \
671     sys/filsys.h \
672     sys/fs/s5param.h \
673     sys/fs_types.h \
674     sys/fstyp.h \
675     sys/ioctl.h \
676     sys/mntent.h \
677     sys/mount.h \
678     sys/param.h \
679     sys/socket.h \
680     sys/statfs.h \
681     sys/statvfs.h \
682     sys/systeminfo.h \
683     sys/time.h \
684     sys/timeb.h \
685     sys/vfs.h \
686     sys/wait.h \
687     syslog.h \
688     termios.h \
689     unistd.h \
690     values.h \
691   )
693   jm_INCLUDED_REGEX([lib/regex.c])
695   AC_REQUIRE([jm_ASSERT])
696   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
697   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
698   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
699   AC_REQUIRE([jm_CHECK_DECLS])
701   AC_REQUIRE([jm_PREREQ])
703   AC_REQUIRE([jm_FUNC_MKTIME])
704   AC_REQUIRE([jm_FUNC_LSTAT])
705   AC_REQUIRE([jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
706   AC_REQUIRE([jm_FUNC_STAT])
707   AC_REQUIRE([jm_FUNC_REALLOC])
708   AC_REQUIRE([jm_FUNC_MALLOC])
709   AC_REQUIRE([AC_FUNC_STRERROR_R])
710   AC_REQUIRE([jm_FUNC_READDIR])
711   AC_REQUIRE([jm_FUNC_MEMCMP])
712   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
713   AC_REQUIRE([kd_FUNC_FNMATCH_CASE_RPL])
714   AC_REQUIRE([jm_AFS])
715   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
716   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
717   AC_REQUIRE([AM_FUNC_ERROR_AT_LINE])
718   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
719   AC_REQUIRE([jm_FUNC_MKTIME])
721   AC_REQUIRE([AC_FUNC_VPRINTF])
722   AC_REQUIRE([AC_FUNC_ALLOCA])
724   AC_REPLACE_FUNCS(strncasecmp)
725   AC_REPLACE_FUNCS(stpcpy strstr strtol strtoul)
726   AC_REPLACE_FUNCS(memcmp rpmatch)
728   dnl used by e.g. intl/*domain.c and lib/canon-host.c
729   AC_REPLACE_FUNCS(strdup)
731   AC_REPLACE_FUNCS(memcpy memset)
732   AC_CHECK_FUNCS(getpagesize)
734   # By default, argmatch should fail calling usage (1).
735   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
736             [Define to the function xargmatch calls on failures.])
737   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
738             [Define to the declaration of the xargmatch failure function.])
740   dnl Used to define SETVBUF in sys2.h.
741   dnl This evokes the following warning from autoconf:
742   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
743   AC_FUNC_SETVBUF_REVERSED
745   AC_CHECK_FUNCS(getdelim)
747   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
749   AC_CHECK_FUNCS( \
750     acl \
751     bcopy \
752     endgrent \
753     endpwent \
754     fchdir \
755     fdatasync \
756     fseeko \
757     ftime \
758     getcwd \
759     gethrtime \
760     getmntinfo \
761     hasmntopt \
762     isascii \
763     listmntent \
764     localeconv \
765     memcpy \
766     mempcpy \
767     mkfifo \
768     realpath \
769     resolvepath \
770     sethostname \
771     strchr \
772     strerror \
773     strrchr \
774     sysinfo \
775     tzset \
776   )
778   AM_FUNC_GETLINE
779   if test $am_cv_func_working_getline != yes; then
780     AC_CHECK_FUNCS(getdelim)
781   fi
783   jm_GLIBC21
784   jm_ICONV
786   # These tests are for df.
787   jm_FSTYPENAME
791 AC_DEFUN(jm_CHECK_ALL_TYPES,
793   dnl Checks for typedefs, structures, and compiler characteristics.
794   AC_REQUIRE([AC_C_BIGENDIAN])
795   AC_REQUIRE([AC_PROG_CC_STDC])
796   AC_REQUIRE([AC_C_CONST])
797   AC_REQUIRE([AC_C_VOLATILE])
798   AC_REQUIRE([AC_C_INLINE])
799   AC_REQUIRE([AC_C_LONG_DOUBLE])
801   AC_REQUIRE([AC_HEADER_DIRENT])
802   AC_REQUIRE([AC_HEADER_STDC])
803   AC_CHECK_MEMBERS([struct stat.st_blksize],,,[$ac_includes_default
804 #include <sys/stat.h>
805   ])
806   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
808   AC_REQUIRE([AC_STRUCT_TM])
809   AC_REQUIRE([AC_STRUCT_TIMEZONE])
810   AC_REQUIRE([AC_HEADER_STAT])
811   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
812   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
813   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
815   AC_REQUIRE([AC_TYPE_GETGROUPS])
816   AC_REQUIRE([AC_TYPE_MODE_T])
817   AC_REQUIRE([AC_TYPE_OFF_T])
818   AC_REQUIRE([AC_TYPE_PID_T])
819   AC_REQUIRE([AC_TYPE_SIGNAL])
820   AC_REQUIRE([AC_TYPE_SIZE_T])
821   AC_REQUIRE([AC_TYPE_UID_T])
822   AC_CHECK_TYPE(ino_t, unsigned long)
824   dnl This relies on the fact that autoconf 2.14a's implementation of
825   dnl AC_CHECK_TYPE checks includes unistd.h.
826   AC_CHECK_TYPE(ssize_t, int)
828   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
829   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
831   AC_REQUIRE([AC_HEADER_MAJOR])
832   AC_REQUIRE([AC_HEADER_DIRENT])
836 #serial 7
838 dnl Initially derived from code in GNU grep.
839 dnl Mostly written by Jim Meyering.
841 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
843 AC_DEFUN(jm_INCLUDED_REGEX,
844   [
845     dnl Even packages that don't use regex.c can use this macro.
846     dnl Of course, for them it doesn't do anything.
848     # Assume we'll default to using the included regex.c.
849     ac_use_included_regex=yes
851     # However, if the system regex support is good enough that it passes the
852     # the following run test, then default to *not* using the included regex.c.
853     # If cross compiling, assume the test would fail and use the included
854     # regex.c.  The first failing regular expression is from `Spencer ere
855     # test #75' in grep-2.3.
856     AC_CACHE_CHECK([for working re_compile_pattern],
857                    jm_cv_func_working_re_compile_pattern,
858       AC_TRY_RUN(
859 [#include <stdio.h>
860 #include <regex.h>
861           int
862           main ()
863           {
864             static struct re_pattern_buffer regex;
865             const char *s;
866             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
867             /* Add this third left square bracket, [, to balance the
868                three right ones below.  Otherwise autoconf-2.14 chokes.  */
869             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
870             /* This should fail with _Invalid character class name_ error.  */
871             if (!s)
872               exit (1);
874             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
875             s = re_compile_pattern ("{1", 2, &regex);
877             exit (s ? 1 : 0);
878           }
879         ],
880                jm_cv_func_working_re_compile_pattern=yes,
881                jm_cv_func_working_re_compile_pattern=no,
882                dnl When crosscompiling, assume it's broken.
883                jm_cv_func_working_re_compile_pattern=no))
884     if test $jm_cv_func_working_re_compile_pattern = yes; then
885       ac_use_included_regex=no
886     fi
888     test -n "$1" || AC_MSG_ERROR([missing argument])
889     syscmd([test -f $1])
890     ifelse(sysval, 0,
891       [
893         AC_ARG_WITH(included-regex,
894         [  --without-included-regex don't compile regex; this is the default on
895                           systems with version 2 of the GNU C library
896                           (use with caution on other system)],
897                     jm_with_regex=$withval,
898                     jm_with_regex=$ac_use_included_regex)
899         if test "$jm_with_regex" = yes; then
900           AC_SUBST(LIBOBJS)
901           LIBOBJS="$LIBOBJS regex.$ac_objext"
902         fi
903       ],
904     )
905   ]
908 #serial 2
909 dnl based on code from Eleftherios Gkioulekas
911 AC_DEFUN(jm_ASSERT,
913   AC_MSG_CHECKING(whether to enable assertions)
914   AC_ARG_ENABLE(assert,
915         [  --disable-assert        turn off assertions],
916         [ AC_MSG_RESULT(no)
917           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
918         [ AC_MSG_RESULT(yes) ]
919                )
922 #serial 3
924 dnl From Paul Eggert.
926 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
927 # doesn't clash with <sys/types.h>, and declares uintmax_t.
929 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
931   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
932   [AC_TRY_COMPILE(
933     [#include <sys/types.h>
934 #include <inttypes.h>],
935     [uintmax_t i = (uintmax_t) -1;],
936     jm_ac_cv_header_inttypes_h=yes,
937     jm_ac_cv_header_inttypes_h=no)])
938   if test $jm_ac_cv_header_inttypes_h = yes; then
939     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
940 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
941    and declares uintmax_t. ])
942   fi
945 #serial 3
947 dnl From Jim Meyering.
949 dnl Check whether struct dirent has a member named d_type.
952 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
953   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
954    AC_CACHE_CHECK([for d_type member in directory struct],
955                   jm_cv_struct_dirent_d_type,
956      [AC_TRY_LINK(dnl
957        [
958 #include <sys/types.h>
959 #ifdef HAVE_DIRENT_H
960 # include <dirent.h>
961 #else /* not HAVE_DIRENT_H */
962 # define dirent direct
963 # ifdef HAVE_SYS_NDIR_H
964 #  include <sys/ndir.h>
965 # endif /* HAVE_SYS_NDIR_H */
966 # ifdef HAVE_SYS_DIR_H
967 #  include <sys/dir.h>
968 # endif /* HAVE_SYS_DIR_H */
969 # ifdef HAVE_NDIR_H
970 #  include <ndir.h>
971 # endif /* HAVE_NDIR_H */
972 #endif /* HAVE_DIRENT_H */
973        ],
974        [struct dirent dp; dp.d_type = 0;],
976        jm_cv_struct_dirent_d_type=yes,
977        jm_cv_struct_dirent_d_type=no)
978      ]
979    )
980    if test $jm_cv_struct_dirent_d_type = yes; then
981      AC_DEFINE(D_TYPE_IN_DIRENT, 1,
982   [Define if there is a member named d_type in the struct describing
983    directory headers.])
984    fi
985   ]
988 #serial 3
990 dnl From Jim Meyering.
992 dnl Check whether struct dirent has a member named d_ino.
995 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
996   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
997    AC_CACHE_CHECK([for d_ino member in directory struct],
998                   jm_cv_struct_dirent_d_ino,
999      [AC_TRY_LINK(dnl
1000        [
1001 #include <sys/types.h>
1002 #ifdef HAVE_DIRENT_H
1003 # include <dirent.h>
1004 #else /* not HAVE_DIRENT_H */
1005 # define dirent direct
1006 # ifdef HAVE_SYS_NDIR_H
1007 #  include <sys/ndir.h>
1008 # endif /* HAVE_SYS_NDIR_H */
1009 # ifdef HAVE_SYS_DIR_H
1010 #  include <sys/dir.h>
1011 # endif /* HAVE_SYS_DIR_H */
1012 # ifdef HAVE_NDIR_H
1013 #  include <ndir.h>
1014 # endif /* HAVE_NDIR_H */
1015 #endif /* HAVE_DIRENT_H */
1016        ],
1017        [struct dirent dp; dp.d_ino = 0;],
1019        jm_cv_struct_dirent_d_ino=yes,
1020        jm_cv_struct_dirent_d_ino=no)
1021      ]
1022    )
1023    if test $jm_cv_struct_dirent_d_ino = yes; then
1024      AC_DEFINE(D_INO_IN_DIRENT, 1,
1025   [Define if there is a member named d_ino in the struct describing
1026    directory headers.])
1027    fi
1028   ]
1031 #serial 16
1033 dnl This is just a wrapper function to encapsulate this kludge.
1034 dnl Putting it in a separate file like this helps share it between
1035 dnl different packages.
1036 AC_DEFUN(jm_CHECK_DECLS,
1038   AC_REQUIRE([_jm_DECL_HEADERS])
1039   AC_REQUIRE([AC_HEADER_TIME])
1040   headers='
1041 #include <stdio.h>
1042 #if HAVE_STRING_H
1043 # if !STDC_HEADERS && HAVE_MEMORY_H
1044 #  include <memory.h>
1045 # endif
1046 # include <string.h>
1047 #else
1048 # if HAVE_STRINGS_H
1049 #  include <strings.h>
1050 # endif
1051 #endif
1052 #if HAVE_STDLIB_H
1053 # include <stdlib.h>
1054 #endif
1055 #if HAVE_UNISTD_H
1056 # include <unistd.h>
1057 #endif
1059 #include <sys/types.h>
1060 #if TIME_WITH_SYS_TIME
1061 # include <sys/time.h>
1062 # include <time.h>
1063 #else
1064 # if HAVE_SYS_TIME_H
1065 #  include <sys/time.h>
1066 # else
1067 #  include <time.h>
1068 # endif
1069 #endif
1071 #if HAVE_UTMP_H
1072 # include <utmp.h>
1073 #endif
1076   AC_CHECK_DECLS([
1077     free,
1078     getenv,
1079     geteuid,
1080     getgrgid,
1081     getlogin,
1082     getpwuid,
1083     getuid,
1084     getutent,
1085     lseek,
1086     malloc,
1087     memchr,
1088     memrchr,
1089     realloc,
1090     stpcpy,
1091     strndup,
1092     strnlen,
1093     strstr,
1094     strtoul,
1095     strtoull,
1096     ttyname], , , $headers)
1099 dnl FIXME: when autoconf has support for it.
1100 dnl This is a little helper so we can require these header checks.
1101 AC_DEFUN(_jm_DECL_HEADERS,
1103   AC_REQUIRE([AC_HEADER_STDC])
1104   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
1105                    utmp.h utmpx.h)
1108 #serial 5
1110 dnl These are the prerequisite macros for files in the lib/
1111 dnl directories of the fileutils, sh-utils, and textutils packages.
1113 AC_DEFUN(jm_PREREQ,
1115   jm_PREREQ_ADDEXT
1116   jm_PREREQ_CANON_HOST
1117   jm_PREREQ_ERROR
1118   jm_PREREQ_QUOTEARG
1119   jm_PREREQ_READUTMP
1120   jm_PREREQ_REGEX
1123 AC_DEFUN(jm_PREREQ_ADDEXT,
1125   dnl For addext.c.
1126   AC_SYS_LONG_FILE_NAMES
1127   AC_CHECK_FUNCS(pathconf)
1128   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1131 AC_DEFUN(jm_PREREQ_CANON_HOST,
1133   dnl Add any libraries as early as possible.
1134   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1135   dnl so we have to add -lnsl to LIBS before checking for that function.
1136   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1138   dnl These come from -lnsl on Solaris5.5.1.
1139   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1141   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1142   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1143                    netinet/in.h arpa/inet.h)
1146 AC_DEFUN(jm_PREREQ_QUOTEARG,
1148   AC_CHECK_FUNCS(isascii iswprint mbrtowc)
1149   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
1150   AC_HEADER_STDC
1151   AC_C_BACKSLASH_A
1152   AC_MBSTATE_T_OBJECT
1153   AM_C_PROTOTYPES
1156 AC_DEFUN(jm_PREREQ_READUTMP,
1158   AC_HEADER_STDC
1159   AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
1160   AC_CHECK_FUNCS(utmpname)
1161   AC_CHECK_FUNCS(utmpxname)
1162   AM_C_PROTOTYPES
1164   utmp_includes="\
1165 $ac_includes_default
1166 #ifdef HAVE_UTMPX_H
1167 # include <utmpx.h>
1168 #else
1169 # include <utmp.h>
1170 #endif
1172   AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
1173   AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
1174   AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
1175   AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
1178 AC_DEFUN(jm_PREREQ_REGEX,
1180   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1181   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1182   dnl to get them.
1183   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
1184   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
1185   AC_HEADER_STDC
1186   AC_FUNC_ALLOCA
1189 #serial 1
1191 dnl FIXME: put these prerequisite-only *.m4 files in a separate
1192 dnl directory -- otherwise, they'll conflict with existing files.
1194 dnl These are the prerequisite macros for GNU's error.c file.
1195 AC_DEFUN(jm_PREREQ_ERROR,
1197   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
1198   AC_HEADER_STDC
1201 #serial 3
1203 dnl From Paul Eggert.
1205 AC_DEFUN(AC_C_BACKSLASH_A,
1207   AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1208    [AC_TRY_COMPILE([],
1209      [
1210 #if '\a' == 'a'
1211       syntax error;
1212 #endif
1213       char buf['\a' == 'a' ? -1 : 1];
1214       buf[0] = '\a';
1215       return buf[0] != "\a"[0];
1216      ],
1217      ac_cv_c_backslash_a=yes,
1218      ac_cv_c_backslash_a=no)])
1219   if test $ac_cv_c_backslash_a = yes; then
1220     AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1221       [Define if backslash-a works in C strings.])
1222   fi
1225 # serial 1
1227 # From Paul Eggert.
1229 # Some versions of BeOS define mbstate_t to be an incomplete type,
1230 # so you can't declare an object of that type.
1231 # Check for this incompatibility with Standard C.
1233 AC_DEFUN(AC_MBSTATE_T_OBJECT,
1234   [AC_CACHE_CHECK([for mbstate_t object type], ac_cv_type_mbstate_t_object,
1235     [AC_TRY_COMPILE([#include <wchar.h>],
1236       [mbstate_t x; return sizeof x;],
1237       ac_cv_type_mbstate_t_object=yes,
1238       ac_cv_type_mbstate_t_object=no)])
1239    if test $ac_cv_type_mbstate_t_object = yes; then
1240      AC_DEFINE(HAVE_MBSTATE_T_OBJECT, 1,
1241                [Define if mbstate_t is an object type.])
1242    fi])
1244 #serial 7
1246 dnl From Jim Meyering.
1247 dnl A wrapper around AC_FUNC_MKTIME.
1249 AC_DEFUN(jm_FUNC_MKTIME,
1250 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
1252  dnl mktime.c uses localtime_r if it exists.  Check for it.
1253  AC_CHECK_FUNCS(localtime_r)
1255  if test $ac_cv_func_working_mktime = no; then
1256    AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
1257     [Define to rpl_mktime if the replacement function should be used.])
1258  fi
1261 #serial 3
1263 dnl From Jim Meyering.
1264 dnl Determine whether lstat has the bug that it succeeds when given the
1265 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
1266 dnl (as of 1998-11-01) do this.
1268 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
1269 dnl compile the wrapper function.
1272 AC_DEFUN(jm_FUNC_LSTAT,
1274  AC_CACHE_CHECK([whether lstat accepts an empty string],
1275   jm_cv_func_lstat_empty_string_bug,
1276   [AC_TRY_RUN([
1277 #   include <sys/types.h>
1278 #   include <sys/stat.h>
1280     int
1281     main ()
1282     {
1283       struct stat sbuf;
1284       exit (lstat ("", &sbuf) ? 1 : 0);
1285     }
1286           ],
1287          jm_cv_func_lstat_empty_string_bug=yes,
1288          jm_cv_func_lstat_empty_string_bug=no,
1289          dnl When crosscompiling, assume lstat is broken.
1290          jm_cv_func_lstat_empty_string_bug=yes)
1291   ])
1292   if test $jm_cv_func_lstat_empty_string_bug = yes; then
1293     AC_SUBST(LIBOBJS)
1294     LIBOBJS="$LIBOBJS lstat.$ac_objext"
1295     AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
1296 [Define if lstat has the bug that it succeeds when given the zero-length
1297    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1298    do this. ])
1299   fi
1302 #serial 1
1304 dnl From Jim Meyering.
1305 dnl FIXME: describe
1307 AC_DEFUN(jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK,
1309  AC_CACHE_CHECK(
1310   [whether lstat dereferences a symlink specified with a trailing slash],
1311   jm_cv_func_lstat_dereferences_slashed_symlink,
1312   [
1313    rm -f conftest.sym conftest.file
1314    : > conftest.file
1315    if ln -s conftest.file conftest.sym; then
1316      AC_TRY_RUN([
1317 #     include <sys/types.h>
1318 #     include <sys/stat.h>
1320       int
1321       main ()
1322       {
1323         struct stat sbuf;
1324         /* Linux will dereference the symlink and fail.
1325            That is better in the sense that it means we will not
1326            have to compile and use the lstat wrapper.  */
1327         exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
1328       }
1329       ],
1330       jm_cv_func_lstat_dereferences_slashed_symlink=yes,
1331       jm_cv_func_lstat_dereferences_slashed_symlink=no,
1332       dnl When crosscompiling, be pessimistic so we will end up using the
1333       dnl replacement version of lstat that checkes for trailing slashes
1334       dnl and calls lstat a second time when necessary.
1335       jm_cv_func_lstat_dereferences_slashed_symlink=no
1336      )
1337    else
1338      # If the `ln -s' command failed, then we probably don't even
1339      # have an lstat function.
1340      jm_cv_func_lstat_dereferences_slashed_symlink=no
1341    fi
1342   ])
1344   test $jm_cv_func_lstat_dereferences_slashed_symlink = yes \
1345     && zero_one=1 \
1346     || zero_one=0
1347   AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, $zero_one,
1348     [Define if lstat dereferences a symlink specified with a trailing slash])
1350   if test $jm_cv_func_lstat_dereferences_slashed_symlink = no; then
1351     AC_SUBST(LIBOBJS)
1352     # Append lstat.o if it's not already in $LIBOBJS.
1353     case "$LIBOBJS" in
1354       *lstat.$ac_objext*) ;;
1355       *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
1356     esac
1357   fi
1360 #serial 3
1362 dnl From Jim Meyering.
1363 dnl Determine whether stat has the bug that it succeeds when given the
1364 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
1365 dnl (as of 1998-11-01) do this.
1367 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
1368 dnl compile the wrapper function.
1371 AC_DEFUN(jm_FUNC_STAT,
1373  AC_CACHE_CHECK([whether stat accepts an empty string],
1374   jm_cv_func_stat_empty_string_bug,
1375   [AC_TRY_RUN([
1376 #   include <sys/types.h>
1377 #   include <sys/stat.h>
1379     int
1380     main ()
1381     {
1382       struct stat sbuf;
1383       exit (stat ("", &sbuf) ? 1 : 0);
1384     }
1385           ],
1386          jm_cv_func_stat_empty_string_bug=yes,
1387          jm_cv_func_stat_empty_string_bug=no,
1388          dnl When crosscompiling, assume stat is broken.
1389          jm_cv_func_stat_empty_string_bug=yes)
1390   ])
1391   if test $jm_cv_func_stat_empty_string_bug = yes; then
1392     AC_SUBST(LIBOBJS)
1393     LIBOBJS="$LIBOBJS stat.$ac_objext"
1394     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
1395 [Define if stat has the bug that it succeeds when given the zero-length
1396    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1397    do this. ])
1398   fi
1401 #serial 3
1403 dnl From Jim Meyering.
1404 dnl Determine whether realloc works when both arguments are 0.
1405 dnl If it doesn't, arrange to use the replacement function.
1408 AC_DEFUN(jm_FUNC_REALLOC,
1410  dnl xmalloc.c requires that this symbol be defined so it doesn't
1411  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
1412  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
1413                     [Define if the realloc check has been performed. ])
1415  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
1416   [AC_TRY_RUN([
1417     char *realloc ();
1418     int
1419     main ()
1420     {
1421       exit (realloc (0, 0) ? 0 : 1);
1422     }
1423           ],
1424          jm_cv_func_working_realloc=yes,
1425          jm_cv_func_working_realloc=no,
1426          dnl When crosscompiling, assume realloc is broken.
1427          jm_cv_func_working_realloc=no)
1428   ])
1429   if test $jm_cv_func_working_realloc = no; then
1430     AC_SUBST(LIBOBJS)
1431     LIBOBJS="$LIBOBJS realloc.$ac_objext"
1432     AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
1433       [Define to rpl_realloc if the replacement function should be used.])
1434   fi
1437 #serial 3
1439 dnl From Jim Meyering.
1440 dnl Determine whether malloc accepts 0 as its argument.
1441 dnl If it doesn't, arrange to use the replacement function.
1444 AC_DEFUN(jm_FUNC_MALLOC,
1446  dnl xmalloc.c requires that this symbol be defined so it doesn't
1447  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
1448  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
1449                     [Define if the malloc check has been performed. ])
1451  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1452   [AC_TRY_RUN([
1453     char *malloc ();
1454     int
1455     main ()
1456     {
1457       exit (malloc (0) ? 0 : 1);
1458     }
1459           ],
1460          jm_cv_func_working_malloc=yes,
1461          jm_cv_func_working_malloc=no,
1462          dnl When crosscompiling, assume malloc is broken.
1463          jm_cv_func_working_malloc=no)
1464   ])
1465   if test $jm_cv_func_working_malloc = no; then
1466     AC_SUBST(LIBOBJS)
1467     LIBOBJS="$LIBOBJS malloc.$ac_objext"
1468     AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
1469       [Define to rpl_malloc if the replacement function should be used.])
1470   fi
1473 #serial 3
1475 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1476 dnl to test whether a NULL return value really means there are no more files
1477 dnl in the directory.
1479 dnl Detect the problem by creating a directory containing 300 files (254 not
1480 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1481 dnl removes all of them.
1483 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1485 dnl Written by Jim Meyering.
1487 AC_DEFUN(jm_FUNC_READDIR,
1488 [dnl
1489 AC_REQUIRE([AC_HEADER_DIRENT])
1490 AC_CHECK_HEADERS(string.h)
1491 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1492   [dnl
1493   # Arrange for deletion of the temporary directory this test creates, in
1494   # case the test itself fails to delete everything -- as happens on Sunos.
1495   ac_clean_files="$ac_clean_files conf-dir"
1497   AC_TRY_RUN(
1498 [#   include <stdio.h>
1499 #   include <sys/types.h>
1500 #   if HAVE_STRING_H
1501 #    include <string.h>
1502 #   endif
1504 #   ifdef HAVE_DIRENT_H
1505 #    include <dirent.h>
1506 #    define NLENGTH(direct) (strlen((direct)->d_name))
1507 #   else /* not HAVE_DIRENT_H */
1508 #    define dirent direct
1509 #    define NLENGTH(direct) ((direct)->d_namlen)
1510 #    ifdef HAVE_SYS_NDIR_H
1511 #     include <sys/ndir.h>
1512 #    endif /* HAVE_SYS_NDIR_H */
1513 #    ifdef HAVE_SYS_DIR_H
1514 #     include <sys/dir.h>
1515 #    endif /* HAVE_SYS_DIR_H */
1516 #    ifdef HAVE_NDIR_H
1517 #     include <ndir.h>
1518 #    endif /* HAVE_NDIR_H */
1519 #   endif /* HAVE_DIRENT_H */
1521 #   define DOT_OR_DOTDOT(Basename) \
1522      (Basename[0] == '.' && (Basename[1] == '\0' \
1523                              || (Basename[1] == '.' && Basename[2] == '\0')))
1525     static void
1526     create_300_file_dir (const char *dir)
1527     {
1528       int i;
1530       if (mkdir (dir, 0700))
1531         abort ();
1532       if (chdir (dir))
1533         abort ();
1535       for (i = 0; i < 300; i++)
1536         {
1537           char file_name[4];
1538           FILE *out;
1540           sprintf (file_name, "%03d", i);
1541           out = fopen (file_name, "w");
1542           if (!out)
1543             abort ();
1544           if (fclose (out) == EOF)
1545             abort ();
1546         }
1548       if (chdir (".."))
1549         abort ();
1550     }
1552     static void
1553     remove_dir (const char *dir)
1554     {
1555       DIR *dirp;
1557       if (chdir (dir))
1558         abort ();
1560       dirp = opendir (".");
1561       if (dirp == NULL)
1562         abort ();
1564       while (1)
1565         {
1566           struct dirent *dp = readdir (dirp);
1567           if (dp == NULL)
1568             break;
1570           if (DOT_OR_DOTDOT (dp->d_name))
1571             continue;
1573           if (unlink (dp->d_name))
1574             abort ();
1575         }
1576       closedir (dirp);
1578       if (chdir (".."))
1579         abort ();
1581       if (rmdir (dir))
1582         exit (1);
1583     }
1585     int
1586     main ()
1587     {
1588       const char *dir = "conf-dir";
1589       create_300_file_dir (dir);
1590       remove_dir (dir);
1591       exit (0);
1592     }],
1593   jm_cv_func_working_readdir=yes,
1594   jm_cv_func_working_readdir=no,
1595   jm_cv_func_working_readdir=no)])
1597   if test $jm_cv_func_working_readdir = yes; then
1598     AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
1599 [Define if readdir is found to work properly in some unusual cases. ])
1600   fi
1603 #serial 4
1605 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1606 dnl the losing memcmp on some x86 Next systems.
1607 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1608 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1609 [AC_TRY_RUN(
1610 [int
1611 main ()
1613   /* Some versions of memcmp are not 8-bit clean.  */
1614   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1615   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1616     exit (1);
1618   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1619      or more and with at least one buffer not starting on a 4-byte boundary.
1620      William Lewis provided this test program.   */
1621   {
1622     char foo[21];
1623     char bar[21];
1624     int i;
1625     for (i = 0; i < 4; i++)
1626       {
1627         char *a = foo + i;
1628         char *b = bar + i;
1629         strcpy (a, "--------01111111");
1630         strcpy (b, "--------10000000");
1631         if (memcmp (a, b, 16) >= 0)
1632           exit (1);
1633       }
1634     exit (0);
1635   }
1637    jm_cv_func_memcmp_working=yes,
1638    jm_cv_func_memcmp_working=no,
1639    jm_cv_func_memcmp_working=no)])
1640 test $jm_cv_func_memcmp_working = no \
1641   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
1642 AC_SUBST(LIBOBJS)dnl
1645 AC_DEFUN(jm_FUNC_MEMCMP,
1646 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1647  if test $jm_cv_func_memcmp_working = no; then
1648    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
1649      [Define to rpl_memcmp if the replacement function should be used.])
1650  fi
1653 #serial 4
1655 dnl From Jim Meyering.
1657 dnl See if the glibc *_unlocked I/O macros are available.
1658 dnl Use only those *_unlocked macros that are declared.
1661 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1662   [
1663     # Kludge (not executed) to make autoheader do the right thing.
1664     if test a = b; then
1665       AC_CHECK_DECLS([clearerr_unlocked, feof_unlocked, ferror_unlocked,
1666         fflush_unlocked, fputc_unlocked, fread_unlocked, fwrite_unlocked,
1667         getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked])
1668     fi
1670     io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
1671     fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
1672     getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
1673     for jm_io_func in $io_functions; do
1674       # Check for the existence of each function only if its declared.
1675       # Otherwise, we'd get the Solaris5.5.1 functions that are not
1676       # declared, and that have been removed from Solaris5.6.  The resulting
1677       # 5.5.1 binaries would not run on 5.6 due to shared library differences.
1678       AC_CHECK_DECLS([$jm_io_func],
1679                      jm_declared=yes,
1680                      jm_declared=no,
1681                      [#include <stdio.h>])
1682       if test $jm_declared = yes; then
1683         AC_CHECK_FUNCS($jm_io_func)
1684       fi
1685     done
1686   ]
1689 #serial 2
1691 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1692 dnl define fnmatch to rpl_fnmatch.
1695 # AC_FUNC_FNMATCH
1696 # ---------------
1697 # We look for fnmatch.h to avoid that the test fails in C++.
1698 AC_DEFUN(kd_FUNC_FNMATCH_CASE,
1699 [AC_CHECK_HEADERS(fnmatch.h)
1700 AC_CACHE_CHECK(for working fnmatch with case folding, ac_cv_func_fnmatch_works,
1701 # Some versions of Solaris or SCO have a broken fnmatch function.
1702 # So we run a test program.  If we are cross-compiling, take no chance.
1703 # Also want FNM_CASEFOLD
1704 # Thanks to John Oleynick and Franc,ois Pinard for this test.
1705 [AC_TRY_RUN(
1706 [#include <stdio.h>
1707 #define _GNU_SOURCE
1708 #if HAVE_FNMATCH_H
1709 # include <fnmatch.h>
1710 #endif
1713 main ()
1715   exit (fnmatch ("A*", "abc", FNM_CASEFOLD) != 0);
1717 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
1718 ac_cv_func_fnmatch_works=no)])
1719 if test $ac_cv_func_fnmatch_works = yes; then
1720   AC_DEFINE(HAVE_FNMATCH, 1,
1721             [Define if your system has a working `fnmatch' function with case folding.])
1723 ])# AC_FUNC_FNMATCH
1726 AC_DEFUN(kd_FUNC_FNMATCH_CASE_RPL,
1728   AC_REQUIRE([AM_GLIBC])
1729   kd_FUNC_FNMATCH_CASE
1730   if test $ac_cv_func_fnmatch_works = no \
1731       && test $ac_cv_gnu_library = no; then
1732     AC_SUBST(LIBOBJS)
1733     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
1734     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
1735       [Define to rpl_fnmatch if the replacement function should be used.])
1736   fi
1739 #serial 2
1741 dnl From Gordon Matzigkeit.
1742 dnl Test for the GNU C Library.
1743 dnl FIXME: this should migrate into libit.
1745 AC_DEFUN(AM_GLIBC,
1746   [
1747     AC_CACHE_CHECK(whether we are using the GNU C Library,
1748       ac_cv_gnu_library,
1749       [AC_EGREP_CPP([Thanks for using GNU],
1750         [
1751 #include <features.h>
1752 #ifdef __GNU_LIBRARY__
1753   Thanks for using GNU
1754 #endif
1755         ],
1756         ac_cv_gnu_library=yes,
1757         ac_cv_gnu_library=no)
1758       ]
1759     )
1760     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1761       ac_cv_glibc,
1762       [AC_EGREP_CPP([Thanks for using GNU too],
1763         [
1764 #include <features.h>
1765 #ifdef __GLIBC__
1766   Thanks for using GNU too
1767 #endif
1768         ],
1769         ac_cv_glibc=yes, ac_cv_glibc=no)
1770       ]
1771     )
1772   ]
1775 #serial 3
1777 AC_DEFUN(jm_AFS,
1778   AC_MSG_CHECKING(for AFS)
1779   if test -d /afs; then
1780     AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
1781     ac_result=yes
1782   else
1783     ac_result=no
1784   fi
1785   AC_MSG_RESULT($ac_result)
1788 #serial 2
1790 # autoconf tests required for use of xstrtoumax.c
1792 AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
1794   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
1795   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1796   AC_CHECK_HEADERS(stdlib.h)
1798   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
1799     jm_cv_func_strtoumax_macro,
1800     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
1801 #ifdef strtoumax
1802  inttypes_h_defines_strtoumax
1803 #endif],
1804       jm_cv_func_strtoumax_macro=yes,
1805       jm_cv_func_strtoumax_macro=no))
1807   if test "$jm_cv_func_strtoumax_macro" != yes; then
1808     AC_REPLACE_FUNCS(strtoumax)
1809   fi
1811   dnl We don't need (and can't compile) the replacement strtoull
1812   dnl unless the type `unsigned long long' exists.
1813   dnl Also, only the replacement strtoumax invokes strtoull,
1814   dnl so we need the replacement strtoull only if strtoumax does not exist.
1815   case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
1816     yes,no,no)
1817       AC_REPLACE_FUNCS(strtoull)
1818       ;;
1819   esac
1823 #serial 2
1825 dnl From Paul Eggert.
1827 AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
1829   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
1830   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
1831     [unsigned long long ullmax = (unsigned long long) -1;
1832      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
1833     ac_cv_type_unsigned_long_long=yes,
1834     ac_cv_type_unsigned_long_long=no)])
1835   if test $ac_cv_type_unsigned_long_long = yes; then
1836     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
1837       [Define if you have the unsigned long long type.])
1838   fi
1841 #serial 1
1842 dnl Run a program to determine whether whether link(2) follows symlinks.
1843 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
1845 AC_DEFUN(jm_AC_FUNC_LINK_FOLLOWS_SYMLINK,
1846 [dnl
1847   AC_CACHE_CHECK([whether link(2) follows symlinks],
1848                  jm_ac_cv_func_link_follows_symlink,
1849   [
1850     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
1851     dnl the appropriate framework.
1852     test -z "$ac_cv_header_unistd_h" \
1853       && AC_CHECK_HEADERS(unistd.h)
1855     # Create a regular file.
1856     echo > conftest.file
1857     AC_TRY_RUN(
1858       [
1859 #       include <sys/types.h>
1860 #       include <sys/stat.h>
1861 #       ifdef HAVE_UNISTD_H
1862 #        include <unistd.h>
1863 #       endif
1865 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
1866           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
1867            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
1869         int
1870         main ()
1871         {
1872           const char *file = "conftest.file";
1873           const char *sym = "conftest.sym";
1874           const char *hard = "conftest.hard";
1875           struct stat sb_file, sb_hard;
1877           /* Create a symlink to the regular file. */
1878           if (symlink (file, sym))
1879             abort ();
1881           /* Create a hard link to that symlink.  */
1882           if (link (sym, hard))
1883             abort ();
1885           if (lstat (hard, &sb_hard))
1886             abort ();
1887           if (lstat (file, &sb_file))
1888             abort ();
1890           /* If the dev/inode of hard and file are the same, then
1891              the link call followed the symlink.  */
1892           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
1893         }
1894       ],
1895       jm_ac_cv_func_link_follows_symlink=yes,
1896       jm_ac_cv_func_link_follows_symlink=no,
1897       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
1898     )
1899   ])
1900   if test $jm_ac_cv_func_link_follows_symlink = yes; then
1901     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
1902       [Define if `link(2)' dereferences symbolic links.])
1903   fi
1906 # From Jim Meyering.  Use this if you use the GNU error.[ch].
1907 # FIXME: Migrate into libit
1909 AC_DEFUN([AM_FUNC_ERROR_AT_LINE],
1910 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1911  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1912               am_cv_lib_error_at_line=yes,
1913               am_cv_lib_error_at_line=no)])
1914  if test $am_cv_lib_error_at_line = no; then
1915    LIBOBJS="$LIBOBJS error.$ac_objext"
1916  fi
1917  AC_SUBST(LIBOBJS)dnl
1920 #serial 9
1922 dnl This macro is intended to be used solely in this file.
1923 dnl These are the prerequisite macros for GNU's strftime.c replacement.
1924 AC_DEFUN(_jm_STRFTIME_PREREQS,
1926  dnl strftime.c uses localtime_r if it exists.  Check for it.
1927  AC_CHECK_FUNCS(localtime_r)
1929  AC_CHECK_HEADERS(limits.h)
1930  AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
1932  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
1933  AC_STRUCT_TIMEZONE
1935  AC_CHECK_FUNCS(mblen mbrlen)
1937  AC_CHECK_MEMBER(struct tm.tm_gmtoff,
1938                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
1939                             [Define if struct tm has the tm_gmtoff member.])],
1940                  ,
1941                  [#include <time.h>])
1944 dnl Determine if the strftime function has all the features of the GNU one.
1946 dnl From Jim Meyering.
1948 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
1949 [AC_REQUIRE([AC_HEADER_TIME])dnl
1951  _jm_STRFTIME_PREREQS
1953  AC_REQUIRE([AC_C_CONST])dnl
1954  AC_REQUIRE([AC_HEADER_STDC])dnl
1955  AC_CHECK_HEADERS(sys/time.h)
1956  AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
1957   [# Set TZ to GMT0 to make strftime give consistent results during the test.
1958    ac_save_TZ="${TZ-GMT0}"
1959    TZ=GMT0
1960    export TZ
1961    AC_TRY_RUN(
1962 [ /* Ulrich Drepper provided parts of the test program.  */
1963 #if STDC_HEADERS
1964 # include <stdlib.h>
1965 #endif
1967 #if TIME_WITH_SYS_TIME
1968 # include <sys/time.h>
1969 # include <time.h>
1970 #else
1971 # if HAVE_SYS_TIME_H
1972 #  include <sys/time.h>
1973 # else
1974 #  include <time.h>
1975 # endif
1976 #endif
1978 static int
1979 compare (const char *fmt, const struct tm *tm, const char *expected)
1981   char buf[99];
1982   strftime (buf, 99, fmt, tm);
1983   if (strcmp (buf, expected))
1984     {
1985 #ifdef SHOW_FAILURES
1986       printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
1987               fmt, expected, buf);
1988 #endif
1989       return 1;
1990     }
1991   return 0;
1995 main ()
1997   int n_fail = 0;
1998   struct tm *tm;
1999   time_t t = 738367; /* Fri Jan  9 13:06:07 1970 */
2000   tm = gmtime (&t);
2002 #undef CMP
2003 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
2005   CMP ("%-m", "1");             /* GNU */
2006   CMP ("%A", "Friday");
2007   CMP ("%^A", "FRIDAY");        /* The ^ is a GNU extension.  */
2008   CMP ("%B", "January");
2009   CMP ("%^B", "JANUARY");
2010   CMP ("%C", "19");             /* POSIX.2 */
2011   CMP ("%D", "01/09/70");       /* POSIX.2 */
2012   CMP ("%F", "1970-01-09");
2013   CMP ("%G", "1970");           /* GNU */
2014   CMP ("%H", "13");
2015   CMP ("%I", "01");
2016   CMP ("%M", "06");
2017   CMP ("%M", "06");
2018   CMP ("%R", "13:06");          /* POSIX.2 */
2019   CMP ("%S", "07");
2020   CMP ("%T", "13:06:07");       /* POSIX.2 */
2021   CMP ("%U", "01");
2022   CMP ("%V", "02");
2023   CMP ("%W", "01");
2024   CMP ("%X", "13:06:07");
2025   CMP ("%Y", "1970");
2026   CMP ("%Z", "GMT");
2027   CMP ("%_m", " 1");            /* GNU */
2028   CMP ("%a", "Fri");
2029   CMP ("%^a", "FRI");
2030   CMP ("%b", "Jan");
2031   CMP ("%^b", "JAN");
2032   CMP ("%c", "Fri Jan  9 13:06:07 1970");
2033   CMP ("%^c", "FRI JAN  9 13:06:07 1970");
2034   CMP ("%d", "09");
2035   CMP ("%e", " 9");             /* POSIX.2 */
2036   CMP ("%g", "70");             /* GNU */
2037   CMP ("%h", "Jan");            /* POSIX.2 */
2038   CMP ("%^h", "JAN");
2039   CMP ("%j", "009");
2040   CMP ("%k", "13");             /* GNU */
2041   CMP ("%l", " 1");             /* GNU */
2042   CMP ("%m", "01");
2043   CMP ("%n", "\n");             /* POSIX.2 */
2044   CMP ("%p", "PM");
2045   CMP ("%r", "01:06:07 PM");    /* POSIX.2 */
2046   CMP ("%s", "738367");         /* GNU */
2047   CMP ("%t", "\t");             /* POSIX.2 */
2048   CMP ("%u", "5");              /* POSIX.2 */
2049   CMP ("%w", "5");
2050   CMP ("%x", "01/09/70");
2051   CMP ("%y", "70");
2052   CMP ("%z", "+0000");          /* GNU */
2054   exit (n_fail ? 1 : 0);
2056              jm_cv_func_working_gnu_strftime=yes,
2057              jm_cv_func_working_gnu_strftime=no,
2058              dnl When crosscompiling, assume strftime is missing or broken.
2059              jm_cv_func_working_gnu_strftime=no)
2060    dnl If TZ wasn't set before, this sets it to GMT0.  No real harm done.
2061    TZ="$ac_save_TZ"
2062   ])
2063   if test $jm_cv_func_working_gnu_strftime = no; then
2064     AC_SUBST(LIBOBJS)
2065     LIBOBJS="$LIBOBJS strftime.$ac_objext"
2066     AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
2067       [Define to gnu_strftime if the replacement function should be used.])
2068   fi
2071 AC_DEFUN(jm_FUNC_STRFTIME,
2073   _jm_STRFTIME_PREREQS
2074   AC_REPLACE_FUNCS(strftime)
2077 #serial 4
2079 dnl See if there's a working, system-supplied version of the getline function.
2080 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
2081 dnl have a function by that name in -linet that doesn't have anything
2082 dnl to do with the function we need.
2083 AC_DEFUN(AM_FUNC_GETLINE,
2084 [dnl
2085   am_getline_needs_run_time_check=no
2086   AC_CHECK_FUNC(getline,
2087                 dnl Found it in some library.  Verify that it works.
2088                 am_getline_needs_run_time_check=yes,
2089                 am_cv_func_working_getline=no)
2090   if test $am_getline_needs_run_time_check = yes; then
2091     AC_CHECK_HEADERS(string.h)
2092     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
2093     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
2094     AC_TRY_RUN([
2095 #    include <stdio.h>
2096 #    include <sys/types.h>
2097 #    if HAVE_STRING_H
2098 #     include <string.h>
2099 #    endif
2100     int foo()
2101     {
2102        char *path;
2103        size_t n;
2104        FILE *stream;
2105        char terminator;
2106        size_t offset;
2107        getstr(&path, &n, stream, terminator, offset);
2108      }
2110     int main ()
2111     { /* Based on a test program from Karl Heuer.  */
2112       char *line = NULL;
2113       size_t siz = 0;
2114       int len;
2115       FILE *in = fopen ("./conftest.data", "r");
2116       if (!in)
2117         return 1;
2118       len = getline (&line, &siz, in);
2119       nread = getstr (&path, &pathsize, fp, '\0', count);
2121       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
2122     }
2123     ], am_cv_func_working_getline=yes dnl The library version works.
2124     , am_cv_func_working_getline=no dnl The library version does NOT work.
2125     , am_cv_func_working_getline=no dnl We're cross compiling.
2126     )])
2127   fi
2129   if test $am_cv_func_working_getline = no; then
2130     AC_LIBOBJ(getline)
2131   fi
2134 #serial 2
2136 # Test for the GNU C Library, version 2.1 or newer.
2137 # From Bruno Haible.
2139 AC_DEFUN(jm_GLIBC21,
2140   [
2141     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2142       ac_cv_gnu_library_2_1,
2143       [AC_EGREP_CPP([Lucky GNU user],
2144         [
2145 #include <features.h>
2146 #ifdef __GNU_LIBRARY__
2147  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2148   Lucky GNU user
2149  #endif
2150 #endif
2151         ],
2152         ac_cv_gnu_library_2_1=yes,
2153         ac_cv_gnu_library_2_1=no)
2154       ]
2155     )
2156     AC_SUBST(GLIBC21)
2157     GLIBC21="$ac_cv_gnu_library_2_1"
2158   ]
2161 #serial 1
2163 dnl From Bruno Haible.
2165 AC_DEFUN(jm_ICONV,
2167   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2168   dnl those with the standalone portable libiconv installed).
2169   AC_CACHE_CHECK(for iconv, jm_cv_func_iconv, [
2170     jm_cv_func_iconv="no, consider installing libiconv"
2171     jm_cv_lib_iconv=no
2172     AC_TRY_LINK([#include <stdlib.h>
2173 #include <iconv.h>],
2174       [iconv_t cd = iconv_open("","");
2175        iconv(cd,NULL,NULL,NULL,NULL);
2176        iconv_close(cd);],
2177       jm_cv_func_iconv=yes)
2178     if test "$jm_cv_func_iconv" != yes; then
2179       jm_save_LIBS="$LIBS"
2180       LIBS="$LIBS -liconv"
2181       AC_TRY_LINK([#include <stdlib.h>
2182 #include <iconv.h>],
2183         [iconv_t cd = iconv_open("","");
2184          iconv(cd,NULL,NULL,NULL,NULL);
2185          iconv_close(cd);],
2186         jm_cv_lib_iconv=yes
2187         jm_cv_func_iconv=yes)
2188       LIBS="$jm_save_LIBS"
2189     fi
2190   ])
2191   if test "$jm_cv_func_iconv" = yes; then
2192     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2193   fi
2194   LIBICONV=
2195   if test "$jm_cv_lib_iconv" = yes; then
2196     LIBICONV="-liconv"
2197   fi
2198   AC_SUBST(LIBICONV)
2201 #serial 2
2203 dnl From Jim Meyering.
2205 dnl See if struct statfs has the f_fstypename member.
2206 dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
2209 AC_DEFUN(jm_FSTYPENAME,
2210   [
2211     AC_CACHE_CHECK([for f_fstypename in struct statfs],
2212                    fu_cv_sys_f_fstypename_in_statfs,
2213       [
2214         AC_TRY_COMPILE(
2215           [
2216 #include <sys/param.h>
2217 #include <sys/types.h>
2218 #include <sys/mount.h>
2219           ],
2220           [struct statfs s; int i = sizeof s.f_fstypename;],
2221           fu_cv_sys_f_fstypename_in_statfs=yes,
2222           fu_cv_sys_f_fstypename_in_statfs=no
2223         )
2224       ]
2225     )
2227     if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
2228       AC_DEFINE_UNQUOTED(HAVE_F_FSTYPENAME_IN_STATFS, 1,
2229                          [Define if struct statfs has the f_fstypename member.])
2230     fi
2231   ]
2234 #serial 4
2236 dnl From Paul Eggert.
2238 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
2239 # if it exists.
2241 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
2242  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
2243    ac_cv_struct_st_mtim_nsec,
2244    [ac_save_CPPFLAGS="$CPPFLAGS"
2245     ac_cv_struct_st_mtim_nsec=no
2246     # tv_nsec -- the usual case
2247     # _tv_nsec -- Solaris 2.6, if
2248     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
2249     #    && !defined __EXTENSIONS__)
2250     # st__tim.tv_nsec -- UnixWare 2.1.2
2251     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
2252       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
2253       AC_TRY_COMPILE([#include <sys/types.h>
2254 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
2255         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
2256     done
2257     CPPFLAGS="$ac_save_CPPFLAGS"])
2259   if test $ac_cv_struct_st_mtim_nsec != no; then
2260     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
2261       [Define to be the nanoseconds member of struct stat's st_mtim,
2262    if it exists.])
2263   fi
2267 #serial 2
2269 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
2271 AC_DEFUN(AC_STRUCT_ST_DM_MODE,
2272  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
2273    [AC_TRY_COMPILE([#include <sys/types.h>
2274 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
2275      ac_cv_struct_st_dm_mode=yes,
2276      ac_cv_struct_st_dm_mode=no)])
2278   if test $ac_cv_struct_st_dm_mode = yes; then
2279     AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
2280                        [Define if struct stat has an st_dm_mode member. ])
2281   fi
2285 #serial 4
2287 dnl From Jim Meyering
2289 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
2290 dnl in time.h or sys/time.h.
2292 AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
2294   AC_REQUIRE([AC_HEADER_TIME])
2295   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
2296     [AC_TRY_COMPILE(
2297       [
2298 #      if TIME_WITH_SYS_TIME
2299 #       include <sys/time.h>
2300 #       include <time.h>
2301 #      else
2302 #       if HAVE_SYS_TIME_H
2303 #        include <sys/time.h>
2304 #       else
2305 #        include <time.h>
2306 #       endif
2307 #      endif
2308       ],
2309       [static struct timespec x; x.tv_sec = x.tv_nsec;],
2310       fu_cv_sys_struct_timespec=yes,
2311       fu_cv_sys_struct_timespec=no)
2312     ])
2314   if test $fu_cv_sys_struct_timespec = yes; then
2315     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
2316                        [Define if struct timespec is declared in <time.h>. ])
2317   fi
2320 #serial 5
2322 dnl From Paul Eggert.
2324 AC_PREREQ(2.13)
2326 # Define uintmax_t to `unsigned long' or `unsigned long long'
2327 # if <inttypes.h> does not exist.
2329 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
2331   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2332   if test $jm_ac_cv_header_inttypes_h = no; then
2333     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2334     test $ac_cv_type_unsigned_long_long = yes \
2335       && ac_type='unsigned long long' \
2336       || ac_type='unsigned long'
2337     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2338 [  Define to unsigned long or unsigned long long
2339    if <inttypes.h> doesn't define.])
2340   fi
2343 # Macro to add for using GNU gettext.
2344 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2346 # This file can be copied and used freely without restrictions.  It can
2347 # be used in projects which are not available under the GNU Public License
2348 # but which still want to provide support for the GNU gettext functionality.
2349 # Please note that the actual code is *not* freely available.
2351 # serial 108
2353 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2355 AC_DEFUN(AM_WITH_NLS,
2356   [AC_MSG_CHECKING([whether NLS is requested])
2357     dnl Default is enabled NLS
2358     AC_ARG_ENABLE(nls,
2359       [  --disable-nls           do not use Native Language Support],
2360       USE_NLS=$enableval, USE_NLS=yes)
2361     AC_MSG_RESULT($USE_NLS)
2362     AC_SUBST(USE_NLS)
2364     USE_INCLUDED_LIBINTL=no
2366     dnl If we use NLS figure out what method
2367     if test "$USE_NLS" = "yes"; then
2368       AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.])
2369       AC_MSG_CHECKING([whether included gettext is requested])
2370       AC_ARG_WITH(included-gettext,
2371         [  --with-included-gettext use the GNU gettext library included here],
2372         nls_cv_force_use_gnu_gettext=$withval,
2373         nls_cv_force_use_gnu_gettext=no)
2374       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2376       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2377       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2378         dnl User does not insist on using GNU NLS library.  Figure out what
2379         dnl to use.  If gettext or catgets are available (in this order) we
2380         dnl use this.  Else we have to fall back to GNU NLS library.
2381         dnl catgets is only used if permitted by option --with-catgets.
2382         nls_cv_header_intl=
2383         nls_cv_header_libgt=
2384         CATOBJEXT=NONE
2386         AC_CHECK_HEADER(libintl.h,
2387           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
2388             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
2389                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
2391            if test "$gt_cv_func_gettext_libc" != "yes"; then
2392              AC_CHECK_LIB(intl, bindtextdomain,
2393                [AC_CHECK_LIB(intl, gettext)])
2394            fi
2396            if test "$gt_cv_func_gettext_libc" = "yes" \
2397               || test "$ac_cv_lib_intl_gettext" = "yes"; then
2398               AC_DEFINE(HAVE_GETTEXT, 1,
2399           [Define to 1 if you have gettext and don't want to use GNU gettext.])
2400               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2401                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2402               if test "$MSGFMT" != "no"; then
2403                 AC_CHECK_FUNCS(dcgettext)
2404                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2405                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2406                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2407                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
2408                                return _nl_msg_cat_cntr],
2409                   [CATOBJEXT=.gmo
2410                    DATADIRNAME=share],
2411                   [CATOBJEXT=.mo
2412                    DATADIRNAME=lib])
2413                 INSTOBJEXT=.mo
2414               fi
2415             fi
2416         ])
2418         if test "$CATOBJEXT" = "NONE"; then
2419           AC_MSG_CHECKING([whether catgets can be used])
2420           AC_ARG_WITH(catgets,
2421             [  --with-catgets          use catgets functions if available],
2422             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
2423           AC_MSG_RESULT($nls_cv_use_catgets)
2425           if test "$nls_cv_use_catgets" = "yes"; then
2426             dnl No gettext in C library.  Try catgets next.
2427             AC_CHECK_LIB(i, main)
2428             AC_CHECK_FUNC(catgets,
2429               [AC_DEFINE(HAVE_CATGETS, 1,
2430                          [Define as 1 if you have catgets and don't want to use GNU gettext.])
2431                INTLOBJS="\$(CATOBJS)"
2432                AC_PATH_PROG(GENCAT, gencat, no)dnl
2433                if test "$GENCAT" != "no"; then
2434                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
2435                  if test "$GMSGFMT" = "no"; then
2436                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
2437                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
2438                  fi
2439                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2440                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2441                  USE_INCLUDED_LIBINTL=yes
2442                  CATOBJEXT=.cat
2443                  INSTOBJEXT=.cat
2444                  DATADIRNAME=lib
2445                  INTLDEPS='$(top_builddir)/intl/libintl.a'
2446                  INTLLIBS=$INTLDEPS
2447                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2448                  nls_cv_header_intl=intl/libintl.h
2449                  nls_cv_header_libgt=intl/libgettext.h
2450                fi])
2451           fi
2452         fi
2454         if test "$CATOBJEXT" = "NONE"; then
2455           dnl Neither gettext nor catgets in included in the C library.
2456           dnl Fall back on GNU gettext library.
2457           nls_cv_use_gnu_gettext=yes
2458         fi
2459       fi
2461       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2462         dnl Mark actions used to generate GNU NLS library.
2463         INTLOBJS="\$(GETTOBJS)"
2464         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2465           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2466         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2467         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2468           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2469         AC_SUBST(MSGFMT)
2470         USE_INCLUDED_LIBINTL=yes
2471         CATOBJEXT=.gmo
2472         INSTOBJEXT=.mo
2473         DATADIRNAME=share
2474         INTLDEPS='$(top_builddir)/intl/libintl.a'
2475         INTLLIBS=$INTLDEPS
2476         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2477         nls_cv_header_intl=intl/libintl.h
2478         nls_cv_header_libgt=intl/libgettext.h
2479       fi
2481       dnl Test whether we really found GNU xgettext.
2482       if test "$XGETTEXT" != ":"; then
2483         dnl If it is no GNU xgettext we define it as : so that the
2484         dnl Makefiles still can work.
2485         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2486           : ;
2487         else
2488           AC_MSG_RESULT(
2489             [found xgettext program is not GNU xgettext; ignore it])
2490           XGETTEXT=":"
2491         fi
2492       fi
2494       # We need to process the po/ directory.
2495       POSUB=po
2496     else
2497       DATADIRNAME=share
2498       nls_cv_header_intl=intl/libintl.h
2499       nls_cv_header_libgt=intl/libgettext.h
2500     fi
2501     if test -z "$nls_cv_header_intl"; then
2502       # Clean out junk possibly left behind by a previous configuration.
2503       rm -f intl/libintl.h
2504     fi
2505     AC_CONFIG_LINKS($nls_cv_header_intl:$nls_cv_header_libgt)
2506     AC_OUTPUT_COMMANDS(
2507      [case "$CONFIG_FILES" in *po/Makefile.in*)
2508         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
2509       esac])
2512     # If this is used in GNU gettext we have to set USE_NLS to `yes'
2513     # because some of the sources are only built for this goal.
2514     if test "$PACKAGE" = gettext; then
2515       USE_NLS=yes
2516       USE_INCLUDED_LIBINTL=yes
2517     fi
2519     dnl These rules are solely for the distribution goal.  While doing this
2520     dnl we only have to keep exactly one list of the available catalogs
2521     dnl in configure.in.
2522     for lang in $ALL_LINGUAS; do
2523       GMOFILES="$GMOFILES $lang.gmo"
2524       POFILES="$POFILES $lang.po"
2525     done
2527     dnl Make all variables we use known to autoconf.
2528     AC_SUBST(USE_INCLUDED_LIBINTL)
2529     AC_SUBST(CATALOGS)
2530     AC_SUBST(CATOBJEXT)
2531     AC_SUBST(DATADIRNAME)
2532     AC_SUBST(GMOFILES)
2533     AC_SUBST(INSTOBJEXT)
2534     AC_SUBST(INTLDEPS)
2535     AC_SUBST(INTLLIBS)
2536     AC_SUBST(INTLOBJS)
2537     AC_SUBST(POFILES)
2538     AC_SUBST(POSUB)
2539   ])
2541 AC_DEFUN(AM_GNU_GETTEXT,
2542   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2543    AC_REQUIRE([AC_PROG_CC])dnl
2544    AC_REQUIRE([AC_PROG_RANLIB])dnl
2545    AC_REQUIRE([AC_ISC_POSIX])dnl
2546    AC_REQUIRE([AC_HEADER_STDC])dnl
2547    AC_REQUIRE([AC_C_CONST])dnl
2548    AC_REQUIRE([AC_C_INLINE])dnl
2549    AC_REQUIRE([AC_TYPE_OFF_T])dnl
2550    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2551    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2552    AC_REQUIRE([AC_FUNC_MMAP])dnl
2554    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
2555 unistd.h sys/param.h])
2556    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
2557 strdup __argz_count __argz_stringify __argz_next])
2559    if test "${ac_cv_func_stpcpy+set}" != "set"; then
2560      AC_CHECK_FUNCS(stpcpy)
2561    fi
2562    if test "${ac_cv_func_stpcpy}" = "yes"; then
2563      AC_DEFINE(HAVE_STPCPY, 1, [Define to 1 if you have the stpcpy function.])
2564    fi
2566    AM_LC_MESSAGES
2567    AM_WITH_NLS
2569    if test "x$CATOBJEXT" != "x"; then
2570      if test "x$ALL_LINGUAS" = "x"; then
2571        LINGUAS=
2572      else
2573        AC_MSG_CHECKING(for catalogs to be installed)
2574        NEW_LINGUAS=
2575        for lang in ${LINGUAS=$ALL_LINGUAS}; do
2576          case "$ALL_LINGUAS" in
2577           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
2578          esac
2579        done
2580        LINGUAS=$NEW_LINGUAS
2581        AC_MSG_RESULT($LINGUAS)
2582      fi
2584      dnl Construct list of names of catalog files to be constructed.
2585      if test -n "$LINGUAS"; then
2586        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2587      fi
2588    fi
2590    dnl The reference to <locale.h> in the installed <libintl.h> file
2591    dnl must be resolved because we cannot expect the users of this
2592    dnl to define HAVE_LOCALE_H.
2593    if test $ac_cv_header_locale_h = yes; then
2594      INCLUDE_LOCALE_H="#include <locale.h>"
2595    else
2596      INCLUDE_LOCALE_H="\
2597 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
2598    fi
2599    AC_SUBST(INCLUDE_LOCALE_H)
2601    dnl Determine which catalog format we have (if any is needed)
2602    dnl For now we know about two different formats:
2603    dnl   Linux libc-5 and the normal X/Open format
2604    test -d intl || mkdir intl
2605    if test "$CATOBJEXT" = ".cat"; then
2606      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
2608      dnl Transform the SED scripts while copying because some dumb SEDs
2609      dnl cannot handle comments.
2610      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
2611    fi
2612    dnl po2tbl.sed is always needed.
2613    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
2614      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
2616    dnl In the intl/Makefile.in we have a special dependency which makes
2617    dnl only sense for gettext.  We comment this out for non-gettext
2618    dnl packages.
2619    if test "$PACKAGE" = "gettext"; then
2620      GT_NO="#NO#"
2621      GT_YES=
2622    else
2623      GT_NO=
2624      GT_YES="#YES#"
2625    fi
2626    AC_SUBST(GT_NO)
2627    AC_SUBST(GT_YES)
2629    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2630    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
2631    dnl Try to locate is.
2632    MKINSTALLDIRS=
2633    if test -n "$ac_aux_dir"; then
2634      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2635    fi
2636    if test -z "$MKINSTALLDIRS"; then
2637      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2638    fi
2639    AC_SUBST(MKINSTALLDIRS)
2641    dnl *** For now the libtool support in intl/Makefile is not for real.
2642    l=
2643    AC_SUBST(l)
2645    dnl Generate list of files to be processed by xgettext which will
2646    dnl be included in po/Makefile.
2647    test -d po || mkdir po
2648    case "$srcdir" in
2649    .)
2650      posrcprefix="../" ;;
2651    /* | [[A-Za-z]]:*)
2652      posrcprefix="$srcdir/" ;;
2653    *)
2654      posrcprefix="../$srcdir/" ;;
2655    esac
2656    rm -f po/POTFILES
2657    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
2658         < $srcdir/po/POTFILES.in > po/POTFILES
2659   ])
2661 # Search path for a program which passes the given test.
2662 # Ulrich Drepper <drepper@cygnus.com>, 1996.
2664 # This file can be copied and used freely without restrictions.  It can
2665 # be used in projects which are not available under the GNU Public License
2666 # but which still want to provide support for the GNU gettext functionality.
2667 # Please note that the actual code is *not* freely available.
2669 # serial 1
2671 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2672 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2673 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
2674 [# Extract the first word of "$2", so it can be a program name with args.
2675 set dummy $2; ac_word=[$]2
2676 AC_MSG_CHECKING([for $ac_word])
2677 AC_CACHE_VAL(ac_cv_path_$1,
2678 [case "[$]$1" in
2679   /*)
2680   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2681   ;;
2682   *)
2683   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2684   for ac_dir in ifelse([$5], , $PATH, [$5]); do
2685     test -z "$ac_dir" && ac_dir=.
2686     if test -f $ac_dir/$ac_word; then
2687       if [$3]; then
2688         ac_cv_path_$1="$ac_dir/$ac_word"
2689         break
2690       fi
2691     fi
2692   done
2693   IFS="$ac_save_ifs"
2694 dnl If no 4th arg is given, leave the cache variable unset,
2695 dnl so AC_PATH_PROGS will keep looking.
2696 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2697 ])dnl
2698   ;;
2699 esac])dnl
2700 $1="$ac_cv_path_$1"
2701 if test -n "[$]$1"; then
2702   AC_MSG_RESULT([$]$1)
2703 else
2704   AC_MSG_RESULT(no)
2706 AC_SUBST($1)dnl
2709 # Check whether LC_MESSAGES is available in <locale.h>.
2710 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2712 # This file can be copied and used freely without restrictions.  It can
2713 # be used in projects which are not available under the GNU Public License
2714 # but which still want to provide support for the GNU gettext functionality.
2715 # Please note that the actual code is *not* freely available.
2717 # serial 2
2719 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2721 AC_DEFUN(AM_LC_MESSAGES,
2722   [if test $ac_cv_header_locale_h = yes; then
2723     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2724       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2725        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2726     if test $am_cv_val_LC_MESSAGES = yes; then
2727       AC_DEFINE(HAVE_LC_MESSAGES, 1,
2728                 [Define if your locale.h file contains LC_MESSAGES.])
2729     fi
2730   fi])