* changed libc dependencies to remove libc6-dev build-depends (closes:
[findutils.git] / aclocal.m4
blob2357ec5f616254ad315d5e13264b01be488d843f
1 # aclocal.m4 generated automatically by aclocal 1.4d
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], [m4_pattern_allow([AM_CFLAGS])])
95 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_CPPFLAGS])])
96 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_CXXFLAGS])])
97 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_OBJCFLAGS])])
98 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_FFLAGS])])
99 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_RFLAGS])])
100 ifdef([m4_pattern_allow], [m4_pattern_allow([AM_GCJFLAGS])])
102 # Some tools Automake needs.
103 AC_REQUIRE([AM_SANITY_CHECK])dnl
104 AC_REQUIRE([AC_ARG_PROGRAM])dnl
105 AM_MISSING_PROG(ACLOCAL, aclocal)
106 AM_MISSING_PROG(AUTOCONF, autoconf)
107 AM_MISSING_PROG(AUTOMAKE, automake)
108 AM_MISSING_PROG(AUTOHEADER, autoheader)
109 AM_MISSING_PROG(MAKEINFO, makeinfo)
110 AM_MISSING_PROG(AMTAR, tar)
111 AM_MISSING_INSTALL_SH
112 # We need awk for the "check" target.  The system "awk" is bad on
113 # some platforms.
114 AC_REQUIRE([AC_PROG_AWK])dnl
115 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
116 AC_REQUIRE([AM_DEP_TRACK])dnl
117 AC_REQUIRE([AM_SET_DEPDIR])dnl
118 AC_PROVIDE_IFELSE([AC_PROG_][CC],
119                   [AM_DEPENDENCIES(CC)],
120                   [define([AC_PROG_][CC],
121                           defn([AC_PROG_][CC])[AM_DEPENDENCIES(CC)])])dnl
122 AC_PROVIDE_IFELSE([AC_PROG_][CXX],
123                   [AM_DEPENDENCIES(CXX)],
124                   [define([AC_PROG_][CXX],
125                           defn([AC_PROG_][CXX])[AM_DEPENDENCIES(CXX)])])dnl
129 # Check to make sure that the build environment is sane.
132 # serial 3
134 # AM_SANITY_CHECK
135 # ---------------
136 AC_DEFUN([AM_SANITY_CHECK],
137 [AC_MSG_CHECKING([whether build environment is sane])
138 # Just in case
139 sleep 1
140 echo timestamp > conftest.file
141 # Do `set' in a subshell so we don't clobber the current shell's
142 # arguments.  Must try -L first in case configure is actually a
143 # symlink; some systems play weird games with the mod time of symlinks
144 # (eg FreeBSD returns the mod time of the symlink's containing
145 # directory).
146 if (
147    set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
148    if test "$[*]" = "X"; then
149       # -L didn't work.
150       set X `ls -t $srcdir/configure conftest.file`
151    fi
152    if test "$[*]" != "X $srcdir/configure conftest.file" \
153       && test "$[*]" != "X conftest.file $srcdir/configure"; then
155       # If neither matched, then we have a broken ls.  This can happen
156       # if, for instance, CONFIG_SHELL is bash and it inherits a
157       # broken ls alias from the environment.  This has actually
158       # happened.  Such a system could not be considered "sane".
159       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
160 alias in your environment])
161    fi
163    test "$[2]" = conftest.file
164    )
165 then
166    # Ok.
167    :
168 else
169    AC_MSG_ERROR([newly created file is older than distributed files!
170 Check your system clock])
172 rm -f conftest*
173 AC_MSG_RESULT(yes)])
176 # serial 2
178 # AM_MISSING_PROG(NAME, PROGRAM)
179 # ------------------------------
180 AC_DEFUN([AM_MISSING_PROG],
181 [AC_REQUIRE([AM_MISSING_HAS_RUN])
182 $1=${$1-"${am_missing_run}$2"}
183 AC_SUBST($1)])
186 # AM_MISSING_INSTALL_SH
187 # ---------------------
188 # Like AM_MISSING_PROG, but only looks for install-sh.
189 AC_DEFUN([AM_MISSING_INSTALL_SH],
190 [AC_REQUIRE([AM_MISSING_HAS_RUN])
191 if test -z "$install_sh"; then
192    for install_sh in "$ac_aux_dir/install-sh" \
193                      "$ac_aux_dir/install.sh" \
194                      "${am_missing_run}${ac_auxdir}/install-sh";
195    do
196      test -f "$install_sh" && break
197    done
198    # FIXME: an evil hack: we remove the SHELL invocation from
199    # install_sh because automake adds it back in.  Sigh.
200    install_sh=`echo $install_sh | sed -e 's/\${SHELL}//'`
202 AC_SUBST(install_sh)])
205 # AM_MISSING_HAS_RUN
206 # ------------------
207 # Define MISSING if not defined so far and test if it supports --run.
208 # If it does, set am_missing_run to use it, otherwise, to nothing.
209 AC_DEFUN([AM_MISSING_HAS_RUN],
210 [test x"${MISSING+set}" = xset ||
211   MISSING="\${SHELL} `CDPATH=:; cd $ac_aux_dir && pwd`/missing"
212 # Use eval to expand $SHELL
213 if eval "$MISSING --run :"; then
214   am_missing_run="$MISSING --run "
215 else
216   am_missing_run=
217   am_backtick='`'
218   AC_MSG_WARN([${am_backtick}missing' script is too old or missing])
222 # serial 3
224 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
225 # written in clear, in which case automake, when reading aclocal.m4,
226 # will think it sees a *use*, and therefore will trigger all it's
227 # C support machinery.  Also note that it means that autoscan, seeing
228 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
230 # AM_DEPENDENCIES(NAME)
231 # ---------------------
232 # See how the compiler implements dependency checking.
233 # NAME is "CC", "CXX" or "OBJC".
234 # We try a few techniques and use that to set a single cache variable.
235 AC_DEFUN([AM_DEPENDENCIES],
236 [AC_REQUIRE([AM_SET_DEPDIR])dnl
237 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
238 ifelse([$1], CC,
239        [AC_REQUIRE([AC_PROG_][CC])dnl
240 AC_REQUIRE([AC_PROG_][CPP])
241 depcc="$CC"
242 depcpp="$CPP"],
243        [$1], CXX, [AC_REQUIRE([AC_PROG_][CXX])dnl
244 AC_REQUIRE([AC_PROG_][CXXCPP])
245 depcc="$CXX"
246 depcpp="$CXXCPP"],
247        [$1], OBJC, [am_cv_OBJC_dependencies_compiler_type=gcc],
248        [AC_REQUIRE([AC_PROG_][$1])dnl
249 depcc="$$1"
250 depcpp=""])
252 AC_REQUIRE([AM_MAKE_INCLUDE])
254 AC_CACHE_CHECK([dependency style of $depcc],
255                [am_cv_$1_dependencies_compiler_type],
256 [if test -z "$AMDEP"; then
257   # We make a subdir and do the tests there.  Otherwise we can end up
258   # making bogus files that we don't know about and never remove.  For
259   # instance it was reported that on HP-UX the gcc test will end up
260   # making a dummy file named `D' -- because `-MD' means `put the output
261   # in D'.
262   mkdir confdir
263   # Copy depcomp to subdir because otherwise we won't find it if we're
264   # using a relative directory.
265   cp "$am_depcomp" confdir
266   cd confdir
268   am_cv_$1_dependencies_compiler_type=none
269   for depmode in `sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < "./depcomp"`; do
270     # We need to recreate these files for each test, as the compiler may
271     # overwrite some of them when testing with obscure command lines.
272     # This happens at least with the AIX C compiler.
273     echo '#include "conftest.h"' > conftest.c
274     echo 'int i;' > conftest.h
276     case "$depmode" in
277     nosideeffect)
278       # after this tag, mechanisms are not by side-effect, so they'll
279       # only be used when explicitly requested
280       if test "x$enable_dependency_tracking" = xyes; then
281         continue
282       else
283         break
284       fi
285       ;;
286     none) break ;;
287     esac
288     # We check with `-c' and `-o' for the sake of the "dashmstdout"
289     # mode.  It turns out that the SunPro C++ compiler does not properly
290     # handle `-M -o', and we need to detect this.
291     if depmode="$depmode" \
292        source=conftest.c object=conftest.o \
293        depfile=conftest.Po tmpdepfile=conftest.TPo \
294        $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 &&
295        grep conftest.h conftest.Po > /dev/null 2>&1; then
296       am_cv_$1_dependencies_compiler_type="$depmode"
297       break
298     fi
299   done
301   cd ..
302   rm -rf confdir
303 else
304   am_cv_$1_dependencies_compiler_type=none
307 $1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type"
308 AC_SUBST([$1DEPMODE])
312 # AM_SET_DEPDIR
313 # -------------
314 # Choose a directory name for dependency files.
315 # This macro is AC_REQUIREd in AM_DEPENDENCIES
316 AC_DEFUN([AM_SET_DEPDIR],
317 [if test -d .deps || mkdir .deps 2> /dev/null || test -d .deps; then
318   DEPDIR=.deps
319   # We redirect because .deps might already exist and be populated.
320   # In this situation we don't want to see an error.
321   rmdir .deps > /dev/null 2>&1
322 else
323   DEPDIR=_deps
325 AC_SUBST(DEPDIR)
329 # AM_DEP_TRACK
330 # ------------
331 AC_DEFUN([AM_DEP_TRACK],
332 [AC_ARG_ENABLE(dependency-tracking,
333 [  --disable-dependency-tracking Speeds up one-time builds
334   --enable-dependency-tracking  Do not reject slow dependency extractors])
335 if test "x$enable_dependency_tracking" = xno; then
336   AMDEP="#"
337 else
338   am_depcomp="$ac_aux_dir/depcomp"
339   if test ! -f "$am_depcomp"; then
340     AMDEP="#"
341   else
342     AMDEP=
343   fi
345 AC_SUBST(AMDEP)
346 if test -z "$AMDEP"; then
347   AMDEPBACKSLASH='\'
348 else
349   AMDEPBACKSLASH=
351 pushdef([subst], defn([AC_SUBST]))
352 subst(AMDEPBACKSLASH)
353 popdef([subst])
356 # Generate code to set up dependency tracking.
357 # This macro should only be invoked once -- use via AC_REQUIRE.
358 # Usage:
359 # AM_OUTPUT_DEPENDENCY_COMMANDS
362 # This code is only required when automatic dependency tracking
363 # is enabled.  FIXME.  This creates each `.P' file that we will
364 # need in order to bootstrap the dependency handling code.
365 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[
366 AC_OUTPUT_COMMANDS([
367 test x"$AMDEP" != x"" ||
368 for mf in $CONFIG_FILES; do
369   case "$mf" in
370   Makefile) dirpart=.;;
371   */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;;
372   *) continue;;
373   esac
374   grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
375   # Extract the definition of DEP_FILES from the Makefile without
376   # running `make'.
377   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
378   test -z "$DEPDIR" && continue
379   # When using ansi2knr, U may be empty or an underscore; expand it
380   U=`sed -n -e '/^U = / s///p' < "$mf"`
381   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
382   # We invoke sed twice because it is the simplest approach to
383   # changing $(DEPDIR) to its actual value in the expansion.
384   for file in `sed -n -e '
385     /^DEP_FILES = .*\\\\$/ {
386       s/^DEP_FILES = //
387       :loop
388         s/\\\\$//
389         p
390         n
391         /\\\\$/ b loop
392       p
393     }
394     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
395        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
396     # Make sure the directory exists.
397     test -f "$dirpart/$file" && continue
398     fdir=`echo "$file" | sed -e 's|/[^/]*$||'`
399     $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1
400     # echo "creating $dirpart/$file"
401     echo '# dummy' > "$dirpart/$file"
402   done
403 done
404 ], [AMDEP="$AMDEP"
405 ac_aux_dir="$ac_aux_dir"])])
407 # AM_MAKE_INCLUDE()
408 # -----------------
409 # Check to see how make treats includes.
410 AC_DEFUN([AM_MAKE_INCLUDE],
411 [am_make=${MAKE-make}
412 # BSD make uses .include
413 cat > confinc << 'END'
414 doit:
415         @echo done
417 # If we don't find an include directive, just comment out the code.
418 AC_MSG_CHECKING([for style of include used by $am_make])
419 _am_include='#'
420 for am_inc in include .include; do
421    echo "$am_inc confinc" > confmf
422    if test "`$am_make -f confmf 2> /dev/null`" = "done"; then
423       _am_include=$am_inc
424       break
425    fi
426 done
427 AC_SUBST(_am_include)
428 AC_MSG_RESULT($_am_include)
429 rm -f confinc confmf
432 #serial 1
433 dnl This test replaces the one in autoconf.
434 dnl Currently this macro should have the same name as the autoconf macro
435 dnl because gettext's gettext.m4 (distributed in the automake package)
436 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
437 dnl give these diagnostics:
438 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
439 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
441 undefine([AC_ISC_POSIX])
442 AC_DEFUN(AC_ISC_POSIX,
443   [
444     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
445     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
446   ]
450 # serial 1
452 AC_DEFUN([AM_C_PROTOTYPES],
453 [AC_REQUIRE([AM_PROG_CC_STDC])
454 AC_REQUIRE([AC_PROG_CPP])
455 AC_MSG_CHECKING([for function prototypes])
456 if test "$am_cv_prog_cc_stdc" != no; then
457   AC_MSG_RESULT(yes)
458   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
459   U= ANSI2KNR=
460 else
461   AC_MSG_RESULT(no)
462   U=_ ANSI2KNR=./ansi2knr
464 # Ensure some checks needed by ansi2knr itself.
465 AC_HEADER_STDC
466 AC_CHECK_HEADERS(string.h)
467 AC_SUBST(U)dnl
468 AC_SUBST(ANSI2KNR)dnl
472 # serial 1
474 # @defmac AC_PROG_CC_STDC
475 # @maindex PROG_CC_STDC
476 # @ovindex CC
477 # If the C compiler in not in ANSI C mode by default, try to add an option
478 # to output variable @code{CC} to make it so.  This macro tries various
479 # options that select ANSI C on some system or another.  It considers the
480 # compiler to be in ANSI C mode if it handles function prototypes correctly.
482 # If you use this macro, you should check after calling it whether the C
483 # compiler has been set to accept ANSI C; if not, the shell variable
484 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
485 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
486 # program @code{ansi2knr}, which comes with Ghostscript.
487 # @end defmac
489 AC_DEFUN([AM_PROG_CC_STDC],
490 [AC_REQUIRE([AC_PROG_CC])
491 AC_BEFORE([$0], [AC_C_INLINE])
492 AC_BEFORE([$0], [AC_C_CONST])
493 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
494 dnl a magic option to avoid problems with ANSI preprocessor commands
495 dnl like #elif.
496 dnl FIXME: can't do this because then AC_AIX won't work due to a
497 dnl circular dependency.
498 dnl AC_BEFORE([$0], [AC_PROG_CPP])
499 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
500 AC_CACHE_VAL(am_cv_prog_cc_stdc,
501 [am_cv_prog_cc_stdc=no
502 ac_save_CC="$CC"
503 # Don't try gcc -ansi; that turns off useful extensions and
504 # breaks some systems' header files.
505 # AIX                   -qlanglvl=ansi
506 # Ultrix and OSF/1      -std1
507 # HP-UX 10.20 and later -Ae
508 # HP-UX older versions  -Aa -D_HPUX_SOURCE
509 # SVR4                  -Xc -D__EXTENSIONS__
510 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
512   CC="$ac_save_CC $ac_arg"
513   AC_TRY_COMPILE(
514 [#include <stdarg.h>
515 #include <stdio.h>
516 #include <sys/types.h>
517 #include <sys/stat.h>
518 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
519 struct buf { int x; };
520 FILE * (*rcsopen) (struct buf *, struct stat *, int);
521 static char *e (p, i)
522      char **p;
523      int i;
525   return p[i];
527 static char *f (char * (*g) (char **, int), char **p, ...)
529   char *s;
530   va_list v;
531   va_start (v,p);
532   s = g (p, va_arg (v,int));
533   va_end (v);
534   return s;
536 int test (int i, double x);
537 struct s1 {int (*f) (int a);};
538 struct s2 {int (*f) (double a);};
539 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
540 int argc;
541 char **argv;
542 ], [
543 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
545 [am_cv_prog_cc_stdc="$ac_arg"; break])
546 done
547 CC="$ac_save_CC"
549 if test -z "$am_cv_prog_cc_stdc"; then
550   AC_MSG_RESULT([none needed])
551 else
552   AC_MSG_RESULT([$am_cv_prog_cc_stdc])
554 case "x$am_cv_prog_cc_stdc" in
555   x|xno) ;;
556   *) CC="$CC $am_cv_prog_cc_stdc" ;;
557 esac
560 #serial 13, with several lines deleted for fileutils.
562 dnl Misc type-related macros for fileutils, sh-utils, textutils.
564 AC_DEFUN(jm_MACROS,
566   AC_PREREQ(2.14a)
568   GNU_PACKAGE="GNU $PACKAGE"
569   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
570     [The concatenation of the strings `GNU ', and PACKAGE.])
571   AC_SUBST(GNU_PACKAGE)
573   AC_SUBST(OPTIONAL_BIN_PROGS)
574   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
575   AC_SUBST(MAN)
576   AC_SUBST(DF_PROG)
578   dnl This macro actually runs replacement code.  See isc-posix.m4.
579   AC_REQUIRE([AC_ISC_POSIX])dnl
581   AC_CHECK_HEADERS( \
582     errno.h  \
583     fcntl.h \
584     fenv.h \
585     float.h \
586     limits.h \
587     memory.h \
588     mntent.h \
589     mnttab.h \
590     netdb.h \
591     paths.h \
592     stdlib.h \
593     stddef.h \
594     string.h \
595     sys/acl.h \
596     sys/filsys.h \
597     sys/fs/s5param.h \
598     sys/fs_types.h \
599     sys/fstyp.h \
600     sys/ioctl.h \
601     sys/mntent.h \
602     sys/mount.h \
603     sys/param.h \
604     sys/socket.h \
605     sys/statfs.h \
606     sys/statvfs.h \
607     sys/systeminfo.h \
608     sys/time.h \
609     sys/timeb.h \
610     sys/vfs.h \
611     sys/wait.h \
612     syslog.h \
613     termios.h \
614     unistd.h \
615     values.h \
616   )
618   jm_INCLUDED_REGEX([lib/regex.c])
620   AC_REQUIRE([jm_ASSERT])
621   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
622   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
623   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
624   AC_REQUIRE([jm_CHECK_DECLS])
626   AC_REQUIRE([jm_PREREQ])
628   AC_REQUIRE([jm_FUNC_MKTIME])
629   AC_REQUIRE([jm_FUNC_LSTAT])
630   AC_REQUIRE([jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
631   AC_REQUIRE([jm_FUNC_STAT])
632   AC_REQUIRE([jm_FUNC_REALLOC])
633   AC_REQUIRE([jm_FUNC_MALLOC])
634   AC_REQUIRE([AC_FUNC_STRERROR_R])
635   AC_REQUIRE([jm_FUNC_READDIR])
636   AC_REQUIRE([jm_FUNC_MEMCMP])
637   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
638   AC_REQUIRE([kd_FUNC_FNMATCH_CASE_RPL])
639   AC_REQUIRE([jm_AFS])
640   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
641   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
642   AC_REQUIRE([AM_FUNC_ERROR_AT_LINE])
643   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
644   AC_REQUIRE([jm_FUNC_MKTIME])
646   AC_REQUIRE([AC_FUNC_VPRINTF])
647   AC_REQUIRE([AC_FUNC_ALLOCA])
649   AC_REPLACE_FUNCS(strncasecmp)
650   AC_REPLACE_FUNCS(stpcpy strstr strtol strtoul)
651   AC_REPLACE_FUNCS(memcmp rpmatch)
653   dnl used by e.g. intl/*domain.c and lib/canon-host.c
654   AC_REPLACE_FUNCS(strdup)
656   AC_REPLACE_FUNCS(memcpy memset)
657   AC_CHECK_FUNCS(getpagesize)
659   # By default, argmatch should fail calling usage (1).
660   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
661             [Define to the function xargmatch calls on failures.])
662   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
663             [Define to the declaration of the xargmatch failure function.])
665   dnl Used to define SETVBUF in sys2.h.
666   dnl This evokes the following warning from autoconf:
667   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
668   AC_FUNC_SETVBUF_REVERSED
670   AC_CHECK_FUNCS(getdelim)
672   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
674   AC_CHECK_FUNCS( \
675     acl \
676     bcopy \
677     endgrent \
678     endpwent \
679     fchdir \
680     fdatasync \
681     fseeko \
682     ftime \
683     getcwd \
684     gethrtime \
685     getmntinfo \
686     hasmntopt \
687     isascii \
688     listmntent \
689     localeconv \
690     memcpy \
691     mempcpy \
692     mkfifo \
693     realpath \
694     resolvepath \
695     sethostname \
696     strchr \
697     strerror \
698     strrchr \
699     sysinfo \
700     tzset \
701   )
703   AM_FUNC_GETLINE
704   if test $am_cv_func_working_getline != yes; then
705     AC_CHECK_FUNCS(getdelim)
706   fi
708   jm_GLIBC21
709   jm_ICONV
711   # These tests are for df.
712   jm_FSTYPENAME
716 AC_DEFUN(jm_CHECK_ALL_TYPES,
718   dnl Checks for typedefs, structures, and compiler characteristics.
719   AC_REQUIRE([AC_C_BIGENDIAN])
720   AC_REQUIRE([AC_PROG_CC_STDC])
721   AC_REQUIRE([AC_C_CONST])
722   AC_REQUIRE([AC_C_VOLATILE])
723   AC_REQUIRE([AC_C_INLINE])
724   AC_REQUIRE([AC_C_LONG_DOUBLE])
726   AC_REQUIRE([AC_HEADER_DIRENT])
727   AC_REQUIRE([AC_HEADER_STDC])
728   AC_CHECK_MEMBERS([struct stat.st_blksize],,,[$ac_includes_default
729 #include <sys/stat.h>
730   ])
731   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
733   AC_REQUIRE([AC_STRUCT_TM])
734   AC_REQUIRE([AC_STRUCT_TIMEZONE])
735   AC_REQUIRE([AC_HEADER_STAT])
736   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
737   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
738   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
740   AC_REQUIRE([AC_TYPE_GETGROUPS])
741   AC_REQUIRE([AC_TYPE_MODE_T])
742   AC_REQUIRE([AC_TYPE_OFF_T])
743   AC_REQUIRE([AC_TYPE_PID_T])
744   AC_REQUIRE([AC_TYPE_SIGNAL])
745   AC_REQUIRE([AC_TYPE_SIZE_T])
746   AC_REQUIRE([AC_TYPE_UID_T])
747   AC_CHECK_TYPE(ino_t, unsigned long)
749   dnl This relies on the fact that autoconf 2.14a's implementation of
750   dnl AC_CHECK_TYPE checks includes unistd.h.
751   AC_CHECK_TYPE(ssize_t, int)
753   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
754   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
756   AC_REQUIRE([AC_HEADER_MAJOR])
757   AC_REQUIRE([AC_HEADER_DIRENT])
761 #serial 7
763 dnl Initially derived from code in GNU grep.
764 dnl Mostly written by Jim Meyering.
766 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
768 AC_DEFUN(jm_INCLUDED_REGEX,
769   [
770     dnl Even packages that don't use regex.c can use this macro.
771     dnl Of course, for them it doesn't do anything.
773     # Assume we'll default to using the included regex.c.
774     ac_use_included_regex=yes
776     # However, if the system regex support is good enough that it passes the
777     # the following run test, then default to *not* using the included regex.c.
778     # If cross compiling, assume the test would fail and use the included
779     # regex.c.  The first failing regular expression is from `Spencer ere
780     # test #75' in grep-2.3.
781     AC_CACHE_CHECK([for working re_compile_pattern],
782                    jm_cv_func_working_re_compile_pattern,
783       AC_TRY_RUN(
784 [#include <stdio.h>
785 #include <regex.h>
786           int
787           main ()
788           {
789             static struct re_pattern_buffer regex;
790             const char *s;
791             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
792             /* Add this third left square bracket, [, to balance the
793                three right ones below.  Otherwise autoconf-2.14 chokes.  */
794             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
795             /* This should fail with _Invalid character class name_ error.  */
796             if (!s)
797               exit (1);
799             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
800             s = re_compile_pattern ("{1", 2, &regex);
802             exit (s ? 1 : 0);
803           }
804         ],
805                jm_cv_func_working_re_compile_pattern=yes,
806                jm_cv_func_working_re_compile_pattern=no,
807                dnl When crosscompiling, assume it's broken.
808                jm_cv_func_working_re_compile_pattern=no))
809     if test $jm_cv_func_working_re_compile_pattern = yes; then
810       ac_use_included_regex=no
811     fi
813     test -n "$1" || AC_MSG_ERROR([missing argument])
814     syscmd([test -f $1])
815     ifelse(sysval, 0,
816       [
818         AC_ARG_WITH(included-regex,
819         [  --without-included-regex don't compile regex; this is the default on
820                           systems with version 2 of the GNU C library
821                           (use with caution on other system)],
822                     jm_with_regex=$withval,
823                     jm_with_regex=$ac_use_included_regex)
824         if test "$jm_with_regex" = yes; then
825           AC_SUBST(LIBOBJS)
826           LIBOBJS="$LIBOBJS regex.$ac_objext"
827         fi
828       ],
829     )
830   ]
833 #serial 2
834 dnl based on code from Eleftherios Gkioulekas
836 AC_DEFUN(jm_ASSERT,
838   AC_MSG_CHECKING(whether to enable assertions)
839   AC_ARG_ENABLE(assert,
840         [  --disable-assert        turn off assertions],
841         [ AC_MSG_RESULT(no)
842           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
843         [ AC_MSG_RESULT(yes) ]
844                )
847 #serial 3
849 dnl From Paul Eggert.
851 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
852 # doesn't clash with <sys/types.h>, and declares uintmax_t.
854 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
856   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
857   [AC_TRY_COMPILE(
858     [#include <sys/types.h>
859 #include <inttypes.h>],
860     [uintmax_t i = (uintmax_t) -1;],
861     jm_ac_cv_header_inttypes_h=yes,
862     jm_ac_cv_header_inttypes_h=no)])
863   if test $jm_ac_cv_header_inttypes_h = yes; then
864     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
865 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
866    and declares uintmax_t. ])
867   fi
870 #serial 3
872 dnl From Jim Meyering.
874 dnl Check whether struct dirent has a member named d_type.
877 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
878   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
879    AC_CACHE_CHECK([for d_type member in directory struct],
880                   jm_cv_struct_dirent_d_type,
881      [AC_TRY_LINK(dnl
882        [
883 #include <sys/types.h>
884 #ifdef HAVE_DIRENT_H
885 # include <dirent.h>
886 #else /* not HAVE_DIRENT_H */
887 # define dirent direct
888 # ifdef HAVE_SYS_NDIR_H
889 #  include <sys/ndir.h>
890 # endif /* HAVE_SYS_NDIR_H */
891 # ifdef HAVE_SYS_DIR_H
892 #  include <sys/dir.h>
893 # endif /* HAVE_SYS_DIR_H */
894 # ifdef HAVE_NDIR_H
895 #  include <ndir.h>
896 # endif /* HAVE_NDIR_H */
897 #endif /* HAVE_DIRENT_H */
898        ],
899        [struct dirent dp; dp.d_type = 0;],
901        jm_cv_struct_dirent_d_type=yes,
902        jm_cv_struct_dirent_d_type=no)
903      ]
904    )
905    if test $jm_cv_struct_dirent_d_type = yes; then
906      AC_DEFINE(D_TYPE_IN_DIRENT, 1,
907   [Define if there is a member named d_type in the struct describing
908    directory headers.])
909    fi
910   ]
913 #serial 3
915 dnl From Jim Meyering.
917 dnl Check whether struct dirent has a member named d_ino.
920 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
921   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
922    AC_CACHE_CHECK([for d_ino member in directory struct],
923                   jm_cv_struct_dirent_d_ino,
924      [AC_TRY_LINK(dnl
925        [
926 #include <sys/types.h>
927 #ifdef HAVE_DIRENT_H
928 # include <dirent.h>
929 #else /* not HAVE_DIRENT_H */
930 # define dirent direct
931 # ifdef HAVE_SYS_NDIR_H
932 #  include <sys/ndir.h>
933 # endif /* HAVE_SYS_NDIR_H */
934 # ifdef HAVE_SYS_DIR_H
935 #  include <sys/dir.h>
936 # endif /* HAVE_SYS_DIR_H */
937 # ifdef HAVE_NDIR_H
938 #  include <ndir.h>
939 # endif /* HAVE_NDIR_H */
940 #endif /* HAVE_DIRENT_H */
941        ],
942        [struct dirent dp; dp.d_ino = 0;],
944        jm_cv_struct_dirent_d_ino=yes,
945        jm_cv_struct_dirent_d_ino=no)
946      ]
947    )
948    if test $jm_cv_struct_dirent_d_ino = yes; then
949      AC_DEFINE(D_INO_IN_DIRENT, 1,
950   [Define if there is a member named d_ino in the struct describing
951    directory headers.])
952    fi
953   ]
956 #serial 16
958 dnl This is just a wrapper function to encapsulate this kludge.
959 dnl Putting it in a separate file like this helps share it between
960 dnl different packages.
961 AC_DEFUN(jm_CHECK_DECLS,
963   AC_REQUIRE([_jm_DECL_HEADERS])
964   AC_REQUIRE([AC_HEADER_TIME])
965   headers='
966 #include <stdio.h>
967 #if HAVE_STRING_H
968 # if !STDC_HEADERS && HAVE_MEMORY_H
969 #  include <memory.h>
970 # endif
971 # include <string.h>
972 #else
973 # if HAVE_STRINGS_H
974 #  include <strings.h>
975 # endif
976 #endif
977 #if HAVE_STDLIB_H
978 # include <stdlib.h>
979 #endif
980 #if HAVE_UNISTD_H
981 # include <unistd.h>
982 #endif
984 #include <sys/types.h>
985 #if TIME_WITH_SYS_TIME
986 # include <sys/time.h>
987 # include <time.h>
988 #else
989 # if HAVE_SYS_TIME_H
990 #  include <sys/time.h>
991 # else
992 #  include <time.h>
993 # endif
994 #endif
996 #if HAVE_UTMP_H
997 # include <utmp.h>
998 #endif
1001   AC_CHECK_DECLS([
1002     free,
1003     getenv,
1004     geteuid,
1005     getgrgid,
1006     getlogin,
1007     getpwuid,
1008     getuid,
1009     getutent,
1010     lseek,
1011     malloc,
1012     memchr,
1013     memrchr,
1014     realloc,
1015     stpcpy,
1016     strndup,
1017     strnlen,
1018     strstr,
1019     strtoul,
1020     strtoull,
1021     ttyname], , , $headers)
1024 dnl FIXME: when autoconf has support for it.
1025 dnl This is a little helper so we can require these header checks.
1026 AC_DEFUN(_jm_DECL_HEADERS,
1028   AC_REQUIRE([AC_HEADER_STDC])
1029   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
1030                    utmp.h utmpx.h)
1033 #serial 5
1035 dnl These are the prerequisite macros for files in the lib/
1036 dnl directories of the fileutils, sh-utils, and textutils packages.
1038 AC_DEFUN(jm_PREREQ,
1040   jm_PREREQ_ADDEXT
1041   jm_PREREQ_CANON_HOST
1042   jm_PREREQ_ERROR
1043   jm_PREREQ_QUOTEARG
1044   jm_PREREQ_READUTMP
1045   jm_PREREQ_REGEX
1048 AC_DEFUN(jm_PREREQ_ADDEXT,
1050   dnl For addext.c.
1051   AC_SYS_LONG_FILE_NAMES
1052   AC_CHECK_FUNCS(pathconf)
1053   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1056 AC_DEFUN(jm_PREREQ_CANON_HOST,
1058   dnl Add any libraries as early as possible.
1059   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1060   dnl so we have to add -lnsl to LIBS before checking for that function.
1061   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1063   dnl These come from -lnsl on Solaris5.5.1.
1064   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1066   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1067   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1068                    netinet/in.h arpa/inet.h)
1071 AC_DEFUN(jm_PREREQ_QUOTEARG,
1073   AC_CHECK_FUNCS(isascii iswprint mbrtowc)
1074   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
1075   AC_HEADER_STDC
1076   AC_C_BACKSLASH_A
1077   AC_MBSTATE_T_OBJECT
1078   AM_C_PROTOTYPES
1081 AC_DEFUN(jm_PREREQ_READUTMP,
1083   AC_HEADER_STDC
1084   AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
1085   AC_CHECK_FUNCS(utmpname)
1086   AC_CHECK_FUNCS(utmpxname)
1087   AM_C_PROTOTYPES
1089   utmp_includes="\
1090 $ac_includes_default
1091 #ifdef HAVE_UTMPX_H
1092 # include <utmpx.h>
1093 #else
1094 # include <utmp.h>
1095 #endif
1097   AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
1098   AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
1099   AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
1100   AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
1103 AC_DEFUN(jm_PREREQ_REGEX,
1105   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1106   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1107   dnl to get them.
1108   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
1109   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
1110   AC_HEADER_STDC
1111   AC_FUNC_ALLOCA
1114 #serial 1
1116 dnl FIXME: put these prerequisite-only *.m4 files in a separate
1117 dnl directory -- otherwise, they'll conflict with existing files.
1119 dnl These are the prerequisite macros for GNU's error.c file.
1120 AC_DEFUN(jm_PREREQ_ERROR,
1122   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
1123   AC_HEADER_STDC
1126 #serial 3
1128 dnl From Paul Eggert.
1130 AC_DEFUN(AC_C_BACKSLASH_A,
1132   AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1133    [AC_TRY_COMPILE([],
1134      [
1135 #if '\a' == 'a'
1136       syntax error;
1137 #endif
1138       char buf['\a' == 'a' ? -1 : 1];
1139       buf[0] = '\a';
1140       return buf[0] != "\a"[0];
1141      ],
1142      ac_cv_c_backslash_a=yes,
1143      ac_cv_c_backslash_a=no)])
1144   if test $ac_cv_c_backslash_a = yes; then
1145     AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1146       [Define if backslash-a works in C strings.])
1147   fi
1150 # serial 1
1152 # From Paul Eggert.
1154 # Some versions of BeOS define mbstate_t to be an incomplete type,
1155 # so you can't declare an object of that type.
1156 # Check for this incompatibility with Standard C.
1158 AC_DEFUN(AC_MBSTATE_T_OBJECT,
1159   [AC_CACHE_CHECK([for mbstate_t object type], ac_cv_type_mbstate_t_object,
1160     [AC_TRY_COMPILE([#include <wchar.h>],
1161       [mbstate_t x; return sizeof x;],
1162       ac_cv_type_mbstate_t_object=yes,
1163       ac_cv_type_mbstate_t_object=no)])
1164    if test $ac_cv_type_mbstate_t_object = yes; then
1165      AC_DEFINE(HAVE_MBSTATE_T_OBJECT, 1,
1166                [Define if mbstate_t is an object type.])
1167    fi])
1169 #serial 7
1171 dnl From Jim Meyering.
1172 dnl A wrapper around AC_FUNC_MKTIME.
1174 AC_DEFUN(jm_FUNC_MKTIME,
1175 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
1177  dnl mktime.c uses localtime_r if it exists.  Check for it.
1178  AC_CHECK_FUNCS(localtime_r)
1180  if test $ac_cv_func_working_mktime = no; then
1181    AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
1182     [Define to rpl_mktime if the replacement function should be used.])
1183  fi
1186 #serial 3
1188 dnl From Jim Meyering.
1189 dnl Determine whether lstat has the bug that it succeeds when given the
1190 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
1191 dnl (as of 1998-11-01) do this.
1193 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
1194 dnl compile the wrapper function.
1197 AC_DEFUN(jm_FUNC_LSTAT,
1199  AC_CACHE_CHECK([whether lstat accepts an empty string],
1200   jm_cv_func_lstat_empty_string_bug,
1201   [AC_TRY_RUN([
1202 #   include <sys/types.h>
1203 #   include <sys/stat.h>
1205     int
1206     main ()
1207     {
1208       struct stat sbuf;
1209       exit (lstat ("", &sbuf) ? 1 : 0);
1210     }
1211           ],
1212          jm_cv_func_lstat_empty_string_bug=yes,
1213          jm_cv_func_lstat_empty_string_bug=no,
1214          dnl When crosscompiling, assume lstat is broken.
1215          jm_cv_func_lstat_empty_string_bug=yes)
1216   ])
1217   if test $jm_cv_func_lstat_empty_string_bug = yes; then
1218     AC_SUBST(LIBOBJS)
1219     LIBOBJS="$LIBOBJS lstat.$ac_objext"
1220     AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
1221 [Define if lstat has the bug that it succeeds when given the zero-length
1222    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1223    do this. ])
1224   fi
1227 #serial 1
1229 dnl From Jim Meyering.
1230 dnl FIXME: describe
1232 AC_DEFUN(jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK,
1234  AC_CACHE_CHECK(
1235   [whether lstat dereferences a symlink specified with a trailing slash],
1236   jm_cv_func_lstat_dereferences_slashed_symlink,
1237   [
1238    rm -f conftest.sym conftest.file
1239    : > conftest.file
1240    if ln -s conftest.file conftest.sym; then
1241      AC_TRY_RUN([
1242 #     include <sys/types.h>
1243 #     include <sys/stat.h>
1245       int
1246       main ()
1247       {
1248         struct stat sbuf;
1249         /* Linux will dereference the symlink and fail.
1250            That is better in the sense that it means we will not
1251            have to compile and use the lstat wrapper.  */
1252         exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
1253       }
1254       ],
1255       jm_cv_func_lstat_dereferences_slashed_symlink=yes,
1256       jm_cv_func_lstat_dereferences_slashed_symlink=no,
1257       dnl When crosscompiling, be pessimistic so we will end up using the
1258       dnl replacement version of lstat that checkes for trailing slashes
1259       dnl and calls lstat a second time when necessary.
1260       jm_cv_func_lstat_dereferences_slashed_symlink=no
1261      )
1262    else
1263      # If the `ln -s' command failed, then we probably don't even
1264      # have an lstat function.
1265      jm_cv_func_lstat_dereferences_slashed_symlink=no
1266    fi
1267   ])
1269   test $jm_cv_func_lstat_dereferences_slashed_symlink = yes \
1270     && zero_one=1 \
1271     || zero_one=0
1272   AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, $zero_one,
1273     [Define if lstat dereferences a symlink specified with a trailing slash])
1275   if test $jm_cv_func_lstat_dereferences_slashed_symlink = no; then
1276     AC_SUBST(LIBOBJS)
1277     # Append lstat.o if it's not already in $LIBOBJS.
1278     case "$LIBOBJS" in
1279       *lstat.$ac_objext*) ;;
1280       *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
1281     esac
1282   fi
1285 #serial 3
1287 dnl From Jim Meyering.
1288 dnl Determine whether stat has the bug that it succeeds when given the
1289 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
1290 dnl (as of 1998-11-01) do this.
1292 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
1293 dnl compile the wrapper function.
1296 AC_DEFUN(jm_FUNC_STAT,
1298  AC_CACHE_CHECK([whether stat accepts an empty string],
1299   jm_cv_func_stat_empty_string_bug,
1300   [AC_TRY_RUN([
1301 #   include <sys/types.h>
1302 #   include <sys/stat.h>
1304     int
1305     main ()
1306     {
1307       struct stat sbuf;
1308       exit (stat ("", &sbuf) ? 1 : 0);
1309     }
1310           ],
1311          jm_cv_func_stat_empty_string_bug=yes,
1312          jm_cv_func_stat_empty_string_bug=no,
1313          dnl When crosscompiling, assume stat is broken.
1314          jm_cv_func_stat_empty_string_bug=yes)
1315   ])
1316   if test $jm_cv_func_stat_empty_string_bug = yes; then
1317     AC_SUBST(LIBOBJS)
1318     LIBOBJS="$LIBOBJS stat.$ac_objext"
1319     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
1320 [Define if stat has the bug that it succeeds when given the zero-length
1321    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1322    do this. ])
1323   fi
1326 #serial 3
1328 dnl From Jim Meyering.
1329 dnl Determine whether realloc works when both arguments are 0.
1330 dnl If it doesn't, arrange to use the replacement function.
1333 AC_DEFUN(jm_FUNC_REALLOC,
1335  dnl xmalloc.c requires that this symbol be defined so it doesn't
1336  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
1337  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
1338                     [Define if the realloc check has been performed. ])
1340  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
1341   [AC_TRY_RUN([
1342     char *realloc ();
1343     int
1344     main ()
1345     {
1346       exit (realloc (0, 0) ? 0 : 1);
1347     }
1348           ],
1349          jm_cv_func_working_realloc=yes,
1350          jm_cv_func_working_realloc=no,
1351          dnl When crosscompiling, assume realloc is broken.
1352          jm_cv_func_working_realloc=no)
1353   ])
1354   if test $jm_cv_func_working_realloc = no; then
1355     AC_SUBST(LIBOBJS)
1356     LIBOBJS="$LIBOBJS realloc.$ac_objext"
1357     AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
1358       [Define to rpl_realloc if the replacement function should be used.])
1359   fi
1362 #serial 3
1364 dnl From Jim Meyering.
1365 dnl Determine whether malloc accepts 0 as its argument.
1366 dnl If it doesn't, arrange to use the replacement function.
1369 AC_DEFUN(jm_FUNC_MALLOC,
1371  dnl xmalloc.c requires that this symbol be defined so it doesn't
1372  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
1373  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
1374                     [Define if the malloc check has been performed. ])
1376  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1377   [AC_TRY_RUN([
1378     char *malloc ();
1379     int
1380     main ()
1381     {
1382       exit (malloc (0) ? 0 : 1);
1383     }
1384           ],
1385          jm_cv_func_working_malloc=yes,
1386          jm_cv_func_working_malloc=no,
1387          dnl When crosscompiling, assume malloc is broken.
1388          jm_cv_func_working_malloc=no)
1389   ])
1390   if test $jm_cv_func_working_malloc = no; then
1391     AC_SUBST(LIBOBJS)
1392     LIBOBJS="$LIBOBJS malloc.$ac_objext"
1393     AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
1394       [Define to rpl_malloc if the replacement function should be used.])
1395   fi
1398 #serial 3
1400 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1401 dnl to test whether a NULL return value really means there are no more files
1402 dnl in the directory.
1404 dnl Detect the problem by creating a directory containing 300 files (254 not
1405 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1406 dnl removes all of them.
1408 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1410 dnl Written by Jim Meyering.
1412 AC_DEFUN(jm_FUNC_READDIR,
1413 [dnl
1414 AC_REQUIRE([AC_HEADER_DIRENT])
1415 AC_CHECK_HEADERS(string.h)
1416 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1417   [dnl
1418   # Arrange for deletion of the temporary directory this test creates, in
1419   # case the test itself fails to delete everything -- as happens on Sunos.
1420   ac_clean_files="$ac_clean_files conf-dir"
1422   AC_TRY_RUN(
1423 [#   include <stdio.h>
1424 #   include <sys/types.h>
1425 #   if HAVE_STRING_H
1426 #    include <string.h>
1427 #   endif
1429 #   ifdef HAVE_DIRENT_H
1430 #    include <dirent.h>
1431 #    define NLENGTH(direct) (strlen((direct)->d_name))
1432 #   else /* not HAVE_DIRENT_H */
1433 #    define dirent direct
1434 #    define NLENGTH(direct) ((direct)->d_namlen)
1435 #    ifdef HAVE_SYS_NDIR_H
1436 #     include <sys/ndir.h>
1437 #    endif /* HAVE_SYS_NDIR_H */
1438 #    ifdef HAVE_SYS_DIR_H
1439 #     include <sys/dir.h>
1440 #    endif /* HAVE_SYS_DIR_H */
1441 #    ifdef HAVE_NDIR_H
1442 #     include <ndir.h>
1443 #    endif /* HAVE_NDIR_H */
1444 #   endif /* HAVE_DIRENT_H */
1446 #   define DOT_OR_DOTDOT(Basename) \
1447      (Basename[0] == '.' && (Basename[1] == '\0' \
1448                              || (Basename[1] == '.' && Basename[2] == '\0')))
1450     static void
1451     create_300_file_dir (const char *dir)
1452     {
1453       int i;
1455       if (mkdir (dir, 0700))
1456         abort ();
1457       if (chdir (dir))
1458         abort ();
1460       for (i = 0; i < 300; i++)
1461         {
1462           char file_name[4];
1463           FILE *out;
1465           sprintf (file_name, "%03d", i);
1466           out = fopen (file_name, "w");
1467           if (!out)
1468             abort ();
1469           if (fclose (out) == EOF)
1470             abort ();
1471         }
1473       if (chdir (".."))
1474         abort ();
1475     }
1477     static void
1478     remove_dir (const char *dir)
1479     {
1480       DIR *dirp;
1482       if (chdir (dir))
1483         abort ();
1485       dirp = opendir (".");
1486       if (dirp == NULL)
1487         abort ();
1489       while (1)
1490         {
1491           struct dirent *dp = readdir (dirp);
1492           if (dp == NULL)
1493             break;
1495           if (DOT_OR_DOTDOT (dp->d_name))
1496             continue;
1498           if (unlink (dp->d_name))
1499             abort ();
1500         }
1501       closedir (dirp);
1503       if (chdir (".."))
1504         abort ();
1506       if (rmdir (dir))
1507         exit (1);
1508     }
1510     int
1511     main ()
1512     {
1513       const char *dir = "conf-dir";
1514       create_300_file_dir (dir);
1515       remove_dir (dir);
1516       exit (0);
1517     }],
1518   jm_cv_func_working_readdir=yes,
1519   jm_cv_func_working_readdir=no,
1520   jm_cv_func_working_readdir=no)])
1522   if test $jm_cv_func_working_readdir = yes; then
1523     AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
1524 [Define if readdir is found to work properly in some unusual cases. ])
1525   fi
1528 #serial 4
1530 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1531 dnl the losing memcmp on some x86 Next systems.
1532 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1533 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1534 [AC_TRY_RUN(
1535 [int
1536 main ()
1538   /* Some versions of memcmp are not 8-bit clean.  */
1539   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1540   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1541     exit (1);
1543   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1544      or more and with at least one buffer not starting on a 4-byte boundary.
1545      William Lewis provided this test program.   */
1546   {
1547     char foo[21];
1548     char bar[21];
1549     int i;
1550     for (i = 0; i < 4; i++)
1551       {
1552         char *a = foo + i;
1553         char *b = bar + i;
1554         strcpy (a, "--------01111111");
1555         strcpy (b, "--------10000000");
1556         if (memcmp (a, b, 16) >= 0)
1557           exit (1);
1558       }
1559     exit (0);
1560   }
1562    jm_cv_func_memcmp_working=yes,
1563    jm_cv_func_memcmp_working=no,
1564    jm_cv_func_memcmp_working=no)])
1565 test $jm_cv_func_memcmp_working = no \
1566   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
1567 AC_SUBST(LIBOBJS)dnl
1570 AC_DEFUN(jm_FUNC_MEMCMP,
1571 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1572  if test $jm_cv_func_memcmp_working = no; then
1573    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
1574      [Define to rpl_memcmp if the replacement function should be used.])
1575  fi
1578 #serial 4
1580 dnl From Jim Meyering.
1582 dnl See if the glibc *_unlocked I/O macros are available.
1583 dnl Use only those *_unlocked macros that are declared.
1586 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1587   [
1588     # Kludge (not executed) to make autoheader do the right thing.
1589     if test a = b; then
1590       AC_CHECK_DECLS([clearerr_unlocked, feof_unlocked, ferror_unlocked,
1591         fflush_unlocked, fputc_unlocked, fread_unlocked, fwrite_unlocked,
1592         getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked])
1593     fi
1595     io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
1596     fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
1597     getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
1598     for jm_io_func in $io_functions; do
1599       # Check for the existence of each function only if its declared.
1600       # Otherwise, we'd get the Solaris5.5.1 functions that are not
1601       # declared, and that have been removed from Solaris5.6.  The resulting
1602       # 5.5.1 binaries would not run on 5.6 due to shared library differences.
1603       AC_CHECK_DECLS([$jm_io_func],
1604                      jm_declared=yes,
1605                      jm_declared=no,
1606                      [#include <stdio.h>])
1607       if test $jm_declared = yes; then
1608         AC_CHECK_FUNCS($jm_io_func)
1609       fi
1610     done
1611   ]
1614 #serial 2
1616 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1617 dnl define fnmatch to rpl_fnmatch.
1620 # AC_FUNC_FNMATCH
1621 # ---------------
1622 # We look for fnmatch.h to avoid that the test fails in C++.
1623 AC_DEFUN(kd_FUNC_FNMATCH_CASE,
1624 [AC_CHECK_HEADERS(fnmatch.h)
1625 AC_CACHE_CHECK(for working fnmatch with case folding, ac_cv_func_fnmatch_works,
1626 # Some versions of Solaris or SCO have a broken fnmatch function.
1627 # So we run a test program.  If we are cross-compiling, take no chance.
1628 # Also want FNM_CASEFOLD
1629 # Thanks to John Oleynick and Franc,ois Pinard for this test.
1630 [AC_TRY_RUN(
1631 [#include <stdio.h>
1632 #define _GNU_SOURCE
1633 #if HAVE_FNMATCH_H
1634 # include <fnmatch.h>
1635 #endif
1638 main ()
1640   exit (fnmatch ("A*", "abc", FNM_CASEFOLD) != 0);
1642 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
1643 ac_cv_func_fnmatch_works=no)])
1644 if test $ac_cv_func_fnmatch_works = yes; then
1645   AC_DEFINE(HAVE_FNMATCH, 1,
1646             [Define if your system has a working `fnmatch' function with case folding.])
1648 ])# AC_FUNC_FNMATCH
1651 AC_DEFUN(kd_FUNC_FNMATCH_CASE_RPL,
1653   AC_REQUIRE([AM_GLIBC])
1654   kd_FUNC_FNMATCH_CASE
1655   if test $ac_cv_func_fnmatch_works = no \
1656       && test $ac_cv_gnu_library = no; then
1657     AC_SUBST(LIBOBJS)
1658     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
1659     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
1660       [Define to rpl_fnmatch if the replacement function should be used.])
1661   fi
1664 #serial 2
1666 dnl From Gordon Matzigkeit.
1667 dnl Test for the GNU C Library.
1668 dnl FIXME: this should migrate into libit.
1670 AC_DEFUN(AM_GLIBC,
1671   [
1672     AC_CACHE_CHECK(whether we are using the GNU C Library,
1673       ac_cv_gnu_library,
1674       [AC_EGREP_CPP([Thanks for using GNU],
1675         [
1676 #include <features.h>
1677 #ifdef __GNU_LIBRARY__
1678   Thanks for using GNU
1679 #endif
1680         ],
1681         ac_cv_gnu_library=yes,
1682         ac_cv_gnu_library=no)
1683       ]
1684     )
1685     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1686       ac_cv_glibc,
1687       [AC_EGREP_CPP([Thanks for using GNU too],
1688         [
1689 #include <features.h>
1690 #ifdef __GLIBC__
1691   Thanks for using GNU too
1692 #endif
1693         ],
1694         ac_cv_glibc=yes, ac_cv_glibc=no)
1695       ]
1696     )
1697   ]
1700 #serial 3
1702 AC_DEFUN(jm_AFS,
1703   AC_MSG_CHECKING(for AFS)
1704   if test -d /afs; then
1705     AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
1706     ac_result=yes
1707   else
1708     ac_result=no
1709   fi
1710   AC_MSG_RESULT($ac_result)
1713 #serial 2
1715 # autoconf tests required for use of xstrtoumax.c
1717 AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
1719   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
1720   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1721   AC_CHECK_HEADERS(stdlib.h)
1723   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
1724     jm_cv_func_strtoumax_macro,
1725     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
1726 #ifdef strtoumax
1727  inttypes_h_defines_strtoumax
1728 #endif],
1729       jm_cv_func_strtoumax_macro=yes,
1730       jm_cv_func_strtoumax_macro=no))
1732   if test "$jm_cv_func_strtoumax_macro" != yes; then
1733     AC_REPLACE_FUNCS(strtoumax)
1734   fi
1736   dnl We don't need (and can't compile) the replacement strtoull
1737   dnl unless the type `unsigned long long' exists.
1738   dnl Also, only the replacement strtoumax invokes strtoull,
1739   dnl so we need the replacement strtoull only if strtoumax does not exist.
1740   case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
1741     yes,no,no)
1742       AC_REPLACE_FUNCS(strtoull)
1743       ;;
1744   esac
1748 #serial 2
1750 dnl From Paul Eggert.
1752 AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
1754   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
1755   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
1756     [unsigned long long ullmax = (unsigned long long) -1;
1757      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
1758     ac_cv_type_unsigned_long_long=yes,
1759     ac_cv_type_unsigned_long_long=no)])
1760   if test $ac_cv_type_unsigned_long_long = yes; then
1761     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
1762       [Define if you have the unsigned long long type.])
1763   fi
1766 #serial 1
1767 dnl Run a program to determine whether whether link(2) follows symlinks.
1768 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
1770 AC_DEFUN(jm_AC_FUNC_LINK_FOLLOWS_SYMLINK,
1771 [dnl
1772   AC_CACHE_CHECK([whether link(2) follows symlinks],
1773                  jm_ac_cv_func_link_follows_symlink,
1774   [
1775     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
1776     dnl the appropriate framework.
1777     test -z "$ac_cv_header_unistd_h" \
1778       && AC_CHECK_HEADERS(unistd.h)
1780     # Create a regular file.
1781     echo > conftest.file
1782     AC_TRY_RUN(
1783       [
1784 #       include <sys/types.h>
1785 #       include <sys/stat.h>
1786 #       ifdef HAVE_UNISTD_H
1787 #        include <unistd.h>
1788 #       endif
1790 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
1791           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
1792            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
1794         int
1795         main ()
1796         {
1797           const char *file = "conftest.file";
1798           const char *sym = "conftest.sym";
1799           const char *hard = "conftest.hard";
1800           struct stat sb_file, sb_hard;
1802           /* Create a symlink to the regular file. */
1803           if (symlink (file, sym))
1804             abort ();
1806           /* Create a hard link to that symlink.  */
1807           if (link (sym, hard))
1808             abort ();
1810           if (lstat (hard, &sb_hard))
1811             abort ();
1812           if (lstat (file, &sb_file))
1813             abort ();
1815           /* If the dev/inode of hard and file are the same, then
1816              the link call followed the symlink.  */
1817           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
1818         }
1819       ],
1820       jm_ac_cv_func_link_follows_symlink=yes,
1821       jm_ac_cv_func_link_follows_symlink=no,
1822       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
1823     )
1824   ])
1825   if test $jm_ac_cv_func_link_follows_symlink = yes; then
1826     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
1827       [Define if `link(2)' dereferences symbolic links.])
1828   fi
1831 # From Jim Meyering.  Use this if you use the GNU error.[ch].
1832 # FIXME: Migrate into libit
1834 AC_DEFUN([AM_FUNC_ERROR_AT_LINE],
1835 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1836  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1837               am_cv_lib_error_at_line=yes,
1838               am_cv_lib_error_at_line=no)])
1839  if test $am_cv_lib_error_at_line = no; then
1840    LIBOBJS="$LIBOBJS error.$ac_objext"
1841  fi
1842  AC_SUBST(LIBOBJS)dnl
1845 #serial 9
1847 dnl This macro is intended to be used solely in this file.
1848 dnl These are the prerequisite macros for GNU's strftime.c replacement.
1849 AC_DEFUN(_jm_STRFTIME_PREREQS,
1851  dnl strftime.c uses localtime_r if it exists.  Check for it.
1852  AC_CHECK_FUNCS(localtime_r)
1854  AC_CHECK_HEADERS(limits.h)
1855  AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
1857  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
1858  AC_STRUCT_TIMEZONE
1860  AC_CHECK_FUNCS(mblen mbrlen)
1862  AC_CHECK_MEMBER(struct tm.tm_gmtoff,
1863                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
1864                             [Define if struct tm has the tm_gmtoff member.])],
1865                  ,
1866                  [#include <time.h>])
1869 dnl Determine if the strftime function has all the features of the GNU one.
1871 dnl From Jim Meyering.
1873 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
1874 [AC_REQUIRE([AC_HEADER_TIME])dnl
1876  _jm_STRFTIME_PREREQS
1878  AC_REQUIRE([AC_C_CONST])dnl
1879  AC_REQUIRE([AC_HEADER_STDC])dnl
1880  AC_CHECK_HEADERS(sys/time.h)
1881  AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
1882   [# Set TZ to GMT0 to make strftime give consistent results during the test.
1883    ac_save_TZ="${TZ-GMT0}"
1884    TZ=GMT0
1885    export TZ
1886    AC_TRY_RUN(
1887 [ /* Ulrich Drepper provided parts of the test program.  */
1888 #if STDC_HEADERS
1889 # include <stdlib.h>
1890 #endif
1892 #if TIME_WITH_SYS_TIME
1893 # include <sys/time.h>
1894 # include <time.h>
1895 #else
1896 # if HAVE_SYS_TIME_H
1897 #  include <sys/time.h>
1898 # else
1899 #  include <time.h>
1900 # endif
1901 #endif
1903 static int
1904 compare (const char *fmt, const struct tm *tm, const char *expected)
1906   char buf[99];
1907   strftime (buf, 99, fmt, tm);
1908   if (strcmp (buf, expected))
1909     {
1910 #ifdef SHOW_FAILURES
1911       printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
1912               fmt, expected, buf);
1913 #endif
1914       return 1;
1915     }
1916   return 0;
1920 main ()
1922   int n_fail = 0;
1923   struct tm *tm;
1924   time_t t = 738367; /* Fri Jan  9 13:06:07 1970 */
1925   tm = gmtime (&t);
1927 #undef CMP
1928 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
1930   CMP ("%-m", "1");             /* GNU */
1931   CMP ("%A", "Friday");
1932   CMP ("%^A", "FRIDAY");        /* The ^ is a GNU extension.  */
1933   CMP ("%B", "January");
1934   CMP ("%^B", "JANUARY");
1935   CMP ("%C", "19");             /* POSIX.2 */
1936   CMP ("%D", "01/09/70");       /* POSIX.2 */
1937   CMP ("%F", "1970-01-09");
1938   CMP ("%G", "1970");           /* GNU */
1939   CMP ("%H", "13");
1940   CMP ("%I", "01");
1941   CMP ("%M", "06");
1942   CMP ("%M", "06");
1943   CMP ("%R", "13:06");          /* POSIX.2 */
1944   CMP ("%S", "07");
1945   CMP ("%T", "13:06:07");       /* POSIX.2 */
1946   CMP ("%U", "01");
1947   CMP ("%V", "02");
1948   CMP ("%W", "01");
1949   CMP ("%X", "13:06:07");
1950   CMP ("%Y", "1970");
1951   CMP ("%Z", "GMT");
1952   CMP ("%_m", " 1");            /* GNU */
1953   CMP ("%a", "Fri");
1954   CMP ("%^a", "FRI");
1955   CMP ("%b", "Jan");
1956   CMP ("%^b", "JAN");
1957   CMP ("%c", "Fri Jan  9 13:06:07 1970");
1958   CMP ("%^c", "FRI JAN  9 13:06:07 1970");
1959   CMP ("%d", "09");
1960   CMP ("%e", " 9");             /* POSIX.2 */
1961   CMP ("%g", "70");             /* GNU */
1962   CMP ("%h", "Jan");            /* POSIX.2 */
1963   CMP ("%^h", "JAN");
1964   CMP ("%j", "009");
1965   CMP ("%k", "13");             /* GNU */
1966   CMP ("%l", " 1");             /* GNU */
1967   CMP ("%m", "01");
1968   CMP ("%n", "\n");             /* POSIX.2 */
1969   CMP ("%p", "PM");
1970   CMP ("%r", "01:06:07 PM");    /* POSIX.2 */
1971   CMP ("%s", "738367");         /* GNU */
1972   CMP ("%t", "\t");             /* POSIX.2 */
1973   CMP ("%u", "5");              /* POSIX.2 */
1974   CMP ("%w", "5");
1975   CMP ("%x", "01/09/70");
1976   CMP ("%y", "70");
1977   CMP ("%z", "+0000");          /* GNU */
1979   exit (n_fail ? 1 : 0);
1981              jm_cv_func_working_gnu_strftime=yes,
1982              jm_cv_func_working_gnu_strftime=no,
1983              dnl When crosscompiling, assume strftime is missing or broken.
1984              jm_cv_func_working_gnu_strftime=no)
1985    dnl If TZ wasn't set before, this sets it to GMT0.  No real harm done.
1986    TZ="$ac_save_TZ"
1987   ])
1988   if test $jm_cv_func_working_gnu_strftime = no; then
1989     AC_SUBST(LIBOBJS)
1990     LIBOBJS="$LIBOBJS strftime.$ac_objext"
1991     AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
1992       [Define to gnu_strftime if the replacement function should be used.])
1993   fi
1996 AC_DEFUN(jm_FUNC_STRFTIME,
1998   _jm_STRFTIME_PREREQS
1999   AC_REPLACE_FUNCS(strftime)
2002 #serial 4
2004 dnl See if there's a working, system-supplied version of the getline function.
2005 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
2006 dnl have a function by that name in -linet that doesn't have anything
2007 dnl to do with the function we need.
2008 AC_DEFUN(AM_FUNC_GETLINE,
2009 [dnl
2010   am_getline_needs_run_time_check=no
2011   AC_CHECK_FUNC(getline,
2012                 dnl Found it in some library.  Verify that it works.
2013                 am_getline_needs_run_time_check=yes,
2014                 am_cv_func_working_getline=no)
2015   if test $am_getline_needs_run_time_check = yes; then
2016     AC_CHECK_HEADERS(string.h)
2017     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
2018     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
2019     AC_TRY_RUN([
2020 #    include <stdio.h>
2021 #    include <sys/types.h>
2022 #    if HAVE_STRING_H
2023 #     include <string.h>
2024 #    endif
2025     int foo()
2026     {
2027        char *path;
2028        size_t n;
2029        FILE *stream;
2030        char terminator;
2031        size_t offset;
2032        getstr(&path, &n, stream, terminator, offset);
2033      }
2035     int main ()
2036     { /* Based on a test program from Karl Heuer.  */
2037       char *line = NULL;
2038       size_t siz = 0;
2039       int len;
2040       FILE *in = fopen ("./conftest.data", "r");
2041       if (!in)
2042         return 1;
2043       len = getline (&line, &siz, in);
2044       nread = getstr (&path, &pathsize, fp, '\0', count);
2046       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
2047     }
2048     ], am_cv_func_working_getline=yes dnl The library version works.
2049     , am_cv_func_working_getline=no dnl The library version does NOT work.
2050     , am_cv_func_working_getline=no dnl We're cross compiling.
2051     )])
2052   fi
2054   if test $am_cv_func_working_getline = no; then
2055     AC_LIBOBJ(getline)
2056   fi
2059 #serial 2
2061 # Test for the GNU C Library, version 2.1 or newer.
2062 # From Bruno Haible.
2064 AC_DEFUN(jm_GLIBC21,
2065   [
2066     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2067       ac_cv_gnu_library_2_1,
2068       [AC_EGREP_CPP([Lucky GNU user],
2069         [
2070 #include <features.h>
2071 #ifdef __GNU_LIBRARY__
2072  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2073   Lucky GNU user
2074  #endif
2075 #endif
2076         ],
2077         ac_cv_gnu_library_2_1=yes,
2078         ac_cv_gnu_library_2_1=no)
2079       ]
2080     )
2081     AC_SUBST(GLIBC21)
2082     GLIBC21="$ac_cv_gnu_library_2_1"
2083   ]
2086 #serial 1
2088 dnl From Bruno Haible.
2090 AC_DEFUN(jm_ICONV,
2092   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2093   dnl those with the standalone portable libiconv installed).
2094   AC_CACHE_CHECK(for iconv, jm_cv_func_iconv, [
2095     jm_cv_func_iconv="no, consider installing libiconv"
2096     jm_cv_lib_iconv=no
2097     AC_TRY_LINK([#include <stdlib.h>
2098 #include <iconv.h>],
2099       [iconv_t cd = iconv_open("","");
2100        iconv(cd,NULL,NULL,NULL,NULL);
2101        iconv_close(cd);],
2102       jm_cv_func_iconv=yes)
2103     if test "$jm_cv_func_iconv" != yes; then
2104       jm_save_LIBS="$LIBS"
2105       LIBS="$LIBS -liconv"
2106       AC_TRY_LINK([#include <stdlib.h>
2107 #include <iconv.h>],
2108         [iconv_t cd = iconv_open("","");
2109          iconv(cd,NULL,NULL,NULL,NULL);
2110          iconv_close(cd);],
2111         jm_cv_lib_iconv=yes
2112         jm_cv_func_iconv=yes)
2113       LIBS="$jm_save_LIBS"
2114     fi
2115   ])
2116   if test "$jm_cv_func_iconv" = yes; then
2117     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2118   fi
2119   LIBICONV=
2120   if test "$jm_cv_lib_iconv" = yes; then
2121     LIBICONV="-liconv"
2122   fi
2123   AC_SUBST(LIBICONV)
2126 #serial 2
2128 dnl From Jim Meyering.
2130 dnl See if struct statfs has the f_fstypename member.
2131 dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
2134 AC_DEFUN(jm_FSTYPENAME,
2135   [
2136     AC_CACHE_CHECK([for f_fstypename in struct statfs],
2137                    fu_cv_sys_f_fstypename_in_statfs,
2138       [
2139         AC_TRY_COMPILE(
2140           [
2141 #include <sys/param.h>
2142 #include <sys/types.h>
2143 #include <sys/mount.h>
2144           ],
2145           [struct statfs s; int i = sizeof s.f_fstypename;],
2146           fu_cv_sys_f_fstypename_in_statfs=yes,
2147           fu_cv_sys_f_fstypename_in_statfs=no
2148         )
2149       ]
2150     )
2152     if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
2153       AC_DEFINE_UNQUOTED(HAVE_F_FSTYPENAME_IN_STATFS, 1,
2154                          [Define if struct statfs has the f_fstypename member.])
2155     fi
2156   ]
2159 #serial 4
2161 dnl From Paul Eggert.
2163 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
2164 # if it exists.
2166 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
2167  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
2168    ac_cv_struct_st_mtim_nsec,
2169    [ac_save_CPPFLAGS="$CPPFLAGS"
2170     ac_cv_struct_st_mtim_nsec=no
2171     # tv_nsec -- the usual case
2172     # _tv_nsec -- Solaris 2.6, if
2173     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
2174     #    && !defined __EXTENSIONS__)
2175     # st__tim.tv_nsec -- UnixWare 2.1.2
2176     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
2177       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
2178       AC_TRY_COMPILE([#include <sys/types.h>
2179 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
2180         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
2181     done
2182     CPPFLAGS="$ac_save_CPPFLAGS"])
2184   if test $ac_cv_struct_st_mtim_nsec != no; then
2185     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
2186       [Define to be the nanoseconds member of struct stat's st_mtim,
2187    if it exists.])
2188   fi
2192 #serial 2
2194 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
2196 AC_DEFUN(AC_STRUCT_ST_DM_MODE,
2197  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
2198    [AC_TRY_COMPILE([#include <sys/types.h>
2199 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
2200      ac_cv_struct_st_dm_mode=yes,
2201      ac_cv_struct_st_dm_mode=no)])
2203   if test $ac_cv_struct_st_dm_mode = yes; then
2204     AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
2205                        [Define if struct stat has an st_dm_mode member. ])
2206   fi
2210 #serial 4
2212 dnl From Jim Meyering
2214 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
2215 dnl in time.h or sys/time.h.
2217 AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
2219   AC_REQUIRE([AC_HEADER_TIME])
2220   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
2221     [AC_TRY_COMPILE(
2222       [
2223 #      if TIME_WITH_SYS_TIME
2224 #       include <sys/time.h>
2225 #       include <time.h>
2226 #      else
2227 #       if HAVE_SYS_TIME_H
2228 #        include <sys/time.h>
2229 #       else
2230 #        include <time.h>
2231 #       endif
2232 #      endif
2233       ],
2234       [static struct timespec x; x.tv_sec = x.tv_nsec;],
2235       fu_cv_sys_struct_timespec=yes,
2236       fu_cv_sys_struct_timespec=no)
2237     ])
2239   if test $fu_cv_sys_struct_timespec = yes; then
2240     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
2241                        [Define if struct timespec is declared in <time.h>. ])
2242   fi
2245 #serial 5
2247 dnl From Paul Eggert.
2249 AC_PREREQ(2.13)
2251 # Define uintmax_t to `unsigned long' or `unsigned long long'
2252 # if <inttypes.h> does not exist.
2254 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
2256   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2257   if test $jm_ac_cv_header_inttypes_h = no; then
2258     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2259     test $ac_cv_type_unsigned_long_long = yes \
2260       && ac_type='unsigned long long' \
2261       || ac_type='unsigned long'
2262     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2263 [  Define to unsigned long or unsigned long long
2264    if <inttypes.h> doesn't define.])
2265   fi
2268 # Macro to add for using GNU gettext.
2269 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2271 # This file can be copied and used freely without restrictions.  It can
2272 # be used in projects which are not available under the GNU Public License
2273 # but which still want to provide support for the GNU gettext functionality.
2274 # Please note that the actual code is *not* freely available.
2276 # serial 108
2278 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2280 AC_DEFUN(AM_WITH_NLS,
2281   [AC_MSG_CHECKING([whether NLS is requested])
2282     dnl Default is enabled NLS
2283     AC_ARG_ENABLE(nls,
2284       [  --disable-nls           do not use Native Language Support],
2285       USE_NLS=$enableval, USE_NLS=yes)
2286     AC_MSG_RESULT($USE_NLS)
2287     AC_SUBST(USE_NLS)
2289     USE_INCLUDED_LIBINTL=no
2291     dnl If we use NLS figure out what method
2292     if test "$USE_NLS" = "yes"; then
2293       AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.])
2294       AC_MSG_CHECKING([whether included gettext is requested])
2295       AC_ARG_WITH(included-gettext,
2296         [  --with-included-gettext use the GNU gettext library included here],
2297         nls_cv_force_use_gnu_gettext=$withval,
2298         nls_cv_force_use_gnu_gettext=no)
2299       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2301       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2302       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2303         dnl User does not insist on using GNU NLS library.  Figure out what
2304         dnl to use.  If gettext or catgets are available (in this order) we
2305         dnl use this.  Else we have to fall back to GNU NLS library.
2306         dnl catgets is only used if permitted by option --with-catgets.
2307         nls_cv_header_intl=
2308         nls_cv_header_libgt=
2309         CATOBJEXT=NONE
2311         AC_CHECK_HEADER(libintl.h,
2312           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
2313             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
2314                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
2316            if test "$gt_cv_func_gettext_libc" != "yes"; then
2317              AC_CHECK_LIB(intl, bindtextdomain,
2318                [AC_CHECK_LIB(intl, gettext)])
2319            fi
2321            if test "$gt_cv_func_gettext_libc" = "yes" \
2322               || test "$ac_cv_lib_intl_gettext" = "yes"; then
2323               AC_DEFINE(HAVE_GETTEXT, 1,
2324           [Define to 1 if you have gettext and don't want to use GNU gettext.])
2325               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2326                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2327               if test "$MSGFMT" != "no"; then
2328                 AC_CHECK_FUNCS(dcgettext)
2329                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2330                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2331                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2332                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
2333                                return _nl_msg_cat_cntr],
2334                   [CATOBJEXT=.gmo
2335                    DATADIRNAME=share],
2336                   [CATOBJEXT=.mo
2337                    DATADIRNAME=lib])
2338                 INSTOBJEXT=.mo
2339               fi
2340             fi
2341         ])
2343         if test "$CATOBJEXT" = "NONE"; then
2344           AC_MSG_CHECKING([whether catgets can be used])
2345           AC_ARG_WITH(catgets,
2346             [  --with-catgets          use catgets functions if available],
2347             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
2348           AC_MSG_RESULT($nls_cv_use_catgets)
2350           if test "$nls_cv_use_catgets" = "yes"; then
2351             dnl No gettext in C library.  Try catgets next.
2352             AC_CHECK_LIB(i, main)
2353             AC_CHECK_FUNC(catgets,
2354               [AC_DEFINE(HAVE_CATGETS, 1,
2355                          [Define as 1 if you have catgets and don't want to use GNU gettext.])
2356                INTLOBJS="\$(CATOBJS)"
2357                AC_PATH_PROG(GENCAT, gencat, no)dnl
2358                if test "$GENCAT" != "no"; then
2359                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
2360                  if test "$GMSGFMT" = "no"; then
2361                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
2362                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
2363                  fi
2364                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2365                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2366                  USE_INCLUDED_LIBINTL=yes
2367                  CATOBJEXT=.cat
2368                  INSTOBJEXT=.cat
2369                  DATADIRNAME=lib
2370                  INTLDEPS='$(top_builddir)/intl/libintl.a'
2371                  INTLLIBS=$INTLDEPS
2372                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2373                  nls_cv_header_intl=intl/libintl.h
2374                  nls_cv_header_libgt=intl/libgettext.h
2375                fi])
2376           fi
2377         fi
2379         if test "$CATOBJEXT" = "NONE"; then
2380           dnl Neither gettext nor catgets in included in the C library.
2381           dnl Fall back on GNU gettext library.
2382           nls_cv_use_gnu_gettext=yes
2383         fi
2384       fi
2386       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2387         dnl Mark actions used to generate GNU NLS library.
2388         INTLOBJS="\$(GETTOBJS)"
2389         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2390           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2391         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2392         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2393           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2394         AC_SUBST(MSGFMT)
2395         USE_INCLUDED_LIBINTL=yes
2396         CATOBJEXT=.gmo
2397         INSTOBJEXT=.mo
2398         DATADIRNAME=share
2399         INTLDEPS='$(top_builddir)/intl/libintl.a'
2400         INTLLIBS=$INTLDEPS
2401         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2402         nls_cv_header_intl=intl/libintl.h
2403         nls_cv_header_libgt=intl/libgettext.h
2404       fi
2406       dnl Test whether we really found GNU xgettext.
2407       if test "$XGETTEXT" != ":"; then
2408         dnl If it is no GNU xgettext we define it as : so that the
2409         dnl Makefiles still can work.
2410         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2411           : ;
2412         else
2413           AC_MSG_RESULT(
2414             [found xgettext program is not GNU xgettext; ignore it])
2415           XGETTEXT=":"
2416         fi
2417       fi
2419       # We need to process the po/ directory.
2420       POSUB=po
2421     else
2422       DATADIRNAME=share
2423       nls_cv_header_intl=intl/libintl.h
2424       nls_cv_header_libgt=intl/libgettext.h
2425     fi
2426     if test -z "$nls_cv_header_intl"; then
2427       # Clean out junk possibly left behind by a previous configuration.
2428       rm -f intl/libintl.h
2429     fi
2430     AC_CONFIG_LINKS($nls_cv_header_intl:$nls_cv_header_libgt)
2431     AC_OUTPUT_COMMANDS(
2432      [case "$CONFIG_FILES" in *po/Makefile.in*)
2433         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
2434       esac])
2437     # If this is used in GNU gettext we have to set USE_NLS to `yes'
2438     # because some of the sources are only built for this goal.
2439     if test "$PACKAGE" = gettext; then
2440       USE_NLS=yes
2441       USE_INCLUDED_LIBINTL=yes
2442     fi
2444     dnl These rules are solely for the distribution goal.  While doing this
2445     dnl we only have to keep exactly one list of the available catalogs
2446     dnl in configure.in.
2447     for lang in $ALL_LINGUAS; do
2448       GMOFILES="$GMOFILES $lang.gmo"
2449       POFILES="$POFILES $lang.po"
2450     done
2452     dnl Make all variables we use known to autoconf.
2453     AC_SUBST(USE_INCLUDED_LIBINTL)
2454     AC_SUBST(CATALOGS)
2455     AC_SUBST(CATOBJEXT)
2456     AC_SUBST(DATADIRNAME)
2457     AC_SUBST(GMOFILES)
2458     AC_SUBST(INSTOBJEXT)
2459     AC_SUBST(INTLDEPS)
2460     AC_SUBST(INTLLIBS)
2461     AC_SUBST(INTLOBJS)
2462     AC_SUBST(POFILES)
2463     AC_SUBST(POSUB)
2464   ])
2466 AC_DEFUN(AM_GNU_GETTEXT,
2467   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2468    AC_REQUIRE([AC_PROG_CC])dnl
2469    AC_REQUIRE([AC_PROG_RANLIB])dnl
2470    AC_REQUIRE([AC_ISC_POSIX])dnl
2471    AC_REQUIRE([AC_HEADER_STDC])dnl
2472    AC_REQUIRE([AC_C_CONST])dnl
2473    AC_REQUIRE([AC_C_INLINE])dnl
2474    AC_REQUIRE([AC_TYPE_OFF_T])dnl
2475    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2476    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2477    AC_REQUIRE([AC_FUNC_MMAP])dnl
2479    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
2480 unistd.h sys/param.h])
2481    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
2482 strdup __argz_count __argz_stringify __argz_next])
2484    if test "${ac_cv_func_stpcpy+set}" != "set"; then
2485      AC_CHECK_FUNCS(stpcpy)
2486    fi
2487    if test "${ac_cv_func_stpcpy}" = "yes"; then
2488      AC_DEFINE(HAVE_STPCPY, 1, [Define to 1 if you have the stpcpy function.])
2489    fi
2491    AM_LC_MESSAGES
2492    AM_WITH_NLS
2494    if test "x$CATOBJEXT" != "x"; then
2495      if test "x$ALL_LINGUAS" = "x"; then
2496        LINGUAS=
2497      else
2498        AC_MSG_CHECKING(for catalogs to be installed)
2499        NEW_LINGUAS=
2500        for lang in ${LINGUAS=$ALL_LINGUAS}; do
2501          case "$ALL_LINGUAS" in
2502           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
2503          esac
2504        done
2505        LINGUAS=$NEW_LINGUAS
2506        AC_MSG_RESULT($LINGUAS)
2507      fi
2509      dnl Construct list of names of catalog files to be constructed.
2510      if test -n "$LINGUAS"; then
2511        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2512      fi
2513    fi
2515    dnl The reference to <locale.h> in the installed <libintl.h> file
2516    dnl must be resolved because we cannot expect the users of this
2517    dnl to define HAVE_LOCALE_H.
2518    if test $ac_cv_header_locale_h = yes; then
2519      INCLUDE_LOCALE_H="#include <locale.h>"
2520    else
2521      INCLUDE_LOCALE_H="\
2522 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
2523    fi
2524    AC_SUBST(INCLUDE_LOCALE_H)
2526    dnl Determine which catalog format we have (if any is needed)
2527    dnl For now we know about two different formats:
2528    dnl   Linux libc-5 and the normal X/Open format
2529    test -d intl || mkdir intl
2530    if test "$CATOBJEXT" = ".cat"; then
2531      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
2533      dnl Transform the SED scripts while copying because some dumb SEDs
2534      dnl cannot handle comments.
2535      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
2536    fi
2537    dnl po2tbl.sed is always needed.
2538    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
2539      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
2541    dnl In the intl/Makefile.in we have a special dependency which makes
2542    dnl only sense for gettext.  We comment this out for non-gettext
2543    dnl packages.
2544    if test "$PACKAGE" = "gettext"; then
2545      GT_NO="#NO#"
2546      GT_YES=
2547    else
2548      GT_NO=
2549      GT_YES="#YES#"
2550    fi
2551    AC_SUBST(GT_NO)
2552    AC_SUBST(GT_YES)
2554    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2555    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
2556    dnl Try to locate is.
2557    MKINSTALLDIRS=
2558    if test -n "$ac_aux_dir"; then
2559      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2560    fi
2561    if test -z "$MKINSTALLDIRS"; then
2562      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2563    fi
2564    AC_SUBST(MKINSTALLDIRS)
2566    dnl *** For now the libtool support in intl/Makefile is not for real.
2567    l=
2568    AC_SUBST(l)
2570    dnl Generate list of files to be processed by xgettext which will
2571    dnl be included in po/Makefile.
2572    test -d po || mkdir po
2573    case "$srcdir" in
2574    .)
2575      posrcprefix="../" ;;
2576    /* | [[A-Za-z]]:*)
2577      posrcprefix="$srcdir/" ;;
2578    *)
2579      posrcprefix="../$srcdir/" ;;
2580    esac
2581    rm -f po/POTFILES
2582    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
2583         < $srcdir/po/POTFILES.in > po/POTFILES
2584   ])
2586 # Search path for a program which passes the given test.
2587 # Ulrich Drepper <drepper@cygnus.com>, 1996.
2589 # This file can be copied and used freely without restrictions.  It can
2590 # be used in projects which are not available under the GNU Public License
2591 # but which still want to provide support for the GNU gettext functionality.
2592 # Please note that the actual code is *not* freely available.
2594 # serial 1
2596 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2597 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2598 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
2599 [# Extract the first word of "$2", so it can be a program name with args.
2600 set dummy $2; ac_word=[$]2
2601 AC_MSG_CHECKING([for $ac_word])
2602 AC_CACHE_VAL(ac_cv_path_$1,
2603 [case "[$]$1" in
2604   /*)
2605   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2606   ;;
2607   *)
2608   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2609   for ac_dir in ifelse([$5], , $PATH, [$5]); do
2610     test -z "$ac_dir" && ac_dir=.
2611     if test -f $ac_dir/$ac_word; then
2612       if [$3]; then
2613         ac_cv_path_$1="$ac_dir/$ac_word"
2614         break
2615       fi
2616     fi
2617   done
2618   IFS="$ac_save_ifs"
2619 dnl If no 4th arg is given, leave the cache variable unset,
2620 dnl so AC_PATH_PROGS will keep looking.
2621 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2622 ])dnl
2623   ;;
2624 esac])dnl
2625 $1="$ac_cv_path_$1"
2626 if test -n "[$]$1"; then
2627   AC_MSG_RESULT([$]$1)
2628 else
2629   AC_MSG_RESULT(no)
2631 AC_SUBST($1)dnl
2634 # Check whether LC_MESSAGES is available in <locale.h>.
2635 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2637 # This file can be copied and used freely without restrictions.  It can
2638 # be used in projects which are not available under the GNU Public License
2639 # but which still want to provide support for the GNU gettext functionality.
2640 # Please note that the actual code is *not* freely available.
2642 # serial 2
2644 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2646 AC_DEFUN(AM_LC_MESSAGES,
2647   [if test $ac_cv_header_locale_h = yes; then
2648     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2649       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2650        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2651     if test $am_cv_val_LC_MESSAGES = yes; then
2652       AC_DEFINE(HAVE_LC_MESSAGES, 1,
2653                 [Define if your locale.h file contains LC_MESSAGES.])
2654     fi
2655   fi])