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