source: trunk/third/findutils/aclocal.m4 @ 18896

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