*** empty log message ***
[findutils.git] / aclocal.m4
blob4c797ccce6fb6940ba22bbd1c3e1c91511247fbf
1 # aclocal.m4 generated automatically by aclocal 1.4a
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 3
49 AC_PREREQ([2.13])
51 # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
52 # -----------------------------------------------------------
53 # If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED.
54 # The purpose of this macro is to provide the user with a means to
55 # check macros which are provided without letting her know how the
56 # information is coded.
57 # If this macro is not defined by Autoconf, define it here.
58 ifdef([AC_PROVIDE_IFELSE],
59       [],
60       [define([AC_PROVIDE_IFELSE],
61               [ifdef([AC_PROVIDE_$1],
62                      [$2], [$3])])])
65 # AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE])
66 # ----------------------------------------------
67 AC_DEFUN([AM_INIT_AUTOMAKE],
68 [dnl We require 2.13 because we rely on SHELL being computed by configure.
69 AC_REQUIRE([AC_PROG_INSTALL])dnl
70 # test to see if srcdir already configured
71 if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" &&
72    test -f $srcdir/config.status; then
73   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
76 # Define the identity of the package.
77 PACKAGE=$1
78 AC_SUBST(PACKAGE)dnl
79 VERSION=$2
80 AC_SUBST(VERSION)dnl
81 ifelse([$3],,
82 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
83 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])
85 # Some tools Automake needs.
86 AC_REQUIRE([AM_SANITY_CHECK])dnl
87 AC_REQUIRE([AC_ARG_PROGRAM])dnl
88 AM_MISSING_PROG(ACLOCAL, aclocal)
89 AM_MISSING_PROG(AUTOCONF, autoconf)
90 AM_MISSING_PROG(AUTOMAKE, automake)
91 AM_MISSING_PROG(AUTOHEADER, autoheader)
92 AM_MISSING_PROG(MAKEINFO, makeinfo)
93 AM_MISSING_PROG(AMTAR, tar)
94 AM_MISSING_INSTALL_SH
95 # We need awk for the "check" target.  The system "awk" is bad on
96 # some platforms.
97 AC_REQUIRE([AC_PROG_AWK])dnl
98 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
99 AC_REQUIRE([AM_DEP_TRACK])dnl
100 AC_REQUIRE([AM_SET_DEPDIR])dnl
101 AC_PROVIDE_IFELSE([AC_PROG_CC],
102                   [AM_DEPENDENCIES(CC)],
103                   [define([AC_PROG_CC],
104                           defn([AC_PROG_CC])[AM_DEPENDENCIES(CC)])])dnl
105 AC_PROVIDE_IFELSE([AC_PROG_CXX],
106                   [AM_DEPENDENCIES(CXX)],
107                   [define([AC_PROG_CXX],
108                           defn([AC_PROG_CXX])[AM_DEPENDENCIES(CXX)])])dnl
112 # Check to make sure that the build environment is sane.
115 AC_DEFUN([AM_SANITY_CHECK],
116 [AC_MSG_CHECKING([whether build environment is sane])
117 # Just in case
118 sleep 1
119 echo timestamp > conftestfile
120 # Do `set' in a subshell so we don't clobber the current shell's
121 # arguments.  Must try -L first in case configure is actually a
122 # symlink; some systems play weird games with the mod time of symlinks
123 # (eg FreeBSD returns the mod time of the symlink's containing
124 # directory).
125 if (
126    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
127    if test "[$]*" = "X"; then
128       # -L didn't work.
129       set X `ls -t $srcdir/configure conftestfile`
130    fi
131    if test "[$]*" != "X $srcdir/configure conftestfile" \
132       && test "[$]*" != "X conftestfile $srcdir/configure"; then
134       # If neither matched, then we have a broken ls.  This can happen
135       # if, for instance, CONFIG_SHELL is bash and it inherits a
136       # broken ls alias from the environment.  This has actually
137       # happened.  Such a system could not be considered "sane".
138       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
139 alias in your environment])
140    fi
142    test "[$]2" = conftestfile
143    )
144 then
145    # Ok.
146    :
147 else
148    AC_MSG_ERROR([newly created file is older than distributed files!
149 Check your system clock])
151 rm -f conftest*
152 AC_MSG_RESULT(yes)])
154 # AM_MISSING_PROG(NAME, PROGRAM)
155 AC_DEFUN([AM_MISSING_PROG], [
156 AC_REQUIRE([AM_MISSING_HAS_RUN])
157 $1=${$1-"${am_missing_run}$2"}
158 AC_SUBST($1)])
160 # Like AM_MISSING_PROG, but only looks for install-sh.
161 # AM_MISSING_INSTALL_SH()
162 AC_DEFUN([AM_MISSING_INSTALL_SH], [
163 AC_REQUIRE([AM_MISSING_HAS_RUN])
164 if test -z "$install_sh"; then
165    install_sh="$ac_aux_dir/install-sh"
166    test -f "$install_sh" || install_sh="$ac_aux_dir/install.sh"
167    test -f "$install_sh" || install_sh="${am_missing_run}${ac_auxdir}/install-sh"
168    dnl FIXME: an evil hack: we remove the SHELL invocation from
169    dnl install_sh because automake adds it back in.  Sigh.
170    install_sh="`echo $install_sh | sed -e 's/\${SHELL}//'`"
172 AC_SUBST(install_sh)])
174 # AM_MISSING_HAS_RUN.
175 # Define MISSING if not defined so far and test if it supports --run.
176 # If it does, set am_missing_run to use it, otherwise, to nothing.
177 AC_DEFUN([AM_MISSING_HAS_RUN], [
178 test x"${MISSING+set}" = xset || \
179   MISSING="\${SHELL} `CDPATH=:; cd $ac_aux_dir && pwd`/missing"
180 # Use eval to expand $SHELL
181 if eval "$MISSING --run :"; then
182   am_missing_run="$MISSING --run "
183 else
184   am_missing_run=
185   am_backtick='`'
186   AC_MSG_WARN([${am_backtick}missing' script is too old or missing])
190 # See how the compiler implements dependency checking.
191 # Usage:
192 # AM_DEPENDENCIES(NAME)
193 # NAME is "CC", "CXX" or "OBJC".
195 # We try a few techniques and use that to set a single cache variable.
197 AC_DEFUN([AM_DEPENDENCIES],[
198 AC_REQUIRE([AM_SET_DEPDIR])
199 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])
200 ifelse([$1],CC,[
201 AC_REQUIRE([AC_PROG_CC])
202 AC_REQUIRE([AC_PROG_CPP])
203 depcc="$CC"
204 depcpp="$CPP"],[$1],CXX,[
205 AC_REQUIRE([AC_PROG_CXX])
206 AC_REQUIRE([AC_PROG_CXXCPP])
207 depcc="$CXX"
208 depcpp="$CXXCPP"],[$1],OBJC,[
209 am_cv_OBJC_dependencies_compiler_type=gcc],[
210 AC_REQUIRE([AC_PROG_][$1])
211 depcc="$[$1]"
212 depcpp=""])
213 AC_MSG_CHECKING([dependency style of $depcc])
214 AC_CACHE_VAL(am_cv_[$1]_dependencies_compiler_type,[
215 if test -z "$AMDEP"; then
216   echo '#include "conftest.h"' > conftest.c
217   echo 'int i;' > conftest.h
219   am_cv_[$1]_dependencies_compiler_type=none
220   for depmode in `sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < "$am_depcomp"`; do
221     case "$depmode" in
222     nosideeffect)
223       # after this tag, mechanisms are not by side-effect, so they'll
224       # only be used when explicitly requested
225       if test "x$enable_dependency_tracking" = xyes; then
226         continue
227       else
228         break
229       fi
230       ;;
231     none) break ;;
232     esac
233     # We check with `-c' and `-o' for the sake of the "dashmstdout"
234     # mode.  It turns out that the SunPro C++ compiler does not properly
235     # handle `-M -o', and we need to detect this.
236     if depmode="$depmode" \
237        source=conftest.c object=conftest.o \
238        depfile=conftest.Po tmpdepfile=conftest.TPo \
239        $SHELL $am_depcomp $depcc -c conftest.c -o conftest.o 2>/dev/null &&
240        grep conftest.h conftest.Po > /dev/null 2>&1; then
241       am_cv_[$1]_dependencies_compiler_type="$depmode"
242       break
243     fi
244   done
246   rm -f conftest.*
247 else
248   am_cv_[$1]_dependencies_compiler_type=none
251 AC_MSG_RESULT($am_cv_[$1]_dependencies_compiler_type)
252 [$1]DEPMODE="depmode=$am_cv_[$1]_dependencies_compiler_type"
253 AC_SUBST([$1]DEPMODE)
256 # Choose a directory name for dependency files.
257 # This macro is AC_REQUIREd in AM_DEPENDENCIES
259 AC_DEFUN([AM_SET_DEPDIR],[
260 if test -d .deps || mkdir .deps 2> /dev/null || test -d .deps; then
261   DEPDIR=.deps
262 else
263   DEPDIR=_deps
265 AC_SUBST(DEPDIR)
268 AC_DEFUN([AM_DEP_TRACK],[
269 AC_ARG_ENABLE(dependency-tracking,
270 [  --disable-dependency-tracking Speeds up one-time builds
271   --enable-dependency-tracking  Do not reject slow dependency extractors])
272 if test "x$enable_dependency_tracking" = xno; then
273   AMDEP="#"
274 else
275   am_depcomp="$ac_aux_dir/depcomp"
276   if test ! -f "$am_depcomp"; then
277     AMDEP="#"
278   else
279     AMDEP=
280   fi
282 AC_SUBST(AMDEP)
283 if test -z "$AMDEP"; then
284   AMDEPBACKSLASH='\'
285 else
286   AMDEPBACKSLASH=
288 pushdef([subst], defn([AC_SUBST]))
289 subst(AMDEPBACKSLASH)
290 popdef([subst])
293 # Generate code to set up dependency tracking.
294 # This macro should only be invoked once -- use via AC_REQUIRE.
295 # Usage:
296 # AM_OUTPUT_DEPENDENCY_COMMANDS
299 # This code is only required when automatic dependency tracking
300 # is enabled.  FIXME.  This creates each `.P' file that we will
301 # need in order to bootstrap the dependency handling code.
302 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[
303 AC_OUTPUT_COMMANDS([
304 test x"$AMDEP" != x"" ||
305 for mf in $CONFIG_FILES; do
306   case "$mf" in
307   Makefile) dirpart=.;;
308   */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;;
309   *) continue;;
310   esac
311   grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
312   # Extract the definition of DEP_FILES from the Makefile without
313   # running `make'.
314   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
315   test -z "$DEPDIR" && continue
316   # When using ansi2knr, U may be empty or an underscore; expand it
317   U=`sed -n -e '/^U = / s///p' < "$mf"`
318   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
319   # We invoke sed twice because it is the simplest approach to
320   # changing $(DEPDIR) to its actual value in the expansion.
321   for file in `sed -n -e '
322     /^DEP_FILES = .*\\\\$/ {
323       s/^DEP_FILES = //
324       :loop
325         s/\\\\$//
326         p
327         n
328         /\\\\$/ b loop
329       p
330     }
331     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
332        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
333     # Make sure the directory exists.
334     test -f "$dirpart/$file" && continue
335     fdir=`echo "$file" | sed -e 's|/[^/]*$||'`
336     $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1
337     # echo "creating $dirpart/$file"
338     echo '# dummy' > "$dirpart/$file"
339   done
340 done
341 ], [AMDEP="$AMDEP"
342 ac_aux_dir="$ac_aux_dir"])])
344 #serial 1
345 dnl This test replaces the one in autoconf.
346 dnl Currently this macro should have the same name as the autoconf macro
347 dnl because gettext's gettext.m4 (distributed in the automake package)
348 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
349 dnl give these diagnostics:
350 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
351 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
353 undefine([AC_ISC_POSIX])
354 AC_DEFUN(AC_ISC_POSIX,
355   [
356     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
357     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
358   ]
362 # serial 1
364 AC_DEFUN([AM_C_PROTOTYPES],
365 [AC_REQUIRE([AM_PROG_CC_STDC])
366 AC_REQUIRE([AC_PROG_CPP])
367 AC_MSG_CHECKING([for function prototypes])
368 if test "$am_cv_prog_cc_stdc" != no; then
369   AC_MSG_RESULT(yes)
370   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
371   U= ANSI2KNR=
372 else
373   AC_MSG_RESULT(no)
374   U=_ ANSI2KNR=./ansi2knr
375   # Ensure some checks needed by ansi2knr itself.
376   AC_HEADER_STDC
377   AC_CHECK_HEADERS(string.h)
379 AC_SUBST(U)dnl
380 AC_SUBST(ANSI2KNR)dnl
384 # serial 1
386 # @defmac AC_PROG_CC_STDC
387 # @maindex PROG_CC_STDC
388 # @ovindex CC
389 # If the C compiler in not in ANSI C mode by default, try to add an option
390 # to output variable @code{CC} to make it so.  This macro tries various
391 # options that select ANSI C on some system or another.  It considers the
392 # compiler to be in ANSI C mode if it handles function prototypes correctly.
394 # If you use this macro, you should check after calling it whether the C
395 # compiler has been set to accept ANSI C; if not, the shell variable
396 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
397 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
398 # program @code{ansi2knr}, which comes with Ghostscript.
399 # @end defmac
401 AC_DEFUN([AM_PROG_CC_STDC],
402 [AC_REQUIRE([AC_PROG_CC])
403 AC_BEFORE([$0], [AC_C_INLINE])
404 AC_BEFORE([$0], [AC_C_CONST])
405 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
406 dnl a magic option to avoid problems with ANSI preprocessor commands
407 dnl like #elif.
408 dnl FIXME: can't do this because then AC_AIX won't work due to a
409 dnl circular dependency.
410 dnl AC_BEFORE([$0], [AC_PROG_CPP])
411 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
412 AC_CACHE_VAL(am_cv_prog_cc_stdc,
413 [am_cv_prog_cc_stdc=no
414 ac_save_CC="$CC"
415 # Don't try gcc -ansi; that turns off useful extensions and
416 # breaks some systems' header files.
417 # AIX                   -qlanglvl=ansi
418 # Ultrix and OSF/1      -std1
419 # HP-UX 10.20 and later -Ae
420 # HP-UX older versions  -Aa -D_HPUX_SOURCE
421 # SVR4                  -Xc -D__EXTENSIONS__
422 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
424   CC="$ac_save_CC $ac_arg"
425   AC_TRY_COMPILE(
426 [#include <stdarg.h>
427 #include <stdio.h>
428 #include <sys/types.h>
429 #include <sys/stat.h>
430 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
431 struct buf { int x; };
432 FILE * (*rcsopen) (struct buf *, struct stat *, int);
433 static char *e (p, i)
434      char **p;
435      int i;
437   return p[i];
439 static char *f (char * (*g) (char **, int), char **p, ...)
441   char *s;
442   va_list v;
443   va_start (v,p);
444   s = g (p, va_arg (v,int));
445   va_end (v);
446   return s;
448 int test (int i, double x);
449 struct s1 {int (*f) (int a);};
450 struct s2 {int (*f) (double a);};
451 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
452 int argc;
453 char **argv;
454 ], [
455 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
457 [am_cv_prog_cc_stdc="$ac_arg"; break])
458 done
459 CC="$ac_save_CC"
461 if test -z "$am_cv_prog_cc_stdc"; then
462   AC_MSG_RESULT([none needed])
463 else
464   AC_MSG_RESULT($am_cv_prog_cc_stdc)
466 case "x$am_cv_prog_cc_stdc" in
467   x|xno) ;;
468   *) CC="$CC $am_cv_prog_cc_stdc" ;;
469 esac
472 #serial 8
474 dnl By default, many hosts won't let programs access large files;
475 dnl one must use special compiler options to get large-file access to work.
476 dnl For more details about this brain damage please see:
477 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
479 dnl Written by Paul Eggert <eggert@twinsun.com>.
481 dnl Internal subroutine of AC_SYS_LARGEFILE.
482 dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
483 AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
484   [AC_CACHE_CHECK([for $1 value to request large file support],
485      ac_cv_sys_largefile_$1,
486      [if ($GETCONF LFS_$1) >conftest.1 2>conftest.2 && test ! -s conftest.2
487       then
488         ac_cv_sys_largefile_$1=`cat conftest.1`
489       else
490         ac_cv_sys_largefile_$1=no
491         ifelse($1, CFLAGS,
492           [case "$host_os" in
493            # HP-UX 10.20 requires -D__STDC_EXT__ with gcc 2.95.1.
494 [          hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
495              if test "$GCC" = yes; then
496                ac_cv_sys_largefile_CFLAGS=-D__STDC_EXT__
497              fi
498              ;;
499            # IRIX 6.2 and later require cc -n32.
500 [          irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)]
501              if test "$GCC" != yes; then
502                ac_cv_sys_largefile_CFLAGS=-n32
503              fi
504            esac
505            if test "$ac_cv_sys_largefile_CFLAGS" != no; then
506              ac_save_CC="$CC"
507              CC="$CC $ac_cv_sys_largefile_CFLAGS"
508              AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
509              CC="$ac_save_CC"
510            fi])
511       fi
512       rm -f conftest*])])
514 dnl Internal subroutine of AC_SYS_LARGEFILE.
515 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
516 AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
517   [case $2 in
518    no) ;;
519    ?*)
520      case "[$]$1" in
521      '') $1=$2 ;;
522      *) $1=[$]$1' '$2 ;;
523      esac ;;
524    esac])
526 dnl Internal subroutine of AC_SYS_LARGEFILE.
527 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
528 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
529   [AC_CACHE_CHECK([for $1], $2,
530      [$2=no
531       $4
532       for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
533         case "$ac_flag" in
534         -D$1)
535           $2=1 ;;
536         -D$1=*)
537           $2=`expr " $ac_flag" : '[[^=]]*=\(.*\)'` ;;
538         esac
539       done
540       ])
541    if test "[$]$2" != no; then
542      AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
543    fi])
545 AC_DEFUN(AC_SYS_LARGEFILE,
546   [AC_REQUIRE([AC_CANONICAL_HOST])
547    AC_ARG_ENABLE(largefile,
548      [  --disable-largefile     omit support for large files])
549    if test "$enable_largefile" != no; then
550      AC_CHECK_TOOL(GETCONF, getconf)
551      AC_SYS_LARGEFILE_FLAGS(CFLAGS)
552      AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
553      AC_SYS_LARGEFILE_FLAGS(LIBS)
555      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
556        case "$ac_flag" in
557        no) ;;
558        -D_FILE_OFFSET_BITS=*) ;;
559        -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
560        -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
561        -D?* | -I?*)
562          AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
563        *)
564          AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
565        esac
566      done
567      AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
568      AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
569      AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
570        ac_cv_sys_file_offset_bits,
571        [Number of bits in a file offset, on hosts where this is settable.],
572        [case "$host_os" in
573         # HP-UX 10.20 and later
574 [       hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
575           ac_cv_sys_file_offset_bits=64 ;;
576         esac])
577      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
578        ac_cv_sys_largefile_source,
579        [Define to make fseeko etc. visible, on some hosts.],
580        [case "$host_os" in
581         # HP-UX 10.20 and later
582 [       hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
583           ac_cv_sys_largefile_source=1 ;;
584         esac])
585      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
586        ac_cv_sys_large_files,
587        [Define for large files, on AIX-style hosts.],
588        [case "$host_os" in
589         # AIX 4.2 and later
590 [       aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)]
591           ac_cv_sys_large_files=1 ;;
592         esac])
593    fi
594   ])
596 #serial 13, with several lines deleted for fileutils.
598 dnl Misc type-related macros for fileutils, sh-utils, textutils.
600 AC_DEFUN(jm_MACROS,
602   AC_PREREQ(2.14a)
604   GNU_PACKAGE="GNU $PACKAGE"
605   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
606     [The concatenation of the strings `GNU ', and PACKAGE.])
607   AC_SUBST(GNU_PACKAGE)
609   AC_SUBST(OPTIONAL_BIN_PROGS)
610   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
611   AC_SUBST(MAN)
612   AC_SUBST(DF_PROG)
614   dnl This macro actually runs replacement code.  See isc-posix.m4.
615   AC_REQUIRE([AC_ISC_POSIX])dnl
617   AC_CHECK_HEADERS( \
618     errno.h  \
619     fcntl.h \
620     fenv.h \
621     float.h \
622     limits.h \
623     memory.h \
624     mntent.h \
625     mnttab.h \
626     netdb.h \
627     paths.h \
628     stdlib.h \
629     stddef.h \
630     string.h \
631     sys/acl.h \
632     sys/filsys.h \
633     sys/fs/s5param.h \
634     sys/fs_types.h \
635     sys/fstyp.h \
636     sys/ioctl.h \
637     sys/mntent.h \
638     sys/mount.h \
639     sys/param.h \
640     sys/socket.h \
641     sys/statfs.h \
642     sys/statvfs.h \
643     sys/systeminfo.h \
644     sys/time.h \
645     sys/timeb.h \
646     sys/vfs.h \
647     sys/wait.h \
648     syslog.h \
649     termios.h \
650     unistd.h \
651     values.h \
652   )
654   jm_INCLUDED_REGEX([lib/regex.c])
656   AC_REQUIRE([jm_ASSERT])
657   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
658   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
659   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
660   AC_REQUIRE([jm_CHECK_DECLS])
662   AC_REQUIRE([jm_PREREQ])
664   AC_REQUIRE([jm_FUNC_MKTIME])
665   AC_REQUIRE([jm_FUNC_LSTAT])
666   AC_REQUIRE([jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
667   AC_REQUIRE([jm_FUNC_STAT])
668   AC_REQUIRE([jm_FUNC_REALLOC])
669   AC_REQUIRE([jm_FUNC_MALLOC])
670   AC_REQUIRE([jm_FUNC_STRERROR_R])
671   AC_REQUIRE([jm_FUNC_READDIR])
672   AC_REQUIRE([jm_FUNC_MEMCMP])
673   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
674   AC_REQUIRE([kd_FUNC_FNMATCH_CASE_RPL])
675   AC_REQUIRE([jm_AFS])
676   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
677   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
678   AC_REQUIRE([AM_FUNC_ERROR_AT_LINE])
679   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
680   AC_REQUIRE([jm_FUNC_MKTIME])
682   AC_REQUIRE([AC_FUNC_VPRINTF])
683   AC_REQUIRE([AC_FUNC_ALLOCA])
685   AC_REPLACE_FUNCS(strncasecmp)
686   AC_REPLACE_FUNCS(stpcpy strstr strtol strtoul)
687   AC_REPLACE_FUNCS(memcmp rpmatch)
689   dnl used by e.g. intl/*domain.c and lib/canon-host.c
690   AC_REPLACE_FUNCS(strdup)
692   AC_REPLACE_FUNCS(memcpy memset)
693   AC_CHECK_FUNCS(getpagesize)
695   # By default, argmatch should fail calling usage (1).
696   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
697             [Define to the function xargmatch calls on failures.])
698   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
699             [Define to the declaration of the xargmatch failure function.])
701   dnl Used to define SETVBUF in sys2.h.
702   dnl This evokes the following warning from autoconf:
703   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
704   AC_FUNC_SETVBUF_REVERSED
706   # used by sleep and shred
707   # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
708   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
709   AC_SEARCH_LIBS(clock_gettime, [rt posix4])
710   AC_CHECK_FUNCS(clock_gettime)
711   AC_CHECK_FUNCS(gettimeofday)
713   AC_CHECK_FUNCS(getdelim)
715   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
717   AC_CHECK_FUNCS( \
718     acl \
719     bcopy \
720     endgrent \
721     endpwent \
722     fchdir \
723     fdatasync \
724     fseeko \
725     ftime \
726     ftruncate \
727     getcwd \
728     gethrtime \
729     getmntinfo \
730     hasmntopt \
731     isascii \
732     listmntent \
733     localeconv \
734     memcpy \
735     mempcpy \
736     mkfifo \
737     realpath \
738     resolvepath \
739     sethostname \
740     strchr \
741     strerror \
742     strrchr \
743     sysinfo \
744     tzset \
745   )
747   AM_FUNC_GETLINE
748   if test $am_cv_func_working_getline != yes; then
749     AC_CHECK_FUNCS(getdelim)
750   fi
752   # These tests are for df.
753   jm_FSTYPENAME
757 AC_DEFUN(jm_CHECK_ALL_TYPES,
759   dnl Checks for typedefs, structures, and compiler characteristics.
760   AC_REQUIRE([AC_C_BIGENDIAN])
761   AC_REQUIRE([AC_PROG_CC_STDC])
762   AC_REQUIRE([AC_C_CONST])
763   AC_REQUIRE([AC_C_VOLATILE])
764   AC_REQUIRE([AC_C_INLINE])
765   AC_REQUIRE([AC_C_LONG_DOUBLE])
767   AC_REQUIRE([AC_HEADER_DIRENT])
768   AC_REQUIRE([AC_HEADER_STDC])
769   AC_CHECK_MEMBERS((struct stat.st_blksize),,,[$ac_includes_default
770 #include <sys/stat.h>
771   ])
772   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
774   AC_REQUIRE([AC_STRUCT_TM])
775   AC_REQUIRE([AC_STRUCT_TIMEZONE])
776   AC_REQUIRE([AC_HEADER_STAT])
777   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
778   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
779   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
781   AC_REQUIRE([AC_TYPE_GETGROUPS])
782   AC_REQUIRE([AC_TYPE_MODE_T])
783   AC_REQUIRE([AC_TYPE_OFF_T])
784   AC_REQUIRE([AC_TYPE_PID_T])
785   AC_REQUIRE([AC_TYPE_SIGNAL])
786   AC_REQUIRE([AC_TYPE_SIZE_T])
787   AC_REQUIRE([AC_TYPE_UID_T])
788   AC_CHECK_TYPE(ino_t, unsigned long)
790   dnl This relies on the fact that autoconf 2.14a's implementation of
791   dnl AC_CHECK_TYPE checks includes unistd.h.
792   AC_CHECK_TYPE(ssize_t, int)
794   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
795   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
797   AC_REQUIRE([AC_HEADER_MAJOR])
798   AC_REQUIRE([AC_HEADER_DIRENT])
802 #serial 7
804 dnl Initially derived from code in GNU grep.
805 dnl Mostly written by Jim Meyering.
807 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
809 AC_DEFUN(jm_INCLUDED_REGEX,
810   [
811     dnl Even packages that don't use regex.c can use this macro.
812     dnl Of course, for them it doesn't do anything.
814     # Assume we'll default to using the included regex.c.
815     ac_use_included_regex=yes
817     # However, if the system regex support is good enough that it passes the
818     # the following run test, then default to *not* using the included regex.c.
819     # If cross compiling, assume the test would fail and use the included
820     # regex.c.  The first failing regular expression is from `Spencer ere
821     # test #75' in grep-2.3.
822     AC_CACHE_CHECK([for working re_compile_pattern],
823                    jm_cv_func_working_re_compile_pattern,
824       AC_TRY_RUN(
825 [#include <stdio.h>
826 #include <regex.h>
827           int
828           main ()
829           {
830             static struct re_pattern_buffer regex;
831             const char *s;
832             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
833             /* Add this third left square bracket, [, to balance the
834                three right ones below.  Otherwise autoconf-2.14 chokes.  */
835             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
836             /* This should fail with _Invalid character class name_ error.  */
837             if (!s)
838               exit (1);
840             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
841             s = re_compile_pattern ("{1", 2, &regex);
843             exit (s ? 1 : 0);
844           }
845         ],
846                jm_cv_func_working_re_compile_pattern=yes,
847                jm_cv_func_working_re_compile_pattern=no,
848                dnl When crosscompiling, assume it's broken.
849                jm_cv_func_working_re_compile_pattern=no))
850     if test $jm_cv_func_working_re_compile_pattern = yes; then
851       ac_use_included_regex=no
852     fi
854     test -n "$1" || AC_MSG_ERROR([missing argument])
855     syscmd([test -f $1])
856     ifelse(sysval, 0,
857       [
859         AC_ARG_WITH(included-regex,
860         [  --without-included-regex don't compile regex; this is the default on
861                           systems with version 2 of the GNU C library
862                           (use with caution on other system)],
863                     jm_with_regex=$withval,
864                     jm_with_regex=$ac_use_included_regex)
865         if test "$jm_with_regex" = yes; then
866           AC_SUBST(LIBOBJS)
867           LIBOBJS="$LIBOBJS regex.$ac_objext"
868         fi
869       ],
870     )
871   ]
874 #serial 2
875 dnl based on code from Eleftherios Gkioulekas
877 AC_DEFUN(jm_ASSERT,
879   AC_MSG_CHECKING(whether to enable assertions)
880   AC_ARG_ENABLE(assert,
881         [  --disable-assert        turn off assertions],
882         [ AC_MSG_RESULT(no)
883           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
884         [ AC_MSG_RESULT(yes) ]
885                )
888 #serial 3
890 dnl From Paul Eggert.
892 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
893 # doesn't clash with <sys/types.h>, and declares uintmax_t.
895 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
897   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
898   [AC_TRY_COMPILE(
899     [#include <sys/types.h>
900 #include <inttypes.h>],
901     [uintmax_t i = (uintmax_t) -1;],
902     jm_ac_cv_header_inttypes_h=yes,
903     jm_ac_cv_header_inttypes_h=no)])
904   if test $jm_ac_cv_header_inttypes_h = yes; then
905     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
906 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
907    and declares uintmax_t. ])
908   fi
911 #serial 3
913 dnl From Jim Meyering.
915 dnl Check whether struct dirent has a member named d_type.
918 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
919   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
920    AC_CACHE_CHECK([for d_type member in directory struct],
921                   jm_cv_struct_dirent_d_type,
922      [AC_TRY_LINK(dnl
923        [
924 #include <sys/types.h>
925 #ifdef HAVE_DIRENT_H
926 # include <dirent.h>
927 #else /* not HAVE_DIRENT_H */
928 # define dirent direct
929 # ifdef HAVE_SYS_NDIR_H
930 #  include <sys/ndir.h>
931 # endif /* HAVE_SYS_NDIR_H */
932 # ifdef HAVE_SYS_DIR_H
933 #  include <sys/dir.h>
934 # endif /* HAVE_SYS_DIR_H */
935 # ifdef HAVE_NDIR_H
936 #  include <ndir.h>
937 # endif /* HAVE_NDIR_H */
938 #endif /* HAVE_DIRENT_H */
939        ],
940        [struct dirent dp; dp.d_type = 0;],
942        jm_cv_struct_dirent_d_type=yes,
943        jm_cv_struct_dirent_d_type=no)
944      ]
945    )
946    if test $jm_cv_struct_dirent_d_type = yes; then
947      AC_DEFINE(D_TYPE_IN_DIRENT, 1,
948   [Define if there is a member named d_type in the struct describing
949    directory headers.])
950    fi
951   ]
954 #serial 3
956 dnl From Jim Meyering.
958 dnl Check whether struct dirent has a member named d_ino.
961 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
962   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
963    AC_CACHE_CHECK([for d_ino member in directory struct],
964                   jm_cv_struct_dirent_d_ino,
965      [AC_TRY_LINK(dnl
966        [
967 #include <sys/types.h>
968 #ifdef HAVE_DIRENT_H
969 # include <dirent.h>
970 #else /* not HAVE_DIRENT_H */
971 # define dirent direct
972 # ifdef HAVE_SYS_NDIR_H
973 #  include <sys/ndir.h>
974 # endif /* HAVE_SYS_NDIR_H */
975 # ifdef HAVE_SYS_DIR_H
976 #  include <sys/dir.h>
977 # endif /* HAVE_SYS_DIR_H */
978 # ifdef HAVE_NDIR_H
979 #  include <ndir.h>
980 # endif /* HAVE_NDIR_H */
981 #endif /* HAVE_DIRENT_H */
982        ],
983        [struct dirent dp; dp.d_ino = 0;],
985        jm_cv_struct_dirent_d_ino=yes,
986        jm_cv_struct_dirent_d_ino=no)
987      ]
988    )
989    if test $jm_cv_struct_dirent_d_ino = yes; then
990      AC_DEFINE(D_INO_IN_DIRENT, 1,
991   [Define if there is a member named d_ino in the struct describing
992    directory headers.])
993    fi
994   ]
997 #serial 9, except remove memchr and nanosleep as findutils doesn't need them
999 dnl This is just a wrapper function to encapsulate this kludge.
1000 dnl Putting it in a separate file like this helps share it between
1001 dnl different packages.
1002 AC_DEFUN(jm_CHECK_DECLS,
1004   AC_REQUIRE([_jm_DECL_HEADERS])
1005   AC_REQUIRE([AC_HEADER_TIME])
1006   headers='
1007 #include <stdio.h>
1008 #if HAVE_STRING_H
1009 # if !STDC_HEADERS && HAVE_MEMORY_H
1010 #  include <memory.h>
1011 # endif
1012 # include <string.h>
1013 #else
1014 # if HAVE_STRINGS_H
1015 #  include <strings.h>
1016 # endif
1017 #endif
1018 #if HAVE_STDLIB_H
1019 # include <stdlib.h>
1020 #endif
1021 #if HAVE_UNISTD_H
1022 # include <unistd.h>
1023 #endif
1025 #include <sys/types.h>
1026 #if TIME_WITH_SYS_TIME
1027 # include <sys/time.h>
1028 # include <time.h>
1029 #else
1030 # if HAVE_SYS_TIME_H
1031 #  include <sys/time.h>
1032 # else
1033 #  include <time.h>
1034 # endif
1035 #endif
1038   AC_CHECK_DECLS((
1039     free,
1040     getenv,
1041     geteuid,
1042     getlogin,
1043     lseek,
1044     malloc,
1045     realloc,
1046     stpcpy,
1047     strstr,
1048     strtoul,
1049     strtoull,
1050     ttyname), , , $headers)
1053 dnl FIXME: when autoconf has support for it.
1054 dnl This is a little helper so we can require these header checks.
1055 AC_DEFUN(_jm_DECL_HEADERS,
1057   AC_REQUIRE([AC_HEADER_STDC])
1058   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h)
1061 #serial 5
1063 dnl These are the prerequisite macros for files in the lib/
1064 dnl directories of the fileutils, sh-utils, and textutils packages.
1066 AC_DEFUN(jm_PREREQ,
1068   jm_PREREQ_ADDEXT
1069   jm_PREREQ_CANON_HOST
1070   jm_PREREQ_ERROR
1071   jm_PREREQ_QUOTEARG
1072   jm_PREREQ_READUTMP
1073   jm_PREREQ_REGEX
1076 AC_DEFUN(jm_PREREQ_ADDEXT,
1078   dnl For addext.c.
1079   AC_SYS_LONG_FILE_NAMES
1080   AC_CHECK_FUNCS(pathconf)
1081   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1084 AC_DEFUN(jm_PREREQ_CANON_HOST,
1086   dnl Add any libraries as early as possible.
1087   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1088   dnl so we have to add -lnsl to LIBS before checking for that function.
1089   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1091   dnl These come from -lnsl on Solaris5.5.1.
1092   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1094   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1095   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1096                    netinet/in.h arpa/inet.h)
1099 AC_DEFUN(jm_PREREQ_QUOTEARG,
1101   AC_CHECK_FUNCS(isascii iswprint mbrtowc)
1102   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
1103   AC_HEADER_STDC
1104   AC_C_BACKSLASH_A
1105   AC_MBSTATE_T_OBJECT
1106   AM_C_PROTOTYPES
1109 AC_DEFUN(jm_PREREQ_READUTMP,
1111   AC_HEADER_STDC
1112   AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
1113   AC_CHECK_FUNCS(utmpname)
1114   AC_CHECK_FUNCS(utmpxname)
1115   AM_C_PROTOTYPES
1117   utmp_includes="\
1118 $ac_includes_default
1119 #ifdef HAVE_UTMPX_H
1120 # include <utmpx.h>
1121 #else
1122 # include <utmp.h>
1123 #endif
1125   AC_CHECK_MEMBERS((struct utmpx.ut_user),,,[$utmp_includes])
1126   AC_CHECK_MEMBERS((struct utmp.ut_user),,,[$utmp_includes])
1127   AC_CHECK_MEMBERS((struct utmpx.ut_name),,,[$utmp_includes])
1128   AC_CHECK_MEMBERS((struct utmp.ut_name),,,[$utmp_includes])
1131 AC_DEFUN(jm_PREREQ_REGEX,
1133   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1134   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1135   dnl to get them.
1136   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
1137   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
1138   AC_HEADER_STDC
1139   AC_FUNC_ALLOCA
1142 #serial 1
1144 dnl FIXME: put these prerequisite-only *.m4 files in a separate
1145 dnl directory -- otherwise, they'll conflict with existing files.
1147 dnl These are the prerequisite macros for GNU's error.c file.
1148 AC_DEFUN(jm_PREREQ_ERROR,
1150   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
1151   AC_HEADER_STDC
1154 #serial 3
1156 dnl From Paul Eggert.
1158 AC_DEFUN(AC_C_BACKSLASH_A,
1160   AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1161    [AC_TRY_COMPILE([],
1162      [
1163 #if '\a' == 'a'
1164       syntax error;
1165 #endif
1166       char buf['\a' == 'a' ? -1 : 1];
1167       buf[0] = '\a';
1168       return buf[0] != "\a"[0];
1169      ],
1170      ac_cv_c_backslash_a=yes,
1171      ac_cv_c_backslash_a=no)])
1172   if test $ac_cv_c_backslash_a = yes; then
1173     AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1174       [Define if backslash-a works in C strings.])
1175   fi
1178 # serial 1
1180 # From Paul Eggert.
1182 # Some versions of BeOS define mbstate_t to be an incomplete type,
1183 # so you can't declare an object of that type.
1184 # Check for this incompatibility with Standard C.
1186 AC_DEFUN(AC_MBSTATE_T_OBJECT,
1187   [AC_CACHE_CHECK([for mbstate_t object type], ac_cv_type_mbstate_t_object,
1188     [AC_TRY_COMPILE([#include <wchar.h>],
1189       [mbstate_t x; return sizeof x;],
1190       ac_cv_type_mbstate_t_object=yes,
1191       ac_cv_type_mbstate_t_object=no)])
1192    if test $ac_cv_type_mbstate_t_object = yes; then
1193      AC_DEFINE(HAVE_MBSTATE_T_OBJECT, 1,
1194                [Define if mbstate_t is an object type.])
1195    fi])
1197 #serial 7
1199 dnl From Jim Meyering.
1200 dnl A wrapper around AC_FUNC_MKTIME.
1202 AC_DEFUN(jm_FUNC_MKTIME,
1203 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
1205  dnl mktime.c uses localtime_r if it exists.  Check for it.
1206  AC_CHECK_FUNCS(localtime_r)
1208  if test $ac_cv_func_working_mktime = no; then
1209    AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
1210     [Define to rpl_mktime if the replacement function should be used.])
1211  fi
1214 #serial 3
1216 dnl From Jim Meyering.
1217 dnl Determine whether lstat has the bug that it succeeds when given the
1218 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
1219 dnl (as of 1998-11-01) do this.
1221 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
1222 dnl compile the wrapper function.
1225 AC_DEFUN(jm_FUNC_LSTAT,
1227  AC_CACHE_CHECK([whether lstat accepts an empty string],
1228   jm_cv_func_lstat_empty_string_bug,
1229   [AC_TRY_RUN([
1230 #   include <sys/types.h>
1231 #   include <sys/stat.h>
1233     int
1234     main ()
1235     {
1236       struct stat sbuf;
1237       exit (lstat ("", &sbuf) ? 1 : 0);
1238     }
1239           ],
1240          jm_cv_func_lstat_empty_string_bug=yes,
1241          jm_cv_func_lstat_empty_string_bug=no,
1242          dnl When crosscompiling, assume lstat is broken.
1243          jm_cv_func_lstat_empty_string_bug=yes)
1244   ])
1245   if test $jm_cv_func_lstat_empty_string_bug = yes; then
1246     AC_SUBST(LIBOBJS)
1247     LIBOBJS="$LIBOBJS lstat.$ac_objext"
1248     AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
1249 [Define if lstat has the bug that it succeeds when given the zero-length
1250    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1251    do this. ])
1252   fi
1255 #serial 1
1257 dnl From Jim Meyering.
1258 dnl FIXME: describe
1260 AC_DEFUN(jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK,
1262  AC_CACHE_CHECK(
1263   [whether lstat dereferences a symlink specified with a trailing slash],
1264   jm_cv_func_lstat_dereferences_slashed_symlink,
1265   [
1266    rm -f conftest.sym conftest.file
1267    : > conftest.file
1268    if ln -s conftest.file conftest.sym; then
1269      AC_TRY_RUN([
1270 #     include <sys/types.h>
1271 #     include <sys/stat.h>
1273       int
1274       main ()
1275       {
1276         struct stat sbuf;
1277         /* Linux will dereference the symlink and fail.
1278            That is better in the sense that it means we will not
1279            have to compile and use the lstat wrapper.  */
1280         exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
1281       }
1282       ],
1283       jm_cv_func_lstat_dereferences_slashed_symlink=yes,
1284       jm_cv_func_lstat_dereferences_slashed_symlink=no,
1285       dnl When crosscompiling, be pessimistic so we will end up using the
1286       dnl replacement version of lstat that checkes for trailing slashes
1287       dnl and calls lstat a second time when necessary.
1288       jm_cv_func_lstat_dereferences_slashed_symlink=no
1289      )
1290    else
1291      # If the `ln -s' command failed, then we probably don't even
1292      # have an lstat function.
1293      jm_cv_func_lstat_dereferences_slashed_symlink=no
1294    fi
1295   ])
1297   test $jm_cv_func_lstat_dereferences_slashed_symlink = yes \
1298     && zero_one=1 \
1299     || zero_one=0
1300   AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, $zero_one,
1301     [Define if lstat dereferences a symlink specified with a trailing slash])
1303   if test $jm_cv_func_lstat_dereferences_slashed_symlink = no; then
1304     AC_SUBST(LIBOBJS)
1305     # Append lstat.o if it's not already in $LIBOBJS.
1306     case "$LIBOBJS" in
1307       *lstat.$ac_objext*) ;;
1308       *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
1309     esac
1310   fi
1313 #serial 3
1315 dnl From Jim Meyering.
1316 dnl Determine whether stat has the bug that it succeeds when given the
1317 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
1318 dnl (as of 1998-11-01) do this.
1320 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
1321 dnl compile the wrapper function.
1324 AC_DEFUN(jm_FUNC_STAT,
1326  AC_CACHE_CHECK([whether stat accepts an empty string],
1327   jm_cv_func_stat_empty_string_bug,
1328   [AC_TRY_RUN([
1329 #   include <sys/types.h>
1330 #   include <sys/stat.h>
1332     int
1333     main ()
1334     {
1335       struct stat sbuf;
1336       exit (stat ("", &sbuf) ? 1 : 0);
1337     }
1338           ],
1339          jm_cv_func_stat_empty_string_bug=yes,
1340          jm_cv_func_stat_empty_string_bug=no,
1341          dnl When crosscompiling, assume stat is broken.
1342          jm_cv_func_stat_empty_string_bug=yes)
1343   ])
1344   if test $jm_cv_func_stat_empty_string_bug = yes; then
1345     AC_SUBST(LIBOBJS)
1346     LIBOBJS="$LIBOBJS stat.$ac_objext"
1347     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
1348 [Define if stat has the bug that it succeeds when given the zero-length
1349    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1350    do this. ])
1351   fi
1354 #serial 3
1356 dnl From Jim Meyering.
1357 dnl Determine whether realloc works when both arguments are 0.
1358 dnl If it doesn't, arrange to use the replacement function.
1361 AC_DEFUN(jm_FUNC_REALLOC,
1363  dnl xmalloc.c requires that this symbol be defined so it doesn't
1364  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
1365  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
1366                     [Define if the realloc check has been performed. ])
1368  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
1369   [AC_TRY_RUN([
1370     char *realloc ();
1371     int
1372     main ()
1373     {
1374       exit (realloc (0, 0) ? 0 : 1);
1375     }
1376           ],
1377          jm_cv_func_working_realloc=yes,
1378          jm_cv_func_working_realloc=no,
1379          dnl When crosscompiling, assume realloc is broken.
1380          jm_cv_func_working_realloc=no)
1381   ])
1382   if test $jm_cv_func_working_realloc = no; then
1383     AC_SUBST(LIBOBJS)
1384     LIBOBJS="$LIBOBJS realloc.$ac_objext"
1385     AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
1386       [Define to rpl_realloc if the replacement function should be used.])
1387   fi
1390 #serial 3
1392 dnl From Jim Meyering.
1393 dnl Determine whether malloc accepts 0 as its argument.
1394 dnl If it doesn't, arrange to use the replacement function.
1397 AC_DEFUN(jm_FUNC_MALLOC,
1399  dnl xmalloc.c requires that this symbol be defined so it doesn't
1400  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
1401  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
1402                     [Define if the malloc check has been performed. ])
1404  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1405   [AC_TRY_RUN([
1406     char *malloc ();
1407     int
1408     main ()
1409     {
1410       exit (malloc (0) ? 0 : 1);
1411     }
1412           ],
1413          jm_cv_func_working_malloc=yes,
1414          jm_cv_func_working_malloc=no,
1415          dnl When crosscompiling, assume malloc is broken.
1416          jm_cv_func_working_malloc=no)
1417   ])
1418   if test $jm_cv_func_working_malloc = no; then
1419     AC_SUBST(LIBOBJS)
1420     LIBOBJS="$LIBOBJS malloc.$ac_objext"
1421     AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
1422       [Define to rpl_malloc if the replacement function should be used.])
1423   fi
1426 #serial 2
1428 dnl From Jim Meyering.
1429 dnl Determine whether the strerror_r implementation is one of
1430 dnl the broken ones that returns `int' rather than `char*'.
1431 dnl Actually, this tests only whether it returns a scalar
1432 dnl or an array, but that should be enough.
1433 dnl On at least DEC UNIX 4.0[A-D] and HP-UX B.10.20, strerror_r
1434 dnl returns `int'.  This is used by lib/error.c.
1436 AC_DEFUN(jm_FUNC_STRERROR_R,
1438   # Check strerror_r
1439   AC_CHECK_FUNCS([strerror_r])
1440   if test $ac_cv_func_strerror_r = yes; then
1441     AC_CHECK_HEADERS(string.h)
1442     AC_CACHE_CHECK([for working strerror_r],
1443                    jm_cv_func_working_strerror_r,
1444      [
1445       AC_TRY_COMPILE(
1446        [
1447 #       include <stdio.h>
1448 #       if HAVE_STRING_H
1449 #        include <string.h>
1450 #       endif
1451        ],
1452        [
1453          int buf; /* avoiding square brackets makes this easier */
1454          char x = *strerror_r (0, buf, sizeof buf);
1455        ],
1456        jm_cv_func_working_strerror_r=yes,
1457        jm_cv_func_working_strerror_r=no
1458       )
1459       if test $jm_cv_func_working_strerror_r = yes; then
1460         AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
1461           [Define to 1 if strerror_r returns a string.])
1462       fi
1463     ])
1464   fi
1467 #serial 3
1469 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1470 dnl to test whether a NULL return value really means there are no more files
1471 dnl in the directory.
1473 dnl Detect the problem by creating a directory containing 300 files (254 not
1474 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1475 dnl removes all of them.
1477 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1479 dnl Written by Jim Meyering.
1481 AC_DEFUN(jm_FUNC_READDIR,
1482 [dnl
1483 AC_REQUIRE([AC_HEADER_DIRENT])
1484 AC_CHECK_HEADERS(string.h)
1485 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1486   [dnl
1487   # Arrange for deletion of the temporary directory this test creates, in
1488   # case the test itself fails to delete everything -- as happens on Sunos.
1489   ac_clean_files="$ac_clean_files conf-dir"
1491   AC_TRY_RUN(
1492 [#   include <stdio.h>
1493 #   include <sys/types.h>
1494 #   if HAVE_STRING_H
1495 #    include <string.h>
1496 #   endif
1498 #   ifdef HAVE_DIRENT_H
1499 #    include <dirent.h>
1500 #    define NLENGTH(direct) (strlen((direct)->d_name))
1501 #   else /* not HAVE_DIRENT_H */
1502 #    define dirent direct
1503 #    define NLENGTH(direct) ((direct)->d_namlen)
1504 #    ifdef HAVE_SYS_NDIR_H
1505 #     include <sys/ndir.h>
1506 #    endif /* HAVE_SYS_NDIR_H */
1507 #    ifdef HAVE_SYS_DIR_H
1508 #     include <sys/dir.h>
1509 #    endif /* HAVE_SYS_DIR_H */
1510 #    ifdef HAVE_NDIR_H
1511 #     include <ndir.h>
1512 #    endif /* HAVE_NDIR_H */
1513 #   endif /* HAVE_DIRENT_H */
1515 #   define DOT_OR_DOTDOT(Basename) \
1516      (Basename[0] == '.' && (Basename[1] == '\0' \
1517                              || (Basename[1] == '.' && Basename[2] == '\0')))
1519     static void
1520     create_300_file_dir (const char *dir)
1521     {
1522       int i;
1524       if (mkdir (dir, 0700))
1525         abort ();
1526       if (chdir (dir))
1527         abort ();
1529       for (i = 0; i < 300; i++)
1530         {
1531           char file_name[4];
1532           FILE *out;
1534           sprintf (file_name, "%03d", i);
1535           out = fopen (file_name, "w");
1536           if (!out)
1537             abort ();
1538           if (fclose (out) == EOF)
1539             abort ();
1540         }
1542       if (chdir (".."))
1543         abort ();
1544     }
1546     static void
1547     remove_dir (const char *dir)
1548     {
1549       DIR *dirp;
1551       if (chdir (dir))
1552         abort ();
1554       dirp = opendir (".");
1555       if (dirp == NULL)
1556         abort ();
1558       while (1)
1559         {
1560           struct dirent *dp = readdir (dirp);
1561           if (dp == NULL)
1562             break;
1564           if (DOT_OR_DOTDOT (dp->d_name))
1565             continue;
1567           if (unlink (dp->d_name))
1568             abort ();
1569         }
1570       closedir (dirp);
1572       if (chdir (".."))
1573         abort ();
1575       if (rmdir (dir))
1576         exit (1);
1577     }
1579     int
1580     main ()
1581     {
1582       const char *dir = "conf-dir";
1583       create_300_file_dir (dir);
1584       remove_dir (dir);
1585       exit (0);
1586     }],
1587   jm_cv_func_working_readdir=yes,
1588   jm_cv_func_working_readdir=no,
1589   jm_cv_func_working_readdir=no)])
1591   if test $jm_cv_func_working_readdir = yes; then
1592     AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
1593 [Define if readdir is found to work properly in some unusual cases. ])
1594   fi
1597 #serial 4
1599 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1600 dnl the losing memcmp on some x86 Next systems.
1601 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1602 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1603 [AC_TRY_RUN(
1604 [int
1605 main ()
1607   /* Some versions of memcmp are not 8-bit clean.  */
1608   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1609   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1610     exit (1);
1612   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1613      or more and with at least one buffer not starting on a 4-byte boundary.
1614      William Lewis provided this test program.   */
1615   {
1616     char foo[21];
1617     char bar[21];
1618     int i;
1619     for (i = 0; i < 4; i++)
1620       {
1621         char *a = foo + i;
1622         char *b = bar + i;
1623         strcpy (a, "--------01111111");
1624         strcpy (b, "--------10000000");
1625         if (memcmp (a, b, 16) >= 0)
1626           exit (1);
1627       }
1628     exit (0);
1629   }
1631    jm_cv_func_memcmp_working=yes,
1632    jm_cv_func_memcmp_working=no,
1633    jm_cv_func_memcmp_working=no)])
1634 test $jm_cv_func_memcmp_working = no \
1635   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
1636 AC_SUBST(LIBOBJS)dnl
1639 AC_DEFUN(jm_FUNC_MEMCMP,
1640 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1641  if test $jm_cv_func_memcmp_working = no; then
1642    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
1643      [Define to rpl_memcmp if the replacement function should be used.])
1644  fi
1647 #serial 3
1649 dnl From Jim Meyering.
1651 dnl See if the glibc *_unlocked I/O macros are available.
1652 dnl Use only those *_unlocked macros that are declared.
1655 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1656   [
1657     io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
1658     fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
1659     getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
1660     for jm_io_func in $io_functions; do
1661       # Check for the existence of each function only if its declared.
1662       # Otherwise, we'd get the Solaris5.5.1 functions that are not
1663       # declared, and that have been removed from Solaris5.6.  The resulting
1664       # 5.5.1 binaries would not run on 5.6 due to shared library differences.
1665       AC_CHECK_DECLS(($jm_io_func),
1666                      jm_declared=yes,
1667                      jm_declared=no,
1668                      [#include <stdio.h>])
1669       if test $jm_declared = yes; then
1670         AC_CHECK_FUNCS($jm_io_func)
1671       fi
1672     done
1673   ]
1676 #serial 2
1678 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1679 dnl define fnmatch to rpl_fnmatch.
1682 # AC_FUNC_FNMATCH
1683 # ---------------
1684 # We look for fnmatch.h to avoid that the test fails in C++.
1685 AC_DEFUN(kd_FUNC_FNMATCH_CASE,
1686 [AC_CHECK_HEADERS(fnmatch.h)
1687 AC_CACHE_CHECK(for working fnmatch with case folding, ac_cv_func_fnmatch_works,
1688 # Some versions of Solaris or SCO have a broken fnmatch function.
1689 # So we run a test program.  If we are cross-compiling, take no chance.
1690 # Also want FNM_CASEFOLD
1691 # Thanks to John Oleynick and Franc,ois Pinard for this test.
1692 [AC_TRY_RUN(
1693 [#include <stdio.h>
1694 #define _GNU_SOURCE
1695 #if HAVE_FNMATCH_H
1696 # include <fnmatch.h>
1697 #endif
1700 main ()
1702   exit (fnmatch ("A*", "abc", FNM_CASEFOLD) != 0);
1704 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
1705 ac_cv_func_fnmatch_works=no)])
1706 if test $ac_cv_func_fnmatch_works = yes; then
1707   AC_DEFINE(HAVE_FNMATCH, 1,
1708             [Define if your system has a working `fnmatch' function with case folding.])
1710 ])# AC_FUNC_FNMATCH
1713 AC_DEFUN(kd_FUNC_FNMATCH_CASE_RPL,
1715   AC_REQUIRE([AM_GLIBC])
1716   kd_FUNC_FNMATCH_CASE
1717   if test $ac_cv_func_fnmatch_works = no \
1718       && test $ac_cv_gnu_library = no; then
1719     AC_SUBST(LIBOBJS)
1720     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
1721     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
1722       [Define to rpl_fnmatch if the replacement function should be used.])
1723   fi
1726 #serial 2
1728 dnl From Gordon Matzigkeit.
1729 dnl Test for the GNU C Library.
1730 dnl FIXME: this should migrate into libit.
1732 AC_DEFUN(AM_GLIBC,
1733   [
1734     AC_CACHE_CHECK(whether we are using the GNU C Library,
1735       ac_cv_gnu_library,
1736       [AC_EGREP_CPP([Thanks for using GNU],
1737         [
1738 #include <features.h>
1739 #ifdef __GNU_LIBRARY__
1740   Thanks for using GNU
1741 #endif
1742         ],
1743         ac_cv_gnu_library=yes,
1744         ac_cv_gnu_library=no)
1745       ]
1746     )
1747     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1748       ac_cv_glibc,
1749       [AC_EGREP_CPP([Thanks for using GNU too],
1750         [
1751 #include <features.h>
1752 #ifdef __GLIBC__
1753   Thanks for using GNU too
1754 #endif
1755         ],
1756         ac_cv_glibc=yes, ac_cv_glibc=no)
1757       ]
1758     )
1759   ]
1762 #serial 1
1764 AC_DEFUN(jm_AFS,
1765   AC_CHECKING(for AFS)
1766   test -d /afs \
1767     && AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
1770 #serial 2
1772 # autoconf tests required for use of xstrtoumax.c
1774 AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
1776   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
1777   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1778   AC_CHECK_HEADERS(stdlib.h)
1780   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
1781     jm_cv_func_strtoumax_macro,
1782     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
1783 #ifdef strtoumax
1784  inttypes_h_defines_strtoumax
1785 #endif],
1786       jm_cv_func_strtoumax_macro=yes,
1787       jm_cv_func_strtoumax_macro=no))
1789   if test "$jm_cv_func_strtoumax_macro" != yes; then
1790     AC_REPLACE_FUNCS(strtoumax)
1791   fi
1793   dnl We don't need (and can't compile) the replacement strtoull
1794   dnl unless the type `unsigned long long' exists.
1795   dnl Also, only the replacement strtoumax invokes strtoull,
1796   dnl so we need the replacement strtoull only if strtoumax does not exist.
1797   case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
1798     yes,no,no)
1799       AC_REPLACE_FUNCS(strtoull)
1800       ;;
1801   esac
1805 #serial 2
1807 dnl From Paul Eggert.
1809 AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
1811   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
1812   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
1813     [unsigned long long ullmax = (unsigned long long) -1;
1814      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
1815     ac_cv_type_unsigned_long_long=yes,
1816     ac_cv_type_unsigned_long_long=no)])
1817   if test $ac_cv_type_unsigned_long_long = yes; then
1818     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
1819       [Define if you have the unsigned long long type.])
1820   fi
1823 #serial 1
1824 dnl Run a program to determine whether whether link(2) follows symlinks.
1825 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
1827 AC_DEFUN(jm_AC_FUNC_LINK_FOLLOWS_SYMLINK,
1828 [dnl
1829   AC_CACHE_CHECK([whether link(2) follows symlinks],
1830                  jm_ac_cv_func_link_follows_symlink,
1831   [
1832     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
1833     dnl the appropriate framework.
1834     test -z "$ac_cv_header_unistd_h" \
1835       && AC_CHECK_HEADERS(unistd.h)
1837     # Create a regular file.
1838     echo > conftest.file
1839     AC_TRY_RUN(
1840       [
1841 #       include <sys/types.h>
1842 #       include <sys/stat.h>
1843 #       ifdef HAVE_UNISTD_H
1844 #        include <unistd.h>
1845 #       endif
1847 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
1848           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
1849            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
1851         int
1852         main ()
1853         {
1854           const char *file = "conftest.file";
1855           const char *sym = "conftest.sym";
1856           const char *hard = "conftest.hard";
1857           struct stat sb_file, sb_hard;
1859           /* Create a symlink to the regular file. */
1860           if (symlink (file, sym))
1861             abort ();
1863           /* Create a hard link to that symlink.  */
1864           if (link (sym, hard))
1865             abort ();
1867           if (lstat (hard, &sb_hard))
1868             abort ();
1869           if (lstat (file, &sb_file))
1870             abort ();
1872           /* If the dev/inode of hard and file are the same, then
1873              the link call followed the symlink.  */
1874           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
1875         }
1876       ],
1877       jm_ac_cv_func_link_follows_symlink=yes,
1878       jm_ac_cv_func_link_follows_symlink=no,
1879       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
1880     )
1881   ])
1882   if test $jm_ac_cv_func_link_follows_symlink = yes; then
1883     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
1884       [Define if `link(2)' dereferences symbolic links.])
1885   fi
1888 # From Jim Meyering.  Use this if you use the GNU error.[ch].
1889 # FIXME: Migrate into libit
1891 AC_DEFUN([AM_FUNC_ERROR_AT_LINE],
1892 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1893  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1894               am_cv_lib_error_at_line=yes,
1895               am_cv_lib_error_at_line=no)])
1896  if test $am_cv_lib_error_at_line = no; then
1897    LIBOBJS="$LIBOBJS error.$ac_objext"
1898  fi
1899  AC_SUBST(LIBOBJS)dnl
1902 #serial 9
1904 dnl This macro is intended to be used solely in this file.
1905 dnl These are the prerequisite macros for GNU's strftime.c replacement.
1906 AC_DEFUN(_jm_STRFTIME_PREREQS,
1908  dnl strftime.c uses localtime_r if it exists.  Check for it.
1909  AC_CHECK_FUNCS(localtime_r)
1911  AC_CHECK_HEADERS(limits.h)
1912  AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
1914  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
1915  AC_STRUCT_TIMEZONE
1917  AC_CHECK_FUNCS(mblen mbrlen)
1919  AC_CHECK_MEMBER(struct tm.tm_gmtoff,
1920                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
1921                             [Define if struct tm has the tm_gmtoff member.])],
1922                  ,
1923                  [#include <time.h>])
1926 dnl Determine if the strftime function has all the features of the GNU one.
1928 dnl From Jim Meyering.
1930 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
1931 [AC_REQUIRE([AC_HEADER_TIME])dnl
1933  _jm_STRFTIME_PREREQS
1935  AC_REQUIRE([AC_C_CONST])dnl
1936  AC_REQUIRE([AC_HEADER_STDC])dnl
1937  AC_CHECK_HEADERS(sys/time.h)
1938  AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
1939   [# Set TZ to GMT0 to make strftime give consistent results during the test.
1940    ac_save_TZ="${TZ-GMT0}"
1941    TZ=GMT0
1942    export TZ
1943    AC_TRY_RUN(
1944 [ /* Ulrich Drepper provided parts of the test program.  */
1945 #if STDC_HEADERS
1946 # include <stdlib.h>
1947 #endif
1949 #if TIME_WITH_SYS_TIME
1950 # include <sys/time.h>
1951 # include <time.h>
1952 #else
1953 # if HAVE_SYS_TIME_H
1954 #  include <sys/time.h>
1955 # else
1956 #  include <time.h>
1957 # endif
1958 #endif
1960 static int
1961 compare (const char *fmt, const struct tm *tm, const char *expected)
1963   char buf[99];
1964   strftime (buf, 99, fmt, tm);
1965   if (strcmp (buf, expected))
1966     {
1967 #ifdef SHOW_FAILURES
1968       printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
1969               fmt, expected, buf);
1970 #endif
1971       return 1;
1972     }
1973   return 0;
1977 main ()
1979   int n_fail = 0;
1980   struct tm *tm;
1981   time_t t = 738367; /* Fri Jan  9 13:06:07 1970 */
1982   tm = gmtime (&t);
1984 #undef CMP
1985 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
1987   CMP ("%-m", "1");             /* GNU */
1988   CMP ("%A", "Friday");
1989   CMP ("%^A", "FRIDAY");        /* The ^ is a GNU extension.  */
1990   CMP ("%B", "January");
1991   CMP ("%^B", "JANUARY");
1992   CMP ("%C", "19");             /* POSIX.2 */
1993   CMP ("%D", "01/09/70");       /* POSIX.2 */
1994   CMP ("%F", "1970-01-09");
1995   CMP ("%G", "1970");           /* GNU */
1996   CMP ("%H", "13");
1997   CMP ("%I", "01");
1998   CMP ("%M", "06");
1999   CMP ("%M", "06");
2000   CMP ("%R", "13:06");          /* POSIX.2 */
2001   CMP ("%S", "07");
2002   CMP ("%T", "13:06:07");       /* POSIX.2 */
2003   CMP ("%U", "01");
2004   CMP ("%V", "02");
2005   CMP ("%W", "01");
2006   CMP ("%X", "13:06:07");
2007   CMP ("%Y", "1970");
2008   CMP ("%Z", "GMT");
2009   CMP ("%_m", " 1");            /* GNU */
2010   CMP ("%a", "Fri");
2011   CMP ("%^a", "FRI");
2012   CMP ("%b", "Jan");
2013   CMP ("%^b", "JAN");
2014   CMP ("%c", "Fri Jan  9 13:06:07 1970");
2015   CMP ("%^c", "FRI JAN  9 13:06:07 1970");
2016   CMP ("%d", "09");
2017   CMP ("%e", " 9");             /* POSIX.2 */
2018   CMP ("%g", "70");             /* GNU */
2019   CMP ("%h", "Jan");            /* POSIX.2 */
2020   CMP ("%^h", "JAN");
2021   CMP ("%j", "009");
2022   CMP ("%k", "13");             /* GNU */
2023   CMP ("%l", " 1");             /* GNU */
2024   CMP ("%m", "01");
2025   CMP ("%n", "\n");             /* POSIX.2 */
2026   CMP ("%p", "PM");
2027   CMP ("%r", "01:06:07 PM");    /* POSIX.2 */
2028   CMP ("%s", "738367");         /* GNU */
2029   CMP ("%t", "\t");             /* POSIX.2 */
2030   CMP ("%u", "5");              /* POSIX.2 */
2031   CMP ("%w", "5");
2032   CMP ("%x", "01/09/70");
2033   CMP ("%y", "70");
2034   CMP ("%z", "+0000");          /* GNU */
2036   exit (n_fail ? 1 : 0);
2038              jm_cv_func_working_gnu_strftime=yes,
2039              jm_cv_func_working_gnu_strftime=no,
2040              dnl When crosscompiling, assume strftime is missing or broken.
2041              jm_cv_func_working_gnu_strftime=no)
2042    dnl If TZ wasn't set before, this sets it to GMT0.  No real harm done.
2043    TZ="$ac_save_TZ"
2044   ])
2045   if test $jm_cv_func_working_gnu_strftime = no; then
2046     AC_SUBST(LIBOBJS)
2047     LIBOBJS="$LIBOBJS strftime.$ac_objext"
2048     AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
2049       [Define to gnu_strftime if the replacement function should be used.])
2050   fi
2053 AC_DEFUN(jm_FUNC_STRFTIME,
2055   _jm_STRFTIME_PREREQS
2056   AC_REPLACE_FUNCS(strftime)
2059 #serial 3
2061 dnl See if there's a working, system-supplied version of the getline function.
2062 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
2063 dnl have a function by that name in -linet that doesn't have anything
2064 dnl to do with the function we need.
2065 AC_DEFUN(AM_FUNC_GETLINE,
2066 [dnl
2067   am_getline_needs_run_time_check=no
2068   AC_CHECK_FUNC(getline,
2069                 dnl Found it in some library.  Verify that it works.
2070                 am_getline_needs_run_time_check=yes,
2071                 am_cv_func_working_getline=no)
2072   if test $am_getline_needs_run_time_check = yes; then
2073     AC_CHECK_HEADERS(string.h)
2074     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
2075     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
2076     AC_TRY_RUN([
2077 #    include <stdio.h>
2078 #    include <sys/types.h>
2079 #    if HAVE_STRING_H
2080 #     include <string.h>
2081 #    endif
2082     int main ()
2083     { /* Based on a test program from Karl Heuer.  */
2084       char *line = NULL;
2085       size_t siz = 0;
2086       int len;
2087       FILE *in = fopen ("./conftest.data", "r");
2088       if (!in)
2089         return 1;
2090       len = getline (&line, &siz, in);
2091       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
2092     }
2093     ], am_cv_func_working_getline=yes dnl The library version works.
2094     , am_cv_func_working_getline=no dnl The library version does NOT work.
2095     , am_cv_func_working_getline=no dnl We're cross compiling.
2096     )])
2097   fi
2099   if test $am_cv_func_working_getline = yes; then
2100     AC_DEFINE(HAVE_GETLINE, 1,
2101       [Define if you have the GETLINE function.])dnl
2102   fi
2105 #serial 2
2107 dnl From Jim Meyering.
2109 dnl See if struct statfs has the f_fstypename member.
2110 dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
2113 AC_DEFUN(jm_FSTYPENAME,
2114   [
2115     AC_CACHE_CHECK([for f_fstypename in struct statfs],
2116                    fu_cv_sys_f_fstypename_in_statfs,
2117       [
2118         AC_TRY_COMPILE(
2119           [
2120 #include <sys/param.h>
2121 #include <sys/types.h>
2122 #include <sys/mount.h>
2123           ],
2124           [struct statfs s; int i = sizeof s.f_fstypename;],
2125           fu_cv_sys_f_fstypename_in_statfs=yes,
2126           fu_cv_sys_f_fstypename_in_statfs=no
2127         )
2128       ]
2129     )
2131     if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
2132       AC_DEFINE_UNQUOTED(HAVE_F_FSTYPENAME_IN_STATFS, 1,
2133                          [Define if struct statfs has the f_fstypename member.])
2134     fi
2135   ]
2138 #serial 4
2140 dnl From Paul Eggert.
2142 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
2143 # if it exists.
2145 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
2146  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
2147    ac_cv_struct_st_mtim_nsec,
2148    [ac_save_CPPFLAGS="$CPPFLAGS"
2149     ac_cv_struct_st_mtim_nsec=no
2150     # tv_nsec -- the usual case
2151     # _tv_nsec -- Solaris 2.6, if
2152     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
2153     #    && !defined __EXTENSIONS__)
2154     # st__tim.tv_nsec -- UnixWare 2.1.2
2155     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
2156       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
2157       AC_TRY_COMPILE([#include <sys/types.h>
2158 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
2159         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
2160     done
2161     CPPFLAGS="$ac_save_CPPFLAGS"])
2163   if test $ac_cv_struct_st_mtim_nsec != no; then
2164     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
2165       [Define to be the nanoseconds member of struct stat's st_mtim,
2166    if it exists.])
2167   fi
2171 #serial 2
2173 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
2175 AC_DEFUN(AC_STRUCT_ST_DM_MODE,
2176  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
2177    [AC_TRY_COMPILE([#include <sys/types.h>
2178 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
2179      ac_cv_struct_st_dm_mode=yes,
2180      ac_cv_struct_st_dm_mode=no)])
2182   if test $ac_cv_struct_st_dm_mode = yes; then
2183     AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
2184                        [Define if struct stat has an st_dm_mode member. ])
2185   fi
2189 #serial 4
2191 dnl From Jim Meyering
2193 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
2194 dnl in time.h or sys/time.h.
2196 AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
2198   AC_REQUIRE([AC_HEADER_TIME])
2199   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
2200     [AC_TRY_COMPILE(
2201       [
2202 #      if TIME_WITH_SYS_TIME
2203 #       include <sys/time.h>
2204 #       include <time.h>
2205 #      else
2206 #       if HAVE_SYS_TIME_H
2207 #        include <sys/time.h>
2208 #       else
2209 #        include <time.h>
2210 #       endif
2211 #      endif
2212       ],
2213       [static struct timespec x; x.tv_sec = x.tv_nsec;],
2214       fu_cv_sys_struct_timespec=yes,
2215       fu_cv_sys_struct_timespec=no)
2216     ])
2218   if test $fu_cv_sys_struct_timespec = yes; then
2219     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
2220                        [Define if struct timespec is declared in <time.h>. ])
2221   fi
2224 #serial 5
2226 dnl From Paul Eggert.
2228 AC_PREREQ(2.13)
2230 # Define uintmax_t to `unsigned long' or `unsigned long long'
2231 # if <inttypes.h> does not exist.
2233 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
2235   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2236   if test $jm_ac_cv_header_inttypes_h = no; then
2237     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2238     test $ac_cv_type_unsigned_long_long = yes \
2239       && ac_type='unsigned long long' \
2240       || ac_type='unsigned long'
2241     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2242 [  Define to unsigned long or unsigned long long
2243    if <inttypes.h> doesn't define.])
2244   fi
2247 # Macro to add for using GNU gettext.
2248 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2250 # This file can be copied and used freely without restrictions.  It can
2251 # be used in projects which are not available under the GNU Public License
2252 # but which still want to provide support for the GNU gettext functionality.
2253 # Please note that the actual code is *not* freely available.
2255 # serial 108
2257 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2259 AC_DEFUN(AM_WITH_NLS,
2260   [AC_MSG_CHECKING([whether NLS is requested])
2261     dnl Default is enabled NLS
2262     AC_ARG_ENABLE(nls,
2263       [  --disable-nls           do not use Native Language Support],
2264       USE_NLS=$enableval, USE_NLS=yes)
2265     AC_MSG_RESULT($USE_NLS)
2266     AC_SUBST(USE_NLS)
2268     USE_INCLUDED_LIBINTL=no
2270     dnl If we use NLS figure out what method
2271     if test "$USE_NLS" = "yes"; then
2272       AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.])
2273       AC_MSG_CHECKING([whether included gettext is requested])
2274       AC_ARG_WITH(included-gettext,
2275         [  --with-included-gettext use the GNU gettext library included here],
2276         nls_cv_force_use_gnu_gettext=$withval,
2277         nls_cv_force_use_gnu_gettext=no)
2278       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2280       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2281       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2282         dnl User does not insist on using GNU NLS library.  Figure out what
2283         dnl to use.  If gettext or catgets are available (in this order) we
2284         dnl use this.  Else we have to fall back to GNU NLS library.
2285         dnl catgets is only used if permitted by option --with-catgets.
2286         nls_cv_header_intl=
2287         nls_cv_header_libgt=
2288         CATOBJEXT=NONE
2290         AC_CHECK_HEADER(libintl.h,
2291           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
2292             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
2293                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
2295            if test "$gt_cv_func_gettext_libc" != "yes"; then
2296              AC_CHECK_LIB(intl, bindtextdomain,
2297                [AC_CHECK_LIB(intl, gettext)])
2298            fi
2300            if test "$gt_cv_func_gettext_libc" = "yes" \
2301               || test "$ac_cv_lib_intl_gettext" = "yes"; then
2302               AC_DEFINE(HAVE_GETTEXT, 1,
2303           [Define to 1 if you have gettext and don't want to use GNU gettext.])
2304               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2305                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2306               if test "$MSGFMT" != "no"; then
2307                 AC_CHECK_FUNCS(dcgettext)
2308                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2309                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2310                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2311                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
2312                                return _nl_msg_cat_cntr],
2313                   [CATOBJEXT=.gmo
2314                    DATADIRNAME=share],
2315                   [CATOBJEXT=.mo
2316                    DATADIRNAME=lib])
2317                 INSTOBJEXT=.mo
2318               fi
2319             fi
2320         ])
2322         if test "$CATOBJEXT" = "NONE"; then
2323           AC_MSG_CHECKING([whether catgets can be used])
2324           AC_ARG_WITH(catgets,
2325             [  --with-catgets          use catgets functions if available],
2326             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
2327           AC_MSG_RESULT($nls_cv_use_catgets)
2329           if test "$nls_cv_use_catgets" = "yes"; then
2330             dnl No gettext in C library.  Try catgets next.
2331             AC_CHECK_LIB(i, main)
2332             AC_CHECK_FUNC(catgets,
2333               [AC_DEFINE(HAVE_CATGETS, 1,
2334                          [Define as 1 if you have catgets and don't want to use GNU gettext.])
2335                INTLOBJS="\$(CATOBJS)"
2336                AC_PATH_PROG(GENCAT, gencat, no)dnl
2337                if test "$GENCAT" != "no"; then
2338                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
2339                  if test "$GMSGFMT" = "no"; then
2340                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
2341                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
2342                  fi
2343                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2344                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2345                  USE_INCLUDED_LIBINTL=yes
2346                  CATOBJEXT=.cat
2347                  INSTOBJEXT=.cat
2348                  DATADIRNAME=lib
2349                  INTLDEPS='$(top_builddir)/intl/libintl.a'
2350                  INTLLIBS=$INTLDEPS
2351                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2352                  nls_cv_header_intl=intl/libintl.h
2353                  nls_cv_header_libgt=intl/libgettext.h
2354                fi])
2355           fi
2356         fi
2358         if test "$CATOBJEXT" = "NONE"; then
2359           dnl Neither gettext nor catgets in included in the C library.
2360           dnl Fall back on GNU gettext library.
2361           nls_cv_use_gnu_gettext=yes
2362         fi
2363       fi
2365       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2366         dnl Mark actions used to generate GNU NLS library.
2367         INTLOBJS="\$(GETTOBJS)"
2368         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2369           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2370         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2371         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2372           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2373         AC_SUBST(MSGFMT)
2374         USE_INCLUDED_LIBINTL=yes
2375         CATOBJEXT=.gmo
2376         INSTOBJEXT=.mo
2377         DATADIRNAME=share
2378         INTLDEPS='$(top_builddir)/intl/libintl.a'
2379         INTLLIBS=$INTLDEPS
2380         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2381         nls_cv_header_intl=intl/libintl.h
2382         nls_cv_header_libgt=intl/libgettext.h
2383       fi
2385       dnl Test whether we really found GNU xgettext.
2386       if test "$XGETTEXT" != ":"; then
2387         dnl If it is no GNU xgettext we define it as : so that the
2388         dnl Makefiles still can work.
2389         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2390           : ;
2391         else
2392           AC_MSG_RESULT(
2393             [found xgettext program is not GNU xgettext; ignore it])
2394           XGETTEXT=":"
2395         fi
2396       fi
2398       # We need to process the po/ directory.
2399       POSUB=po
2400     else
2401       DATADIRNAME=share
2402       nls_cv_header_intl=intl/libintl.h
2403       nls_cv_header_libgt=intl/libgettext.h
2404     fi
2405     if test -z "$nls_cv_header_intl"; then
2406       # Clean out junk possibly left behind by a previous configuration.
2407       rm -f intl/libintl.h
2408     fi
2409     AC_CONFIG_LINKS($nls_cv_header_intl:$nls_cv_header_libgt)
2410     AC_OUTPUT_COMMANDS(
2411      [case "$CONFIG_FILES" in *po/Makefile.in*)
2412         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
2413       esac])
2416     # If this is used in GNU gettext we have to set USE_NLS to `yes'
2417     # because some of the sources are only built for this goal.
2418     if test "$PACKAGE" = gettext; then
2419       USE_NLS=yes
2420       USE_INCLUDED_LIBINTL=yes
2421     fi
2423     dnl These rules are solely for the distribution goal.  While doing this
2424     dnl we only have to keep exactly one list of the available catalogs
2425     dnl in configure.in.
2426     for lang in $ALL_LINGUAS; do
2427       GMOFILES="$GMOFILES $lang.gmo"
2428       POFILES="$POFILES $lang.po"
2429     done
2431     dnl Make all variables we use known to autoconf.
2432     AC_SUBST(USE_INCLUDED_LIBINTL)
2433     AC_SUBST(CATALOGS)
2434     AC_SUBST(CATOBJEXT)
2435     AC_SUBST(DATADIRNAME)
2436     AC_SUBST(GMOFILES)
2437     AC_SUBST(INSTOBJEXT)
2438     AC_SUBST(INTLDEPS)
2439     AC_SUBST(INTLLIBS)
2440     AC_SUBST(INTLOBJS)
2441     AC_SUBST(POFILES)
2442     AC_SUBST(POSUB)
2443   ])
2445 AC_DEFUN(AM_GNU_GETTEXT,
2446   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2447    AC_REQUIRE([AC_PROG_CC])dnl
2448    AC_REQUIRE([AC_PROG_RANLIB])dnl
2449    AC_REQUIRE([AC_ISC_POSIX])dnl
2450    AC_REQUIRE([AC_HEADER_STDC])dnl
2451    AC_REQUIRE([AC_C_CONST])dnl
2452    AC_REQUIRE([AC_C_INLINE])dnl
2453    AC_REQUIRE([AC_TYPE_OFF_T])dnl
2454    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2455    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2456    AC_REQUIRE([AC_FUNC_MMAP])dnl
2458    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
2459 unistd.h sys/param.h])
2460    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
2461 strdup __argz_count __argz_stringify __argz_next])
2463    if test "${ac_cv_func_stpcpy+set}" != "set"; then
2464      AC_CHECK_FUNCS(stpcpy)
2465    fi
2466    if test "${ac_cv_func_stpcpy}" = "yes"; then
2467      AC_DEFINE(HAVE_STPCPY, 1, [Define to 1 if you have the stpcpy function.])
2468    fi
2470    AM_LC_MESSAGES
2471    AM_WITH_NLS
2473    if test "x$CATOBJEXT" != "x"; then
2474      if test "x$ALL_LINGUAS" = "x"; then
2475        LINGUAS=
2476      else
2477        AC_MSG_CHECKING(for catalogs to be installed)
2478        NEW_LINGUAS=
2479        for lang in ${LINGUAS=$ALL_LINGUAS}; do
2480          case "$ALL_LINGUAS" in
2481           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
2482          esac
2483        done
2484        LINGUAS=$NEW_LINGUAS
2485        AC_MSG_RESULT($LINGUAS)
2486      fi
2488      dnl Construct list of names of catalog files to be constructed.
2489      if test -n "$LINGUAS"; then
2490        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2491      fi
2492    fi
2494    dnl The reference to <locale.h> in the installed <libintl.h> file
2495    dnl must be resolved because we cannot expect the users of this
2496    dnl to define HAVE_LOCALE_H.
2497    if test $ac_cv_header_locale_h = yes; then
2498      INCLUDE_LOCALE_H="#include <locale.h>"
2499    else
2500      INCLUDE_LOCALE_H="\
2501 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
2502    fi
2503    AC_SUBST(INCLUDE_LOCALE_H)
2505    dnl Determine which catalog format we have (if any is needed)
2506    dnl For now we know about two different formats:
2507    dnl   Linux libc-5 and the normal X/Open format
2508    test -d intl || mkdir intl
2509    if test "$CATOBJEXT" = ".cat"; then
2510      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
2512      dnl Transform the SED scripts while copying because some dumb SEDs
2513      dnl cannot handle comments.
2514      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
2515    fi
2516    dnl po2tbl.sed is always needed.
2517    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
2518      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
2520    dnl In the intl/Makefile.in we have a special dependency which makes
2521    dnl only sense for gettext.  We comment this out for non-gettext
2522    dnl packages.
2523    if test "$PACKAGE" = "gettext"; then
2524      GT_NO="#NO#"
2525      GT_YES=
2526    else
2527      GT_NO=
2528      GT_YES="#YES#"
2529    fi
2530    AC_SUBST(GT_NO)
2531    AC_SUBST(GT_YES)
2533    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2534    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
2535    dnl Try to locate is.
2536    MKINSTALLDIRS=
2537    if test -n "$ac_aux_dir"; then
2538      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2539    fi
2540    if test -z "$MKINSTALLDIRS"; then
2541      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2542    fi
2543    AC_SUBST(MKINSTALLDIRS)
2545    dnl *** For now the libtool support in intl/Makefile is not for real.
2546    l=
2547    AC_SUBST(l)
2549    dnl Generate list of files to be processed by xgettext which will
2550    dnl be included in po/Makefile.
2551    test -d po || mkdir po
2552    case "$srcdir" in
2553    .)
2554      posrcprefix="../" ;;
2555    /* | [[A-Za-z]]:*)
2556      posrcprefix="$srcdir/" ;;
2557    *)
2558      posrcprefix="../$srcdir/" ;;
2559    esac
2560    rm -f po/POTFILES
2561    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
2562         < $srcdir/po/POTFILES.in > po/POTFILES
2563   ])
2565 # Search path for a program which passes the given test.
2566 # Ulrich Drepper <drepper@cygnus.com>, 1996.
2568 # This file can be copied and used freely without restrictions.  It can
2569 # be used in projects which are not available under the GNU Public License
2570 # but which still want to provide support for the GNU gettext functionality.
2571 # Please note that the actual code is *not* freely available.
2573 # serial 1
2575 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2576 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2577 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
2578 [# Extract the first word of "$2", so it can be a program name with args.
2579 set dummy $2; ac_word=[$]2
2580 AC_MSG_CHECKING([for $ac_word])
2581 AC_CACHE_VAL(ac_cv_path_$1,
2582 [case "[$]$1" in
2583   /*)
2584   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2585   ;;
2586   *)
2587   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2588   for ac_dir in ifelse([$5], , $PATH, [$5]); do
2589     test -z "$ac_dir" && ac_dir=.
2590     if test -f $ac_dir/$ac_word; then
2591       if [$3]; then
2592         ac_cv_path_$1="$ac_dir/$ac_word"
2593         break
2594       fi
2595     fi
2596   done
2597   IFS="$ac_save_ifs"
2598 dnl If no 4th arg is given, leave the cache variable unset,
2599 dnl so AC_PATH_PROGS will keep looking.
2600 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2601 ])dnl
2602   ;;
2603 esac])dnl
2604 $1="$ac_cv_path_$1"
2605 if test -n "[$]$1"; then
2606   AC_MSG_RESULT([$]$1)
2607 else
2608   AC_MSG_RESULT(no)
2610 AC_SUBST($1)dnl
2613 # Check whether LC_MESSAGES is available in <locale.h>.
2614 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2616 # This file can be copied and used freely without restrictions.  It can
2617 # be used in projects which are not available under the GNU Public License
2618 # but which still want to provide support for the GNU gettext functionality.
2619 # Please note that the actual code is *not* freely available.
2621 # serial 2
2623 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2625 AC_DEFUN(AM_LC_MESSAGES,
2626   [if test $ac_cv_header_locale_h = yes; then
2627     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2628       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2629        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2630     if test $am_cv_val_LC_MESSAGES = yes; then
2631       AC_DEFINE(HAVE_LC_MESSAGES, 1,
2632                 [Define if your locale.h file contains LC_MESSAGES.])
2633     fi
2634   fi])