Changes the location of bison.simple after running bison on local
[findutils.git] / aclocal.m4
blob3a5c21dda90a88b3bc9d03da7d0a9b7207290e48
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 # This test replaces the one in autoconf.
509 # Currently this macro should have the same name as the autoconf macro
510 # because gettext's gettext.m4 (distributed in the automake package)
511 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
512 # give these diagnostics:
513 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
514 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
516 undefine([AC_ISC_POSIX])
518 AC_DEFUN([AC_ISC_POSIX],
519   [
520     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
521     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
522   ]
526 # serial 1
528 AC_DEFUN([AM_C_PROTOTYPES],
529 [AC_REQUIRE([AM_PROG_CC_STDC])
530 AC_REQUIRE([AC_PROG_CPP])
531 AC_MSG_CHECKING([for function prototypes])
532 if test "$am_cv_prog_cc_stdc" != no; then
533   AC_MSG_RESULT(yes)
534   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
535   U= ANSI2KNR=
536 else
537   AC_MSG_RESULT(no)
538   U=_ ANSI2KNR=./ansi2knr
540 # Ensure some checks needed by ansi2knr itself.
541 AC_HEADER_STDC
542 AC_CHECK_HEADERS(string.h)
543 AC_SUBST(U)dnl
544 AC_SUBST(ANSI2KNR)dnl
548 # serial 1
550 # @defmac AC_PROG_CC_STDC
551 # @maindex PROG_CC_STDC
552 # @ovindex CC
553 # If the C compiler in not in ANSI C mode by default, try to add an option
554 # to output variable @code{CC} to make it so.  This macro tries various
555 # options that select ANSI C on some system or another.  It considers the
556 # compiler to be in ANSI C mode if it handles function prototypes correctly.
558 # If you use this macro, you should check after calling it whether the C
559 # compiler has been set to accept ANSI C; if not, the shell variable
560 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
561 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
562 # program @code{ansi2knr}, which comes with Ghostscript.
563 # @end defmac
565 AC_DEFUN([AM_PROG_CC_STDC],
566 [AC_REQUIRE([AC_PROG_CC])
567 AC_BEFORE([$0], [AC_C_INLINE])
568 AC_BEFORE([$0], [AC_C_CONST])
569 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
570 dnl a magic option to avoid problems with ANSI preprocessor commands
571 dnl like #elif.
572 dnl FIXME: can't do this because then AC_AIX won't work due to a
573 dnl circular dependency.
574 dnl AC_BEFORE([$0], [AC_PROG_CPP])
575 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
576 AC_CACHE_VAL(am_cv_prog_cc_stdc,
577 [am_cv_prog_cc_stdc=no
578 ac_save_CC="$CC"
579 # Don't try gcc -ansi; that turns off useful extensions and
580 # breaks some systems' header files.
581 # AIX                   -qlanglvl=ansi
582 # Ultrix and OSF/1      -std1
583 # HP-UX 10.20 and later -Ae
584 # HP-UX older versions  -Aa -D_HPUX_SOURCE
585 # SVR4                  -Xc -D__EXTENSIONS__
586 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
588   CC="$ac_save_CC $ac_arg"
589   AC_TRY_COMPILE(
590 [#include <stdarg.h>
591 #include <stdio.h>
592 #include <sys/types.h>
593 #include <sys/stat.h>
594 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
595 struct buf { int x; };
596 FILE * (*rcsopen) (struct buf *, struct stat *, int);
597 static char *e (p, i)
598      char **p;
599      int i;
601   return p[i];
603 static char *f (char * (*g) (char **, int), char **p, ...)
605   char *s;
606   va_list v;
607   va_start (v,p);
608   s = g (p, va_arg (v,int));
609   va_end (v);
610   return s;
612 int test (int i, double x);
613 struct s1 {int (*f) (int a);};
614 struct s2 {int (*f) (double a);};
615 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
616 int argc;
617 char **argv;
618 ], [
619 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
621 [am_cv_prog_cc_stdc="$ac_arg"; break])
622 done
623 CC="$ac_save_CC"
625 if test -z "$am_cv_prog_cc_stdc"; then
626   AC_MSG_RESULT([none needed])
627 else
628   AC_MSG_RESULT([$am_cv_prog_cc_stdc])
630 case "x$am_cv_prog_cc_stdc" in
631   x|xno) ;;
632   *) CC="$CC $am_cv_prog_cc_stdc" ;;
633 esac
636 #serial 13, with several lines deleted for fileutils.
638 dnl Misc type-related macros for fileutils, sh-utils, textutils.
640 AC_DEFUN(jm_MACROS,
642   AC_PREREQ(2.14a)
644   GNU_PACKAGE="GNU $PACKAGE"
645   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
646     [The concatenation of the strings `GNU ', and PACKAGE.])
647   AC_SUBST(GNU_PACKAGE)
649   AC_SUBST(OPTIONAL_BIN_PROGS)
650   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
651   AC_SUBST(MAN)
652   AC_SUBST(DF_PROG)
654   dnl This macro actually runs replacement code.  See isc-posix.m4.
655   AC_REQUIRE([AC_ISC_POSIX])dnl
657   AC_CHECK_HEADERS( \
658     errno.h  \
659     fcntl.h \
660     fenv.h \
661     float.h \
662     limits.h \
663     memory.h \
664     mntent.h \
665     mnttab.h \
666     netdb.h \
667     paths.h \
668     stdlib.h \
669     stddef.h \
670     string.h \
671     sys/acl.h \
672     sys/filsys.h \
673     sys/fs/s5param.h \
674     sys/fs_types.h \
675     sys/fstyp.h \
676     sys/ioctl.h \
677     sys/mntent.h \
678     sys/mount.h \
679     sys/param.h \
680     sys/socket.h \
681     sys/statfs.h \
682     sys/statvfs.h \
683     sys/systeminfo.h \
684     sys/time.h \
685     sys/timeb.h \
686     sys/vfs.h \
687     sys/wait.h \
688     syslog.h \
689     termios.h \
690     unistd.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   # These tests are for df.
784   jm_FSTYPENAME
788 AC_DEFUN(jm_CHECK_ALL_TYPES,
790   dnl Checks for typedefs, structures, and compiler characteristics.
791   AC_REQUIRE([AC_C_BIGENDIAN])
792   AC_REQUIRE([AC_PROG_CC_STDC])
793   AC_REQUIRE([AC_C_CONST])
794   AC_REQUIRE([AC_C_VOLATILE])
795   AC_REQUIRE([AC_C_INLINE])
796   AC_REQUIRE([AC_C_LONG_DOUBLE])
798   AC_REQUIRE([AC_HEADER_DIRENT])
799   AC_REQUIRE([AC_HEADER_STDC])
800   AC_CHECK_MEMBERS([struct stat.st_blksize],,,[$ac_includes_default
801 #include <sys/stat.h>
802   ])
803   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
805   AC_REQUIRE([AC_STRUCT_TM])
806   AC_REQUIRE([AC_STRUCT_TIMEZONE])
807   AC_REQUIRE([AC_HEADER_STAT])
808   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
809   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
810   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
812   AC_REQUIRE([AC_TYPE_GETGROUPS])
813   AC_REQUIRE([AC_TYPE_MODE_T])
814   AC_REQUIRE([AC_TYPE_OFF_T])
815   AC_REQUIRE([AC_TYPE_PID_T])
816   AC_REQUIRE([AC_TYPE_SIGNAL])
817   AC_REQUIRE([AC_TYPE_SIZE_T])
818   AC_REQUIRE([AC_TYPE_UID_T])
819   AC_CHECK_TYPE(ino_t, unsigned long)
821   dnl This relies on the fact that autoconf 2.14a's implementation of
822   dnl AC_CHECK_TYPE checks includes unistd.h.
823   AC_CHECK_TYPE(ssize_t, int)
825   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
826   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
828   AC_REQUIRE([AC_HEADER_MAJOR])
829   AC_REQUIRE([AC_HEADER_DIRENT])
833 #serial 7
835 dnl Initially derived from code in GNU grep.
836 dnl Mostly written by Jim Meyering.
838 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
840 AC_DEFUN(jm_INCLUDED_REGEX,
841   [
842     dnl Even packages that don't use regex.c can use this macro.
843     dnl Of course, for them it doesn't do anything.
845     # Assume we'll default to using the included regex.c.
846     ac_use_included_regex=yes
848     # However, if the system regex support is good enough that it passes the
849     # the following run test, then default to *not* using the included regex.c.
850     # If cross compiling, assume the test would fail and use the included
851     # regex.c.  The first failing regular expression is from `Spencer ere
852     # test #75' in grep-2.3.
853     AC_CACHE_CHECK([for working re_compile_pattern],
854                    jm_cv_func_working_re_compile_pattern,
855       AC_TRY_RUN(
856 [#include <stdio.h>
857 #include <regex.h>
858           int
859           main ()
860           {
861             static struct re_pattern_buffer regex;
862             const char *s;
863             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
864             /* Add this third left square bracket, [, to balance the
865                three right ones below.  Otherwise autoconf-2.14 chokes.  */
866             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
867             /* This should fail with _Invalid character class name_ error.  */
868             if (!s)
869               exit (1);
871             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
872             s = re_compile_pattern ("{1", 2, &regex);
874             exit (s ? 1 : 0);
875           }
876         ],
877                jm_cv_func_working_re_compile_pattern=yes,
878                jm_cv_func_working_re_compile_pattern=no,
879                dnl When crosscompiling, assume it's broken.
880                jm_cv_func_working_re_compile_pattern=no))
881     if test $jm_cv_func_working_re_compile_pattern = yes; then
882       ac_use_included_regex=no
883     fi
885     test -n "$1" || AC_MSG_ERROR([missing argument])
886     syscmd([test -f $1])
887     ifelse(sysval, 0,
888       [
890         AC_ARG_WITH(included-regex,
891         [  --without-included-regex don't compile regex; this is the default on
892                           systems with version 2 of the GNU C library
893                           (use with caution on other system)],
894                     jm_with_regex=$withval,
895                     jm_with_regex=$ac_use_included_regex)
896         if test "$jm_with_regex" = yes; then
897           AC_SUBST(LIBOBJS)
898           LIBOBJS="$LIBOBJS regex.$ac_objext"
899         fi
900       ],
901     )
902   ]
905 #serial 2
906 dnl based on code from Eleftherios Gkioulekas
908 AC_DEFUN(jm_ASSERT,
910   AC_MSG_CHECKING(whether to enable assertions)
911   AC_ARG_ENABLE(assert,
912         [  --disable-assert        turn off assertions],
913         [ AC_MSG_RESULT(no)
914           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
915         [ AC_MSG_RESULT(yes) ]
916                )
919 #serial 3
921 dnl From Paul Eggert.
923 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
924 # doesn't clash with <sys/types.h>, and declares uintmax_t.
926 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
928   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
929   [AC_TRY_COMPILE(
930     [#include <sys/types.h>
931 #include <inttypes.h>],
932     [uintmax_t i = (uintmax_t) -1;],
933     jm_ac_cv_header_inttypes_h=yes,
934     jm_ac_cv_header_inttypes_h=no)])
935   if test $jm_ac_cv_header_inttypes_h = yes; then
936     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
937 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
938    and declares uintmax_t. ])
939   fi
942 #serial 3
944 dnl From Jim Meyering.
946 dnl Check whether struct dirent has a member named d_type.
949 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
950   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
951    AC_CACHE_CHECK([for d_type member in directory struct],
952                   jm_cv_struct_dirent_d_type,
953      [AC_TRY_LINK(dnl
954        [
955 #include <sys/types.h>
956 #ifdef HAVE_DIRENT_H
957 # include <dirent.h>
958 #else /* not HAVE_DIRENT_H */
959 # define dirent direct
960 # ifdef HAVE_SYS_NDIR_H
961 #  include <sys/ndir.h>
962 # endif /* HAVE_SYS_NDIR_H */
963 # ifdef HAVE_SYS_DIR_H
964 #  include <sys/dir.h>
965 # endif /* HAVE_SYS_DIR_H */
966 # ifdef HAVE_NDIR_H
967 #  include <ndir.h>
968 # endif /* HAVE_NDIR_H */
969 #endif /* HAVE_DIRENT_H */
970        ],
971        [struct dirent dp; dp.d_type = 0;],
973        jm_cv_struct_dirent_d_type=yes,
974        jm_cv_struct_dirent_d_type=no)
975      ]
976    )
977    if test $jm_cv_struct_dirent_d_type = yes; then
978      AC_DEFINE(D_TYPE_IN_DIRENT, 1,
979   [Define if there is a member named d_type in the struct describing
980    directory headers.])
981    fi
982   ]
985 #serial 3
987 dnl From Jim Meyering.
989 dnl Check whether struct dirent has a member named d_ino.
992 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
993   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
994    AC_CACHE_CHECK([for d_ino member in directory struct],
995                   jm_cv_struct_dirent_d_ino,
996      [AC_TRY_LINK(dnl
997        [
998 #include <sys/types.h>
999 #ifdef HAVE_DIRENT_H
1000 # include <dirent.h>
1001 #else /* not HAVE_DIRENT_H */
1002 # define dirent direct
1003 # ifdef HAVE_SYS_NDIR_H
1004 #  include <sys/ndir.h>
1005 # endif /* HAVE_SYS_NDIR_H */
1006 # ifdef HAVE_SYS_DIR_H
1007 #  include <sys/dir.h>
1008 # endif /* HAVE_SYS_DIR_H */
1009 # ifdef HAVE_NDIR_H
1010 #  include <ndir.h>
1011 # endif /* HAVE_NDIR_H */
1012 #endif /* HAVE_DIRENT_H */
1013        ],
1014        [struct dirent dp; dp.d_ino = 0;],
1016        jm_cv_struct_dirent_d_ino=yes,
1017        jm_cv_struct_dirent_d_ino=no)
1018      ]
1019    )
1020    if test $jm_cv_struct_dirent_d_ino = yes; then
1021      AC_DEFINE(D_INO_IN_DIRENT, 1,
1022   [Define if there is a member named d_ino in the struct describing
1023    directory headers.])
1024    fi
1025   ]
1028 #serial 16
1030 dnl This is just a wrapper function to encapsulate this kludge.
1031 dnl Putting it in a separate file like this helps share it between
1032 dnl different packages.
1033 AC_DEFUN(jm_CHECK_DECLS,
1035   AC_REQUIRE([_jm_DECL_HEADERS])
1036   AC_REQUIRE([AC_HEADER_TIME])
1037   headers='
1038 #include <stdio.h>
1039 #if HAVE_STRING_H
1040 # if !STDC_HEADERS && HAVE_MEMORY_H
1041 #  include <memory.h>
1042 # endif
1043 # include <string.h>
1044 #else
1045 # if HAVE_STRINGS_H
1046 #  include <strings.h>
1047 # endif
1048 #endif
1049 #if HAVE_STDLIB_H
1050 # include <stdlib.h>
1051 #endif
1052 #if HAVE_UNISTD_H
1053 # include <unistd.h>
1054 #endif
1056 #include <sys/types.h>
1057 #if TIME_WITH_SYS_TIME
1058 # include <sys/time.h>
1059 # include <time.h>
1060 #else
1061 # if HAVE_SYS_TIME_H
1062 #  include <sys/time.h>
1063 # else
1064 #  include <time.h>
1065 # endif
1066 #endif
1068 #if HAVE_UTMP_H
1069 # include <utmp.h>
1070 #endif
1073   AC_CHECK_DECLS([
1074     free,
1075     getenv,
1076     geteuid,
1077     getgrgid,
1078     getlogin,
1079     getpwuid,
1080     getuid,
1081     getutent,
1082     lseek,
1083     malloc,
1084     memchr,
1085     memrchr,
1086     realloc,
1087     stpcpy,
1088     strndup,
1089     strnlen,
1090     strstr,
1091     strtoul,
1092     strtoull,
1093     ttyname], , , $headers)
1096 dnl FIXME: when autoconf has support for it.
1097 dnl This is a little helper so we can require these header checks.
1098 AC_DEFUN(_jm_DECL_HEADERS,
1100   AC_REQUIRE([AC_HEADER_STDC])
1101   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
1102                    utmp.h utmpx.h)
1105 #serial 5
1107 dnl These are the prerequisite macros for files in the lib/
1108 dnl directories of the fileutils, sh-utils, and textutils packages.
1110 AC_DEFUN(jm_PREREQ,
1112   jm_PREREQ_ADDEXT
1113   jm_PREREQ_CANON_HOST
1114   jm_PREREQ_ERROR
1115   jm_PREREQ_QUOTEARG
1116   jm_PREREQ_READUTMP
1117   jm_PREREQ_REGEX
1120 AC_DEFUN(jm_PREREQ_ADDEXT,
1122   dnl For addext.c.
1123   AC_SYS_LONG_FILE_NAMES
1124   AC_CHECK_FUNCS(pathconf)
1125   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1128 AC_DEFUN(jm_PREREQ_CANON_HOST,
1130   dnl Add any libraries as early as possible.
1131   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1132   dnl so we have to add -lnsl to LIBS before checking for that function.
1133   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1135   dnl These come from -lnsl on Solaris5.5.1.
1136   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1138   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1139   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1140                    netinet/in.h arpa/inet.h)
1143 AC_DEFUN(jm_PREREQ_QUOTEARG,
1145   AC_CHECK_FUNCS(isascii iswprint mbrtowc)
1146   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
1147   AC_HEADER_STDC
1148   AC_C_BACKSLASH_A
1149   AC_MBSTATE_T_OBJECT
1150   AM_C_PROTOTYPES
1153 AC_DEFUN(jm_PREREQ_READUTMP,
1155   AC_HEADER_STDC
1156   AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
1157   AC_CHECK_FUNCS(utmpname)
1158   AC_CHECK_FUNCS(utmpxname)
1159   AM_C_PROTOTYPES
1161   utmp_includes="\
1162 $ac_includes_default
1163 #ifdef HAVE_UTMPX_H
1164 # include <utmpx.h>
1165 #else
1166 # include <utmp.h>
1167 #endif
1169   AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
1170   AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
1171   AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
1172   AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
1175 AC_DEFUN(jm_PREREQ_REGEX,
1177   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1178   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1179   dnl to get them.
1180   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
1181   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
1182   AC_HEADER_STDC
1183   AC_FUNC_ALLOCA
1186 #serial 1
1188 dnl FIXME: put these prerequisite-only *.m4 files in a separate
1189 dnl directory -- otherwise, they'll conflict with existing files.
1191 dnl These are the prerequisite macros for GNU's error.c file.
1192 AC_DEFUN(jm_PREREQ_ERROR,
1194   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
1195   AC_HEADER_STDC
1198 #serial 3
1200 dnl From Paul Eggert.
1202 AC_DEFUN(AC_C_BACKSLASH_A,
1204   AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1205    [AC_TRY_COMPILE([],
1206      [
1207 #if '\a' == 'a'
1208       syntax error;
1209 #endif
1210       char buf['\a' == 'a' ? -1 : 1];
1211       buf[0] = '\a';
1212       return buf[0] != "\a"[0];
1213      ],
1214      ac_cv_c_backslash_a=yes,
1215      ac_cv_c_backslash_a=no)])
1216   if test $ac_cv_c_backslash_a = yes; then
1217     AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1218       [Define if backslash-a works in C strings.])
1219   fi
1222 # serial 1
1224 # From Paul Eggert.
1226 # Some versions of BeOS define mbstate_t to be an incomplete type,
1227 # so you can't declare an object of that type.
1228 # Check for this incompatibility with Standard C.
1230 AC_DEFUN(AC_MBSTATE_T_OBJECT,
1231   [AC_CACHE_CHECK([for mbstate_t object type], ac_cv_type_mbstate_t_object,
1232     [AC_TRY_COMPILE([#include <wchar.h>],
1233       [mbstate_t x; return sizeof x;],
1234       ac_cv_type_mbstate_t_object=yes,
1235       ac_cv_type_mbstate_t_object=no)])
1236    if test $ac_cv_type_mbstate_t_object = yes; then
1237      AC_DEFINE(HAVE_MBSTATE_T_OBJECT, 1,
1238                [Define if mbstate_t is an object type.])
1239    fi])
1241 #serial 7
1243 dnl From Jim Meyering.
1244 dnl A wrapper around AC_FUNC_MKTIME.
1246 AC_DEFUN(jm_FUNC_MKTIME,
1247 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
1249  dnl mktime.c uses localtime_r if it exists.  Check for it.
1250  AC_CHECK_FUNCS(localtime_r)
1252  if test $ac_cv_func_working_mktime = no; then
1253    AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
1254     [Define to rpl_mktime if the replacement function should be used.])
1255  fi
1258 #serial 3
1260 dnl From Jim Meyering.
1261 dnl Determine whether lstat has the bug that it succeeds when given the
1262 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
1263 dnl (as of 1998-11-01) do this.
1265 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
1266 dnl compile the wrapper function.
1269 AC_DEFUN(jm_FUNC_LSTAT,
1271  AC_CACHE_CHECK([whether lstat accepts an empty string],
1272   jm_cv_func_lstat_empty_string_bug,
1273   [AC_TRY_RUN([
1274 #   include <sys/types.h>
1275 #   include <sys/stat.h>
1277     int
1278     main ()
1279     {
1280       struct stat sbuf;
1281       exit (lstat ("", &sbuf) ? 1 : 0);
1282     }
1283           ],
1284          jm_cv_func_lstat_empty_string_bug=yes,
1285          jm_cv_func_lstat_empty_string_bug=no,
1286          dnl When crosscompiling, assume lstat is broken.
1287          jm_cv_func_lstat_empty_string_bug=yes)
1288   ])
1289   if test $jm_cv_func_lstat_empty_string_bug = yes; then
1290     AC_SUBST(LIBOBJS)
1291     LIBOBJS="$LIBOBJS lstat.$ac_objext"
1292     AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
1293 [Define if lstat has the bug that it succeeds when given the zero-length
1294    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1295    do this. ])
1296   fi
1299 #serial 1
1301 dnl From Jim Meyering.
1302 dnl FIXME: describe
1304 AC_DEFUN(jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK,
1306  AC_CACHE_CHECK(
1307   [whether lstat dereferences a symlink specified with a trailing slash],
1308   jm_cv_func_lstat_dereferences_slashed_symlink,
1309   [
1310    rm -f conftest.sym conftest.file
1311    : > conftest.file
1312    if ln -s conftest.file conftest.sym; then
1313      AC_TRY_RUN([
1314 #     include <sys/types.h>
1315 #     include <sys/stat.h>
1317       int
1318       main ()
1319       {
1320         struct stat sbuf;
1321         /* Linux will dereference the symlink and fail.
1322            That is better in the sense that it means we will not
1323            have to compile and use the lstat wrapper.  */
1324         exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
1325       }
1326       ],
1327       jm_cv_func_lstat_dereferences_slashed_symlink=yes,
1328       jm_cv_func_lstat_dereferences_slashed_symlink=no,
1329       dnl When crosscompiling, be pessimistic so we will end up using the
1330       dnl replacement version of lstat that checkes for trailing slashes
1331       dnl and calls lstat a second time when necessary.
1332       jm_cv_func_lstat_dereferences_slashed_symlink=no
1333      )
1334    else
1335      # If the `ln -s' command failed, then we probably don't even
1336      # have an lstat function.
1337      jm_cv_func_lstat_dereferences_slashed_symlink=no
1338    fi
1339   ])
1341   test $jm_cv_func_lstat_dereferences_slashed_symlink = yes \
1342     && zero_one=1 \
1343     || zero_one=0
1344   AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, $zero_one,
1345     [Define if lstat dereferences a symlink specified with a trailing slash])
1347   if test $jm_cv_func_lstat_dereferences_slashed_symlink = no; then
1348     AC_SUBST(LIBOBJS)
1349     # Append lstat.o if it's not already in $LIBOBJS.
1350     case "$LIBOBJS" in
1351       *lstat.$ac_objext*) ;;
1352       *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
1353     esac
1354   fi
1357 #serial 3
1359 dnl From Jim Meyering.
1360 dnl Determine whether stat has the bug that it succeeds when given the
1361 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
1362 dnl (as of 1998-11-01) do this.
1364 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
1365 dnl compile the wrapper function.
1368 AC_DEFUN(jm_FUNC_STAT,
1370  AC_CACHE_CHECK([whether stat accepts an empty string],
1371   jm_cv_func_stat_empty_string_bug,
1372   [AC_TRY_RUN([
1373 #   include <sys/types.h>
1374 #   include <sys/stat.h>
1376     int
1377     main ()
1378     {
1379       struct stat sbuf;
1380       exit (stat ("", &sbuf) ? 1 : 0);
1381     }
1382           ],
1383          jm_cv_func_stat_empty_string_bug=yes,
1384          jm_cv_func_stat_empty_string_bug=no,
1385          dnl When crosscompiling, assume stat is broken.
1386          jm_cv_func_stat_empty_string_bug=yes)
1387   ])
1388   if test $jm_cv_func_stat_empty_string_bug = yes; then
1389     AC_SUBST(LIBOBJS)
1390     LIBOBJS="$LIBOBJS stat.$ac_objext"
1391     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
1392 [Define if stat has the bug that it succeeds when given the zero-length
1393    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1394    do this. ])
1395   fi
1398 #serial 3
1400 dnl From Jim Meyering.
1401 dnl Determine whether realloc works when both arguments are 0.
1402 dnl If it doesn't, arrange to use the replacement function.
1405 AC_DEFUN(jm_FUNC_REALLOC,
1407  dnl xmalloc.c requires that this symbol be defined so it doesn't
1408  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
1409  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
1410                     [Define if the realloc check has been performed. ])
1412  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
1413   [AC_TRY_RUN([
1414     char *realloc ();
1415     int
1416     main ()
1417     {
1418       exit (realloc (0, 0) ? 0 : 1);
1419     }
1420           ],
1421          jm_cv_func_working_realloc=yes,
1422          jm_cv_func_working_realloc=no,
1423          dnl When crosscompiling, assume realloc is broken.
1424          jm_cv_func_working_realloc=no)
1425   ])
1426   if test $jm_cv_func_working_realloc = no; then
1427     AC_SUBST(LIBOBJS)
1428     LIBOBJS="$LIBOBJS realloc.$ac_objext"
1429     AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
1430       [Define to rpl_realloc if the replacement function should be used.])
1431   fi
1434 #serial 3
1436 dnl From Jim Meyering.
1437 dnl Determine whether malloc accepts 0 as its argument.
1438 dnl If it doesn't, arrange to use the replacement function.
1441 AC_DEFUN(jm_FUNC_MALLOC,
1443  dnl xmalloc.c requires that this symbol be defined so it doesn't
1444  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
1445  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
1446                     [Define if the malloc check has been performed. ])
1448  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1449   [AC_TRY_RUN([
1450     char *malloc ();
1451     int
1452     main ()
1453     {
1454       exit (malloc (0) ? 0 : 1);
1455     }
1456           ],
1457          jm_cv_func_working_malloc=yes,
1458          jm_cv_func_working_malloc=no,
1459          dnl When crosscompiling, assume malloc is broken.
1460          jm_cv_func_working_malloc=no)
1461   ])
1462   if test $jm_cv_func_working_malloc = no; then
1463     AC_SUBST(LIBOBJS)
1464     LIBOBJS="$LIBOBJS malloc.$ac_objext"
1465     AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
1466       [Define to rpl_malloc if the replacement function should be used.])
1467   fi
1470 #serial 3
1472 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1473 dnl to test whether a NULL return value really means there are no more files
1474 dnl in the directory.
1476 dnl Detect the problem by creating a directory containing 300 files (254 not
1477 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1478 dnl removes all of them.
1480 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1482 dnl Written by Jim Meyering.
1484 AC_DEFUN(jm_FUNC_READDIR,
1485 [dnl
1486 AC_REQUIRE([AC_HEADER_DIRENT])
1487 AC_CHECK_HEADERS(string.h)
1488 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1489   [dnl
1490   # Arrange for deletion of the temporary directory this test creates, in
1491   # case the test itself fails to delete everything -- as happens on Sunos.
1492   ac_clean_files="$ac_clean_files conf-dir"
1494   AC_TRY_RUN(
1495 [#   include <stdio.h>
1496 #   include <sys/types.h>
1497 #   if HAVE_STRING_H
1498 #    include <string.h>
1499 #   endif
1501 #   ifdef HAVE_DIRENT_H
1502 #    include <dirent.h>
1503 #    define NLENGTH(direct) (strlen((direct)->d_name))
1504 #   else /* not HAVE_DIRENT_H */
1505 #    define dirent direct
1506 #    define NLENGTH(direct) ((direct)->d_namlen)
1507 #    ifdef HAVE_SYS_NDIR_H
1508 #     include <sys/ndir.h>
1509 #    endif /* HAVE_SYS_NDIR_H */
1510 #    ifdef HAVE_SYS_DIR_H
1511 #     include <sys/dir.h>
1512 #    endif /* HAVE_SYS_DIR_H */
1513 #    ifdef HAVE_NDIR_H
1514 #     include <ndir.h>
1515 #    endif /* HAVE_NDIR_H */
1516 #   endif /* HAVE_DIRENT_H */
1518 #   define DOT_OR_DOTDOT(Basename) \
1519      (Basename[0] == '.' && (Basename[1] == '\0' \
1520                              || (Basename[1] == '.' && Basename[2] == '\0')))
1522     static void
1523     create_300_file_dir (const char *dir)
1524     {
1525       int i;
1527       if (mkdir (dir, 0700))
1528         abort ();
1529       if (chdir (dir))
1530         abort ();
1532       for (i = 0; i < 300; i++)
1533         {
1534           char file_name[4];
1535           FILE *out;
1537           sprintf (file_name, "%03d", i);
1538           out = fopen (file_name, "w");
1539           if (!out)
1540             abort ();
1541           if (fclose (out) == EOF)
1542             abort ();
1543         }
1545       if (chdir (".."))
1546         abort ();
1547     }
1549     static void
1550     remove_dir (const char *dir)
1551     {
1552       DIR *dirp;
1554       if (chdir (dir))
1555         abort ();
1557       dirp = opendir (".");
1558       if (dirp == NULL)
1559         abort ();
1561       while (1)
1562         {
1563           struct dirent *dp = readdir (dirp);
1564           if (dp == NULL)
1565             break;
1567           if (DOT_OR_DOTDOT (dp->d_name))
1568             continue;
1570           if (unlink (dp->d_name))
1571             abort ();
1572         }
1573       closedir (dirp);
1575       if (chdir (".."))
1576         abort ();
1578       if (rmdir (dir))
1579         exit (1);
1580     }
1582     int
1583     main ()
1584     {
1585       const char *dir = "conf-dir";
1586       create_300_file_dir (dir);
1587       remove_dir (dir);
1588       exit (0);
1589     }],
1590   jm_cv_func_working_readdir=yes,
1591   jm_cv_func_working_readdir=no,
1592   jm_cv_func_working_readdir=no)])
1594   if test $jm_cv_func_working_readdir = yes; then
1595     AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
1596 [Define if readdir is found to work properly in some unusual cases. ])
1597   fi
1600 #serial 4
1602 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1603 dnl the losing memcmp on some x86 Next systems.
1604 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1605 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1606 [AC_TRY_RUN(
1607 [int
1608 main ()
1610   /* Some versions of memcmp are not 8-bit clean.  */
1611   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1612   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1613     exit (1);
1615   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1616      or more and with at least one buffer not starting on a 4-byte boundary.
1617      William Lewis provided this test program.   */
1618   {
1619     char foo[21];
1620     char bar[21];
1621     int i;
1622     for (i = 0; i < 4; i++)
1623       {
1624         char *a = foo + i;
1625         char *b = bar + i;
1626         strcpy (a, "--------01111111");
1627         strcpy (b, "--------10000000");
1628         if (memcmp (a, b, 16) >= 0)
1629           exit (1);
1630       }
1631     exit (0);
1632   }
1634    jm_cv_func_memcmp_working=yes,
1635    jm_cv_func_memcmp_working=no,
1636    jm_cv_func_memcmp_working=no)])
1637 test $jm_cv_func_memcmp_working = no \
1638   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
1639 AC_SUBST(LIBOBJS)dnl
1642 AC_DEFUN(jm_FUNC_MEMCMP,
1643 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1644  if test $jm_cv_func_memcmp_working = no; then
1645    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
1646      [Define to rpl_memcmp if the replacement function should be used.])
1647  fi
1650 #serial 4
1652 dnl From Jim Meyering.
1654 dnl See if the glibc *_unlocked I/O macros are available.
1655 dnl Use only those *_unlocked macros that are declared.
1658 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1659   [
1660     # Kludge (not executed) to make autoheader do the right thing.
1661     if test a = b; then
1662       AC_CHECK_DECLS([clearerr_unlocked, feof_unlocked, ferror_unlocked,
1663         fflush_unlocked, fputc_unlocked, fread_unlocked, fwrite_unlocked,
1664         getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked])
1665     fi
1667     io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
1668     fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
1669     getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
1670     for jm_io_func in $io_functions; do
1671       # Check for the existence of each function only if its declared.
1672       # Otherwise, we'd get the Solaris5.5.1 functions that are not
1673       # declared, and that have been removed from Solaris5.6.  The resulting
1674       # 5.5.1 binaries would not run on 5.6 due to shared library differences.
1675       AC_CHECK_DECLS([$jm_io_func],
1676                      jm_declared=yes,
1677                      jm_declared=no,
1678                      [#include <stdio.h>])
1679       if test $jm_declared = yes; then
1680         AC_CHECK_FUNCS($jm_io_func)
1681       fi
1682     done
1683   ]
1686 #serial 2
1688 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1689 dnl define fnmatch to rpl_fnmatch.
1692 # AC_FUNC_FNMATCH
1693 # ---------------
1694 # We look for fnmatch.h to avoid that the test fails in C++.
1695 AC_DEFUN(kd_FUNC_FNMATCH_CASE,
1696 [AC_CHECK_HEADERS(fnmatch.h)
1697 AC_CACHE_CHECK(for working fnmatch with case folding, ac_cv_func_fnmatch_works,
1698 # Some versions of Solaris or SCO have a broken fnmatch function.
1699 # So we run a test program.  If we are cross-compiling, take no chance.
1700 # Also want FNM_CASEFOLD
1701 # Thanks to John Oleynick and Franc,ois Pinard for this test.
1702 [AC_TRY_RUN(
1703 [#include <stdio.h>
1704 #define _GNU_SOURCE
1705 #if HAVE_FNMATCH_H
1706 # include <fnmatch.h>
1707 #endif
1710 main ()
1712   exit (fnmatch ("A*", "abc", FNM_CASEFOLD) != 0);
1714 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
1715 ac_cv_func_fnmatch_works=no)])
1716 if test $ac_cv_func_fnmatch_works = yes; then
1717   AC_DEFINE(HAVE_FNMATCH, 1,
1718             [Define if your system has a working `fnmatch' function with case folding.])
1720 ])# AC_FUNC_FNMATCH
1723 AC_DEFUN(kd_FUNC_FNMATCH_CASE_RPL,
1725   AC_REQUIRE([AM_GLIBC])
1726   kd_FUNC_FNMATCH_CASE
1727   if test $ac_cv_func_fnmatch_works = no \
1728       && test $ac_cv_gnu_library = no; then
1729     AC_SUBST(LIBOBJS)
1730     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
1731     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
1732       [Define to rpl_fnmatch if the replacement function should be used.])
1733   fi
1736 #serial 2
1738 dnl From Gordon Matzigkeit.
1739 dnl Test for the GNU C Library.
1740 dnl FIXME: this should migrate into libit.
1742 AC_DEFUN(AM_GLIBC,
1743   [
1744     AC_CACHE_CHECK(whether we are using the GNU C Library,
1745       ac_cv_gnu_library,
1746       [AC_EGREP_CPP([Thanks for using GNU],
1747         [
1748 #include <features.h>
1749 #ifdef __GNU_LIBRARY__
1750   Thanks for using GNU
1751 #endif
1752         ],
1753         ac_cv_gnu_library=yes,
1754         ac_cv_gnu_library=no)
1755       ]
1756     )
1757     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1758       ac_cv_glibc,
1759       [AC_EGREP_CPP([Thanks for using GNU too],
1760         [
1761 #include <features.h>
1762 #ifdef __GLIBC__
1763   Thanks for using GNU too
1764 #endif
1765         ],
1766         ac_cv_glibc=yes, ac_cv_glibc=no)
1767       ]
1768     )
1769   ]
1772 #serial 3
1774 AC_DEFUN(jm_AFS,
1775   AC_MSG_CHECKING(for AFS)
1776   if test -d /afs; then
1777     AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
1778     ac_result=yes
1779   else
1780     ac_result=no
1781   fi
1782   AC_MSG_RESULT($ac_result)
1785 #serial 2
1787 # autoconf tests required for use of xstrtoumax.c
1789 AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
1791   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
1792   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1793   AC_CHECK_HEADERS(stdlib.h)
1795   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
1796     jm_cv_func_strtoumax_macro,
1797     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
1798 #ifdef strtoumax
1799  inttypes_h_defines_strtoumax
1800 #endif],
1801       jm_cv_func_strtoumax_macro=yes,
1802       jm_cv_func_strtoumax_macro=no))
1804   if test "$jm_cv_func_strtoumax_macro" != yes; then
1805     AC_REPLACE_FUNCS(strtoumax)
1806   fi
1808   dnl We don't need (and can't compile) the replacement strtoull
1809   dnl unless the type `unsigned long long' exists.
1810   dnl Also, only the replacement strtoumax invokes strtoull,
1811   dnl so we need the replacement strtoull only if strtoumax does not exist.
1812   case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
1813     yes,no,no)
1814       AC_REPLACE_FUNCS(strtoull)
1815       ;;
1816   esac
1820 #serial 2
1822 dnl From Paul Eggert.
1824 AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
1826   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
1827   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
1828     [unsigned long long ullmax = (unsigned long long) -1;
1829      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
1830     ac_cv_type_unsigned_long_long=yes,
1831     ac_cv_type_unsigned_long_long=no)])
1832   if test $ac_cv_type_unsigned_long_long = yes; then
1833     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
1834       [Define if you have the unsigned long long type.])
1835   fi
1838 #serial 1
1839 dnl Run a program to determine whether whether link(2) follows symlinks.
1840 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
1842 AC_DEFUN(jm_AC_FUNC_LINK_FOLLOWS_SYMLINK,
1843 [dnl
1844   AC_CACHE_CHECK([whether link(2) follows symlinks],
1845                  jm_ac_cv_func_link_follows_symlink,
1846   [
1847     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
1848     dnl the appropriate framework.
1849     test -z "$ac_cv_header_unistd_h" \
1850       && AC_CHECK_HEADERS(unistd.h)
1852     # Create a regular file.
1853     echo > conftest.file
1854     AC_TRY_RUN(
1855       [
1856 #       include <sys/types.h>
1857 #       include <sys/stat.h>
1858 #       ifdef HAVE_UNISTD_H
1859 #        include <unistd.h>
1860 #       endif
1862 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
1863           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
1864            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
1866         int
1867         main ()
1868         {
1869           const char *file = "conftest.file";
1870           const char *sym = "conftest.sym";
1871           const char *hard = "conftest.hard";
1872           struct stat sb_file, sb_hard;
1874           /* Create a symlink to the regular file. */
1875           if (symlink (file, sym))
1876             abort ();
1878           /* Create a hard link to that symlink.  */
1879           if (link (sym, hard))
1880             abort ();
1882           if (lstat (hard, &sb_hard))
1883             abort ();
1884           if (lstat (file, &sb_file))
1885             abort ();
1887           /* If the dev/inode of hard and file are the same, then
1888              the link call followed the symlink.  */
1889           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
1890         }
1891       ],
1892       jm_ac_cv_func_link_follows_symlink=yes,
1893       jm_ac_cv_func_link_follows_symlink=no,
1894       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
1895     )
1896   ])
1897   if test $jm_ac_cv_func_link_follows_symlink = yes; then
1898     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
1899       [Define if `link(2)' dereferences symbolic links.])
1900   fi
1903 # From Jim Meyering.  Use this if you use the GNU error.[ch].
1904 # FIXME: Migrate into libit
1906 AC_DEFUN([AM_FUNC_ERROR_AT_LINE],
1907 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1908  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1909               am_cv_lib_error_at_line=yes,
1910               am_cv_lib_error_at_line=no)])
1911  if test $am_cv_lib_error_at_line = no; then
1912    LIBOBJS="$LIBOBJS error.$ac_objext"
1913  fi
1914  AC_SUBST(LIBOBJS)dnl
1917 #serial 9
1919 dnl This macro is intended to be used solely in this file.
1920 dnl These are the prerequisite macros for GNU's strftime.c replacement.
1921 AC_DEFUN(_jm_STRFTIME_PREREQS,
1923  dnl strftime.c uses localtime_r if it exists.  Check for it.
1924  AC_CHECK_FUNCS(localtime_r)
1926  AC_CHECK_HEADERS(limits.h)
1927  AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
1929  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
1930  AC_STRUCT_TIMEZONE
1932  AC_CHECK_FUNCS(mblen mbrlen)
1934  AC_CHECK_MEMBER(struct tm.tm_gmtoff,
1935                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
1936                             [Define if struct tm has the tm_gmtoff member.])],
1937                  ,
1938                  [#include <time.h>])
1941 dnl Determine if the strftime function has all the features of the GNU one.
1943 dnl From Jim Meyering.
1945 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
1946 [AC_REQUIRE([AC_HEADER_TIME])dnl
1948  _jm_STRFTIME_PREREQS
1950  AC_REQUIRE([AC_C_CONST])dnl
1951  AC_REQUIRE([AC_HEADER_STDC])dnl
1952  AC_CHECK_HEADERS(sys/time.h)
1953  AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
1954   [# Set TZ to GMT0 to make strftime give consistent results during the test.
1955    ac_save_TZ="${TZ-GMT0}"
1956    TZ=GMT0
1957    export TZ
1958    AC_TRY_RUN(
1959 [ /* Ulrich Drepper provided parts of the test program.  */
1960 #if STDC_HEADERS
1961 # include <stdlib.h>
1962 #endif
1964 #if TIME_WITH_SYS_TIME
1965 # include <sys/time.h>
1966 # include <time.h>
1967 #else
1968 # if HAVE_SYS_TIME_H
1969 #  include <sys/time.h>
1970 # else
1971 #  include <time.h>
1972 # endif
1973 #endif
1975 static int
1976 compare (const char *fmt, const struct tm *tm, const char *expected)
1978   char buf[99];
1979   strftime (buf, 99, fmt, tm);
1980   if (strcmp (buf, expected))
1981     {
1982 #ifdef SHOW_FAILURES
1983       printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
1984               fmt, expected, buf);
1985 #endif
1986       return 1;
1987     }
1988   return 0;
1992 main ()
1994   int n_fail = 0;
1995   struct tm *tm;
1996   time_t t = 738367; /* Fri Jan  9 13:06:07 1970 */
1997   tm = gmtime (&t);
1999 #undef CMP
2000 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
2002   CMP ("%-m", "1");             /* GNU */
2003   CMP ("%A", "Friday");
2004   CMP ("%^A", "FRIDAY");        /* The ^ is a GNU extension.  */
2005   CMP ("%B", "January");
2006   CMP ("%^B", "JANUARY");
2007   CMP ("%C", "19");             /* POSIX.2 */
2008   CMP ("%D", "01/09/70");       /* POSIX.2 */
2009   CMP ("%F", "1970-01-09");
2010   CMP ("%G", "1970");           /* GNU */
2011   CMP ("%H", "13");
2012   CMP ("%I", "01");
2013   CMP ("%M", "06");
2014   CMP ("%M", "06");
2015   CMP ("%R", "13:06");          /* POSIX.2 */
2016   CMP ("%S", "07");
2017   CMP ("%T", "13:06:07");       /* POSIX.2 */
2018   CMP ("%U", "01");
2019   CMP ("%V", "02");
2020   CMP ("%W", "01");
2021   CMP ("%X", "13:06:07");
2022   CMP ("%Y", "1970");
2023   CMP ("%Z", "GMT");
2024   CMP ("%_m", " 1");            /* GNU */
2025   CMP ("%a", "Fri");
2026   CMP ("%^a", "FRI");
2027   CMP ("%b", "Jan");
2028   CMP ("%^b", "JAN");
2029   CMP ("%c", "Fri Jan  9 13:06:07 1970");
2030   CMP ("%^c", "FRI JAN  9 13:06:07 1970");
2031   CMP ("%d", "09");
2032   CMP ("%e", " 9");             /* POSIX.2 */
2033   CMP ("%g", "70");             /* GNU */
2034   CMP ("%h", "Jan");            /* POSIX.2 */
2035   CMP ("%^h", "JAN");
2036   CMP ("%j", "009");
2037   CMP ("%k", "13");             /* GNU */
2038   CMP ("%l", " 1");             /* GNU */
2039   CMP ("%m", "01");
2040   CMP ("%n", "\n");             /* POSIX.2 */
2041   CMP ("%p", "PM");
2042   CMP ("%r", "01:06:07 PM");    /* POSIX.2 */
2043   CMP ("%s", "738367");         /* GNU */
2044   CMP ("%t", "\t");             /* POSIX.2 */
2045   CMP ("%u", "5");              /* POSIX.2 */
2046   CMP ("%w", "5");
2047   CMP ("%x", "01/09/70");
2048   CMP ("%y", "70");
2049   CMP ("%z", "+0000");          /* GNU */
2051   exit (n_fail ? 1 : 0);
2053              jm_cv_func_working_gnu_strftime=yes,
2054              jm_cv_func_working_gnu_strftime=no,
2055              dnl When crosscompiling, assume strftime is missing or broken.
2056              jm_cv_func_working_gnu_strftime=no)
2057    dnl If TZ wasn't set before, this sets it to GMT0.  No real harm done.
2058    TZ="$ac_save_TZ"
2059   ])
2060   if test $jm_cv_func_working_gnu_strftime = no; then
2061     AC_SUBST(LIBOBJS)
2062     LIBOBJS="$LIBOBJS strftime.$ac_objext"
2063     AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
2064       [Define to gnu_strftime if the replacement function should be used.])
2065   fi
2068 AC_DEFUN(jm_FUNC_STRFTIME,
2070   _jm_STRFTIME_PREREQS
2071   AC_REPLACE_FUNCS(strftime)
2074 #serial 4
2076 dnl See if there's a working, system-supplied version of the getline function.
2077 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
2078 dnl have a function by that name in -linet that doesn't have anything
2079 dnl to do with the function we need.
2080 AC_DEFUN(AM_FUNC_GETLINE,
2081 [dnl
2082   am_getline_needs_run_time_check=no
2083   AC_CHECK_FUNC(getline,
2084                 dnl Found it in some library.  Verify that it works.
2085                 am_getline_needs_run_time_check=yes,
2086                 am_cv_func_working_getline=no)
2087   if test $am_getline_needs_run_time_check = yes; then
2088     AC_CHECK_HEADERS(string.h)
2089     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
2090     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
2091     AC_TRY_RUN([
2092 #    include <stdio.h>
2093 #    include <sys/types.h>
2094 #    if HAVE_STRING_H
2095 #     include <string.h>
2096 #    endif
2097     int foo()
2098     {
2099        char *path;
2100        size_t n;
2101        FILE *stream;
2102        char terminator;
2103        size_t offset;
2104        getstr(&path, &n, stream, terminator, offset);
2105      }
2107     int main ()
2108     { /* Based on a test program from Karl Heuer.  */
2109       char *line = NULL;
2110       size_t siz = 0;
2111       int len;
2112       FILE *in = fopen ("./conftest.data", "r");
2113       if (!in)
2114         return 1;
2115       len = getline (&line, &siz, in);
2116       nread = getstr (&path, &pathsize, fp, '\0', count);
2118       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
2119     }
2120     ], am_cv_func_working_getline=yes dnl The library version works.
2121     , am_cv_func_working_getline=no dnl The library version does NOT work.
2122     , am_cv_func_working_getline=no dnl We're cross compiling.
2123     )])
2124   fi
2126   if test $am_cv_func_working_getline = no; then
2127     AC_LIBOBJ(getline)
2128   fi
2131 #serial 2
2133 dnl From Jim Meyering.
2135 dnl See if struct statfs has the f_fstypename member.
2136 dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
2139 AC_DEFUN(jm_FSTYPENAME,
2140   [
2141     AC_CACHE_CHECK([for f_fstypename in struct statfs],
2142                    fu_cv_sys_f_fstypename_in_statfs,
2143       [
2144         AC_TRY_COMPILE(
2145           [
2146 #include <sys/param.h>
2147 #include <sys/types.h>
2148 #include <sys/mount.h>
2149           ],
2150           [struct statfs s; int i = sizeof s.f_fstypename;],
2151           fu_cv_sys_f_fstypename_in_statfs=yes,
2152           fu_cv_sys_f_fstypename_in_statfs=no
2153         )
2154       ]
2155     )
2157     if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
2158       AC_DEFINE_UNQUOTED(HAVE_F_FSTYPENAME_IN_STATFS, 1,
2159                          [Define if struct statfs has the f_fstypename member.])
2160     fi
2161   ]
2164 #serial 4
2166 dnl From Paul Eggert.
2168 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
2169 # if it exists.
2171 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
2172  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
2173    ac_cv_struct_st_mtim_nsec,
2174    [ac_save_CPPFLAGS="$CPPFLAGS"
2175     ac_cv_struct_st_mtim_nsec=no
2176     # tv_nsec -- the usual case
2177     # _tv_nsec -- Solaris 2.6, if
2178     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
2179     #    && !defined __EXTENSIONS__)
2180     # st__tim.tv_nsec -- UnixWare 2.1.2
2181     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
2182       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
2183       AC_TRY_COMPILE([#include <sys/types.h>
2184 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
2185         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
2186     done
2187     CPPFLAGS="$ac_save_CPPFLAGS"])
2189   if test $ac_cv_struct_st_mtim_nsec != no; then
2190     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
2191       [Define to be the nanoseconds member of struct stat's st_mtim,
2192    if it exists.])
2193   fi
2197 #serial 2
2199 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
2201 AC_DEFUN(AC_STRUCT_ST_DM_MODE,
2202  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
2203    [AC_TRY_COMPILE([#include <sys/types.h>
2204 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
2205      ac_cv_struct_st_dm_mode=yes,
2206      ac_cv_struct_st_dm_mode=no)])
2208   if test $ac_cv_struct_st_dm_mode = yes; then
2209     AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
2210                        [Define if struct stat has an st_dm_mode member. ])
2211   fi
2215 #serial 4
2217 dnl From Jim Meyering
2219 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
2220 dnl in time.h or sys/time.h.
2222 AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
2224   AC_REQUIRE([AC_HEADER_TIME])
2225   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
2226     [AC_TRY_COMPILE(
2227       [
2228 #      if TIME_WITH_SYS_TIME
2229 #       include <sys/time.h>
2230 #       include <time.h>
2231 #      else
2232 #       if HAVE_SYS_TIME_H
2233 #        include <sys/time.h>
2234 #       else
2235 #        include <time.h>
2236 #       endif
2237 #      endif
2238       ],
2239       [static struct timespec x; x.tv_sec = x.tv_nsec;],
2240       fu_cv_sys_struct_timespec=yes,
2241       fu_cv_sys_struct_timespec=no)
2242     ])
2244   if test $fu_cv_sys_struct_timespec = yes; then
2245     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
2246                        [Define if struct timespec is declared in <time.h>. ])
2247   fi
2250 #serial 5
2252 dnl From Paul Eggert.
2254 AC_PREREQ(2.13)
2256 # Define uintmax_t to `unsigned long' or `unsigned long long'
2257 # if <inttypes.h> does not exist.
2259 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
2261   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2262   if test $jm_ac_cv_header_inttypes_h = no; then
2263     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2264     test $ac_cv_type_unsigned_long_long = yes \
2265       && ac_type='unsigned long long' \
2266       || ac_type='unsigned long'
2267     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2268 [  Define to unsigned long or unsigned long long
2269    if <inttypes.h> doesn't define.])
2270   fi
2273 # Macro to add for using GNU gettext.
2274 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2276 # This file can be copied and used freely without restrictions.  It can
2277 # be used in projects which are not available under the GNU Public License
2278 # but which still want to provide support for the GNU gettext functionality.
2279 # Please note that the actual code is *not* freely available.
2281 # serial 9
2283 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
2284 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
2285 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
2286 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
2287 dnl    AM-DISABLE-SHARED). Otherwise, a static library
2288 dnl    $(top_builddir)/intl/libintl.a will be created.
2289 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
2290 dnl    implementations (in libc or libintl) without the ngettext() function
2291 dnl    will be ignored.
2292 dnl LIBDIR is used to find the intl libraries.  If empty,
2293 dnl    the value `$(top_builddir)/intl/' is used.
2295 dnl The result of the configuration is one of three cases:
2296 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
2297 dnl    and used.
2298 dnl    Catalog format: GNU --> install in $(datadir)
2299 dnl    Catalog extension: .mo after installation, .gmo in source tree
2300 dnl 2) GNU gettext has been found in the system's C library.
2301 dnl    Catalog format: GNU --> install in $(datadir)
2302 dnl    Catalog extension: .mo after installation, .gmo in source tree
2303 dnl 3) No internationalization, always use English msgid.
2304 dnl    Catalog format: none
2305 dnl    Catalog extension: none
2306 dnl The use of .gmo is historical (it was needed to avoid overwriting the
2307 dnl GNU format catalogs when building on a platform with an X/Open gettext),
2308 dnl but we keep it in order not to force irrelevant filename changes on the
2309 dnl maintainers.
2311 AC_DEFUN([AM_WITH_NLS],
2312   [AC_MSG_CHECKING([whether NLS is requested])
2313     dnl Default is enabled NLS
2314     AC_ARG_ENABLE(nls,
2315       [  --disable-nls           do not use Native Language Support],
2316       USE_NLS=$enableval, USE_NLS=yes)
2317     AC_MSG_RESULT($USE_NLS)
2318     AC_SUBST(USE_NLS)
2320     BUILD_INCLUDED_LIBINTL=no
2321     USE_INCLUDED_LIBINTL=no
2322     INTLLIBS=
2324     dnl If we use NLS figure out what method
2325     if test "$USE_NLS" = "yes"; then
2326       AC_DEFINE(ENABLE_NLS, 1,
2327         [Define to 1 if translation of program messages to the user's native language
2328    is requested.])
2329       AC_MSG_CHECKING([whether included gettext is requested])
2330       AC_ARG_WITH(included-gettext,
2331         [  --with-included-gettext use the GNU gettext library included here],
2332         nls_cv_force_use_gnu_gettext=$withval,
2333         nls_cv_force_use_gnu_gettext=no)
2334       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2336       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2337       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2338         dnl User does not insist on using GNU NLS library.  Figure out what
2339         dnl to use.  If GNU gettext is available we use this.  Else we have
2340         dnl to fall back to GNU NLS library.
2341         CATOBJEXT=NONE
2343         dnl Add a version number to the cache macros.
2344         define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
2345         define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
2347         AC_CHECK_HEADER(libintl.h,
2348           [AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
2349             [AC_TRY_LINK([#include <libintl.h>
2350 extern int _nl_msg_cat_cntr;],
2351                [bindtextdomain ("", "");
2352 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
2353                gt_cv_func_gnugettext_libc=yes,
2354                gt_cv_func_gnugettext_libc=no)])
2356            if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2357              AC_CACHE_CHECK([for GNU gettext in libintl],
2358                gt_cv_func_gnugettext_libintl,
2359                [gt_save_LIBS="$LIBS"
2360                 LIBS="$LIBS -lintl $LIBICONV"
2361                 AC_TRY_LINK([#include <libintl.h>
2362 extern int _nl_msg_cat_cntr;],
2363                   [bindtextdomain ("", "");
2364 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
2365                   gt_cv_func_gnugettext_libintl=yes,
2366                   gt_cv_func_gnugettext_libintl=no)
2367                 LIBS="$gt_save_LIBS"])
2368            fi
2370            dnl If an already present or preinstalled GNU gettext() is found,
2371            dnl use it.  But if this macro is used in GNU gettext, and GNU
2372            dnl gettext is already preinstalled in libintl, we update this
2373            dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
2374            if test "$gt_cv_func_gnugettext_libc" = "yes" \
2375               || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
2376                    && test "$PACKAGE" != gettext; }; then
2377              AC_DEFINE(HAVE_GETTEXT, 1,
2378                [Define if the GNU gettext() function is already present or preinstalled.])
2380              if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2381                dnl If iconv() is in a separate libiconv library, then anyone
2382                dnl linking with libintl{.a,.so} also needs to link with
2383                dnl libiconv.
2384                INTLLIBS="-lintl $LIBICONV"
2385              fi
2387              gt_save_LIBS="$LIBS"
2388              LIBS="$LIBS $INTLLIBS"
2389              AC_CHECK_FUNCS(dcgettext)
2390              LIBS="$gt_save_LIBS"
2392              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2393                [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2394              if test "$MSGFMT" != "no"; then
2395                AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2396              fi
2398              AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2399                [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2401              CATOBJEXT=.gmo
2402            fi
2403         ])
2405         if test "$CATOBJEXT" = "NONE"; then
2406           dnl GNU gettext is not found in the C library.
2407           dnl Fall back on GNU gettext library.
2408           nls_cv_use_gnu_gettext=yes
2409         fi
2410       fi
2412       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2413         dnl Mark actions used to generate GNU NLS library.
2414         INTLOBJS="\$(GETTOBJS)"
2415         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2416           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2417         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2418         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2419           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2420         AC_SUBST(MSGFMT)
2421         BUILD_INCLUDED_LIBINTL=yes
2422         USE_INCLUDED_LIBINTL=yes
2423         CATOBJEXT=.gmo
2424         INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
2425         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
2426       fi
2428       dnl Test whether we really found GNU xgettext.
2429       if test "$XGETTEXT" != ":"; then
2430         dnl If it is no GNU xgettext we define it as : so that the
2431         dnl Makefiles still can work.
2432         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2433           : ;
2434         else
2435           AC_MSG_RESULT(
2436             [found xgettext program is not GNU xgettext; ignore it])
2437           XGETTEXT=":"
2438         fi
2439       fi
2441       dnl We need to process the po/ directory.
2442       POSUB=po
2443     fi
2444     AC_OUTPUT_COMMANDS(
2445      [for ac_file in $CONFIG_FILES; do
2446         # Support "outfile[:infile[:infile...]]"
2447         case "$ac_file" in
2448           *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
2449         esac
2450         # PO directories have a Makefile.in generated from Makefile.in.in.
2451         case "$ac_file" in */Makefile.in)
2452           # Adjust a relative srcdir.
2453           ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
2454           ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
2455           ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
2456           case "$ac_given_srcdir" in
2457             .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
2458             /*) top_srcdir="$ac_given_srcdir" ;;
2459             *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
2460           esac
2461           if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
2462             rm -f "$ac_dir/POTFILES"
2463             echo creating "$ac_dir/POTFILES"
2464             sed -e "/^#/d" -e "/^[      ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
2465             echo creating "$ac_dir/Makefile"
2466             sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
2467           fi
2468           ;;
2469         esac
2470       done])
2473     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
2474     dnl to 'yes' because some of the testsuite requires it.
2475     if test "$PACKAGE" = gettext; then
2476       BUILD_INCLUDED_LIBINTL=yes
2477     fi
2479     dnl intl/plural.c is generated from intl/plural.y. It requires bison,
2480     dnl because plural.y uses bison specific features. It requires at least
2481     dnl bison-1.26 because earlier versions generate a plural.c that doesn't
2482     dnl compile.
2483     dnl bison is only needed for the maintainer (who touches plural.y). But in
2484     dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
2485     dnl the rule in general Makefile. Now, some people carelessly touch the
2486     dnl files or have a broken "make" program, hence the plural.c rule will
2487     dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
2488     dnl present or too old.
2489     AC_CHECK_PROGS([INTLBISON], [bison])
2490     if test -z "$INTLBISON"; then
2491       ac_verc_fail=yes
2492     else
2493       dnl Found it, now check the version.
2494       AC_MSG_CHECKING([version of bison])
2495 changequote(<<,>>)dnl
2496       ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison .* \([0-9]*\.[0-9.]*\).*$/\1/p'`
2497       case $ac_prog_version in
2498         '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2499         1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
2500 changequote([,])dnl
2501            ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2502         *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2503       esac
2504       AC_MSG_RESULT([$ac_prog_version])
2505     fi
2506     if test $ac_verc_fail = yes; then
2507       INTLBISON=:
2508     fi
2510     dnl These rules are solely for the distribution goal.  While doing this
2511     dnl we only have to keep exactly one list of the available catalogs
2512     dnl in configure.in.
2513     for lang in $ALL_LINGUAS; do
2514       GMOFILES="$GMOFILES $lang.gmo"
2515       POFILES="$POFILES $lang.po"
2516     done
2518     dnl Make all variables we use known to autoconf.
2519     AC_SUBST(BUILD_INCLUDED_LIBINTL)
2520     AC_SUBST(USE_INCLUDED_LIBINTL)
2521     AC_SUBST(CATALOGS)
2522     AC_SUBST(CATOBJEXT)
2523     AC_SUBST(GMOFILES)
2524     AC_SUBST(INTLLIBS)
2525     AC_SUBST(INTLOBJS)
2526     AC_SUBST(POFILES)
2527     AC_SUBST(POSUB)
2529     dnl For backward compatibility. Some configure.ins may be using this.
2530     nls_cv_header_intl=
2531     nls_cv_header_libgt=
2533     dnl For backward compatibility. Some Makefiles may be using this.
2534     DATADIRNAME=share
2535     AC_SUBST(DATADIRNAME)
2537     dnl For backward compatibility. Some Makefiles may be using this.
2538     INSTOBJEXT=.mo
2539     AC_SUBST(INSTOBJEXT)
2541     dnl For backward compatibility. Some Makefiles may be using this.
2542     GENCAT=gencat
2543     AC_SUBST(GENCAT)
2544   ])
2546 dnl Usage: Just like AM_WITH_NLS, which see.
2547 AC_DEFUN([AM_GNU_GETTEXT],
2548   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2549    AC_REQUIRE([AC_PROG_CC])dnl
2550    AC_REQUIRE([AC_CANONICAL_HOST])dnl
2551    AC_REQUIRE([AC_PROG_RANLIB])dnl
2552    AC_REQUIRE([AC_ISC_POSIX])dnl
2553    AC_REQUIRE([AC_HEADER_STDC])dnl
2554    AC_REQUIRE([AC_C_CONST])dnl
2555    AC_REQUIRE([AC_C_INLINE])dnl
2556    AC_REQUIRE([AC_TYPE_OFF_T])dnl
2557    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2558    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2559    AC_REQUIRE([AC_FUNC_MMAP])dnl
2560    AC_REQUIRE([jm_GLIBC21])dnl
2562    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
2563 stdlib.h string.h unistd.h sys/param.h])
2564    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
2565 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
2566 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
2568    AM_ICONV
2569    AM_LANGINFO_CODESET
2570    AM_LC_MESSAGES
2571    AM_WITH_NLS([$1],[$2],[$3])
2573    if test "x$CATOBJEXT" != "x"; then
2574      if test "x$ALL_LINGUAS" = "x"; then
2575        LINGUAS=
2576      else
2577        AC_MSG_CHECKING(for catalogs to be installed)
2578        NEW_LINGUAS=
2579        for presentlang in $ALL_LINGUAS; do
2580          useit=no
2581          for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
2582            # Use the presentlang catalog if desiredlang is
2583            #   a. equal to presentlang, or
2584            #   b. a variant of presentlang (because in this case,
2585            #      presentlang can be used as a fallback for messages
2586            #      which are not translated in the desiredlang catalog).
2587            case "$desiredlang" in
2588              "$presentlang"*) useit=yes;;
2589            esac
2590          done
2591          if test $useit = yes; then
2592            NEW_LINGUAS="$NEW_LINGUAS $presentlang"
2593          fi
2594        done
2595        LINGUAS=$NEW_LINGUAS
2596        AC_MSG_RESULT($LINGUAS)
2597      fi
2599      dnl Construct list of names of catalog files to be constructed.
2600      if test -n "$LINGUAS"; then
2601        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2602      fi
2603    fi
2605    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2606    dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
2607    dnl Try to locate is.
2608    MKINSTALLDIRS=
2609    if test -n "$ac_aux_dir"; then
2610      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2611    fi
2612    if test -z "$MKINSTALLDIRS"; then
2613      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2614    fi
2615    AC_SUBST(MKINSTALLDIRS)
2617    dnl Enable libtool support if the surrounding package wishes it.
2618    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
2619    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
2620   ])
2622 # Search path for a program which passes the given test.
2623 # Ulrich Drepper <drepper@cygnus.com>, 1996.
2625 # This file can be copied and used freely without restrictions.  It can
2626 # be used in projects which are not available under the GNU Public License
2627 # but which still want to provide support for the GNU gettext functionality.
2628 # Please note that the actual code is *not* freely available.
2630 # serial 1
2632 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2633 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2634 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
2635 [# Extract the first word of "$2", so it can be a program name with args.
2636 set dummy $2; ac_word=[$]2
2637 AC_MSG_CHECKING([for $ac_word])
2638 AC_CACHE_VAL(ac_cv_path_$1,
2639 [case "[$]$1" in
2640   /*)
2641   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2642   ;;
2643   *)
2644   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2645   for ac_dir in ifelse([$5], , $PATH, [$5]); do
2646     test -z "$ac_dir" && ac_dir=.
2647     if test -f $ac_dir/$ac_word; then
2648       if [$3]; then
2649         ac_cv_path_$1="$ac_dir/$ac_word"
2650         break
2651       fi
2652     fi
2653   done
2654   IFS="$ac_save_ifs"
2655 dnl If no 4th arg is given, leave the cache variable unset,
2656 dnl so AC_PATH_PROGS will keep looking.
2657 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2658 ])dnl
2659   ;;
2660 esac])dnl
2661 $1="$ac_cv_path_$1"
2662 if test -n "[$]$1"; then
2663   AC_MSG_RESULT([$]$1)
2664 else
2665   AC_MSG_RESULT(no)
2667 AC_SUBST($1)dnl
2670 #serial 2
2672 # Test for the GNU C Library, version 2.1 or newer.
2673 # From Bruno Haible.
2675 AC_DEFUN([jm_GLIBC21],
2676   [
2677     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2678       ac_cv_gnu_library_2_1,
2679       [AC_EGREP_CPP([Lucky GNU user],
2680         [
2681 #include <features.h>
2682 #ifdef __GNU_LIBRARY__
2683  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2684   Lucky GNU user
2685  #endif
2686 #endif
2687         ],
2688         ac_cv_gnu_library_2_1=yes,
2689         ac_cv_gnu_library_2_1=no)
2690       ]
2691     )
2692     AC_SUBST(GLIBC21)
2693     GLIBC21="$ac_cv_gnu_library_2_1"
2694   ]
2697 #serial AM2
2699 dnl From Bruno Haible.
2701 AC_DEFUN([AM_ICONV],
2703   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2704   dnl those with the standalone portable GNU libiconv installed).
2706   AC_ARG_WITH([libiconv-prefix],
2707 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
2708     for dir in `echo "$withval" | tr : ' '`; do
2709       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
2710       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
2711     done
2712    ])
2714   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
2715     am_cv_func_iconv="no, consider installing GNU libiconv"
2716     am_cv_lib_iconv=no
2717     AC_TRY_LINK([#include <stdlib.h>
2718 #include <iconv.h>],
2719       [iconv_t cd = iconv_open("","");
2720        iconv(cd,NULL,NULL,NULL,NULL);
2721        iconv_close(cd);],
2722       am_cv_func_iconv=yes)
2723     if test "$am_cv_func_iconv" != yes; then
2724       am_save_LIBS="$LIBS"
2725       LIBS="$LIBS -liconv"
2726       AC_TRY_LINK([#include <stdlib.h>
2727 #include <iconv.h>],
2728         [iconv_t cd = iconv_open("","");
2729          iconv(cd,NULL,NULL,NULL,NULL);
2730          iconv_close(cd);],
2731         am_cv_lib_iconv=yes
2732         am_cv_func_iconv=yes)
2733       LIBS="$am_save_LIBS"
2734     fi
2735   ])
2736   if test "$am_cv_func_iconv" = yes; then
2737     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2738     AC_MSG_CHECKING([for iconv declaration])
2739     AC_CACHE_VAL(am_cv_proto_iconv, [
2740       AC_TRY_COMPILE([
2741 #include <stdlib.h>
2742 #include <iconv.h>
2743 extern
2744 #ifdef __cplusplus
2746 #endif
2747 #if defined(__STDC__) || defined(__cplusplus)
2748 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
2749 #else
2750 size_t iconv();
2751 #endif
2752 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
2753       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);"])
2754     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
2755     AC_MSG_RESULT([$]{ac_t:-
2756          }[$]am_cv_proto_iconv)
2757     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
2758       [Define as const if the declaration of iconv() needs const.])
2759   fi
2760   LIBICONV=
2761   if test "$am_cv_lib_iconv" = yes; then
2762     LIBICONV="-liconv"
2763   fi
2764   AC_SUBST(LIBICONV)
2767 #serial AM1
2769 dnl From Bruno Haible.
2771 AC_DEFUN([AM_LANGINFO_CODESET],
2773   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
2774     [AC_TRY_LINK([#include <langinfo.h>],
2775       [char* cs = nl_langinfo(CODESET);],
2776       am_cv_langinfo_codeset=yes,
2777       am_cv_langinfo_codeset=no)
2778     ])
2779   if test $am_cv_langinfo_codeset = yes; then
2780     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
2781       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
2782   fi
2785 # Check whether LC_MESSAGES is available in <locale.h>.
2786 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2788 # This file can be copied and used freely without restrictions.  It can
2789 # be used in projects which are not available under the GNU Public License
2790 # but which still want to provide support for the GNU gettext functionality.
2791 # Please note that the actual code is *not* freely available.
2793 # serial 2
2795 AC_DEFUN([AM_LC_MESSAGES],
2796   [if test $ac_cv_header_locale_h = yes; then
2797     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2798       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2799        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2800     if test $am_cv_val_LC_MESSAGES = yes; then
2801       AC_DEFINE(HAVE_LC_MESSAGES, 1,
2802         [Define if your <locale.h> file defines LC_MESSAGES.])
2803     fi
2804   fi])