* find/parser.c (parse_prune): set side_effects to true, to
[findutils.git] / aclocal.m4
bloba4a700948fb81fce6a3f9fd7dcc19aedb1d6ac91
1 dnl aclocal.m4 generated automatically by aclocal 1.4a
3 dnl Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
13 # Like AC_CONFIG_HEADER, but automatically create stamp file.
15 AC_DEFUN(AM_CONFIG_HEADER,
16 [AC_PREREQ([2.12])
17 AC_CONFIG_HEADER([$1])
18 dnl When config.status generates a header, we must update the stamp-h file.
19 dnl This file resides in the same directory as the config header
20 dnl that is generated.  We must strip everything past the first ":",
21 dnl and everything past the last "/".
22 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
23 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
24 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
25 <<am_indx=1
26 for am_file in <<$1>>; do
27   case " <<$>>CONFIG_HEADERS " in
28   *" <<$>>am_file "*<<)>>
29     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
30     ;;
31   esac
32   am_indx=`expr "<<$>>am_indx" + 1`
33 done<<>>dnl>>)
34 changequote([,]))])
36 # Do all the work for Automake.  This macro actually does too much --
37 # some checks are only needed if your package does certain things.
38 # But this isn't really a big deal.
40 # serial 1
42 dnl Usage:
43 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
45 AC_DEFUN(AM_INIT_AUTOMAKE,
46 [AC_REQUIRE([AC_PROG_INSTALL])
47 dnl We require 2.13 because we rely on SHELL being computed by configure.
48 AC_PREREQ([2.13])
49 PACKAGE=[$1]
50 AC_SUBST(PACKAGE)
51 VERSION=[$2]
52 AC_SUBST(VERSION)
53 dnl test to see if srcdir already configured
54 if test "`CDPATH=: && cd $srcdir && pwd`" != "`pwd`" &&
55    test -f $srcdir/config.status; then
56   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
58 ifelse([$3],,
59 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
60 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
61 AC_REQUIRE([AM_SANITY_CHECK])
62 AC_REQUIRE([AC_ARG_PROGRAM])
63 AM_MISSING_PROG(ACLOCAL, aclocal)
64 AM_MISSING_PROG(AUTOCONF, autoconf)
65 AM_MISSING_PROG(AUTOMAKE, automake)
66 AM_MISSING_PROG(AUTOHEADER, autoheader)
67 AM_MISSING_PROG(MAKEINFO, makeinfo)
68 AM_MISSING_PROG(AMTAR, tar)
69 AM_MISSING_INSTALL_SH
70 dnl We need awk for the "check" target.  The system "awk" is bad on
71 dnl some platforms.
72 AC_REQUIRE([AC_PROG_AWK])
73 AC_REQUIRE([AC_PROG_MAKE_SET])
74 AC_REQUIRE([AM_DEP_TRACK])
75 AC_REQUIRE([AM_SET_DEPDIR])
76 ifdef([AC_PROVIDE_AC_PROG_CC], [AM_DEPENDENCIES(CC)], [
77    define([AC_PROG_CC], defn([AC_PROG_CC])[AM_DEPENDENCIES(CC)])])
78 ifdef([AC_PROVIDE_AC_PROG_CXX], [AM_DEPENDENCIES(CXX)], [
79    define([AC_PROG_CXX], defn([AC_PROG_CXX])[AM_DEPENDENCIES(CXX)])])
83 # Check to make sure that the build environment is sane.
86 AC_DEFUN(AM_SANITY_CHECK,
87 [AC_MSG_CHECKING([whether build environment is sane])
88 # Just in case
89 sleep 1
90 echo timestamp > conftestfile
91 # Do `set' in a subshell so we don't clobber the current shell's
92 # arguments.  Must try -L first in case configure is actually a
93 # symlink; some systems play weird games with the mod time of symlinks
94 # (eg FreeBSD returns the mod time of the symlink's containing
95 # directory).
96 if (
97    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
98    if test "[$]*" = "X"; then
99       # -L didn't work.
100       set X `ls -t $srcdir/configure conftestfile`
101    fi
102    if test "[$]*" != "X $srcdir/configure conftestfile" \
103       && test "[$]*" != "X conftestfile $srcdir/configure"; then
105       # If neither matched, then we have a broken ls.  This can happen
106       # if, for instance, CONFIG_SHELL is bash and it inherits a
107       # broken ls alias from the environment.  This has actually
108       # happened.  Such a system could not be considered "sane".
109       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
110 alias in your environment])
111    fi
113    test "[$]2" = conftestfile
114    )
115 then
116    # Ok.
117    :
118 else
119    AC_MSG_ERROR([newly created file is older than distributed files!
120 Check your system clock])
122 rm -f conftest*
123 AC_MSG_RESULT(yes)])
125 dnl AM_MISSING_PROG(NAME, PROGRAM)
126 AC_DEFUN(AM_MISSING_PROG, [
127 AC_REQUIRE([AM_MISSING_HAS_RUN])
128 $1=${$1-"${am_missing_run}$2"}
129 AC_SUBST($1)])
131 dnl Like AM_MISSING_PROG, but only looks for install-sh.
132 dnl AM_MISSING_INSTALL_SH()
133 AC_DEFUN(AM_MISSING_INSTALL_SH, [
134 AC_REQUIRE([AM_MISSING_HAS_RUN])
135 if test -z "$install_sh"; then
136    install_sh="$ac_aux_dir/install-sh"
137    test -f "$install_sh" || install_sh="$ac_aux_dir/install.sh"
138    test -f "$install_sh" || install_sh="${am_missing_run}${ac_auxdir}/install-sh"
139    dnl FIXME: an evil hack: we remove the SHELL invocation from
140    dnl install_sh because automake adds it back in.  Sigh.
141    install_sh="`echo $install_sh | sed -e 's/\${SHELL}//'`"
143 AC_SUBST(install_sh)])
145 dnl AM_MISSING_HAS_RUN.
146 dnl Define MISSING if not defined so far and test if it supports --run.
147 dnl If it does, set am_missing_run to use it, otherwise, to nothing.
148 AC_DEFUN([AM_MISSING_HAS_RUN], [
149 test x"${MISSING+set}" = xset || \
150   MISSING="\${SHELL} `CDPATH=: && cd $ac_aux_dir && pwd`/missing"
151 dnl Use eval to expand $SHELL
152 if eval "$MISSING --run :"; then
153   am_missing_run="$MISSING --run "
154 else
155   am_missing_run=
156   am_backtick='`'
157   AC_MSG_WARN([${am_backtick}missing' script is too old or missing])
161 dnl See how the compiler implements dependency checking.
162 dnl Usage:
163 dnl AM_DEPENDENCIES(NAME)
164 dnl NAME is "CC", "CXX" or "OBJC".
166 dnl We try a few techniques and use that to set a single cache variable.
168 AC_DEFUN(AM_DEPENDENCIES,[
169 AC_REQUIRE([AM_SET_DEPDIR])
170 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])
171 ifelse([$1],CC,[
172 AC_REQUIRE([AC_PROG_CC])
173 AC_REQUIRE([AC_PROG_CPP])
174 depcc="$CC"
175 depcpp="$CPP"],[$1],CXX,[
176 AC_REQUIRE([AC_PROG_CXX])
177 AC_REQUIRE([AC_PROG_CXXCPP])
178 depcc="$CXX"
179 depcpp="$CXXCPP"],[$1],OBJC,[
180 am_cv_OBJC_dependencies_compiler_type=gcc],[
181 AC_REQUIRE([AC_PROG_][$1])
182 depcc="$[$1]"
183 depcpp=""])
184 AC_MSG_CHECKING([dependency style of $depcc])
185 AC_CACHE_VAL(am_cv_[$1]_dependencies_compiler_type,[
186 if test -z "$AMDEP"; then
187   echo '#include "conftest.h"' > conftest.c
188   echo 'int i;' > conftest.h
190   am_cv_[$1]_dependencies_compiler_type=none
191   for depmode in `sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < "$am_depcomp"`; do
192     case "$depmode" in
193     nosideeffect)
194       # after this tag, mechanisms are not by side-effect, so they'll
195       # only be used when explicitly requested
196       if test "x$enable_dependency_tracking" = xyes; then
197         continue
198       else
199         break
200       fi
201       ;;
202     none) break ;;
203     esac
204     if depmode="$depmode" \
205        source=conftest.c object=conftest.o \
206        depfile=conftest.Po tmpdepfile=conftest.TPo \
207        $SHELL $am_depcomp $depcc -c conftest.c 2>/dev/null &&
208        grep conftest.h conftest.Po > /dev/null 2>&1; then
209       am_cv_[$1]_dependencies_compiler_type="$depmode"
210       break
211     fi
212   done
214   rm -f conftest.*
215 else
216   am_cv_[$1]_dependencies_compiler_type=none
219 AC_MSG_RESULT($am_cv_[$1]_dependencies_compiler_type)
220 [$1]DEPMODE="depmode=$am_cv_[$1]_dependencies_compiler_type"
221 AC_SUBST([$1]DEPMODE)
224 dnl Choose a directory name for dependency files.
225 dnl This macro is AC_REQUIREd in AM_DEPENDENCIES
227 AC_DEFUN(AM_SET_DEPDIR,[
228 if test -d .deps || mkdir .deps 2> /dev/null || test -d .deps; then
229   DEPDIR=.deps
230 else
231   DEPDIR=_deps
233 AC_SUBST(DEPDIR)
236 AC_DEFUN(AM_DEP_TRACK,[
237 AC_ARG_ENABLE(dependency-tracking,
238 [  --disable-dependency-tracking Speeds up one-time builds
239   --enable-dependency-tracking  Do not reject slow dependency extractors])
240 if test "x$enable_dependency_tracking" = xno; then
241   AMDEP="#"
242 else
243   am_depcomp="$ac_aux_dir/depcomp"
244   if test ! -f "$am_depcomp"; then
245     AMDEP="#"
246   else
247     AMDEP=
248   fi
250 AC_SUBST(AMDEP)
251 if test -z "$AMDEP"; then
252   AMDEPBACKSLASH='\'
253 else
254   AMDEPBACKSLASH=
256 pushdef([subst], defn([AC_SUBST]))
257 subst(AMDEPBACKSLASH)
258 popdef([subst])
261 dnl Generate code to set up dependency tracking.
262 dnl This macro should only be invoked once -- use via AC_REQUIRE.
263 dnl Usage:
264 dnl AM_OUTPUT_DEPENDENCY_COMMANDS
267 dnl This code is only required when automatic dependency tracking
268 dnl is enabled.  FIXME.  This creates each `.P' file that we will
269 dnl need in order to bootstrap the dependency handling code.
270 AC_DEFUN(AM_OUTPUT_DEPENDENCY_COMMANDS,[
271 AC_OUTPUT_COMMANDS([
272 test x"$AMDEP" != x"" ||
273 for mf in $CONFIG_FILES; do
274   case "$mf" in
275   Makefile) dirpart=.;;
276   */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;;
277   *) continue;;
278   esac
279   grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
280   # Extract the definition of DEP_FILES from the Makefile without
281   # running `make'.
282   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
283   test -z "$DEPDIR" && continue
284   # When using ansi2knr, U may be empty or an underscore; expand it
285   U=`sed -n -e '/^U = / s///p' < "$mf"`
286   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
287   # We invoke sed twice because it is the simplest approach to
288   # changing $(DEPDIR) to its actual value in the expansion.
289   for file in `sed -n -e '
290     /^DEP_FILES = .*\\\\$/ {
291       s/^DEP_FILES = //
292       :loop
293         s/\\\\$//
294         p
295         n
296         /\\\\$/ b loop
297       p
298     }
299     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
300        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
301     # Make sure the directory exists.
302     test -f "$dirpart/$file" && continue
303     fdir=`echo "$file" | sed -e 's|/[^/]*$||'`
304     $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1
305     # echo "creating $dirpart/$file"
306     echo '# dummy' > "$dirpart/$file"
307   done
308 done
309 ], [AMDEP="$AMDEP"
310 ac_aux_dir="$ac_aux_dir"])])
312 #serial 1
313 dnl This test replaces the one in autoconf.
314 dnl Currently this macro should have the same name as the autoconf macro
315 dnl because gettext's gettext.m4 (distributed in the automake package)
316 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
317 dnl give these diagnostics:
318 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
319 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
321 undefine([AC_ISC_POSIX])
322 AC_DEFUN(AC_ISC_POSIX,
323   [
324     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
325     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
326   ]
330 # serial 1
332 AC_DEFUN(AM_C_PROTOTYPES,
333 [AC_REQUIRE([AM_PROG_CC_STDC])
334 AC_REQUIRE([AC_PROG_CPP])
335 AC_MSG_CHECKING([for function prototypes])
336 if test "$am_cv_prog_cc_stdc" != no; then
337   AC_MSG_RESULT(yes)
338   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
339   U= ANSI2KNR=
340 else
341   AC_MSG_RESULT(no)
342   U=_ ANSI2KNR=./ansi2knr
343   # Ensure some checks needed by ansi2knr itself.
344   AC_HEADER_STDC
345   AC_CHECK_HEADERS(string.h)
347 AC_SUBST(U)dnl
348 AC_SUBST(ANSI2KNR)dnl
352 # serial 1
354 # @defmac AC_PROG_CC_STDC
355 # @maindex PROG_CC_STDC
356 # @ovindex CC
357 # If the C compiler in not in ANSI C mode by default, try to add an option
358 # to output variable @code{CC} to make it so.  This macro tries various
359 # options that select ANSI C on some system or another.  It considers the
360 # compiler to be in ANSI C mode if it handles function prototypes correctly.
362 # If you use this macro, you should check after calling it whether the C
363 # compiler has been set to accept ANSI C; if not, the shell variable
364 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
365 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
366 # program @code{ansi2knr}, which comes with Ghostscript.
367 # @end defmac
369 AC_DEFUN(AM_PROG_CC_STDC,
370 [AC_REQUIRE([AC_PROG_CC])
371 AC_BEFORE([$0], [AC_C_INLINE])
372 AC_BEFORE([$0], [AC_C_CONST])
373 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
374 dnl a magic option to avoid problems with ANSI preprocessor commands
375 dnl like #elif.
376 dnl FIXME: can't do this because then AC_AIX won't work due to a
377 dnl circular dependency.
378 dnl AC_BEFORE([$0], [AC_PROG_CPP])
379 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
380 AC_CACHE_VAL(am_cv_prog_cc_stdc,
381 [am_cv_prog_cc_stdc=no
382 ac_save_CC="$CC"
383 # Don't try gcc -ansi; that turns off useful extensions and
384 # breaks some systems' header files.
385 # AIX                   -qlanglvl=ansi
386 # Ultrix and OSF/1      -std1
387 # HP-UX 10.20 and later -Ae
388 # HP-UX older versions  -Aa -D_HPUX_SOURCE
389 # SVR4                  -Xc -D__EXTENSIONS__
390 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
392   CC="$ac_save_CC $ac_arg"
393   AC_TRY_COMPILE(
394 [#include <stdarg.h>
395 #include <stdio.h>
396 #include <sys/types.h>
397 #include <sys/stat.h>
398 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
399 struct buf { int x; };
400 FILE * (*rcsopen) (struct buf *, struct stat *, int);
401 static char *e (p, i)
402      char **p;
403      int i;
405   return p[i];
407 static char *f (char * (*g) (char **, int), char **p, ...)
409   char *s;
410   va_list v;
411   va_start (v,p);
412   s = g (p, va_arg (v,int));
413   va_end (v);
414   return s;
416 int test (int i, double x);
417 struct s1 {int (*f) (int a);};
418 struct s2 {int (*f) (double a);};
419 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
420 int argc;
421 char **argv;
422 ], [
423 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
425 [am_cv_prog_cc_stdc="$ac_arg"; break])
426 done
427 CC="$ac_save_CC"
429 if test -z "$am_cv_prog_cc_stdc"; then
430   AC_MSG_RESULT([none needed])
431 else
432   AC_MSG_RESULT($am_cv_prog_cc_stdc)
434 case "x$am_cv_prog_cc_stdc" in
435   x|xno) ;;
436   *) CC="$CC $am_cv_prog_cc_stdc" ;;
437 esac
440 #serial 8
442 dnl By default, many hosts won't let programs access large files;
443 dnl one must use special compiler options to get large-file access to work.
444 dnl For more details about this brain damage please see:
445 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
447 dnl Written by Paul Eggert <eggert@twinsun.com>.
449 dnl Internal subroutine of AC_SYS_LARGEFILE.
450 dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
451 AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
452   [AC_CACHE_CHECK([for $1 value to request large file support],
453      ac_cv_sys_largefile_$1,
454      [if ($GETCONF LFS_$1) >conftest.1 2>conftest.2 && test ! -s conftest.2
455       then
456         ac_cv_sys_largefile_$1=`cat conftest.1`
457       else
458         ac_cv_sys_largefile_$1=no
459         ifelse($1, CFLAGS,
460           [case "$host_os" in
461            # HP-UX 10.20 requires -D__STDC_EXT__ with gcc 2.95.1.
462 [          hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
463              if test "$GCC" = yes; then
464                ac_cv_sys_largefile_CFLAGS=-D__STDC_EXT__
465              fi
466              ;;
467            # IRIX 6.2 and later require cc -n32.
468 [          irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)]
469              if test "$GCC" != yes; then
470                ac_cv_sys_largefile_CFLAGS=-n32
471              fi
472            esac
473            if test "$ac_cv_sys_largefile_CFLAGS" != no; then
474              ac_save_CC="$CC"
475              CC="$CC $ac_cv_sys_largefile_CFLAGS"
476              AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
477              CC="$ac_save_CC"
478            fi])
479       fi
480       rm -f conftest*])])
482 dnl Internal subroutine of AC_SYS_LARGEFILE.
483 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
484 AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
485   [case $2 in
486    no) ;;
487    ?*)
488      case "[$]$1" in
489      '') $1=$2 ;;
490      *) $1=[$]$1' '$2 ;;
491      esac ;;
492    esac])
494 dnl Internal subroutine of AC_SYS_LARGEFILE.
495 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
496 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
497   [AC_CACHE_CHECK([for $1], $2,
498      [$2=no
499       $4
500       for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
501         case "$ac_flag" in
502         -D$1)
503           $2=1 ;;
504         -D$1=*)
505           $2=`expr " $ac_flag" : '[[^=]]*=\(.*\)'` ;;
506         esac
507       done
508       ])
509    if test "[$]$2" != no; then
510      AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
511    fi])
513 AC_DEFUN(AC_SYS_LARGEFILE,
514   [AC_REQUIRE([AC_CANONICAL_HOST])
515    AC_ARG_ENABLE(largefile,
516      [  --disable-largefile     omit support for large files])
517    if test "$enable_largefile" != no; then
518      AC_CHECK_TOOL(GETCONF, getconf)
519      AC_SYS_LARGEFILE_FLAGS(CFLAGS)
520      AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
521      AC_SYS_LARGEFILE_FLAGS(LIBS)
523      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
524        case "$ac_flag" in
525        no) ;;
526        -D_FILE_OFFSET_BITS=*) ;;
527        -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
528        -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
529        -D?* | -I?*)
530          AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
531        *)
532          AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
533        esac
534      done
535      AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
536      AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
537      AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
538        ac_cv_sys_file_offset_bits,
539        [Number of bits in a file offset, on hosts where this is settable.],
540        [case "$host_os" in
541         # HP-UX 10.20 and later
542 [       hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
543           ac_cv_sys_file_offset_bits=64 ;;
544         esac])
545      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
546        ac_cv_sys_largefile_source,
547        [Define to make fseeko etc. visible, on some hosts.],
548        [case "$host_os" in
549         # HP-UX 10.20 and later
550 [       hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
551           ac_cv_sys_largefile_source=1 ;;
552         esac])
553      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
554        ac_cv_sys_large_files,
555        [Define for large files, on AIX-style hosts.],
556        [case "$host_os" in
557         # AIX 4.2 and later
558 [       aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)]
559           ac_cv_sys_large_files=1 ;;
560         esac])
561    fi
562   ])
564 #serial 13, with several lines deleted for fileutils.
566 dnl Misc type-related macros for fileutils, sh-utils, textutils.
568 AC_DEFUN(jm_MACROS,
570   AC_PREREQ(2.14a)
572   GNU_PACKAGE="GNU $PACKAGE"
573   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
574     [The concatenation of the strings `GNU ', and PACKAGE.])
575   AC_SUBST(GNU_PACKAGE)
577   AC_SUBST(OPTIONAL_BIN_PROGS)
578   AC_SUBST(OPTIONAL_BIN_ZCRIPTS)
579   AC_SUBST(MAN)
580   AC_SUBST(DF_PROG)
582   dnl This macro actually runs replacement code.  See isc-posix.m4.
583   AC_REQUIRE([AC_ISC_POSIX])dnl
585   AC_CHECK_HEADERS( \
586     errno.h  \
587     fcntl.h \
588     fenv.h \
589     float.h \
590     limits.h \
591     memory.h \
592     mntent.h \
593     mnttab.h \
594     netdb.h \
595     paths.h \
596     stdlib.h \
597     stddef.h \
598     string.h \
599     sys/acl.h \
600     sys/filsys.h \
601     sys/fs/s5param.h \
602     sys/fs_types.h \
603     sys/fstyp.h \
604     sys/ioctl.h \
605     sys/mntent.h \
606     sys/mount.h \
607     sys/param.h \
608     sys/socket.h \
609     sys/statfs.h \
610     sys/statvfs.h \
611     sys/systeminfo.h \
612     sys/time.h \
613     sys/timeb.h \
614     sys/vfs.h \
615     sys/wait.h \
616     syslog.h \
617     termios.h \
618     unistd.h \
619     values.h \
620   )
622   jm_INCLUDED_REGEX([lib/regex.c])
624   AC_REQUIRE([jm_ASSERT])
625   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
626   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
627   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
628   AC_REQUIRE([jm_CHECK_DECLS])
630   AC_REQUIRE([jm_PREREQ])
632   AC_REQUIRE([jm_FUNC_MKTIME])
633   AC_REQUIRE([jm_FUNC_LSTAT])
634   AC_REQUIRE([jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
635   AC_REQUIRE([jm_FUNC_STAT])
636   AC_REQUIRE([jm_FUNC_REALLOC])
637   AC_REQUIRE([jm_FUNC_MALLOC])
638   AC_REQUIRE([jm_FUNC_STRERROR_R])
639   AC_REQUIRE([jm_FUNC_READDIR])
640   AC_REQUIRE([jm_FUNC_MEMCMP])
641   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
642   AC_REQUIRE([jm_FUNC_FNMATCH])
643   AC_REQUIRE([jm_AFS])
644   AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
645   AC_REQUIRE([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK])
646   AC_REQUIRE([AM_FUNC_ERROR_AT_LINE])
647   AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
648   AC_REQUIRE([jm_FUNC_MKTIME])
650   AC_REQUIRE([AC_FUNC_VPRINTF])
651   AC_REQUIRE([AC_FUNC_ALLOCA])
653   AC_REPLACE_FUNCS(strncasecmp)
654   AC_REPLACE_FUNCS(stpcpy strstr strtol strtoul)
655   AC_REPLACE_FUNCS(memcmp)
657   dnl used by e.g. intl/*domain.c and lib/canon-host.c
658   AC_REPLACE_FUNCS(strdup)
660   AC_REPLACE_FUNCS(memcpy memset)
661   AC_CHECK_FUNCS(getpagesize)
663   # By default, argmatch should fail calling usage (1).
664   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
665             [Define to the function xargmatch calls on failures.])
666   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
667             [Define to the declaration of the xargmatch failure function.])
669   dnl Used to define SETVBUF in sys2.h.
670   dnl This evokes the following warning from autoconf:
671   dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
672   AC_FUNC_SETVBUF_REVERSED
674   # used by sleep and shred
675   # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
676   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
677   AC_SEARCH_LIBS(clock_gettime, [rt posix4])
678   AC_CHECK_FUNCS(clock_gettime)
679   AC_CHECK_FUNCS(gettimeofday)
681   AC_CHECK_FUNCS(getdelim)
683   AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
685   AC_CHECK_FUNCS( \
686     acl \
687     bcopy \
688     endgrent \
689     endpwent \
690     fchdir \
691     fdatasync \
692     fseeko \
693     ftime \
694     ftruncate \
695     getcwd \
696     gethrtime \
697     getmntinfo \
698     hasmntopt \
699     isascii \
700     listmntent \
701     localeconv \
702     memcpy \
703     mempcpy \
704     mkfifo \
705     realpath \
706     resolvepath \
707     sethostname \
708     strchr \
709     strerror \
710     strrchr \
711     sysinfo \
712     tzset \
713   )
715   AM_FUNC_GETLINE
716   if test $am_cv_func_working_getline != yes; then
717     AC_CHECK_FUNCS(getdelim)
718   fi
721 AC_DEFUN(jm_CHECK_ALL_TYPES,
723   dnl Checks for typedefs, structures, and compiler characteristics.
724   AC_REQUIRE([AC_C_BIGENDIAN])
725   AC_REQUIRE([AC_PROG_CC_STDC])
726   AC_REQUIRE([AC_C_CONST])
727   AC_REQUIRE([AC_C_VOLATILE])
728   AC_REQUIRE([AC_C_INLINE])
729   AC_REQUIRE([AC_C_LONG_DOUBLE])
731   AC_REQUIRE([AC_HEADER_DIRENT])
732   AC_REQUIRE([AC_HEADER_STDC])
733   AC_CHECK_MEMBERS((struct stat.st_blksize),,,[$ac_includes_default
734 #include <sys/stat.h>
735   ])
736   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
738   AC_REQUIRE([AC_STRUCT_TM])
739   AC_REQUIRE([AC_STRUCT_TIMEZONE])
740   AC_REQUIRE([AC_HEADER_STAT])
741   AC_REQUIRE([AC_STRUCT_ST_MTIM_NSEC])
742   AC_REQUIRE([AC_STRUCT_ST_DM_MODE])
743   AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
745   AC_REQUIRE([AC_TYPE_GETGROUPS])
746   AC_REQUIRE([AC_TYPE_MODE_T])
747   AC_REQUIRE([AC_TYPE_OFF_T])
748   AC_REQUIRE([AC_TYPE_PID_T])
749   AC_REQUIRE([AC_TYPE_SIGNAL])
750   AC_REQUIRE([AC_TYPE_SIZE_T])
751   AC_REQUIRE([AC_TYPE_UID_T])
752   AC_CHECK_TYPE(ino_t, unsigned long)
754   dnl This relies on the fact that autoconf 2.14a's implementation of
755   dnl AC_CHECK_TYPE checks includes unistd.h.
756   AC_CHECK_TYPE(ssize_t, int)
758   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
759   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
761   AC_REQUIRE([AC_HEADER_MAJOR])
762   AC_REQUIRE([AC_HEADER_DIRENT])
766 #serial 7
768 dnl Initially derived from code in GNU grep.
769 dnl Mostly written by Jim Meyering.
771 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
773 AC_DEFUN(jm_INCLUDED_REGEX,
774   [
775     dnl Even packages that don't use regex.c can use this macro.
776     dnl Of course, for them it doesn't do anything.
778     # Assume we'll default to using the included regex.c.
779     ac_use_included_regex=yes
781     # However, if the system regex support is good enough that it passes the
782     # the following run test, then default to *not* using the included regex.c.
783     # If cross compiling, assume the test would fail and use the included
784     # regex.c.  The first failing regular expression is from `Spencer ere
785     # test #75' in grep-2.3.
786     AC_CACHE_CHECK([for working re_compile_pattern],
787                    jm_cv_func_working_re_compile_pattern,
788       AC_TRY_RUN(
789 [#include <stdio.h>
790 #include <regex.h>
791           int
792           main ()
793           {
794             static struct re_pattern_buffer regex;
795             const char *s;
796             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
797             /* Add this third left square bracket, [, to balance the
798                three right ones below.  Otherwise autoconf-2.14 chokes.  */
799             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
800             /* This should fail with _Invalid character class name_ error.  */
801             if (!s)
802               exit (1);
804             /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
805             s = re_compile_pattern ("{1", 2, &regex);
807             exit (s ? 1 : 0);
808           }
809         ],
810                jm_cv_func_working_re_compile_pattern=yes,
811                jm_cv_func_working_re_compile_pattern=no,
812                dnl When crosscompiling, assume it's broken.
813                jm_cv_func_working_re_compile_pattern=no))
814     if test $jm_cv_func_working_re_compile_pattern = yes; then
815       ac_use_included_regex=no
816     fi
818     test -n "$1" || AC_MSG_ERROR([missing argument])
819     syscmd([test -f $1])
820     ifelse(sysval, 0,
821       [
823         AC_ARG_WITH(included-regex,
824         [  --without-included-regex don't compile regex; this is the default on
825                           systems with version 2 of the GNU C library
826                           (use with caution on other system)],
827                     jm_with_regex=$withval,
828                     jm_with_regex=$ac_use_included_regex)
829         if test "$jm_with_regex" = yes; then
830           AC_SUBST(LIBOBJS)
831           LIBOBJS="$LIBOBJS regex.$ac_objext"
832         fi
833       ],
834     )
835   ]
838 #serial 2
839 dnl based on code from Eleftherios Gkioulekas
841 AC_DEFUN(jm_ASSERT,
843   AC_MSG_CHECKING(whether to enable assertions)
844   AC_ARG_ENABLE(assert,
845         [  --disable-assert        turn off assertions],
846         [ AC_MSG_RESULT(no)
847           AC_DEFINE(NDEBUG,1,[Define to 1 if assertions should be disabled.]) ],
848         [ AC_MSG_RESULT(yes) ]
849                )
852 #serial 3
854 dnl From Paul Eggert.
856 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
857 # doesn't clash with <sys/types.h>, and declares uintmax_t.
859 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
861   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
862   [AC_TRY_COMPILE(
863     [#include <sys/types.h>
864 #include <inttypes.h>],
865     [uintmax_t i = (uintmax_t) -1;],
866     jm_ac_cv_header_inttypes_h=yes,
867     jm_ac_cv_header_inttypes_h=no)])
868   if test $jm_ac_cv_header_inttypes_h = yes; then
869     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
870 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
871    and declares uintmax_t. ])
872   fi
875 #serial 3
877 dnl From Jim Meyering.
879 dnl Check whether struct dirent has a member named d_type.
882 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
883   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
884    AC_CACHE_CHECK([for d_type member in directory struct],
885                   jm_cv_struct_dirent_d_type,
886      [AC_TRY_LINK(dnl
887        [
888 #include <sys/types.h>
889 #ifdef HAVE_DIRENT_H
890 # include <dirent.h>
891 #else /* not HAVE_DIRENT_H */
892 # define dirent direct
893 # ifdef HAVE_SYS_NDIR_H
894 #  include <sys/ndir.h>
895 # endif /* HAVE_SYS_NDIR_H */
896 # ifdef HAVE_SYS_DIR_H
897 #  include <sys/dir.h>
898 # endif /* HAVE_SYS_DIR_H */
899 # ifdef HAVE_NDIR_H
900 #  include <ndir.h>
901 # endif /* HAVE_NDIR_H */
902 #endif /* HAVE_DIRENT_H */
903        ],
904        [struct dirent dp; dp.d_type = 0;],
906        jm_cv_struct_dirent_d_type=yes,
907        jm_cv_struct_dirent_d_type=no)
908      ]
909    )
910    if test $jm_cv_struct_dirent_d_type = yes; then
911      AC_DEFINE(D_TYPE_IN_DIRENT, 1,
912   [Define if there is a member named d_type in the struct describing
913    directory headers.])
914    fi
915   ]
918 #serial 3
920 dnl From Jim Meyering.
922 dnl Check whether struct dirent has a member named d_ino.
925 AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
926   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
927    AC_CACHE_CHECK([for d_ino member in directory struct],
928                   jm_cv_struct_dirent_d_ino,
929      [AC_TRY_LINK(dnl
930        [
931 #include <sys/types.h>
932 #ifdef HAVE_DIRENT_H
933 # include <dirent.h>
934 #else /* not HAVE_DIRENT_H */
935 # define dirent direct
936 # ifdef HAVE_SYS_NDIR_H
937 #  include <sys/ndir.h>
938 # endif /* HAVE_SYS_NDIR_H */
939 # ifdef HAVE_SYS_DIR_H
940 #  include <sys/dir.h>
941 # endif /* HAVE_SYS_DIR_H */
942 # ifdef HAVE_NDIR_H
943 #  include <ndir.h>
944 # endif /* HAVE_NDIR_H */
945 #endif /* HAVE_DIRENT_H */
946        ],
947        [struct dirent dp; dp.d_ino = 0;],
949        jm_cv_struct_dirent_d_ino=yes,
950        jm_cv_struct_dirent_d_ino=no)
951      ]
952    )
953    if test $jm_cv_struct_dirent_d_ino = yes; then
954      AC_DEFINE(D_INO_IN_DIRENT, 1,
955   [Define if there is a member named d_ino in the struct describing
956    directory headers.])
957    fi
958   ]
961 #serial 9, except remove memchr and nanosleep as findutils doesn't need them
963 dnl This is just a wrapper function to encapsulate this kludge.
964 dnl Putting it in a separate file like this helps share it between
965 dnl different packages.
966 AC_DEFUN(jm_CHECK_DECLS,
968   AC_REQUIRE([_jm_DECL_HEADERS])
969   AC_REQUIRE([AC_HEADER_TIME])
970   headers='
971 #include <stdio.h>
972 #if HAVE_STRING_H
973 # if !STDC_HEADERS && HAVE_MEMORY_H
974 #  include <memory.h>
975 # endif
976 # include <string.h>
977 #else
978 # if HAVE_STRINGS_H
979 #  include <strings.h>
980 # endif
981 #endif
982 #if HAVE_STDLIB_H
983 # include <stdlib.h>
984 #endif
985 #if HAVE_UNISTD_H
986 # include <unistd.h>
987 #endif
989 #include <sys/types.h>
990 #if TIME_WITH_SYS_TIME
991 # include <sys/time.h>
992 # include <time.h>
993 #else
994 # if HAVE_SYS_TIME_H
995 #  include <sys/time.h>
996 # else
997 #  include <time.h>
998 # endif
999 #endif
1002   AC_CHECK_DECLS((
1003     free,
1004     getenv,
1005     geteuid,
1006     getlogin,
1007     lseek,
1008     malloc,
1009     realloc,
1010     stpcpy,
1011     strstr,
1012     strtoul,
1013     strtoull,
1014     ttyname), , , $headers)
1017 dnl FIXME: when autoconf has support for it.
1018 dnl This is a little helper so we can require these header checks.
1019 AC_DEFUN(_jm_DECL_HEADERS,
1021   AC_REQUIRE([AC_HEADER_STDC])
1022   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h)
1025 #serial 5
1027 dnl These are the prerequisite macros for files in the lib/
1028 dnl directories of the fileutils, sh-utils, and textutils packages.
1030 AC_DEFUN(jm_PREREQ,
1032   jm_PREREQ_ADDEXT
1033   jm_PREREQ_CANON_HOST
1034   jm_PREREQ_ERROR
1035   jm_PREREQ_QUOTEARG
1036   jm_PREREQ_READUTMP
1037   jm_PREREQ_REGEX
1040 AC_DEFUN(jm_PREREQ_ADDEXT,
1042   dnl For addext.c.
1043   AC_SYS_LONG_FILE_NAMES
1044   AC_CHECK_FUNCS(pathconf)
1045   AC_CHECK_HEADERS(limits.h string.h unistd.h)
1048 AC_DEFUN(jm_PREREQ_CANON_HOST,
1050   dnl Add any libraries as early as possible.
1051   dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
1052   dnl so we have to add -lnsl to LIBS before checking for that function.
1053   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
1055   dnl These come from -lnsl on Solaris5.5.1.
1056   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1058   AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
1059   AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
1060                    netinet/in.h arpa/inet.h)
1063 AC_DEFUN(jm_PREREQ_QUOTEARG,
1065   AC_CHECK_FUNCS(isascii mbrtowc)
1066   AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
1067   AC_HEADER_STDC
1068   AC_C_BACKSLASH_A
1069   AM_C_PROTOTYPES
1072 AC_DEFUN(jm_PREREQ_READUTMP,
1074   AC_HEADER_STDC
1075   AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
1076   AC_CHECK_FUNCS(utmpname)
1077   AC_CHECK_FUNCS(utmpxname)
1078   AM_C_PROTOTYPES
1080   utmp_includes="\
1081 $ac_includes_default
1082 #ifdef HAVE_UTMPX_H
1083 # include <utmpx.h>
1084 #else
1085 # include <utmp.h>
1086 #endif
1088   AC_CHECK_MEMBERS((struct utmpx.ut_user),,,[$utmp_includes])
1089   AC_CHECK_MEMBERS((struct utmp.ut_user),,,[$utmp_includes])
1090   AC_CHECK_MEMBERS((struct utmpx.ut_name),,,[$utmp_includes])
1091   AC_CHECK_MEMBERS((struct utmp.ut_name),,,[$utmp_includes])
1094 AC_DEFUN(jm_PREREQ_REGEX,
1096   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
1097   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
1098   dnl to get them.
1099   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
1100   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
1101   AC_HEADER_STDC
1102   AC_FUNC_ALLOCA
1105 #serial 1
1107 dnl FIXME: put these prerequisite-only *.m4 files in a separate
1108 dnl directory -- otherwise, they'll conflict with existing files.
1110 dnl These are the prerequisite macros for GNU's error.c file.
1111 AC_DEFUN(jm_PREREQ_ERROR,
1113   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
1114   AC_HEADER_STDC
1117 #serial 3
1119 dnl From Paul Eggert.
1121 AC_DEFUN(AC_C_BACKSLASH_A,
1123   AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1124    [AC_TRY_COMPILE([],
1125      [
1126 #if '\a' == 'a'
1127       syntax error;
1128 #endif
1129       char buf['\a' == 'a' ? -1 : 1];
1130       buf[0] = '\a';
1131       return buf[0] != "\a"[0];
1132      ],
1133      ac_cv_c_backslash_a=yes,
1134      ac_cv_c_backslash_a=no)])
1135   if test $ac_cv_c_backslash_a = yes; then
1136     AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1137       [Define if backslash-a works in C strings.])
1138   fi
1141 #serial 7
1143 dnl From Jim Meyering.
1144 dnl A wrapper around AC_FUNC_MKTIME.
1146 AC_DEFUN(jm_FUNC_MKTIME,
1147 [AC_REQUIRE([AC_FUNC_MKTIME])dnl
1149  dnl mktime.c uses localtime_r if it exists.  Check for it.
1150  AC_CHECK_FUNCS(localtime_r)
1152  if test $ac_cv_func_working_mktime = no; then
1153    AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
1154     [Define to rpl_mktime if the replacement function should be used.])
1155  fi
1158 #serial 3
1160 dnl From Jim Meyering.
1161 dnl Determine whether lstat has the bug that it succeeds when given the
1162 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
1163 dnl (as of 1998-11-01) do this.
1165 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
1166 dnl compile the wrapper function.
1169 AC_DEFUN(jm_FUNC_LSTAT,
1171  AC_CACHE_CHECK([whether lstat accepts an empty string],
1172   jm_cv_func_lstat_empty_string_bug,
1173   [AC_TRY_RUN([
1174 #   include <sys/types.h>
1175 #   include <sys/stat.h>
1177     int
1178     main ()
1179     {
1180       struct stat sbuf;
1181       exit (lstat ("", &sbuf) ? 1 : 0);
1182     }
1183           ],
1184          jm_cv_func_lstat_empty_string_bug=yes,
1185          jm_cv_func_lstat_empty_string_bug=no,
1186          dnl When crosscompiling, assume lstat is broken.
1187          jm_cv_func_lstat_empty_string_bug=yes)
1188   ])
1189   if test $jm_cv_func_lstat_empty_string_bug = yes; then
1190     AC_SUBST(LIBOBJS)
1191     LIBOBJS="$LIBOBJS lstat.$ac_objext"
1192     AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
1193 [Define if lstat has the bug that it succeeds when given the zero-length
1194    file name argument.  The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1195    do this. ])
1196   fi
1199 #serial 1
1201 dnl From Jim Meyering.
1202 dnl FIXME: describe
1204 AC_DEFUN(jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK,
1206  AC_CACHE_CHECK(
1207   [whether lstat dereferences a symlink specified with a trailing slash],
1208   jm_cv_func_lstat_dereferences_slashed_symlink,
1209   [
1210    rm -f conftest.sym conftest.file
1211    : > conftest.file
1212    if ln -s conftest.file conftest.sym; then
1213      AC_TRY_RUN([
1214 #     include <sys/types.h>
1215 #     include <sys/stat.h>
1217       int
1218       main ()
1219       {
1220         struct stat sbuf;
1221         /* Linux will dereference the symlink and fail.
1222            That is better in the sense that it means we will not
1223            have to compile and use the lstat wrapper.  */
1224         exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
1225       }
1226       ],
1227       jm_cv_func_lstat_dereferences_slashed_symlink=yes,
1228       jm_cv_func_lstat_dereferences_slashed_symlink=no,
1229       dnl When crosscompiling, be pessimistic so we will end up using the
1230       dnl replacement version of lstat that checkes for trailing slashes
1231       dnl and calls lstat a second time when necessary.
1232       jm_cv_func_lstat_dereferences_slashed_symlink=no
1233      )
1234    else
1235      # If the `ln -s' command failed, then we probably don't even
1236      # have an lstat function.
1237      jm_cv_func_lstat_dereferences_slashed_symlink=no
1238    fi
1239   ])
1241   test $jm_cv_func_lstat_dereferences_slashed_symlink = yes \
1242     && zero_one=1 \
1243     || zero_one=0
1244   AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, $zero_one,
1245     [Define if lstat dereferences a symlink specified with a trailing slash])
1247   if test $jm_cv_func_lstat_dereferences_slashed_symlink = no; then
1248     AC_SUBST(LIBOBJS)
1249     # Append lstat.o if it's not already in $LIBOBJS.
1250     case "$LIBOBJS" in
1251       *lstat.$ac_objext*) ;;
1252       *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
1253     esac
1254   fi
1257 #serial 3
1259 dnl From Jim Meyering.
1260 dnl Determine whether stat has the bug that it succeeds when given the
1261 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
1262 dnl (as of 1998-11-01) do this.
1264 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
1265 dnl compile the wrapper function.
1268 AC_DEFUN(jm_FUNC_STAT,
1270  AC_CACHE_CHECK([whether stat accepts an empty string],
1271   jm_cv_func_stat_empty_string_bug,
1272   [AC_TRY_RUN([
1273 #   include <sys/types.h>
1274 #   include <sys/stat.h>
1276     int
1277     main ()
1278     {
1279       struct stat sbuf;
1280       exit (stat ("", &sbuf) ? 1 : 0);
1281     }
1282           ],
1283          jm_cv_func_stat_empty_string_bug=yes,
1284          jm_cv_func_stat_empty_string_bug=no,
1285          dnl When crosscompiling, assume stat is broken.
1286          jm_cv_func_stat_empty_string_bug=yes)
1287   ])
1288   if test $jm_cv_func_stat_empty_string_bug = yes; then
1289     AC_SUBST(LIBOBJS)
1290     LIBOBJS="$LIBOBJS stat.$ac_objext"
1291     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
1292 [Define if stat has the bug that it succeeds when given the zero-length
1293    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
1294    do this. ])
1295   fi
1298 #serial 3
1300 dnl From Jim Meyering.
1301 dnl Determine whether realloc works when both arguments are 0.
1302 dnl If it doesn't, arrange to use the replacement function.
1305 AC_DEFUN(jm_FUNC_REALLOC,
1307  dnl xmalloc.c requires that this symbol be defined so it doesn't
1308  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
1309  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
1310                     [Define if the realloc check has been performed. ])
1312  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
1313   [AC_TRY_RUN([
1314     char *realloc ();
1315     int
1316     main ()
1317     {
1318       exit (realloc (0, 0) ? 0 : 1);
1319     }
1320           ],
1321          jm_cv_func_working_realloc=yes,
1322          jm_cv_func_working_realloc=no,
1323          dnl When crosscompiling, assume realloc is broken.
1324          jm_cv_func_working_realloc=no)
1325   ])
1326   if test $jm_cv_func_working_realloc = no; then
1327     AC_SUBST(LIBOBJS)
1328     LIBOBJS="$LIBOBJS realloc.$ac_objext"
1329     AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
1330       [Define to rpl_realloc if the replacement function should be used.])
1331   fi
1334 #serial 3
1336 dnl From Jim Meyering.
1337 dnl Determine whether malloc accepts 0 as its argument.
1338 dnl If it doesn't, arrange to use the replacement function.
1341 AC_DEFUN(jm_FUNC_MALLOC,
1343  dnl xmalloc.c requires that this symbol be defined so it doesn't
1344  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
1345  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
1346                     [Define if the malloc check has been performed. ])
1348  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1349   [AC_TRY_RUN([
1350     char *malloc ();
1351     int
1352     main ()
1353     {
1354       exit (malloc (0) ? 0 : 1);
1355     }
1356           ],
1357          jm_cv_func_working_malloc=yes,
1358          jm_cv_func_working_malloc=no,
1359          dnl When crosscompiling, assume malloc is broken.
1360          jm_cv_func_working_malloc=no)
1361   ])
1362   if test $jm_cv_func_working_malloc = no; then
1363     AC_SUBST(LIBOBJS)
1364     LIBOBJS="$LIBOBJS malloc.$ac_objext"
1365     AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
1366       [Define to rpl_malloc if the replacement function should be used.])
1367   fi
1370 #serial 2
1372 dnl From Jim Meyering.
1373 dnl Determine whether the strerror_r implementation is one of
1374 dnl the broken ones that returns `int' rather than `char*'.
1375 dnl Actually, this tests only whether it returns a scalar
1376 dnl or an array, but that should be enough.
1377 dnl On at least DEC UNIX 4.0[A-D] and HP-UX B.10.20, strerror_r
1378 dnl returns `int'.  This is used by lib/error.c.
1380 AC_DEFUN(jm_FUNC_STRERROR_R,
1382   # Check strerror_r
1383   AC_CHECK_FUNCS([strerror_r])
1384   if test $ac_cv_func_strerror_r = yes; then
1385     AC_CHECK_HEADERS(string.h)
1386     AC_CACHE_CHECK([for working strerror_r],
1387                    jm_cv_func_working_strerror_r,
1388      [
1389       AC_TRY_COMPILE(
1390        [
1391 #       include <stdio.h>
1392 #       if HAVE_STRING_H
1393 #        include <string.h>
1394 #       endif
1395        ],
1396        [
1397          int buf; /* avoiding square brackets makes this easier */
1398          char x = *strerror_r (0, buf, sizeof buf);
1399        ],
1400        jm_cv_func_working_strerror_r=yes,
1401        jm_cv_func_working_strerror_r=no
1402       )
1403       if test $jm_cv_func_working_strerror_r = yes; then
1404         AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
1405           [Define to 1 if strerror_r returns a string.])
1406       fi
1407     ])
1408   fi
1411 #serial 3
1413 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1414 dnl to test whether a NULL return value really means there are no more files
1415 dnl in the directory.
1417 dnl Detect the problem by creating a directory containing 300 files (254 not
1418 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1419 dnl removes all of them.
1421 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1423 dnl Written by Jim Meyering.
1425 AC_DEFUN(jm_FUNC_READDIR,
1426 [dnl
1427 AC_REQUIRE([AC_HEADER_DIRENT])
1428 AC_CHECK_HEADERS(string.h)
1429 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1430   [dnl
1431   # Arrange for deletion of the temporary directory this test creates, in
1432   # case the test itself fails to delete everything -- as happens on Sunos.
1433   ac_clean_files="$ac_clean_files conf-dir"
1435   AC_TRY_RUN(
1436 [#   include <stdio.h>
1437 #   include <sys/types.h>
1438 #   if HAVE_STRING_H
1439 #    include <string.h>
1440 #   endif
1442 #   ifdef HAVE_DIRENT_H
1443 #    include <dirent.h>
1444 #    define NLENGTH(direct) (strlen((direct)->d_name))
1445 #   else /* not HAVE_DIRENT_H */
1446 #    define dirent direct
1447 #    define NLENGTH(direct) ((direct)->d_namlen)
1448 #    ifdef HAVE_SYS_NDIR_H
1449 #     include <sys/ndir.h>
1450 #    endif /* HAVE_SYS_NDIR_H */
1451 #    ifdef HAVE_SYS_DIR_H
1452 #     include <sys/dir.h>
1453 #    endif /* HAVE_SYS_DIR_H */
1454 #    ifdef HAVE_NDIR_H
1455 #     include <ndir.h>
1456 #    endif /* HAVE_NDIR_H */
1457 #   endif /* HAVE_DIRENT_H */
1459 #   define DOT_OR_DOTDOT(Basename) \
1460      (Basename[0] == '.' && (Basename[1] == '\0' \
1461                              || (Basename[1] == '.' && Basename[2] == '\0')))
1463     static void
1464     create_300_file_dir (const char *dir)
1465     {
1466       int i;
1468       if (mkdir (dir, 0700))
1469         abort ();
1470       if (chdir (dir))
1471         abort ();
1473       for (i = 0; i < 300; i++)
1474         {
1475           char file_name[4];
1476           FILE *out;
1478           sprintf (file_name, "%03d", i);
1479           out = fopen (file_name, "w");
1480           if (!out)
1481             abort ();
1482           if (fclose (out) == EOF)
1483             abort ();
1484         }
1486       if (chdir (".."))
1487         abort ();
1488     }
1490     static void
1491     remove_dir (const char *dir)
1492     {
1493       DIR *dirp;
1495       if (chdir (dir))
1496         abort ();
1498       dirp = opendir (".");
1499       if (dirp == NULL)
1500         abort ();
1502       while (1)
1503         {
1504           struct dirent *dp = readdir (dirp);
1505           if (dp == NULL)
1506             break;
1508           if (DOT_OR_DOTDOT (dp->d_name))
1509             continue;
1511           if (unlink (dp->d_name))
1512             abort ();
1513         }
1514       closedir (dirp);
1516       if (chdir (".."))
1517         abort ();
1519       if (rmdir (dir))
1520         exit (1);
1521     }
1523     int
1524     main ()
1525     {
1526       const char *dir = "conf-dir";
1527       create_300_file_dir (dir);
1528       remove_dir (dir);
1529       exit (0);
1530     }],
1531   jm_cv_func_working_readdir=yes,
1532   jm_cv_func_working_readdir=no,
1533   jm_cv_func_working_readdir=no)])
1535   if test $jm_cv_func_working_readdir = yes; then
1536     AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
1537 [Define if readdir is found to work properly in some unusual cases. ])
1538   fi
1541 #serial 4
1543 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1544 dnl the losing memcmp on some x86 Next systems.
1545 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1546 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1547 [AC_TRY_RUN(
1548 [int
1549 main ()
1551   /* Some versions of memcmp are not 8-bit clean.  */
1552   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1553   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1554     exit (1);
1556   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1557      or more and with at least one buffer not starting on a 4-byte boundary.
1558      William Lewis provided this test program.   */
1559   {
1560     char foo[21];
1561     char bar[21];
1562     int i;
1563     for (i = 0; i < 4; i++)
1564       {
1565         char *a = foo + i;
1566         char *b = bar + i;
1567         strcpy (a, "--------01111111");
1568         strcpy (b, "--------10000000");
1569         if (memcmp (a, b, 16) >= 0)
1570           exit (1);
1571       }
1572     exit (0);
1573   }
1575    jm_cv_func_memcmp_working=yes,
1576    jm_cv_func_memcmp_working=no,
1577    jm_cv_func_memcmp_working=no)])
1578 test $jm_cv_func_memcmp_working = no \
1579   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
1580 AC_SUBST(LIBOBJS)dnl
1583 AC_DEFUN(jm_FUNC_MEMCMP,
1584 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1585  if test $jm_cv_func_memcmp_working = no; then
1586    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
1587      [Define to rpl_memcmp if the replacement function should be used.])
1588  fi
1591 #serial 3
1593 dnl From Jim Meyering.
1595 dnl See if the glibc *_unlocked I/O macros are available.
1596 dnl Use only those *_unlocked macros that are declared.
1599 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1600   [
1601     io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
1602     fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
1603     getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
1604     for jm_io_func in $io_functions; do
1605       # Check for the existence of each function only if its declared.
1606       # Otherwise, we'd get the Solaris5.5.1 functions that are not
1607       # declared, and that have been removed from Solaris5.6.  The resulting
1608       # 5.5.1 binaries would not run on 5.6 due to shared library differences.
1609       AC_CHECK_DECLS(($jm_io_func),
1610                      jm_declared=yes,
1611                      jm_declared=no,
1612                      [#include <stdio.h>])
1613       if test $jm_declared = yes; then
1614         AC_CHECK_FUNCS($jm_io_func)
1615       fi
1616     done
1617   ]
1620 #serial 2
1622 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1623 dnl define fnmatch to rpl_fnmatch.
1626 AC_DEFUN(jm_FUNC_FNMATCH,
1628   AC_REQUIRE([AM_GLIBC])
1629   AC_FUNC_FNMATCH
1630   if test $ac_cv_func_fnmatch_works = no \
1631       && test $ac_cv_gnu_library = no; then
1632     AC_SUBST(LIBOBJS)
1633     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
1634     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
1635       [Define to rpl_fnmatch if the replacement function should be used.])
1636   fi
1639 #serial 2
1641 dnl From Gordon Matzigkeit.
1642 dnl Test for the GNU C Library.
1643 dnl FIXME: this should migrate into libit.
1645 AC_DEFUN(AM_GLIBC,
1646   [
1647     AC_CACHE_CHECK(whether we are using the GNU C Library,
1648       ac_cv_gnu_library,
1649       [AC_EGREP_CPP([Thanks for using GNU],
1650         [
1651 #include <features.h>
1652 #ifdef __GNU_LIBRARY__
1653   Thanks for using GNU
1654 #endif
1655         ],
1656         ac_cv_gnu_library=yes,
1657         ac_cv_gnu_library=no)
1658       ]
1659     )
1660     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1661       ac_cv_glibc,
1662       [AC_EGREP_CPP([Thanks for using GNU too],
1663         [
1664 #include <features.h>
1665 #ifdef __GLIBC__
1666   Thanks for using GNU too
1667 #endif
1668         ],
1669         ac_cv_glibc=yes, ac_cv_glibc=no)
1670       ]
1671     )
1672   ]
1675 #serial 1
1677 AC_DEFUN(jm_AFS,
1678   AC_CHECKING(for AFS)
1679   test -d /afs \
1680     && AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
1683 #serial 2
1685 # autoconf tests required for use of xstrtoumax.c
1687 AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
1689   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
1690   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
1691   AC_CHECK_HEADERS(stdlib.h)
1693   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
1694     jm_cv_func_strtoumax_macro,
1695     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
1696 #ifdef strtoumax
1697  inttypes_h_defines_strtoumax
1698 #endif],
1699       jm_cv_func_strtoumax_macro=yes,
1700       jm_cv_func_strtoumax_macro=no))
1702   if test "$jm_cv_func_strtoumax_macro" != yes; then
1703     AC_REPLACE_FUNCS(strtoumax)
1704   fi
1706   dnl We don't need (and can't compile) the replacement strtoull
1707   dnl unless the type `unsigned long long' exists.
1708   dnl Also, only the replacement strtoumax invokes strtoull,
1709   dnl so we need the replacement strtoull only if strtoumax does not exist.
1710   case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
1711     yes,no,no)
1712       AC_REPLACE_FUNCS(strtoull)
1713       ;;
1714   esac
1718 #serial 2
1720 dnl From Paul Eggert.
1722 AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
1724   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
1725   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
1726     [unsigned long long ullmax = (unsigned long long) -1;
1727      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
1728     ac_cv_type_unsigned_long_long=yes,
1729     ac_cv_type_unsigned_long_long=no)])
1730   if test $ac_cv_type_unsigned_long_long = yes; then
1731     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
1732       [Define if you have the unsigned long long type.])
1733   fi
1736 #serial 1
1737 dnl Run a program to determine whether whether link(2) follows symlinks.
1738 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
1740 AC_DEFUN(jm_AC_FUNC_LINK_FOLLOWS_SYMLINK,
1741 [dnl
1742   AC_CACHE_CHECK([whether link(2) follows symlinks],
1743                  jm_ac_cv_func_link_follows_symlink,
1744   [
1745     dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
1746     dnl the appropriate framework.
1747     test -z "$ac_cv_header_unistd_h" \
1748       && AC_CHECK_HEADERS(unistd.h)
1750     # Create a regular file.
1751     echo > conftest.file
1752     AC_TRY_RUN(
1753       [
1754 #       include <sys/types.h>
1755 #       include <sys/stat.h>
1756 #       ifdef HAVE_UNISTD_H
1757 #        include <unistd.h>
1758 #       endif
1760 #       define SAME_INODE(Stat_buf_1, Stat_buf_2) \
1761           ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
1762            && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
1764         int
1765         main ()
1766         {
1767           const char *file = "conftest.file";
1768           const char *sym = "conftest.sym";
1769           const char *hard = "conftest.hard";
1770           struct stat sb_file, sb_hard;
1772           /* Create a symlink to the regular file. */
1773           if (symlink (file, sym))
1774             abort ();
1776           /* Create a hard link to that symlink.  */
1777           if (link (sym, hard))
1778             abort ();
1780           if (lstat (hard, &sb_hard))
1781             abort ();
1782           if (lstat (file, &sb_file))
1783             abort ();
1785           /* If the dev/inode of hard and file are the same, then
1786              the link call followed the symlink.  */
1787           return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
1788         }
1789       ],
1790       jm_ac_cv_func_link_follows_symlink=yes,
1791       jm_ac_cv_func_link_follows_symlink=no,
1792       jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
1793     )
1794   ])
1795   if test $jm_ac_cv_func_link_follows_symlink = yes; then
1796     AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
1797       [Define if `link(2)' dereferences symbolic links.])
1798   fi
1801 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
1802 dnl FIXME: Migrate into libit
1804 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
1805 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1806  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1807               am_cv_lib_error_at_line=yes,
1808               am_cv_lib_error_at_line=no)])
1809  if test $am_cv_lib_error_at_line = no; then
1810    LIBOBJS="$LIBOBJS error.$ac_objext"
1811  fi
1812  AC_SUBST(LIBOBJS)dnl
1815 #serial 9
1817 dnl This macro is intended to be used solely in this file.
1818 dnl These are the prerequisite macros for GNU's strftime.c replacement.
1819 AC_DEFUN(_jm_STRFTIME_PREREQS,
1821  dnl strftime.c uses localtime_r if it exists.  Check for it.
1822  AC_CHECK_FUNCS(localtime_r)
1824  AC_CHECK_HEADERS(limits.h)
1825  AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
1827  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
1828  AC_STRUCT_TIMEZONE
1830  AC_CHECK_FUNCS(mblen mbrlen)
1832  AC_CHECK_MEMBER(struct tm.tm_gmtoff,
1833                  [AC_DEFINE(HAVE_TM_GMTOFF, 1,
1834                             [Define if struct tm has the tm_gmtoff member.])],
1835                  ,
1836                  [#include <time.h>])
1839 dnl Determine if the strftime function has all the features of the GNU one.
1841 dnl From Jim Meyering.
1843 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
1844 [AC_REQUIRE([AC_HEADER_TIME])dnl
1846  _jm_STRFTIME_PREREQS
1848  AC_REQUIRE([AC_C_CONST])dnl
1849  AC_REQUIRE([AC_HEADER_STDC])dnl
1850  AC_CHECK_HEADERS(sys/time.h)
1851  AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
1852   [# Set TZ to GMT0 to make strftime give consistent results during the test.
1853    ac_save_TZ="${TZ-GMT0}"
1854    TZ=GMT0
1855    export TZ
1856    AC_TRY_RUN(
1857 [ /* Ulrich Drepper provided parts of the test program.  */
1858 #if STDC_HEADERS
1859 # include <stdlib.h>
1860 #endif
1862 #if TIME_WITH_SYS_TIME
1863 # include <sys/time.h>
1864 # include <time.h>
1865 #else
1866 # if HAVE_SYS_TIME_H
1867 #  include <sys/time.h>
1868 # else
1869 #  include <time.h>
1870 # endif
1871 #endif
1873 static int
1874 compare (const char *fmt, const struct tm *tm, const char *expected)
1876   char buf[99];
1877   strftime (buf, 99, fmt, tm);
1878   if (strcmp (buf, expected))
1879     {
1880 #ifdef SHOW_FAILURES
1881       printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
1882               fmt, expected, buf);
1883 #endif
1884       return 1;
1885     }
1886   return 0;
1890 main ()
1892   int n_fail = 0;
1893   struct tm *tm;
1894   time_t t = 738367; /* Fri Jan  9 13:06:07 1970 */
1895   tm = gmtime (&t);
1897 #undef CMP
1898 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
1900   CMP ("%-m", "1");             /* GNU */
1901   CMP ("%A", "Friday");
1902   CMP ("%^A", "FRIDAY");        /* The ^ is a GNU extension.  */
1903   CMP ("%B", "January");
1904   CMP ("%^B", "JANUARY");
1905   CMP ("%C", "19");             /* POSIX.2 */
1906   CMP ("%D", "01/09/70");       /* POSIX.2 */
1907   CMP ("%F", "1970-01-09");
1908   CMP ("%G", "1970");           /* GNU */
1909   CMP ("%H", "13");
1910   CMP ("%I", "01");
1911   CMP ("%M", "06");
1912   CMP ("%M", "06");
1913   CMP ("%R", "13:06");          /* POSIX.2 */
1914   CMP ("%S", "07");
1915   CMP ("%T", "13:06:07");       /* POSIX.2 */
1916   CMP ("%U", "01");
1917   CMP ("%V", "02");
1918   CMP ("%W", "01");
1919   CMP ("%X", "13:06:07");
1920   CMP ("%Y", "1970");
1921   CMP ("%Z", "GMT");
1922   CMP ("%_m", " 1");            /* GNU */
1923   CMP ("%a", "Fri");
1924   CMP ("%^a", "FRI");
1925   CMP ("%b", "Jan");
1926   CMP ("%^b", "JAN");
1927   CMP ("%c", "Fri Jan  9 13:06:07 1970");
1928   CMP ("%^c", "FRI JAN  9 13:06:07 1970");
1929   CMP ("%d", "09");
1930   CMP ("%e", " 9");             /* POSIX.2 */
1931   CMP ("%g", "70");             /* GNU */
1932   CMP ("%h", "Jan");            /* POSIX.2 */
1933   CMP ("%^h", "JAN");
1934   CMP ("%j", "009");
1935   CMP ("%k", "13");             /* GNU */
1936   CMP ("%l", " 1");             /* GNU */
1937   CMP ("%m", "01");
1938   CMP ("%n", "\n");             /* POSIX.2 */
1939   CMP ("%p", "PM");
1940   CMP ("%r", "01:06:07 PM");    /* POSIX.2 */
1941   CMP ("%s", "738367");         /* GNU */
1942   CMP ("%t", "\t");             /* POSIX.2 */
1943   CMP ("%u", "5");              /* POSIX.2 */
1944   CMP ("%w", "5");
1945   CMP ("%x", "01/09/70");
1946   CMP ("%y", "70");
1947   CMP ("%z", "+0000");          /* GNU */
1949   exit (n_fail ? 1 : 0);
1951              jm_cv_func_working_gnu_strftime=yes,
1952              jm_cv_func_working_gnu_strftime=no,
1953              dnl When crosscompiling, assume strftime is missing or broken.
1954              jm_cv_func_working_gnu_strftime=no)
1955    dnl If TZ wasn't set before, this sets it to GMT0.  No real harm done.
1956    TZ="$ac_save_TZ"
1957   ])
1958   if test $jm_cv_func_working_gnu_strftime = no; then
1959     AC_SUBST(LIBOBJS)
1960     LIBOBJS="$LIBOBJS strftime.$ac_objext"
1961     AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
1962       [Define to gnu_strftime if the replacement function should be used.])
1963   fi
1966 AC_DEFUN(jm_FUNC_STRFTIME,
1968   _jm_STRFTIME_PREREQS
1969   AC_REPLACE_FUNCS(strftime)
1972 #serial 3
1974 dnl See if there's a working, system-supplied version of the getline function.
1975 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
1976 dnl have a function by that name in -linet that doesn't have anything
1977 dnl to do with the function we need.
1978 AC_DEFUN(AM_FUNC_GETLINE,
1979 [dnl
1980   am_getline_needs_run_time_check=no
1981   AC_CHECK_FUNC(getline,
1982                 dnl Found it in some library.  Verify that it works.
1983                 am_getline_needs_run_time_check=yes,
1984                 am_cv_func_working_getline=no)
1985   if test $am_getline_needs_run_time_check = yes; then
1986     AC_CHECK_HEADERS(string.h)
1987     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
1988     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
1989     AC_TRY_RUN([
1990 #    include <stdio.h>
1991 #    include <sys/types.h>
1992 #    if HAVE_STRING_H
1993 #     include <string.h>
1994 #    endif
1995     int main ()
1996     { /* Based on a test program from Karl Heuer.  */
1997       char *line = NULL;
1998       size_t siz = 0;
1999       int len;
2000       FILE *in = fopen ("./conftest.data", "r");
2001       if (!in)
2002         return 1;
2003       len = getline (&line, &siz, in);
2004       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
2005     }
2006     ], am_cv_func_working_getline=yes dnl The library version works.
2007     , am_cv_func_working_getline=no dnl The library version does NOT work.
2008     , am_cv_func_working_getline=no dnl We're cross compiling.
2009     )])
2010   fi
2012   if test $am_cv_func_working_getline = yes; then
2013     AC_DEFINE(HAVE_GETLINE, 1,
2014       [Define if you have the GETLINE function.])dnl
2015   fi
2018 #serial 4
2020 dnl From Paul Eggert.
2022 # Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
2023 # if it exists.
2025 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
2026  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
2027    ac_cv_struct_st_mtim_nsec,
2028    [ac_save_CPPFLAGS="$CPPFLAGS"
2029     ac_cv_struct_st_mtim_nsec=no
2030     # tv_nsec -- the usual case
2031     # _tv_nsec -- Solaris 2.6, if
2032     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
2033     #    && !defined __EXTENSIONS__)
2034     # st__tim.tv_nsec -- UnixWare 2.1.2
2035     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
2036       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
2037       AC_TRY_COMPILE([#include <sys/types.h>
2038 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
2039         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
2040     done
2041     CPPFLAGS="$ac_save_CPPFLAGS"])
2043   if test $ac_cv_struct_st_mtim_nsec != no; then
2044     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec,
2045       [Define to be the nanoseconds member of struct stat's st_mtim,
2046    if it exists.])
2047   fi
2051 #serial 2
2053 # Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
2055 AC_DEFUN(AC_STRUCT_ST_DM_MODE,
2056  [AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
2057    [AC_TRY_COMPILE([#include <sys/types.h>
2058 #include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
2059      ac_cv_struct_st_dm_mode=yes,
2060      ac_cv_struct_st_dm_mode=no)])
2062   if test $ac_cv_struct_st_dm_mode = yes; then
2063     AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
2064                        [Define if struct stat has an st_dm_mode member. ])
2065   fi
2069 #serial 4
2071 dnl From Jim Meyering
2073 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
2074 dnl in time.h or sys/time.h.
2076 AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
2078   AC_REQUIRE([AC_HEADER_TIME])
2079   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
2080     [AC_TRY_COMPILE(
2081       [
2082 #      if TIME_WITH_SYS_TIME
2083 #       include <sys/time.h>
2084 #       include <time.h>
2085 #      else
2086 #       if HAVE_SYS_TIME_H
2087 #        include <sys/time.h>
2088 #       else
2089 #        include <time.h>
2090 #       endif
2091 #      endif
2092       ],
2093       [static struct timespec x; x.tv_sec = x.tv_nsec;],
2094       fu_cv_sys_struct_timespec=yes,
2095       fu_cv_sys_struct_timespec=no)
2096     ])
2098   if test $fu_cv_sys_struct_timespec = yes; then
2099     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
2100                        [Define if struct timespec is declared in <time.h>. ])
2101   fi
2104 #serial 5
2106 dnl From Paul Eggert.
2108 AC_PREREQ(2.13)
2110 # Define uintmax_t to `unsigned long' or `unsigned long long'
2111 # if <inttypes.h> does not exist.
2113 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
2115   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
2116   if test $jm_ac_cv_header_inttypes_h = no; then
2117     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
2118     test $ac_cv_type_unsigned_long_long = yes \
2119       && ac_type='unsigned long long' \
2120       || ac_type='unsigned long'
2121     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
2122 [  Define to unsigned long or unsigned long long
2123    if <inttypes.h> doesn't define.])
2124   fi
2127 # Macro to add for using GNU gettext.
2128 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2130 # This file can be copied and used freely without restrictions.  It can
2131 # be used in projects which are not available under the GNU Public License
2132 # but which still want to provide support for the GNU gettext functionality.
2133 # Please note that the actual code is *not* freely available.
2135 # serial 108
2137 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2139 AC_DEFUN(AM_WITH_NLS,
2140   [AC_MSG_CHECKING([whether NLS is requested])
2141     dnl Default is enabled NLS
2142     AC_ARG_ENABLE(nls,
2143       [  --disable-nls           do not use Native Language Support],
2144       USE_NLS=$enableval, USE_NLS=yes)
2145     AC_MSG_RESULT($USE_NLS)
2146     AC_SUBST(USE_NLS)
2148     USE_INCLUDED_LIBINTL=no
2150     dnl If we use NLS figure out what method
2151     if test "$USE_NLS" = "yes"; then
2152       AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.])
2153       AC_MSG_CHECKING([whether included gettext is requested])
2154       AC_ARG_WITH(included-gettext,
2155         [  --with-included-gettext use the GNU gettext library included here],
2156         nls_cv_force_use_gnu_gettext=$withval,
2157         nls_cv_force_use_gnu_gettext=no)
2158       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2160       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2161       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2162         dnl User does not insist on using GNU NLS library.  Figure out what
2163         dnl to use.  If gettext or catgets are available (in this order) we
2164         dnl use this.  Else we have to fall back to GNU NLS library.
2165         dnl catgets is only used if permitted by option --with-catgets.
2166         nls_cv_header_intl=
2167         nls_cv_header_libgt=
2168         CATOBJEXT=NONE
2170         AC_CHECK_HEADER(libintl.h,
2171           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
2172             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
2173                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
2175            if test "$gt_cv_func_gettext_libc" != "yes"; then
2176              AC_CHECK_LIB(intl, bindtextdomain,
2177                [AC_CHECK_LIB(intl, gettext)])
2178            fi
2180            if test "$gt_cv_func_gettext_libc" = "yes" \
2181               || test "$ac_cv_lib_intl_gettext" = "yes"; then
2182               AC_DEFINE(HAVE_GETTEXT, 1,
2183           [Define to 1 if you have gettext and don't want to use GNU gettext.])
2184               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2185                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2186               if test "$MSGFMT" != "no"; then
2187                 AC_CHECK_FUNCS(dcgettext)
2188                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2189                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2190                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2191                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
2192                                return _nl_msg_cat_cntr],
2193                   [CATOBJEXT=.gmo
2194                    DATADIRNAME=share],
2195                   [CATOBJEXT=.mo
2196                    DATADIRNAME=lib])
2197                 INSTOBJEXT=.mo
2198               fi
2199             fi
2200         ])
2202         if test "$CATOBJEXT" = "NONE"; then
2203           AC_MSG_CHECKING([whether catgets can be used])
2204           AC_ARG_WITH(catgets,
2205             [  --with-catgets          use catgets functions if available],
2206             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
2207           AC_MSG_RESULT($nls_cv_use_catgets)
2209           if test "$nls_cv_use_catgets" = "yes"; then
2210             dnl No gettext in C library.  Try catgets next.
2211             AC_CHECK_LIB(i, main)
2212             AC_CHECK_FUNC(catgets,
2213               [AC_DEFINE(HAVE_CATGETS, 1,
2214                          [Define as 1 if you have catgets and don't want to use GNU gettext.])
2215                INTLOBJS="\$(CATOBJS)"
2216                AC_PATH_PROG(GENCAT, gencat, no)dnl
2217                if test "$GENCAT" != "no"; then
2218                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
2219                  if test "$GMSGFMT" = "no"; then
2220                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
2221                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
2222                  fi
2223                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2224                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2225                  USE_INCLUDED_LIBINTL=yes
2226                  CATOBJEXT=.cat
2227                  INSTOBJEXT=.cat
2228                  DATADIRNAME=lib
2229                  INTLDEPS='$(top_builddir)/intl/libintl.a'
2230                  INTLLIBS=$INTLDEPS
2231                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2232                  nls_cv_header_intl=intl/libintl.h
2233                  nls_cv_header_libgt=intl/libgettext.h
2234                fi])
2235           fi
2236         fi
2238         if test "$CATOBJEXT" = "NONE"; then
2239           dnl Neither gettext nor catgets in included in the C library.
2240           dnl Fall back on GNU gettext library.
2241           nls_cv_use_gnu_gettext=yes
2242         fi
2243       fi
2245       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2246         dnl Mark actions used to generate GNU NLS library.
2247         INTLOBJS="\$(GETTOBJS)"
2248         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2249           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2250         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2251         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2252           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2253         AC_SUBST(MSGFMT)
2254         USE_INCLUDED_LIBINTL=yes
2255         CATOBJEXT=.gmo
2256         INSTOBJEXT=.mo
2257         DATADIRNAME=share
2258         INTLDEPS='$(top_builddir)/intl/libintl.a'
2259         INTLLIBS=$INTLDEPS
2260         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
2261         nls_cv_header_intl=intl/libintl.h
2262         nls_cv_header_libgt=intl/libgettext.h
2263       fi
2265       dnl Test whether we really found GNU xgettext.
2266       if test "$XGETTEXT" != ":"; then
2267         dnl If it is no GNU xgettext we define it as : so that the
2268         dnl Makefiles still can work.
2269         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2270           : ;
2271         else
2272           AC_MSG_RESULT(
2273             [found xgettext program is not GNU xgettext; ignore it])
2274           XGETTEXT=":"
2275         fi
2276       fi
2278       # We need to process the po/ directory.
2279       POSUB=po
2280     else
2281       DATADIRNAME=share
2282       nls_cv_header_intl=intl/libintl.h
2283       nls_cv_header_libgt=intl/libgettext.h
2284     fi
2285     if test -z "$nls_cv_header_intl"; then
2286       # Clean out junk possibly left behind by a previous configuration.
2287       rm -f intl/libintl.h
2288     fi
2289     AC_CONFIG_LINKS($nls_cv_header_intl:$nls_cv_header_libgt)
2290     AC_OUTPUT_COMMANDS(
2291      [case "$CONFIG_FILES" in *po/Makefile.in*)
2292         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
2293       esac])
2296     # If this is used in GNU gettext we have to set USE_NLS to `yes'
2297     # because some of the sources are only built for this goal.
2298     if test "$PACKAGE" = gettext; then
2299       USE_NLS=yes
2300       USE_INCLUDED_LIBINTL=yes
2301     fi
2303     dnl These rules are solely for the distribution goal.  While doing this
2304     dnl we only have to keep exactly one list of the available catalogs
2305     dnl in configure.in.
2306     for lang in $ALL_LINGUAS; do
2307       GMOFILES="$GMOFILES $lang.gmo"
2308       POFILES="$POFILES $lang.po"
2309     done
2311     dnl Make all variables we use known to autoconf.
2312     AC_SUBST(USE_INCLUDED_LIBINTL)
2313     AC_SUBST(CATALOGS)
2314     AC_SUBST(CATOBJEXT)
2315     AC_SUBST(DATADIRNAME)
2316     AC_SUBST(GMOFILES)
2317     AC_SUBST(INSTOBJEXT)
2318     AC_SUBST(INTLDEPS)
2319     AC_SUBST(INTLLIBS)
2320     AC_SUBST(INTLOBJS)
2321     AC_SUBST(POFILES)
2322     AC_SUBST(POSUB)
2323   ])
2325 AC_DEFUN(AM_GNU_GETTEXT,
2326   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2327    AC_REQUIRE([AC_PROG_CC])dnl
2328    AC_REQUIRE([AC_PROG_RANLIB])dnl
2329    AC_REQUIRE([AC_ISC_POSIX])dnl
2330    AC_REQUIRE([AC_HEADER_STDC])dnl
2331    AC_REQUIRE([AC_C_CONST])dnl
2332    AC_REQUIRE([AC_C_INLINE])dnl
2333    AC_REQUIRE([AC_TYPE_OFF_T])dnl
2334    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2335    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2336    AC_REQUIRE([AC_FUNC_MMAP])dnl
2338    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
2339 unistd.h sys/param.h])
2340    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
2341 strdup __argz_count __argz_stringify __argz_next])
2343    if test "${ac_cv_func_stpcpy+set}" != "set"; then
2344      AC_CHECK_FUNCS(stpcpy)
2345    fi
2346    if test "${ac_cv_func_stpcpy}" = "yes"; then
2347      AC_DEFINE(HAVE_STPCPY, 1, [Define to 1 if you have the stpcpy function.])
2348    fi
2350    AM_LC_MESSAGES
2351    AM_WITH_NLS
2353    if test "x$CATOBJEXT" != "x"; then
2354      if test "x$ALL_LINGUAS" = "x"; then
2355        LINGUAS=
2356      else
2357        AC_MSG_CHECKING(for catalogs to be installed)
2358        NEW_LINGUAS=
2359        for lang in ${LINGUAS=$ALL_LINGUAS}; do
2360          case "$ALL_LINGUAS" in
2361           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
2362          esac
2363        done
2364        LINGUAS=$NEW_LINGUAS
2365        AC_MSG_RESULT($LINGUAS)
2366      fi
2368      dnl Construct list of names of catalog files to be constructed.
2369      if test -n "$LINGUAS"; then
2370        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2371      fi
2372    fi
2374    dnl The reference to <locale.h> in the installed <libintl.h> file
2375    dnl must be resolved because we cannot expect the users of this
2376    dnl to define HAVE_LOCALE_H.
2377    if test $ac_cv_header_locale_h = yes; then
2378      INCLUDE_LOCALE_H="#include <locale.h>"
2379    else
2380      INCLUDE_LOCALE_H="\
2381 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
2382    fi
2383    AC_SUBST(INCLUDE_LOCALE_H)
2385    dnl Determine which catalog format we have (if any is needed)
2386    dnl For now we know about two different formats:
2387    dnl   Linux libc-5 and the normal X/Open format
2388    test -d intl || mkdir intl
2389    if test "$CATOBJEXT" = ".cat"; then
2390      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
2392      dnl Transform the SED scripts while copying because some dumb SEDs
2393      dnl cannot handle comments.
2394      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
2395    fi
2396    dnl po2tbl.sed is always needed.
2397    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
2398      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
2400    dnl In the intl/Makefile.in we have a special dependency which makes
2401    dnl only sense for gettext.  We comment this out for non-gettext
2402    dnl packages.
2403    if test "$PACKAGE" = "gettext"; then
2404      GT_NO="#NO#"
2405      GT_YES=
2406    else
2407      GT_NO=
2408      GT_YES="#YES#"
2409    fi
2410    AC_SUBST(GT_NO)
2411    AC_SUBST(GT_YES)
2413    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2414    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
2415    dnl Try to locate is.
2416    MKINSTALLDIRS=
2417    if test -n "$ac_aux_dir"; then
2418      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2419    fi
2420    if test -z "$MKINSTALLDIRS"; then
2421      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2422    fi
2423    AC_SUBST(MKINSTALLDIRS)
2425    dnl *** For now the libtool support in intl/Makefile is not for real.
2426    l=
2427    AC_SUBST(l)
2429    dnl Generate list of files to be processed by xgettext which will
2430    dnl be included in po/Makefile.
2431    test -d po || mkdir po
2432    case "$srcdir" in
2433    .)
2434      posrcprefix="../" ;;
2435    /* | [[A-Za-z]]:*)
2436      posrcprefix="$srcdir/" ;;
2437    *)
2438      posrcprefix="../$srcdir/" ;;
2439    esac
2440    rm -f po/POTFILES
2441    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
2442         < $srcdir/po/POTFILES.in > po/POTFILES
2443   ])
2445 # Search path for a program which passes the given test.
2446 # Ulrich Drepper <drepper@cygnus.com>, 1996.
2448 # This file can be copied and used freely without restrictions.  It can
2449 # be used in projects which are not available under the GNU Public License
2450 # but which still want to provide support for the GNU gettext functionality.
2451 # Please note that the actual code is *not* freely available.
2453 # serial 1
2455 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2456 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2457 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
2458 [# Extract the first word of "$2", so it can be a program name with args.
2459 set dummy $2; ac_word=[$]2
2460 AC_MSG_CHECKING([for $ac_word])
2461 AC_CACHE_VAL(ac_cv_path_$1,
2462 [case "[$]$1" in
2463   /*)
2464   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2465   ;;
2466   *)
2467   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2468   for ac_dir in ifelse([$5], , $PATH, [$5]); do
2469     test -z "$ac_dir" && ac_dir=.
2470     if test -f $ac_dir/$ac_word; then
2471       if [$3]; then
2472         ac_cv_path_$1="$ac_dir/$ac_word"
2473         break
2474       fi
2475     fi
2476   done
2477   IFS="$ac_save_ifs"
2478 dnl If no 4th arg is given, leave the cache variable unset,
2479 dnl so AC_PATH_PROGS will keep looking.
2480 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2481 ])dnl
2482   ;;
2483 esac])dnl
2484 $1="$ac_cv_path_$1"
2485 if test -n "[$]$1"; then
2486   AC_MSG_RESULT([$]$1)
2487 else
2488   AC_MSG_RESULT(no)
2490 AC_SUBST($1)dnl
2493 # Check whether LC_MESSAGES is available in <locale.h>.
2494 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2496 # This file can be copied and used freely without restrictions.  It can
2497 # be used in projects which are not available under the GNU Public License
2498 # but which still want to provide support for the GNU gettext functionality.
2499 # Please note that the actual code is *not* freely available.
2501 # serial 2
2503 AC_PREREQ(2.13)               dnl Minimum Autoconf version required.
2505 AC_DEFUN(AM_LC_MESSAGES,
2506   [if test $ac_cv_header_locale_h = yes; then
2507     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2508       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2509        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2510     if test $am_cv_val_LC_MESSAGES = yes; then
2511       AC_DEFINE(HAVE_LC_MESSAGES, 1,
2512                 [Define if your locale.h file contains LC_MESSAGES.])
2513     fi
2514   fi])