* find/testsuite/Makefile.am: add CLEANFILES
[findutils.git] / aclocal.m4
blobf939f3d3c7500e58623af85705bcdd36ade7b5a0
1 dnl aclocal.m4 generated automatically by aclocal 1.4
3 dnl Copyright (C) 1994, 1995-8, 1999 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 PACKAGE=[$1]
48 AC_SUBST(PACKAGE)
49 VERSION=[$2]
50 AC_SUBST(VERSION)
51 dnl test to see if srcdir already configured
52 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
53   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
55 ifelse([$3],,
56 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
57 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
58 AC_REQUIRE([AM_SANITY_CHECK])
59 AC_REQUIRE([AC_ARG_PROGRAM])
60 dnl FIXME This is truly gross.
61 missing_dir=`cd $ac_aux_dir && pwd`
62 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
63 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
64 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
65 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
66 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
67 AC_REQUIRE([AC_PROG_MAKE_SET])])
70 # Check to make sure that the build environment is sane.
73 AC_DEFUN(AM_SANITY_CHECK,
74 [AC_MSG_CHECKING([whether build environment is sane])
75 # Just in case
76 sleep 1
77 echo timestamp > conftestfile
78 # Do `set' in a subshell so we don't clobber the current shell's
79 # arguments.  Must try -L first in case configure is actually a
80 # symlink; some systems play weird games with the mod time of symlinks
81 # (eg FreeBSD returns the mod time of the symlink's containing
82 # directory).
83 if (
84    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
85    if test "[$]*" = "X"; then
86       # -L didn't work.
87       set X `ls -t $srcdir/configure conftestfile`
88    fi
89    if test "[$]*" != "X $srcdir/configure conftestfile" \
90       && test "[$]*" != "X conftestfile $srcdir/configure"; then
92       # If neither matched, then we have a broken ls.  This can happen
93       # if, for instance, CONFIG_SHELL is bash and it inherits a
94       # broken ls alias from the environment.  This has actually
95       # happened.  Such a system could not be considered "sane".
96       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
97 alias in your environment])
98    fi
100    test "[$]2" = conftestfile
101    )
102 then
103    # Ok.
104    :
105 else
106    AC_MSG_ERROR([newly created file is older than distributed files!
107 Check your system clock])
109 rm -f conftest*
110 AC_MSG_RESULT(yes)])
112 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
113 dnl The program must properly implement --version.
114 AC_DEFUN(AM_MISSING_PROG,
115 [AC_MSG_CHECKING(for working $2)
116 # Run test in a subshell; some versions of sh will print an error if
117 # an executable is not found, even if stderr is redirected.
118 # Redirect stdin to placate older versions of autoconf.  Sigh.
119 if ($2 --version) < /dev/null > /dev/null 2>&1; then
120    $1=$2
121    AC_MSG_RESULT(found)
122 else
123    $1="$3/missing $2"
124    AC_MSG_RESULT(missing)
126 AC_SUBST($1)])
128 #serial 1
129 dnl This test replaces the one in autoconf.
130 dnl Currently this macro should have the same name as the autoconf macro
131 dnl because gettext's gettext.m4 (distributed in the automake package)
132 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
133 dnl give these diagnostics:
134 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
135 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
137 undefine([AC_ISC_POSIX])
138 AC_DEFUN(AC_ISC_POSIX,
139   [
140     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
141     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
142   ]
146 # serial 1
148 AC_DEFUN(AM_C_PROTOTYPES,
149 [AC_REQUIRE([AM_PROG_CC_STDC])
150 AC_REQUIRE([AC_PROG_CPP])
151 AC_MSG_CHECKING([for function prototypes])
152 if test "$am_cv_prog_cc_stdc" != no; then
153   AC_MSG_RESULT(yes)
154   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
155   U= ANSI2KNR=
156 else
157   AC_MSG_RESULT(no)
158   U=_ ANSI2KNR=./ansi2knr
159   # Ensure some checks needed by ansi2knr itself.
160   AC_HEADER_STDC
161   AC_CHECK_HEADERS(string.h)
163 AC_SUBST(U)dnl
164 AC_SUBST(ANSI2KNR)dnl
168 # serial 1
170 # @defmac AC_PROG_CC_STDC
171 # @maindex PROG_CC_STDC
172 # @ovindex CC
173 # If the C compiler in not in ANSI C mode by default, try to add an option
174 # to output variable @code{CC} to make it so.  This macro tries various
175 # options that select ANSI C on some system or another.  It considers the
176 # compiler to be in ANSI C mode if it handles function prototypes correctly.
178 # If you use this macro, you should check after calling it whether the C
179 # compiler has been set to accept ANSI C; if not, the shell variable
180 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
181 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
182 # program @code{ansi2knr}, which comes with Ghostscript.
183 # @end defmac
185 AC_DEFUN(AM_PROG_CC_STDC,
186 [AC_REQUIRE([AC_PROG_CC])
187 AC_BEFORE([$0], [AC_C_INLINE])
188 AC_BEFORE([$0], [AC_C_CONST])
189 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
190 dnl a magic option to avoid problems with ANSI preprocessor commands
191 dnl like #elif.
192 dnl FIXME: can't do this because then AC_AIX won't work due to a
193 dnl circular dependency.
194 dnl AC_BEFORE([$0], [AC_PROG_CPP])
195 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
196 AC_CACHE_VAL(am_cv_prog_cc_stdc,
197 [am_cv_prog_cc_stdc=no
198 ac_save_CC="$CC"
199 # Don't try gcc -ansi; that turns off useful extensions and
200 # breaks some systems' header files.
201 # AIX                   -qlanglvl=ansi
202 # Ultrix and OSF/1      -std1
203 # HP-UX                 -Aa -D_HPUX_SOURCE
204 # SVR4                  -Xc -D__EXTENSIONS__
205 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
207   CC="$ac_save_CC $ac_arg"
208   AC_TRY_COMPILE(
209 [#include <stdarg.h>
210 #include <stdio.h>
211 #include <sys/types.h>
212 #include <sys/stat.h>
213 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
214 struct buf { int x; };
215 FILE * (*rcsopen) (struct buf *, struct stat *, int);
216 static char *e (p, i)
217      char **p;
218      int i;
220   return p[i];
222 static char *f (char * (*g) (char **, int), char **p, ...)
224   char *s;
225   va_list v;
226   va_start (v,p);
227   s = g (p, va_arg (v,int));
228   va_end (v);
229   return s;
231 int test (int i, double x);
232 struct s1 {int (*f) (int a);};
233 struct s2 {int (*f) (double a);};
234 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
235 int argc;
236 char **argv;
237 ], [
238 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
240 [am_cv_prog_cc_stdc="$ac_arg"; break])
241 done
242 CC="$ac_save_CC"
244 if test -z "$am_cv_prog_cc_stdc"; then
245   AC_MSG_RESULT([none needed])
246 else
247   AC_MSG_RESULT($am_cv_prog_cc_stdc)
249 case "x$am_cv_prog_cc_stdc" in
250   x|xno) ;;
251   *) CC="$CC $am_cv_prog_cc_stdc" ;;
252 esac
255 #serial 1
257 dnl Just like AC_C_CONST from autoconf-2.12, but with an initializer
258 dnl for `charset x' and with
259 dnl   AC_DEFINE(const, )
260 dnl changed to
261 dnl   AC_DEFINE_UNQUOTED(const, [/* empty */])
262 dnl to avoid this warning:
263 dnl   [...]/m4: Warning: Excess arguments to built-in `define' ignored
265 undefine([AC_C_CONST])
266 AC_DEFUN(AC_C_CONST,
267 [dnl This message is consistent in form with the other checking messages,
268 dnl and with the result message.
269 AC_CACHE_CHECK([for working const], ac_cv_c_const,
270 [AC_TRY_COMPILE(,
271 changequote(<<, >>)dnl
273 /* Ultrix mips cc rejects this.  */
274 typedef int charset[2]; const charset x = {0, 0};
275 /* SunOS 4.1.1 cc rejects this.  */
276 char const *const *ccp;
277 char **p;
278 /* NEC SVR4.0.2 mips cc rejects this.  */
279 struct point {int x, y;};
280 static struct point const zero = {0,0};
281 /* AIX XL C 1.02.0.0 rejects this.
282    It does not let you subtract one const X* pointer from another in an arm
283    of an if-expression whose if-part is not a constant expression */
284 const char *g = "string";
285 ccp = &g + (g ? g-g : 0);
286 /* HPUX 7.0 cc rejects these. */
287 ++ccp;
288 p = (char**) ccp;
289 ccp = (char const *const *) p;
290 { /* SCO 3.2v4 cc rejects this.  */
291   char *t;
292   char const *s = 0 ? (char *) 0 : (char const *) 0;
294   *t++ = 0;
296 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
297   int x[] = {25, 17};
298   const int *foo = &x[0];
299   ++foo;
301 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
302   typedef const int *iptr;
303   iptr p = 0;
304   ++p;
306 { /* AIX XL C 1.02.0.0 rejects this saying
307      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
308   struct s { int j; const int *ap[3]; };
309   struct s *b; b->j = 5;
311 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
312   const int foo = 10;
315 changequote([, ])dnl
316 ac_cv_c_const=yes, ac_cv_c_const=no)])
317 if test $ac_cv_c_const = no; then
318   AC_DEFINE_UNQUOTED(const, [/* empty */])
322 #serial 1
324 dnl Just like AC_CHECK_TYPE from autoconf-2.12, but also checks in unistd.h
325 dnl on systems that have it.  Fujitsu UXP/V needs this for ssize_t.
327 undefine([AC_CHECK_TYPE])
328 dnl AC_CHECK_TYPE(TYPE, DEFAULT)
329 AC_DEFUN(AC_CHECK_TYPE,
330 [AC_REQUIRE([AC_HEADER_STDC])dnl
331 AC_CHECK_HEADERS(unistd.h)
332 AC_MSG_CHECKING(for $1)
333 AC_CACHE_VAL(ac_cv_type_$1,
334 [AC_EGREP_CPP(dnl
335 changequote(<<,>>)dnl
336 <<$1[^a-zA-Z_0-9]>>dnl
337 changequote([,]), [#include <sys/types.h>
338 #if STDC_HEADERS
339 # include <stdlib.h>
340 # include <stddef.h>
341 #endif
342 #if HAVE_UNISTD_H
343 # include <unistd.h>
344 #endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
345 AC_MSG_RESULT($ac_cv_type_$1)
346 if test $ac_cv_type_$1 = no; then
347   AC_DEFINE($1, $2)
351 #serial 2
353 dnl Misc type-related macros for fileutils, sh-utils, textutils.
355 AC_DEFUN(jm_MACROS,
357   dnl This macro actually runs replacement code.  See isc-posix.m4.
358   AC_REQUIRE([AC_ISC_POSIX])dnl
360   AC_REQUIRE([jm_WITH_REGEX])
361   AC_REQUIRE([jm_ASSERT])
362   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
363   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
364   AC_CHECK_TYPE(ssize_t, int)
365   AC_REQUIRE([jm_STRUCT_UTIMBUF])
366   AC_REQUIRE([jm_CHECK_DECLS])
368   AC_REQUIRE([jm_PREREQ])
370   AC_REQUIRE([jm_FUNC_MKTIME])
371   AC_REQUIRE([jm_FUNC_LSTAT])
372   AC_REQUIRE([jm_FUNC_STAT])
373   AC_REQUIRE([jm_FUNC_REALLOC])
374   AC_REQUIRE([jm_FUNC_MALLOC])
375   AC_REQUIRE([jm_FUNC_READDIR])
376   AC_REQUIRE([jm_FUNC_MEMCMP])
377   AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
378   AC_REQUIRE([jm_FUNC_FNMATCH])
381 #serial 2
383 dnl Derived from code in GNU grep.
385 AC_DEFUN(jm_WITH_REGEX,
386   [
387     dnl Even packages that don't use regex.c can use this macro.
388     dnl Of course, for them it doesn't do anything.
390     syscmd([test -f lib/regex.c])
391     ifelse(sysval, 0,
392       [
393         AC_ARG_WITH(included-regex,
394             [  --without-included-regex don't compile regex (use with caution)],
395                     jm_with_regex=$withval,
396                     jm_with_regex=yes)
397         if test "$jm_with_regex" = yes; then
398           LIBOBJS="$LIBOBJS regex.o"
399         fi
400       ],
401     )
402   ]
405 #serial 1
406 dnl based on code from Eleftherios Gkioulekas
408 AC_DEFUN(jm_ASSERT,
410   AC_MSG_CHECKING(whether to enable assertions)
411   AC_ARG_ENABLE(assert,
412                 [  --disable-assert        turn off assertions],
413                 [ AC_MSG_RESULT(no)
414                   AC_DEFINE(NDEBUG) ],
415                 [ AC_MSG_RESULT(yes) ]
416                )
419 #serial 2
421 dnl From Paul Eggert.
423 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
424 # doesn't clash with <sys/types.h>, and declares uintmax_t.
426 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
428   if test x = y; then
429     dnl This code is deliberately never run via ./configure.
430     dnl FIXME: this is a gross hack to make autoheader put an entry
431     dnl for `HAVE_INTTYPES_H' in config.h.in.
432     AC_CHECK_FUNCS(INTTYPES_H)
433   fi
434   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
435   [AC_TRY_COMPILE(
436     [#include <sys/types.h>
437 #include <inttypes.h>],
438     [uintmax_t i = (uintmax_t) -1;],
439     jm_ac_cv_header_inttypes_h=yes,
440     jm_ac_cv_header_inttypes_h=no)])
441   if test $jm_ac_cv_header_inttypes_h = yes; then
442     ac_kludge=HAVE_INTTYPES_H
443     AC_DEFINE_UNQUOTED($ac_kludge)
444   fi
447 #serial 1
449 dnl From Paul Eggert.
451 # Define uintmax_t to `unsigned long' or `unsigned long long'
452 # if <inttypes.h> does not exist.
454 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
456   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
457   if test $jm_ac_cv_header_inttypes_h = no; then
458     AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
459     [AC_TRY_COMPILE([],
460       [unsigned long long i = (unsigned long long) -1;],
461       ac_cv_type_unsigned_long_long=yes,
462       ac_cv_type_unsigned_long_long=no)])
463     if test $ac_cv_type_unsigned_long_long = yes; then
464       AC_DEFINE(uintmax_t, unsigned long long)
465     else
466       AC_DEFINE(uintmax_t, unsigned long)
467     fi
468   fi
471 #serial 1
473 dnl From Jim Meyering
475 dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
476 dnl usually in <utime.h>.
477 dnl Some systems have utime.h but don't declare the struct anywhere.
479 AC_DEFUN(jm_STRUCT_UTIMBUF,
481   AC_CHECK_HEADERS(utime.h)
482   AC_REQUIRE([AC_HEADER_TIME])
483   AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf,
484     [AC_TRY_COMPILE(
485       [
486 #ifdef TIME_WITH_SYS_TIME
487 # include <sys/time.h>
488 # include <time.h>
489 #else
490 # ifdef HAVE_SYS_TIME_H
491 #  include <sys/time.h>
492 # else
493 #  include <time.h>
494 # endif
495 #endif
496 #ifdef HAVE_UTIME_H
497 # include <utime.h>
498 #endif
499       ],
500       [static struct utimbuf x; x.actime = x.modtime;],
501       fu_cv_sys_struct_utimbuf=yes,
502       fu_cv_sys_struct_utimbuf=no)
503     ])
505   if test $fu_cv_sys_struct_utimbuf = yes; then
506     if test x = y; then
507       # This code is deliberately never run via ./configure.
508       # FIXME: this is a hack to make autoheader put the corresponding
509       # HAVE_* undef for this symbol in config.h.in.  This saves me the
510       # trouble of having to maintain the #undef in acconfig.h manually.
511       AC_CHECK_FUNCS(STRUCT_UTIMBUF)
512     fi
513     # Defining it this way (rather than via AC_DEFINE) short-circuits the
514     # autoheader check -- autoheader doesn't know it's already been taken
515     # care of by the hack above.
516     ac_kludge=HAVE_STRUCT_UTIMBUF
517     AC_DEFINE_UNQUOTED($ac_kludge)
518   fi
521 #serial 4
523 dnl This is just a wrapper function to encapsulate this kludge.
524 dnl Putting it in a separate file like this helps share it between
525 dnl different packages.
526 AC_DEFUN(jm_CHECK_DECLS,
528   headers='
529 #include <stdio.h>
530 #ifdef HAVE_STRING_H
531 # if !STDC_HEADERS && HAVE_MEMORY_H
532 #  include <memory.h>
533 # endif
534 # include <string.h>
535 #else
536 # ifdef HAVE_STRINGS_H
537 #  include <strings.h>
538 # endif
539 #endif
540 #ifdef HAVE_STDLIB_H
541 # include <stdlib.h>
542 #endif
543 #ifdef HAVE_UNISTD_H
544 # include <unistd.h>
545 #endif
547   if test x = y; then
548     dnl This code is deliberately never run via ./configure.
549     dnl FIXME: this is a gross hack to make autoheader put entries
550     dnl for each of these symbols in the config.h.in.
551     dnl Otherwise, I'd have to update acconfig.h every time I change
552     dnl this list of functions.
553     AC_CHECK_FUNCS(DECL_FREE DECL_LSEEK DECL_MALLOC DECL_MEMCHR DECL_REALLOC \
554                    DECL_STPCPY DECL_STRSTR)
555   fi
556   jm_CHECK_DECLARATIONS($headers, free lseek malloc \
557                         memchr realloc stpcpy strstr)
560 #serial 3
562 AC_DEFUN(jm_CHECK_DECLARATION,
564   AC_REQUIRE([AC_HEADER_STDC])dnl
565   test -z "$ac_cv_header_memory_h" && AC_CHECK_HEADERS(memory.h)
566   test -z "$ac_cv_header_string_h" && AC_CHECK_HEADERS(string.h)
567   test -z "$ac_cv_header_strings_h" && AC_CHECK_HEADERS(strings.h)
568   test -z "$ac_cv_header_stdlib_h" && AC_CHECK_HEADERS(stdlib.h)
569   test -z "$ac_cv_header_unistd_h" && AC_CHECK_HEADERS(unistd.h)
570   AC_MSG_CHECKING([whether $1 is declared])
571   AC_CACHE_VAL(jm_cv_func_decl_$1,
572     [AC_TRY_COMPILE($2,
573       [
574 #ifndef $1
575 char *(*pfn) = (char *(*)) $1
576 #endif
577       ],
578       eval "jm_cv_func_decl_$1=yes",
579       eval "jm_cv_func_decl_$1=no")])
581   if eval "test \"`echo '$jm_cv_func_decl_'$1`\" = yes"; then
582     AC_MSG_RESULT(yes)
583     ifelse([$3], , :, [$3])
584   else
585     AC_MSG_RESULT(no)
586     ifelse([$4], , , [$4
587 ])dnl
588   fi
589 ])dnl
591 dnl jm_CHECK_DECLARATIONS(INCLUDES, FUNCTION... [, ACTION-IF-DECLARED
592 dnl                       [, ACTION-IF-NOT-DECLARED]])
593 AC_DEFUN(jm_CHECK_DECLARATIONS,
595   for jm_func in $2
596   do
597     jm_CHECK_DECLARATION($jm_func, $1,
598     [
599       jm_tr_func=HAVE_DECL_`echo $jm_func | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
600       AC_DEFINE_UNQUOTED($jm_tr_func) $3], $4)dnl
601   done
604 #serial 2
606 dnl These are the prerequisite macros for files in the lib/
607 dnl directories of the fileutils, sh-utils, and textutils packages.
609 AC_DEFUN(jm_PREREQ,
611   jm_PREREQ_ERROR
612   jm_PREREQ_REGEX
615 dnl FIXME: maybe put this in a separate file
616 AC_DEFUN(jm_PREREQ_REGEX,
618   dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
619   dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
620   dnl to get them.
621   AC_CHECK_FUNCS(bzero bcopy isascii btowc)
622   AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
623   AC_HEADER_STDC
624   AC_FUNC_ALLOCA
627 #serial 1
629 dnl FIXME: put these prerequisite-only *.m4 files in a separate
630 dnl directory -- otherwise, they'll conflict with existing files.
632 dnl These are the prerequisite macros for GNU's error.c file.
633 AC_DEFUN(jm_PREREQ_ERROR,
635   AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
636   AC_HEADER_STDC
639 #serial 3
641 dnl From Jim Meyering.
642 dnl If you use this macro in a package, you should
643 dnl add the following two lines to acconfig.h:
644 dnl   /* Define to rpl_mktime if the replacement function should be used.  */
645 dnl   #undef mktime
647 AC_DEFUN(jm_FUNC_MKTIME,
648 [AC_REQUIRE([jm_AM_FUNC_MKTIME])dnl
650  dnl mktime.c uses localtime_r if it exists.  Check for it.
651  AC_CHECK_FUNCS(localtime_r)
653  if test $jm_am_cv_func_working_mktime = no; then
654    AC_DEFINE_UNQUOTED(mktime, rpl_mktime)
655  fi
658 #serial 1001
660 dnl Just like mktime.m4 from automake-1.3b, but with an additional test.
661 dnl Renamed to have jm_ prefix and to use jm_ prefix on cache variable names.
663 AC_DEFUN(jm_AM_FUNC_MKTIME,
664 [AC_REQUIRE([AC_HEADER_TIME])dnl
665  AC_CHECK_HEADERS(sys/time.h unistd.h)
666  AC_CHECK_FUNCS(alarm)
667  AC_CACHE_CHECK([for working mktime], jm_am_cv_func_working_mktime,
668   [AC_TRY_RUN(
669 changequote(<<, >>)dnl
670 <</* Test program from Paul Eggert (eggert@twinsun.com)
671    and Tony Leneis (tony@plaza.ds.adp.com).  */
672 #if TIME_WITH_SYS_TIME
673 # include <sys/time.h>
674 # include <time.h>
675 #else
676 # if HAVE_SYS_TIME_H
677 #  include <sys/time.h>
678 # else
679 #  include <time.h>
680 # endif
681 #endif
683 #if HAVE_UNISTD_H
684 # include <unistd.h>
685 #endif
687 #if !HAVE_ALARM
688 # define alarm(X) /* empty */
689 #endif
691 /* Work around redefinition to rpl_putenv by other config tests.  */
692 #undef putenv
694 static time_t time_t_max;
696 /* Values we'll use to set the TZ environment variable.  */
697 static const char *const tz_strings[] = {
698   (const char *) 0, "TZ=GMT0", "TZ=JST-9",
699   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
701 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
703 /* Fail if mktime fails to convert a date in the spring-forward gap.
704    Based on a problem report from Andreas Jaeger.  */
705 static void
706 spring_forward_gap ()
708   /* glibc (up to about 1998-10-07) failed this test) */
709   struct tm tm;
711   /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
712      instead of "TZ=America/Vancouver" in order to detect the bug even
713      on systems that don't support the Olson extension, or don't have the
714      full zoneinfo tables installed.  */
715   putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
716   tm.tm_year = 98;
717   tm.tm_mon = 3;
718   tm.tm_mday = 5;
719   tm.tm_hour = 2;
720   tm.tm_min = 0;
721   tm.tm_sec = 0;
722   tm.tm_isdst = -1;
723   if (mktime (&tm) == (time_t)-1)
724     exit (1);
727 static void
728 mktime_test (now)
729      time_t now;
731   struct tm *lt;
732   if ((lt = localtime (&now)) && mktime (lt) != now)
733     exit (1);
734   now = time_t_max - now;
735   if ((lt = localtime (&now)) && mktime (lt) != now)
736     exit (1);
739 static void
740 irix_6_4_bug ()
742   /* Based on code from Ariel Faigon.  */
743   struct tm tm;
744   tm.tm_year = 96;
745   tm.tm_mon = 3;
746   tm.tm_mday = 0;
747   tm.tm_hour = 0;
748   tm.tm_min = 0;
749   tm.tm_sec = 0;
750   tm.tm_isdst = -1;
751   mktime (&tm);
752   if (tm.tm_mon != 2 || tm.tm_mday != 31)
753     exit (1);
756 static void
757 bigtime_test (j)
758      int j;
760   struct tm tm;
761   time_t now;
762   tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
763   /* This test makes some buggy mktime implementations loop.
764      Give up after 10 seconds.  */
765   alarm (10);
766   now = mktime (&tm);
767   alarm (0);
768   if (now != (time_t) -1)
769     {
770       struct tm *lt = localtime (&now);
771       if (! (lt
772              && lt->tm_year == tm.tm_year
773              && lt->tm_mon == tm.tm_mon
774              && lt->tm_mday == tm.tm_mday
775              && lt->tm_hour == tm.tm_hour
776              && lt->tm_min == tm.tm_min
777              && lt->tm_sec == tm.tm_sec
778              && lt->tm_yday == tm.tm_yday
779              && lt->tm_wday == tm.tm_wday
780              && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
781                   == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
782         exit (1);
783     }
787 main ()
789   time_t t, delta;
790   int i, j;
792   spring_forward_gap ();
793   for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
794     continue;
795   time_t_max--;
796   delta = time_t_max / 997; /* a suitable prime number */
797   for (i = 0; i < N_STRINGS; i++)
798     {
799       if (tz_strings[i])
800         putenv (tz_strings[i]);
802       for (t = 0; t <= time_t_max - delta; t += delta)
803         mktime_test (t);
804       mktime_test ((time_t) 60 * 60);
805       mktime_test ((time_t) 60 * 60 * 24);
807       for (j = 1; 0 < j; j *= 2)
808         bigtime_test (j);
809       bigtime_test (j - 1);
810     }
811   irix_6_4_bug ();
812   exit (0);
814               >>,
815 changequote([, ])dnl
816              jm_am_cv_func_working_mktime=yes, jm_am_cv_func_working_mktime=no,
817              dnl When crosscompiling, assume mktime is missing or broken.
818              jm_am_cv_func_working_mktime=no)
819   ])
820   if test $jm_am_cv_func_working_mktime = no; then
821     LIBOBJS="$LIBOBJS mktime.o"
822   fi
825 #serial 2
827 dnl From Jim Meyering.
828 dnl Determine whether lstat has the bug that it succeeds when given the
829 dnl zero-length file name argument.  The lstat from SunOS4.1.4 and the Hurd
830 dnl (as of 1998-11-01) do this.
832 dnl If it does, then define HAVE_LSTAT_EMPTY_STRING_BUG and arrange to
833 dnl compile the wrapper function.
836 AC_DEFUN(jm_FUNC_LSTAT,
838  AC_CACHE_CHECK([whether lstat accepts an empty string],
839   jm_cv_func_lstat_empty_string_bug,
840   [AC_TRY_RUN([
841 #   include <sys/types.h>
842 #   include <sys/stat.h>
844     int
845     main ()
846     {
847       struct stat sbuf;
848       exit (lstat ("", &sbuf) ? 1 : 0);
849     }
850           ],
851          jm_cv_func_lstat_empty_string_bug=yes,
852          jm_cv_func_lstat_empty_string_bug=no,
853          dnl When crosscompiling, assume lstat is broken.
854          jm_cv_func_lstat_empty_string_bug=yes)
855   ])
856   if test $jm_cv_func_lstat_empty_string_bug = yes; then
858     LIBOBJS="$LIBOBJS lstat.o"
860     if test $jm_cv_func_lstat_empty_string_bug = yes; then
861       if test x = y; then
862         # This code is deliberately never run via ./configure.
863         # FIXME: this is a hack to make autoheader put the corresponding
864         # HAVE_* undef for this symbol in config.h.in.  This saves me the
865         # trouble of having to maintain the #undef in acconfig.h manually.
866         AC_CHECK_FUNCS(LSTAT_EMPTY_STRING_BUG)
867       fi
868       # Defining it this way (rather than via AC_DEFINE) short-circuits the
869       # autoheader check -- autoheader doesn't know it's already been taken
870       # care of by the hack above.
871       ac_kludge=HAVE_LSTAT_EMPTY_STRING_BUG
872       AC_DEFINE_UNQUOTED($ac_kludge)
873     fi
874   fi
877 #serial 2
879 dnl From Jim Meyering.
880 dnl Determine whether stat has the bug that it succeeds when given the
881 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
882 dnl (as of 1998-11-01) do this.
884 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
885 dnl compile the wrapper function.
888 AC_DEFUN(jm_FUNC_STAT,
890  AC_CACHE_CHECK([whether stat accepts an empty string],
891   jm_cv_func_stat_empty_string_bug,
892   [AC_TRY_RUN([
893 #   include <sys/types.h>
894 #   include <sys/stat.h>
896     int
897     main ()
898     {
899       struct stat sbuf;
900       exit (stat ("", &sbuf) ? 1 : 0);
901     }
902           ],
903          jm_cv_func_stat_empty_string_bug=yes,
904          jm_cv_func_stat_empty_string_bug=no,
905          dnl When crosscompiling, assume stat is broken.
906          jm_cv_func_stat_empty_string_bug=yes)
907   ])
908   if test $jm_cv_func_stat_empty_string_bug = yes; then
910     LIBOBJS="$LIBOBJS stat.o"
912     if test $jm_cv_func_stat_empty_string_bug = yes; then
913       if test x = y; then
914         # This code is deliberately never run via ./configure.
915         # FIXME: this is a hack to make autoheader put the corresponding
916         # HAVE_* undef for this symbol in config.h.in.  This saves me the
917         # trouble of having to maintain the #undef in acconfig.h manually.
918         AC_CHECK_FUNCS(STAT_EMPTY_STRING_BUG)
919       fi
920       # Defining it this way (rather than via AC_DEFINE) short-circuits the
921       # autoheader check -- autoheader doesn't know it's already been taken
922       # care of by the hack above.
923       ac_kludge=HAVE_STAT_EMPTY_STRING_BUG
924       AC_DEFINE_UNQUOTED($ac_kludge)
925     fi
926   fi
929 #serial 1
931 dnl From Jim Meyering.
932 dnl Determine whether realloc works when both arguments are 0.
933 dnl If it doesn't, arrange to use the replacement function.
935 dnl If you use this macro in a package, you should
936 dnl add the following two lines to acconfig.h:
937 dnl  /* Define to rpl_realloc if the replacement function should be used.  */
938 dnl  #undef realloc
941 AC_DEFUN(jm_FUNC_REALLOC,
943  if test x = y; then
944    dnl This code is deliberately never run via ./configure.
945    dnl FIXME: this is a gross hack to make autoheader put an entry
946    dnl for this symbol in config.h.in.
947    AC_CHECK_FUNCS(DONE_WORKING_REALLOC_CHECK)
948  fi
949  dnl xmalloc.c requires that this symbol be defined so it doesn't
950  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
951  ac_kludge=HAVE_DONE_WORKING_REALLOC_CHECK
952  AC_DEFINE_UNQUOTED($ac_kludge)
954  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
955   [AC_TRY_RUN([
956     char *realloc ();
957     int
958     main ()
959     {
960       exit (realloc (0, 0) ? 0 : 1);
961     }
962           ],
963          jm_cv_func_working_realloc=yes,
964          jm_cv_func_working_realloc=no,
965          dnl When crosscompiling, assume realloc is broken.
966          jm_cv_func_working_realloc=no)
967   ])
968   if test $jm_cv_func_working_realloc = no; then
969     LIBOBJS="$LIBOBJS realloc.o"
970     AC_DEFINE_UNQUOTED(realloc, rpl_realloc)
971   fi
974 #serial 1
976 dnl From Jim Meyering.
977 dnl Determine whether malloc accepts 0 as its argument.
978 dnl If it doesn't, arrange to use the replacement function.
980 dnl If you use this macro in a package, you should
981 dnl add the following two lines to acconfig.h:
982 dnl  /* Define to rpl_malloc if the replacement function should be used.  */
983 dnl  #undef malloc
986 AC_DEFUN(jm_FUNC_MALLOC,
988  if test x = y; then
989    dnl This code is deliberately never run via ./configure.
990    dnl FIXME: this is a gross hack to make autoheader put an entry
991    dnl for this symbol in config.h.in.
992    AC_CHECK_FUNCS(DONE_WORKING_MALLOC_CHECK)
993  fi
994  dnl xmalloc.c requires that this symbol be defined so it doesn't
995  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
996  ac_kludge=HAVE_DONE_WORKING_MALLOC_CHECK
997  AC_DEFINE_UNQUOTED($ac_kludge)
999  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
1000   [AC_TRY_RUN([
1001     char *malloc ();
1002     int
1003     main ()
1004     {
1005       exit (malloc (0) ? 0 : 1);
1006     }
1007           ],
1008          jm_cv_func_working_malloc=yes,
1009          jm_cv_func_working_malloc=no,
1010          dnl When crosscompiling, assume malloc is broken.
1011          jm_cv_func_working_malloc=no)
1012   ])
1013   if test $jm_cv_func_working_malloc = no; then
1014     LIBOBJS="$LIBOBJS malloc.o"
1015     AC_DEFINE_UNQUOTED(malloc, rpl_malloc)
1016   fi
1019 #serial 1
1021 dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
1022 dnl to test whether a NULL return value really means there are no more files
1023 dnl in the directory.
1025 dnl Detect the problem by creating a directory containing 300 files (254 not
1026 dnl counting . and .. is the minimum) and see if a loop doing `readdir; unlink'
1027 dnl removes all of them.
1029 dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
1031 dnl Written by Jim Meyering.
1033 AC_DEFUN(jm_FUNC_READDIR,
1034 [dnl
1035 AC_REQUIRE([AC_HEADER_DIRENT])
1036 AC_CHECK_HEADERS(string.h)
1037 AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
1038   [dnl
1039   # Arrange for deletion of the temporary directory this test creates, in
1040   # case the test itself fails to delete everything -- as happens on Sunos.
1041   ac_clean_files="$ac_clean_files conf-dir"
1043   AC_TRY_RUN(
1044   changequote(<<, >>)dnl
1045   <<
1046 #   include <stdio.h>
1047 #   include <sys/types.h>
1048 #   if HAVE_STRING_H
1049 #    include <string.h>
1050 #   endif
1052 #   ifdef HAVE_DIRENT_H
1053 #    include <dirent.h>
1054 #    define NLENGTH(direct) (strlen((direct)->d_name))
1055 #   else /* not HAVE_DIRENT_H */
1056 #    define dirent direct
1057 #    define NLENGTH(direct) ((direct)->d_namlen)
1058 #    ifdef HAVE_SYS_NDIR_H
1059 #     include <sys/ndir.h>
1060 #    endif /* HAVE_SYS_NDIR_H */
1061 #    ifdef HAVE_SYS_DIR_H
1062 #     include <sys/dir.h>
1063 #    endif /* HAVE_SYS_DIR_H */
1064 #    ifdef HAVE_NDIR_H
1065 #     include <ndir.h>
1066 #    endif /* HAVE_NDIR_H */
1067 #   endif /* HAVE_DIRENT_H */
1069 #   define DOT_OR_DOTDOT(Basename) \
1070      (Basename[0] == '.' && (Basename[1] == '\0' \
1071                              || (Basename[1] == '.' && Basename[2] == '\0')))
1073     static void
1074     create_300_file_dir (const char *dir)
1075     {
1076       int i;
1078       if (mkdir (dir, 0700))
1079         abort ();
1080       if (chdir (dir))
1081         abort ();
1083       for (i = 0; i < 300; i++)
1084         {
1085           char file_name[4];
1086           FILE *out;
1088           sprintf (file_name, "%03d", i);
1089           out = fopen (file_name, "w");
1090           if (!out)
1091             abort ();
1092           if (fclose (out) == EOF)
1093             abort ();
1094         }
1096       if (chdir (".."))
1097         abort ();
1098     }
1100     static void
1101     remove_dir (const char *dir)
1102     {
1103       DIR *dirp;
1105       if (chdir (dir))
1106         abort ();
1108       dirp = opendir (".");
1109       if (dirp == NULL)
1110         abort ();
1112       while (1)
1113         {
1114           struct dirent *dp = readdir (dirp);
1115           if (dp == NULL)
1116             break;
1118           if (DOT_OR_DOTDOT (dp->d_name))
1119             continue;
1121           if (unlink (dp->d_name))
1122             abort ();
1123         }
1124       closedir (dirp);
1126       if (chdir (".."))
1127         abort ();
1129       if (rmdir (dir))
1130         exit (1);
1131     }
1133     int
1134     main ()
1135     {
1136       const char *dir = "conf-dir";
1137       create_300_file_dir (dir);
1138       remove_dir (dir);
1139       exit (0);
1140     }
1141   >>,
1142   changequote([, ])dnl
1143   jm_cv_func_working_readdir=yes,
1144   jm_cv_func_working_readdir=no,
1145   jm_cv_func_working_readdir=no)])
1147   if test x = y; then
1148     dnl This code is deliberately never run via ./configure.
1149     dnl FIXME: this is a gross hack to make autoheader put an entry
1150     dnl for this HAVE_-prefixed symbol in config.h.in.
1151     AC_CHECK_FUNCS(WORKING_READDIR)
1152   fi
1155   if test $jm_cv_func_working_readdir = yes; then
1156     ac_kludge=HAVE_WORKING_READDIR
1157     AC_DEFINE_UNQUOTED($ac_kludge)
1158   fi
1161 #serial 2
1163 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
1164 dnl the losing memcmp on some x86 Next systems.
1165 AC_DEFUN(jm_AC_FUNC_MEMCMP,
1166 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
1167 [AC_TRY_RUN(
1168 changequote(<<, >>)dnl
1170 main()
1172   /* Some versions of memcmp are not 8-bit clean.  */
1173   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1174   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
1175     exit (1);
1177   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
1178      or more and with at least one buffer not starting on a 4-byte boundary.
1179      William Lewis provided this test program.   */
1180   {
1181     char foo[21];
1182     char bar[21];
1183     int i;
1184     for (i = 0; i < 4; i++)
1185       {
1186         char *a = foo + i;
1187         char *b = bar + i;
1188         strcpy (a, "--------01111111");
1189         strcpy (b, "--------10000000");
1190         if (memcmp (a, b, 16) >= 0)
1191           exit (1);
1192       }
1193     exit (0);
1194   }
1197 changequote([, ])dnl
1198    jm_cv_func_memcmp_working=yes,
1199    jm_cv_func_memcmp_working=no,
1200    jm_cv_func_memcmp_working=no)])
1201 test $jm_cv_func_memcmp_working = no && LIBOBJS="$LIBOBJS memcmp.o"
1202 AC_SUBST(LIBOBJS)dnl
1205 dnl If you use this macro in a package, you should
1206 dnl add the following two lines to acconfig.h:
1207 dnl   /* Define to rpl_memcmp if the replacement function should be used.  */
1208 dnl   #undef memcmp
1210 AC_DEFUN(jm_FUNC_MEMCMP,
1211 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
1212  if test $jm_cv_func_memcmp_working = no; then
1213    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp)
1214  fi
1217 #serial 1
1219 dnl From Jim Meyering.
1221 dnl See if the glibc *_unlocked I/O macros are available.
1224 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
1225   [AC_CHECK_FUNCS(                              \
1226     clearerr_unlocked                           \
1227     feof_unlocked                               \
1228     ferror_unlocked                             \
1229     fflush_unlocked                             \
1230     fputc_unlocked                              \
1231     fread_unlocked                              \
1232     fwrite_unlocked                             \
1233     getc_unlocked                               \
1234     getchar_unlocked                            \
1235     putc_unlocked                               \
1236     putchar_unlocked                            \
1237    )
1238   ]
1241 #serial 1
1243 dnl Determine whether to add fnmatch.o to LIBOBJS and to
1244 dnl define fnmatch to rpl_fnmatch.
1246 dnl If you use this macro in a package, you should
1247 dnl add the following two lines to acconfig.h:
1248 dnl  /* Define to rpl_fnmatch if the replacement function should be used.  */
1249 dnl  #undef fnmatch
1252 AC_DEFUN(jm_FUNC_FNMATCH,
1254   AC_REQUIRE([AM_GLIBC])
1255   AC_FUNC_FNMATCH
1256   if test $ac_cv_func_fnmatch_works = no \
1257       && test $ac_cv_gnu_library = no; then
1258     LIBOBJS="$LIBOBJS fnmatch.o"
1259     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch)
1260   fi
1263 #serial 2
1265 dnl From Gordon Matzigkeit.
1266 dnl Test for the GNU C Library.
1267 dnl FIXME: this should migrate into libit.
1269 AC_DEFUN(AM_GLIBC,
1270   [
1271     AC_CACHE_CHECK(whether we are using the GNU C Library,
1272       ac_cv_gnu_library,
1273       [AC_EGREP_CPP([Thanks for using GNU],
1274         [
1275 #include <features.h>
1276 #ifdef __GNU_LIBRARY__
1277   Thanks for using GNU
1278 #endif
1279         ],
1280         ac_cv_gnu_library=yes,
1281         ac_cv_gnu_library=no)
1282       ]
1283     )
1284     AC_CACHE_CHECK(for version 2 of the GNU C Library,
1285       ac_cv_glibc,
1286       [AC_EGREP_CPP([Thanks for using GNU too],
1287         [
1288 #include <features.h>
1289 #ifdef __GLIBC__
1290   Thanks for using GNU too
1291 #endif
1292         ],
1293         ac_cv_glibc=yes, ac_cv_glibc=no)
1294       ]
1295     )
1296   ]
1299 # Macro to add for using GNU gettext.
1300 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1302 # This file can be copied and used freely without restrictions.  It can
1303 # be used in projects which are not available under the GNU Public License
1304 # but which still want to provide support for the GNU gettext functionality.
1305 # Please note that the actual code is *not* freely available.
1307 # serial 5
1309 AC_DEFUN(AM_WITH_NLS,
1310   [AC_MSG_CHECKING([whether NLS is requested])
1311     dnl Default is enabled NLS
1312     AC_ARG_ENABLE(nls,
1313       [  --disable-nls           do not use Native Language Support],
1314       USE_NLS=$enableval, USE_NLS=yes)
1315     AC_MSG_RESULT($USE_NLS)
1316     AC_SUBST(USE_NLS)
1318     USE_INCLUDED_LIBINTL=no
1320     dnl If we use NLS figure out what method
1321     if test "$USE_NLS" = "yes"; then
1322       AC_DEFINE(ENABLE_NLS)
1323       AC_MSG_CHECKING([whether included gettext is requested])
1324       AC_ARG_WITH(included-gettext,
1325         [  --with-included-gettext use the GNU gettext library included here],
1326         nls_cv_force_use_gnu_gettext=$withval,
1327         nls_cv_force_use_gnu_gettext=no)
1328       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
1330       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
1331       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
1332         dnl User does not insist on using GNU NLS library.  Figure out what
1333         dnl to use.  If gettext or catgets are available (in this order) we
1334         dnl use this.  Else we have to fall back to GNU NLS library.
1335         dnl catgets is only used if permitted by option --with-catgets.
1336         nls_cv_header_intl=
1337         nls_cv_header_libgt=
1338         CATOBJEXT=NONE
1340         AC_CHECK_HEADER(libintl.h,
1341           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
1342             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
1343                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
1345            if test "$gt_cv_func_gettext_libc" != "yes"; then
1346              AC_CHECK_LIB(intl, bindtextdomain,
1347                [AC_CACHE_CHECK([for gettext in libintl],
1348                  gt_cv_func_gettext_libintl,
1349                  [AC_CHECK_LIB(intl, gettext,
1350                   gt_cv_func_gettext_libintl=yes,
1351                   gt_cv_func_gettext_libintl=no)],
1352                  gt_cv_func_gettext_libintl=no)])
1353            fi
1355            if test "$gt_cv_func_gettext_libc" = "yes" \
1356               || test "$gt_cv_func_gettext_libintl" = "yes"; then
1357               AC_DEFINE(HAVE_GETTEXT)
1358               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1359                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
1360               if test "$MSGFMT" != "no"; then
1361                 AC_CHECK_FUNCS(dcgettext)
1362                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1363                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1364                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1365                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
1366                                return _nl_msg_cat_cntr],
1367                   [CATOBJEXT=.gmo
1368                    DATADIRNAME=share],
1369                   [CATOBJEXT=.mo
1370                    DATADIRNAME=lib])
1371                 INSTOBJEXT=.mo
1372               fi
1373             fi
1374         ])
1376         if test "$CATOBJEXT" = "NONE"; then
1377           AC_MSG_CHECKING([whether catgets can be used])
1378           AC_ARG_WITH(catgets,
1379             [  --with-catgets          use catgets functions if available],
1380             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
1381           AC_MSG_RESULT($nls_cv_use_catgets)
1383           if test "$nls_cv_use_catgets" = "yes"; then
1384             dnl No gettext in C library.  Try catgets next.
1385             AC_CHECK_LIB(i, main)
1386             AC_CHECK_FUNC(catgets,
1387               [AC_DEFINE(HAVE_CATGETS)
1388                INTLOBJS="\$(CATOBJS)"
1389                AC_PATH_PROG(GENCAT, gencat, no)dnl
1390                if test "$GENCAT" != "no"; then
1391                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
1392                  if test "$GMSGFMT" = "no"; then
1393                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
1394                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
1395                  fi
1396                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1397                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1398                  USE_INCLUDED_LIBINTL=yes
1399                  CATOBJEXT=.cat
1400                  INSTOBJEXT=.cat
1401                  DATADIRNAME=lib
1402                  INTLDEPS='$(top_builddir)/intl/libintl.a'
1403                  INTLLIBS=$INTLDEPS
1404                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1405                  nls_cv_header_intl=intl/libintl.h
1406                  nls_cv_header_libgt=intl/libgettext.h
1407                fi])
1408           fi
1409         fi
1411         if test "$CATOBJEXT" = "NONE"; then
1412           dnl Neither gettext nor catgets in included in the C library.
1413           dnl Fall back on GNU gettext library.
1414           nls_cv_use_gnu_gettext=yes
1415         fi
1416       fi
1418       if test "$nls_cv_use_gnu_gettext" = "yes"; then
1419         dnl Mark actions used to generate GNU NLS library.
1420         INTLOBJS="\$(GETTOBJS)"
1421         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1422           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
1423         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1424         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1425           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1426         AC_SUBST(MSGFMT)
1427         USE_INCLUDED_LIBINTL=yes
1428         CATOBJEXT=.gmo
1429         INSTOBJEXT=.mo
1430         DATADIRNAME=share
1431         INTLDEPS='$(top_builddir)/intl/libintl.a'
1432         INTLLIBS=$INTLDEPS
1433         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1434         nls_cv_header_intl=intl/libintl.h
1435         nls_cv_header_libgt=intl/libgettext.h
1436       fi
1438       dnl Test whether we really found GNU xgettext.
1439       if test "$XGETTEXT" != ":"; then
1440         dnl If it is no GNU xgettext we define it as : so that the
1441         dnl Makefiles still can work.
1442         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
1443           : ;
1444         else
1445           AC_MSG_RESULT(
1446             [found xgettext program is not GNU xgettext; ignore it])
1447           XGETTEXT=":"
1448         fi
1449       fi
1451       # We need to process the po/ directory.
1452       POSUB=po
1453     else
1454       DATADIRNAME=share
1455       nls_cv_header_intl=intl/libintl.h
1456       nls_cv_header_libgt=intl/libgettext.h
1457     fi
1458     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
1459     AC_OUTPUT_COMMANDS(
1460      [case "$CONFIG_FILES" in *po/Makefile.in*)
1461         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
1462       esac])
1465     # If this is used in GNU gettext we have to set USE_NLS to `yes'
1466     # because some of the sources are only built for this goal.
1467     if test "$PACKAGE" = gettext; then
1468       USE_NLS=yes
1469       USE_INCLUDED_LIBINTL=yes
1470     fi
1472     dnl These rules are solely for the distribution goal.  While doing this
1473     dnl we only have to keep exactly one list of the available catalogs
1474     dnl in configure.in.
1475     for lang in $ALL_LINGUAS; do
1476       GMOFILES="$GMOFILES $lang.gmo"
1477       POFILES="$POFILES $lang.po"
1478     done
1480     dnl Make all variables we use known to autoconf.
1481     AC_SUBST(USE_INCLUDED_LIBINTL)
1482     AC_SUBST(CATALOGS)
1483     AC_SUBST(CATOBJEXT)
1484     AC_SUBST(DATADIRNAME)
1485     AC_SUBST(GMOFILES)
1486     AC_SUBST(INSTOBJEXT)
1487     AC_SUBST(INTLDEPS)
1488     AC_SUBST(INTLLIBS)
1489     AC_SUBST(INTLOBJS)
1490     AC_SUBST(POFILES)
1491     AC_SUBST(POSUB)
1492   ])
1494 AC_DEFUN(AM_GNU_GETTEXT,
1495   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1496    AC_REQUIRE([AC_PROG_CC])dnl
1497    AC_REQUIRE([AC_PROG_RANLIB])dnl
1498    AC_REQUIRE([AC_ISC_POSIX])dnl
1499    AC_REQUIRE([AC_HEADER_STDC])dnl
1500    AC_REQUIRE([AC_C_CONST])dnl
1501    AC_REQUIRE([AC_C_INLINE])dnl
1502    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1503    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1504    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1505    AC_REQUIRE([AC_FUNC_MMAP])dnl
1507    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1508 unistd.h sys/param.h])
1509    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1510 strdup __argz_count __argz_stringify __argz_next])
1512    if test "${ac_cv_func_stpcpy+set}" != "set"; then
1513      AC_CHECK_FUNCS(stpcpy)
1514    fi
1515    if test "${ac_cv_func_stpcpy}" = "yes"; then
1516      AC_DEFINE(HAVE_STPCPY)
1517    fi
1519    AM_LC_MESSAGES
1520    AM_WITH_NLS
1522    if test "x$CATOBJEXT" != "x"; then
1523      if test "x$ALL_LINGUAS" = "x"; then
1524        LINGUAS=
1525      else
1526        AC_MSG_CHECKING(for catalogs to be installed)
1527        NEW_LINGUAS=
1528        for lang in ${LINGUAS=$ALL_LINGUAS}; do
1529          case "$ALL_LINGUAS" in
1530           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1531          esac
1532        done
1533        LINGUAS=$NEW_LINGUAS
1534        AC_MSG_RESULT($LINGUAS)
1535      fi
1537      dnl Construct list of names of catalog files to be constructed.
1538      if test -n "$LINGUAS"; then
1539        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1540      fi
1541    fi
1543    dnl The reference to <locale.h> in the installed <libintl.h> file
1544    dnl must be resolved because we cannot expect the users of this
1545    dnl to define HAVE_LOCALE_H.
1546    if test $ac_cv_header_locale_h = yes; then
1547      INCLUDE_LOCALE_H="#include <locale.h>"
1548    else
1549      INCLUDE_LOCALE_H="\
1550 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
1551    fi
1552    AC_SUBST(INCLUDE_LOCALE_H)
1554    dnl Determine which catalog format we have (if any is needed)
1555    dnl For now we know about two different formats:
1556    dnl   Linux libc-5 and the normal X/Open format
1557    test -d intl || mkdir intl
1558    if test "$CATOBJEXT" = ".cat"; then
1559      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
1561      dnl Transform the SED scripts while copying because some dumb SEDs
1562      dnl cannot handle comments.
1563      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
1564    fi
1565    dnl po2tbl.sed is always needed.
1566    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
1567      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
1569    dnl In the intl/Makefile.in we have a special dependency which makes
1570    dnl only sense for gettext.  We comment this out for non-gettext
1571    dnl packages.
1572    if test "$PACKAGE" = "gettext"; then
1573      GT_NO="#NO#"
1574      GT_YES=
1575    else
1576      GT_NO=
1577      GT_YES="#YES#"
1578    fi
1579    AC_SUBST(GT_NO)
1580    AC_SUBST(GT_YES)
1582    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1583    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
1584    dnl Try to locate is.
1585    MKINSTALLDIRS=
1586    if test -n "$ac_aux_dir"; then
1587      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1588    fi
1589    if test -z "$MKINSTALLDIRS"; then
1590      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1591    fi
1592    AC_SUBST(MKINSTALLDIRS)
1594    dnl *** For now the libtool support in intl/Makefile is not for real.
1595    l=
1596    AC_SUBST(l)
1598    dnl Generate list of files to be processed by xgettext which will
1599    dnl be included in po/Makefile.
1600    test -d po || mkdir po
1601    if test "x$srcdir" != "x."; then
1602      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
1603        posrcprefix="$srcdir/"
1604      else
1605        posrcprefix="../$srcdir/"
1606      fi
1607    else
1608      posrcprefix="../"
1609    fi
1610    rm -f po/POTFILES
1611    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
1612         < $srcdir/po/POTFILES.in > po/POTFILES
1613   ])
1615 # Search path for a program which passes the given test.
1616 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1618 # This file can be copied and used freely without restrictions.  It can
1619 # be used in projects which are not available under the GNU Public License
1620 # but which still want to provide support for the GNU gettext functionality.
1621 # Please note that the actual code is *not* freely available.
1623 # serial 1
1625 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1626 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1627 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
1628 [# Extract the first word of "$2", so it can be a program name with args.
1629 set dummy $2; ac_word=[$]2
1630 AC_MSG_CHECKING([for $ac_word])
1631 AC_CACHE_VAL(ac_cv_path_$1,
1632 [case "[$]$1" in
1633   /*)
1634   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1635   ;;
1636   *)
1637   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1638   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1639     test -z "$ac_dir" && ac_dir=.
1640     if test -f $ac_dir/$ac_word; then
1641       if [$3]; then
1642         ac_cv_path_$1="$ac_dir/$ac_word"
1643         break
1644       fi
1645     fi
1646   done
1647   IFS="$ac_save_ifs"
1648 dnl If no 4th arg is given, leave the cache variable unset,
1649 dnl so AC_PATH_PROGS will keep looking.
1650 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1651 ])dnl
1652   ;;
1653 esac])dnl
1654 $1="$ac_cv_path_$1"
1655 if test -n "[$]$1"; then
1656   AC_MSG_RESULT([$]$1)
1657 else
1658   AC_MSG_RESULT(no)
1660 AC_SUBST($1)dnl
1663 # Check whether LC_MESSAGES is available in <locale.h>.
1664 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1666 # This file can be copied and used freely without restrictions.  It can
1667 # be used in projects which are not available under the GNU Public License
1668 # but which still want to provide support for the GNU gettext functionality.
1669 # Please note that the actual code is *not* freely available.
1671 # serial 1
1673 AC_DEFUN(AM_LC_MESSAGES,
1674   [if test $ac_cv_header_locale_h = yes; then
1675     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1676       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1677        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1678     if test $am_cv_val_LC_MESSAGES = yes; then
1679       AC_DEFINE(HAVE_LC_MESSAGES)
1680     fi
1681   fi])