OSDN Git Service

2001-11-11 H.J. Lu <hjl@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
1 dnl See if stdbool.h properly defines bool and true/false.
2 AC_DEFUN(gcc_AC_HEADER_STDBOOL,
3 [AC_CACHE_CHECK([for working stdbool.h],
4   ac_cv_header_stdbool_h,
5 [AC_TRY_COMPILE([#include <stdbool.h>],
6 [bool foo = false;],
7 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
8 if test $ac_cv_header_stdbool_h = yes; then
9   AC_DEFINE(HAVE_STDBOOL_H, 1,
10   [Define if you have a working <stdbool.h> header file.])
11 fi
12 ])
13
14 dnl See whether we can include both string.h and strings.h.
15 AC_DEFUN(gcc_AC_HEADER_STRING,
16 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
17   gcc_cv_header_string,
18 [AC_TRY_COMPILE([#include <string.h>
19 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
20 if test $gcc_cv_header_string = yes; then
21   AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
22 fi
23 ])
24
25 dnl See whether we need a declaration for a function.
26 dnl The result is highly dependent on the INCLUDES passed in, so make sure
27 dnl to use a different cache variable name in this macro if it is invoked
28 dnl in a different context somewhere else.
29 dnl gcc_AC_CHECK_DECL(SYMBOL,
30 dnl     [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
31 AC_DEFUN(gcc_AC_CHECK_DECL,
32 [AC_MSG_CHECKING([whether $1 is declared])
33 AC_CACHE_VAL(gcc_cv_have_decl_$1,
34 [AC_TRY_COMPILE([$4],
35 [#ifndef $1
36 char *(*pfn) = (char *(*)) $1 ;
37 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
38 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
39   AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
40 else
41   AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
42 fi
43 ])dnl
44
45 dnl Check multiple functions to see whether each needs a declaration.
46 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
47 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
48 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
49 AC_DEFUN(gcc_AC_CHECK_DECLS,
50 [for ac_func in $1
51 do
52 changequote(, )dnl
53   ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
54 changequote([, ])dnl
55 gcc_AC_CHECK_DECL($ac_func,
56   [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
57   [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
58 dnl It is possible that the include files passed in here are local headers
59 dnl which supply a backup declaration for the relevant prototype based on
60 dnl the definition of (or lack of) the HAVE_DECL_ macro.  If so, this test
61 dnl will always return success.  E.g. see libiberty.h's handling of
62 dnl `basename'.  To avoid this, we define the relevant HAVE_DECL_ macro to
63 dnl 1 so that any local headers used do not provide their own prototype
64 dnl during this test.
65 #undef $ac_tr_decl
66 #define $ac_tr_decl 1
67   $4
68 )
69 done
70 dnl Automatically generate config.h entries via autoheader.
71 if test x = y ; then
72   patsubst(translit([$1], [a-z], [A-Z]), [\w+],
73     [AC_DEFINE([HAVE_DECL_\&], 1,
74       [Define to 1 if we found this declaration otherwise define to 0.])])dnl
75 fi
76 ])
77
78 dnl Check if we have vprintf and possibly _doprnt.
79 dnl Note autoconf checks for vprintf even though we care about vfprintf.
80 AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
81 [AC_FUNC_VPRINTF
82 vfprintf=
83 doprint=
84 if test $ac_cv_func_vprintf != yes ; then
85   vfprintf=vfprintf.o
86   if test $ac_cv_func__doprnt != yes ; then
87     doprint=doprint.o
88   fi
89 fi
90 AC_SUBST(vfprintf)
91 AC_SUBST(doprint)
92 ])    
93
94 dnl Check if we have strstr.
95 AC_DEFUN([gcc_AC_FUNC_STRSTR],
96   [AC_CHECK_FUNCS([strstr], [strstr=], [strstr=strstr.o])
97    AC_SUBST([strstr])])
98
99 dnl See if the printf functions in libc support %p in format strings.
100 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
101 [AC_CACHE_CHECK(whether the printf functions support %p,
102   gcc_cv_func_printf_ptr,
103 [AC_TRY_RUN([#include <stdio.h>
104
105 int main()
106 {
107   char buf[64];
108   char *p = buf, *q = NULL;
109   sprintf(buf, "%p", p);
110   sscanf(buf, "%p", &q);
111   return (p != q);
112 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
113         gcc_cv_func_printf_ptr=no)
114 rm -f core core.* *.core])
115 if test $gcc_cv_func_printf_ptr = yes ; then
116   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
117 fi
118 ])
119
120 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
121 AC_DEFUN(gcc_AC_PROG_LN_S,
122 [AC_MSG_CHECKING(whether ln -s works)
123 AC_CACHE_VAL(gcc_cv_prog_LN_S,
124 [rm -f conftestdata_t
125 echo >conftestdata_f
126 if ln -s conftestdata_f conftestdata_t 2>/dev/null
127 then
128   gcc_cv_prog_LN_S="ln -s"
129 else
130   if ln conftestdata_f conftestdata_t 2>/dev/null
131   then
132     gcc_cv_prog_LN_S=ln
133   else
134     gcc_cv_prog_LN_S=cp
135   fi
136 fi
137 rm -f conftestdata_f conftestdata_t
138 ])dnl
139 LN_S="$gcc_cv_prog_LN_S"
140 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
141   AC_MSG_RESULT(yes)
142 else
143   if test "$gcc_cv_prog_LN_S" = "ln"; then
144     AC_MSG_RESULT([no, using ln])
145   else
146     AC_MSG_RESULT([no, and neither does ln, so using cp])
147   fi
148 fi
149 AC_SUBST(LN_S)dnl
150 ])
151
152 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
153 AC_DEFUN(gcc_AC_PROG_LN,
154 [AC_MSG_CHECKING(whether ln works)
155 AC_CACHE_VAL(gcc_cv_prog_LN,
156 [rm -f conftestdata_t
157 echo >conftestdata_f
158 if ln conftestdata_f conftestdata_t 2>/dev/null
159 then
160   gcc_cv_prog_LN="ln"
161 else
162   if ln -s conftestdata_f conftestdata_t 2>/dev/null
163   then
164     gcc_cv_prog_LN="ln -s"
165   else
166     gcc_cv_prog_LN=cp
167   fi
168 fi
169 rm -f conftestdata_f conftestdata_t
170 ])dnl
171 LN="$gcc_cv_prog_LN"
172 if test "$gcc_cv_prog_LN" = "ln"; then
173   AC_MSG_RESULT(yes)
174 else
175   if test "$gcc_cv_prog_LN" = "ln -s"; then
176     AC_MSG_RESULT([no, using ln -s])
177   else
178     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
179   fi
180 fi
181 AC_SUBST(LN)dnl
182 ])
183
184 dnl See whether the stage1 host compiler accepts the volatile keyword.
185 AC_DEFUN(gcc_AC_C_VOLATILE,
186 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
187 [AC_TRY_COMPILE(, [volatile int foo;],
188         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
189 if test $gcc_cv_c_volatile = yes ; then
190   AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
191 fi
192 ])
193
194 dnl Check whether long double is supported.  This differs from the
195 dnl built-in autoconf test in that it works for cross compiles.
196 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
197 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
198 [if test "$GCC" = yes; then
199   gcc_cv_c_long_double=yes
200 else
201 AC_TRY_COMPILE(,
202 [/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
203 long double foo = 0.0;
204 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
205 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
206 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
207 fi])
208 if test $gcc_cv_c_long_double = yes; then
209   AC_DEFINE(HAVE_LONG_DOUBLE, 1, 
210       [Define if your compiler supports the \`long double' type.])
211 fi
212 ])
213
214 dnl Check whether _Bool is built-in.
215 AC_DEFUN(gcc_AC_C__BOOL,
216 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
217 [AC_TRY_COMPILE(,
218 [_Bool foo;],
219 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
220 ])
221 if test $gcc_cv_c__bool = yes; then
222   AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
223 fi
224 ])
225
226 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
227 dnl of the usual 2.
228 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
229 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
230 [AC_TRY_COMPILE([
231 #include <sys/types.h>
232 #ifdef HAVE_SYS_STAT_H
233 # include <sys/stat.h>
234 #endif
235 #ifdef HAVE_UNISTD_H
236 # include <unistd.h>
237 #endif
238 #ifdef HAVE_DIRECT_H
239 # include <direct.h>
240 #endif], [mkdir ("foo", 0);], 
241         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
242 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
243   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
244 fi
245 ])
246
247 AC_DEFUN(gcc_AC_PROG_INSTALL,
248 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
249 # Find a good install program.  We prefer a C program (faster),
250 # so one script is as good as another.  But avoid the broken or
251 # incompatible versions:
252 # SysV /etc/install, /usr/sbin/install
253 # SunOS /usr/etc/install
254 # IRIX /sbin/install
255 # AIX /bin/install
256 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
257 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
258 # ./install, which can be erroneously created by make from ./install.sh.
259 AC_MSG_CHECKING(for a BSD compatible install)
260 if test -z "$INSTALL"; then
261 AC_CACHE_VAL(ac_cv_path_install,
262 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
263   for ac_dir in $PATH; do
264     # Account for people who put trailing slashes in PATH elements.
265     case "$ac_dir/" in
266     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
267     *)
268       # OSF1 and SCO ODT 3.0 have their own names for install.
269       for ac_prog in ginstall scoinst install; do
270         if test -f $ac_dir/$ac_prog; then
271           if test $ac_prog = install &&
272             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
273             # AIX install.  It has an incompatible calling convention.
274             # OSF/1 installbsd also uses dspmsg, but is usable.
275             :
276           else
277             ac_cv_path_install="$ac_dir/$ac_prog -c"
278             break 2
279           fi
280         fi
281       done
282       ;;
283     esac
284   done
285   IFS="$ac_save_IFS"
286 ])dnl
287   if test "${ac_cv_path_install+set}" = set; then
288     INSTALL="$ac_cv_path_install"
289   else
290     # As a last resort, use the slow shell script.  We don't cache a
291     # path for INSTALL within a source directory, because that will
292     # break other packages using the cache if that directory is
293     # removed, or if the path is relative.
294     INSTALL="$ac_install_sh"
295   fi
296 fi
297 dnl We do special magic for INSTALL instead of AC_SUBST, to get
298 dnl relative paths right.
299 AC_MSG_RESULT($INSTALL)
300 AC_SUBST(INSTALL)dnl
301
302 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
303 # It thinks the first close brace ends the variable substitution.
304 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
305 AC_SUBST(INSTALL_PROGRAM)dnl
306
307 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
308 AC_SUBST(INSTALL_DATA)dnl
309 ])
310
311 dnl Test for GNAT.
312 dnl We require the gnatbind program, and a compiler driver that
313 dnl understands Ada.  The user may set the driver name explicitly
314 dnl with ADAC; also, the user's CC setting is tried.  Failing that,
315 dnl we try gcc and cc, then a sampling of names known to be used for
316 dnl the Ada driver on various systems.
317 dnl
318 dnl Sets the shell variable have_gnat to yes or no as appropriate, and
319 dnl substitutes GNATBIND and ADAC.
320 AC_DEFUN([gcc_AC_PROG_GNAT],
321 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
322 AC_CHECK_TOOL(GNATBIND, gnatbind, no)
323 AC_CACHE_CHECK([for compiler driver that understands Ada],
324                  gcc_cv_prog_adac,
325 [cat >conftest.adb <<EOF
326 procedure conftest is begin null; end conftest;
327 EOF
328 gcc_cv_prog_adac=no
329 # Have to do ac_tool_prefix and user overrides by hand.
330 user_adac=$ADAC
331 user_cc=$CC
332 for cand in ${ac_tool_prefix}$user_adac $user_adac      \
333             ${ac_tool_prefix}$user_cc   $user_cc        \
334             ${ac_tool_prefix}gcc        gcc             \
335             ${ac_tool_prefix}cc         cc              \
336             ${ac_tool_prefix}gnatgcc    gnatgcc         \
337             ${ac_tool_prefix}gnatcc     gnatcc          \
338             ${ac_tool_prefix}adagcc     adagcc          \
339             ${ac_tool_prefix}adacc      adacc           ; do
340   # There is a bug in all released versions of GCC which causes the
341   # driver to exit successfully when the appropriate language module
342   # has not been installed.  This is fixed in 2.95.4, 3.0.2, and 3.1.
343   # Therefore we must check for the error message as well as an
344   # unsuccessful exit.
345   errors=`$cand -c conftest.adb 2>&1 || echo failure`
346   if test x"$errors" = x; then
347     gcc_cv_prog_adac=$cand
348     break
349   fi
350 done
351 rm -f conftest.*])
352 ADAC=$gcc_cv_prog_adac
353 AC_SUBST(ADAC)
354
355 if test x$GNATBIND != xno && test x$ADAC != xno; then
356   have_gnat=yes
357 else
358   have_gnat=no
359 fi
360 ])
361
362 #serial 1
363 dnl This test replaces the one in autoconf.
364 dnl Currently this macro should have the same name as the autoconf macro
365 dnl because gettext's gettext.m4 (distributed in the automake package)
366 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
367 dnl give these diagnostics:
368 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
369 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
370
371 undefine([AC_ISC_POSIX])
372 AC_DEFUN(AC_ISC_POSIX,
373   [
374     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
375     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
376   ]
377 )
378
379
380 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
381 dnl like AC_PATH_PROG but use other cache variables
382 AC_DEFUN(GCC_PATH_PROG,
383 [# Extract the first word of "$2", so it can be a program name with args.
384 set dummy $2; ac_word=[$]2
385 AC_MSG_CHECKING([for $ac_word])
386 AC_CACHE_VAL(gcc_cv_path_$1,
387 [case "[$]$1" in
388   /*)
389   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
390   ;;
391   ?:/*)                  
392   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
393   ;;
394   *)
395   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
396 dnl $ac_dummy forces splitting on constant user-supplied paths.
397 dnl POSIX.2 word splitting is done only on the output of word expansions,
398 dnl not every word.  This closes a longstanding sh security hole.
399   ac_dummy="ifelse([$4], , $PATH, [$4])"
400   for ac_dir in $ac_dummy; do 
401     test -z "$ac_dir" && ac_dir=.
402     if test -f $ac_dir/$ac_word; then
403       gcc_cv_path_$1="$ac_dir/$ac_word"
404       break
405     fi
406   done
407   IFS="$ac_save_ifs"
408 dnl If no 3rd arg is given, leave the cache variable unset,
409 dnl so GCC_PATH_PROGS will keep looking.
410 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
411 ])dnl
412   ;;
413 esac])dnl
414 $1="$gcc_cv_path_$1"
415 if test -n "[$]$1"; then
416   AC_MSG_RESULT([$]$1)
417 else
418   AC_MSG_RESULT(no)
419 fi
420 AC_SUBST($1)dnl
421 ])
422
423 # Check whether mmap can map an arbitrary page from /dev/zero or with
424 # MAP_ANONYMOUS, without MAP_FIXED.
425 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
426 [AC_CHECK_FUNCS(getpagesize)
427 # The test program for the next two tests is the same except for one
428 # set of ifdefs.
429 changequote({{{,}}})dnl
430 {{{cat >ct-mmap.inc <<'EOF'
431 #include <sys/types.h>
432 #include <sys/mman.h>
433 #include <fcntl.h>
434 #include <signal.h>
435 #include <setjmp.h>
436 #include <stdio.h>
437
438 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
439 # define MAP_ANONYMOUS MAP_ANON
440 #endif
441
442 /* This mess was copied from the GNU getpagesize.h.  */
443 #ifndef HAVE_GETPAGESIZE
444 # ifdef HAVE_UNISTD_H
445 #  include <unistd.h>
446 # endif
447
448 /* Assume that all systems that can run configure have sys/param.h.  */
449 # ifndef HAVE_SYS_PARAM_H
450 #  define HAVE_SYS_PARAM_H 1
451 # endif
452
453 # ifdef _SC_PAGESIZE
454 #  define getpagesize() sysconf(_SC_PAGESIZE)
455 # else /* no _SC_PAGESIZE */
456 #  ifdef HAVE_SYS_PARAM_H
457 #   include <sys/param.h>
458 #   ifdef EXEC_PAGESIZE
459 #    define getpagesize() EXEC_PAGESIZE
460 #   else /* no EXEC_PAGESIZE */
461 #    ifdef NBPG
462 #     define getpagesize() NBPG * CLSIZE
463 #     ifndef CLSIZE
464 #      define CLSIZE 1
465 #     endif /* no CLSIZE */
466 #    else /* no NBPG */
467 #     ifdef NBPC
468 #      define getpagesize() NBPC
469 #     else /* no NBPC */
470 #      ifdef PAGESIZE
471 #       define getpagesize() PAGESIZE
472 #      endif /* PAGESIZE */
473 #     endif /* no NBPC */
474 #    endif /* no NBPG */
475 #   endif /* no EXEC_PAGESIZE */
476 #  else /* no HAVE_SYS_PARAM_H */
477 #   define getpagesize() 8192   /* punt totally */
478 #  endif /* no HAVE_SYS_PARAM_H */
479 # endif /* no _SC_PAGESIZE */
480
481 #endif /* no HAVE_GETPAGESIZE */
482
483 #ifndef MAP_FAILED
484 # define MAP_FAILED -1
485 #endif
486
487 #undef perror_exit
488 #define perror_exit(str, val) \
489   do { perror(str); exit(val); } while (0)
490
491 /* Some versions of cygwin mmap require that munmap is called with the
492    same parameters as mmap.  GCC expects that this is not the case.
493    Test for various forms of this problem.  Warning - icky signal games.  */
494
495 static sigset_t unblock_sigsegv;
496 static jmp_buf r;
497 static size_t pg;
498 static int devzero;
499
500 static char *
501 anonmap (size)
502      size_t size;
503 {
504 #ifdef USE_MAP_ANON
505   return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
506                         MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
507 #else
508   return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
509                         MAP_PRIVATE, devzero, 0);
510 #endif
511 }
512
513 static void
514 sigsegv (unused)
515      int unused;
516 {
517   sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
518   longjmp (r, 1);
519 }
520
521 /* Basic functionality test.  */
522 void
523 test_0 ()
524 {
525   char *x = anonmap (pg);
526   if (x == (char *) MAP_FAILED)
527     perror_exit("test 0 mmap", 2);
528
529   *(int *)x += 1;
530
531   if (munmap(x, pg) < 0)
532     perror_exit("test 0 munmap", 3);
533 }
534
535 /* 1. If we map a 2-page region and unmap its second page, the first page
536    must remain.  */
537 static void
538 test_1 ()
539 {
540   char *x = anonmap (pg * 2);
541   if (x == (char *)MAP_FAILED)
542     perror_exit ("test 1 mmap", 4);
543
544   signal (SIGSEGV, sigsegv);
545   if (setjmp (r))
546     perror_exit ("test 1 fault", 5);
547
548   x[0] = 1;
549   x[pg] = 1;
550
551   if (munmap (x + pg, pg) < 0)
552     perror_exit ("test 1 munmap 1", 6);
553   x[0] = 2;
554
555   if (setjmp (r) == 0)
556     {
557       x[pg] = 1;
558       perror_exit ("test 1 no fault", 7);
559     }
560   if (munmap (x, pg) < 0)
561     perror_exit ("test 1 munmap 2", 8);
562 }
563
564 /* 2. If we map a 2-page region and unmap its first page, the second
565    page must remain.  */
566 static void
567 test_2 ()
568 {
569   char *x = anonmap (pg * 2);
570   if (x == (char *)MAP_FAILED)
571     perror_exit ("test 2 mmap", 9);
572
573   signal (SIGSEGV, sigsegv);
574   if (setjmp (r))
575     perror_exit ("test 2 fault", 10);
576
577   x[0] = 1;
578   x[pg] = 1;
579
580   if (munmap (x, pg) < 0)
581     perror_exit ("test 2 munmap 1", 11);
582
583   x[pg] = 2;
584
585   if (setjmp (r) == 0)
586     {
587       x[0] = 1;
588       perror_exit ("test 2 no fault", 12);
589     }
590
591   if (munmap (x+pg, pg) < 0)
592     perror_exit ("test 2 munmap 2", 13);
593 }
594
595 /* 3. If we map two adjacent 1-page regions and unmap them both with
596    one munmap, both must go away.
597
598    Getting two adjacent 1-page regions with two mmap calls is slightly
599    tricky.  All OS's tested skip over already-allocated blocks; therefore
600    we have been careful to unmap all allocated regions in previous tests.
601    HP/UX allocates pages backward in memory.  No OS has yet been observed
602    to be so perverse as to leave unmapped space between consecutive calls
603    to mmap.  */
604
605 static void
606 test_3 ()
607 {
608   char *x, *y, *z;
609
610   x = anonmap (pg);
611   if (x == (char *)MAP_FAILED)
612     perror_exit ("test 3 mmap 1", 14);
613   y = anonmap (pg);
614   if (y == (char *)MAP_FAILED)
615     perror_exit ("test 3 mmap 2", 15);
616
617   if (y != x + pg)
618     {
619       if (y == x - pg)
620         z = y, y = x, x = z;
621       else
622         {
623           fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
624                    (unsigned long)x, (unsigned long)y);
625           exit (16);
626         }
627     }
628
629   signal (SIGSEGV, sigsegv);
630   if (setjmp (r))
631     perror_exit ("test 3 fault", 17);
632
633   x[0] = 1;
634   y[0] = 1;
635
636   if (munmap (x, pg*2) < 0)
637     perror_exit ("test 3 munmap", 18);
638
639   if (setjmp (r) == 0)
640     {
641       x[0] = 1;
642       perror_exit ("test 3 no fault 1", 19);
643     }
644   
645   signal (SIGSEGV, sigsegv);
646   if (setjmp (r) == 0)
647     {
648       y[0] = 1;
649       perror_exit ("test 3 no fault 2", 20);
650     }
651 }
652
653 int
654 main ()
655 {
656   sigemptyset (&unblock_sigsegv);
657   sigaddset (&unblock_sigsegv, SIGSEGV);
658   pg = getpagesize ();
659 #ifndef USE_MAP_ANON
660   devzero = open ("/dev/zero", O_RDWR);
661   if (devzero < 0)
662     perror_exit ("open /dev/zero", 1);
663 #endif
664
665   test_0();
666   test_1();
667   test_2();
668   test_3();
669
670   exit(0);
671 }
672 EOF}}}
673 changequote([,])dnl
674
675 AC_CACHE_CHECK(for working mmap from /dev/zero,
676   ac_cv_func_mmap_dev_zero,
677 [AC_TRY_RUN(
678  [#include "ct-mmap.inc"],
679  ac_cv_func_mmap_dev_zero=yes,
680  [if test $? -lt 4
681  then ac_cv_func_mmap_dev_zero=no
682  else ac_cv_func_mmap_dev_zero=buggy
683  fi],
684  # If this is not cygwin, and /dev/zero is a character device, it's probably
685  # safe to assume it works.
686  [case "$host_os" in
687    cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
688    * ) if test -c /dev/zero
689        then ac_cv_func_mmap_dev_zero=yes
690        else ac_cv_func_mmap_dev_zero=no
691        fi ;;
692   esac])
693 ])
694 if test $ac_cv_func_mmap_dev_zero = yes; then
695   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
696             [Define if mmap can get us zeroed pages from /dev/zero.])
697 fi
698
699 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
700   ac_cv_func_mmap_anon,
701 [AC_TRY_RUN(
702  [#define USE_MAP_ANON
703 #include "ct-mmap.inc"],
704  ac_cv_func_mmap_anon=yes,
705  [if test $? -lt 4
706  then ac_cv_func_mmap_anon=no
707  else ac_cv_func_mmap_anon=buggy
708  fi],
709  # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
710  # just because it's there. Some SCO Un*xen define it but don't implement it.
711  ac_cv_func_mmap_anon=no)
712 ])
713 if test $ac_cv_func_mmap_anon = yes; then
714   AC_DEFINE(HAVE_MMAP_ANON, 1,
715             [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
716 fi
717 rm -f ct-mmap.inc
718 ])
719
720 # Check whether mmap can map a plain file, without MAP_FIXED.
721 AC_DEFUN([AC_FUNC_MMAP_FILE], 
722 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
723 [# Create a file one thousand bytes long.
724 for i in 1 2 3 4 5 6 7 8 9 0
725 do for j in 1 2 3 4 5 6 7 8 9 0
726 do echo $i $j xxxxx
727 done
728 done > conftestdata$$
729
730 AC_TRY_RUN([
731 /* Test by Zack Weinberg.  Modified from MMAP_ANYWHERE test by
732    Richard Henderson and Alexandre Oliva.
733    Check whether read-only mmap of a plain file works. */
734 #include <sys/types.h>
735 #include <sys/stat.h>
736 #include <fcntl.h>
737 #include <sys/mman.h>
738
739 int main()
740 {
741   char *x;
742   int fd;
743   struct stat st;
744
745   fd = open("conftestdata$$", O_RDONLY);
746   if (fd < 0)
747     exit(1);
748
749   if (fstat (fd, &st))
750     exit(2);
751
752   x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
753   if (x == (char *) -1)
754     exit(3);
755
756   if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
757     exit(4);
758
759   if (munmap(x, st.st_size) < 0)
760     exit(5);
761
762   exit(0);
763 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
764 ac_cv_func_mmap_file=no)])
765 if test $ac_cv_func_mmap_file = yes; then
766   AC_DEFINE(HAVE_MMAP_FILE, 1,
767             [Define if read-only mmap of a plain file works.])
768 fi
769 ])
770
771 dnl Locate a program and check that its version is acceptable.
772 dnl AC_PROG_CHECK_VER(var, name, version-switch,
773 dnl                  version-extract-regexp, version-glob)
774 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
775 [AC_CHECK_PROG([$1], [$2], [$2])
776 if test -n "[$]$1"; then
777   # Found it, now check the version.
778   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
779 [changequote(<<,>>)dnl
780   ac_prog_version=`<<$>>$1 $3 2>&1 |
781                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
782 changequote([,])dnl
783   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
784 changequote(<<,>>)dnl
785   case $ac_prog_version in
786     '')     gcc_cv_prog_$2_modern=no;;
787     <<$5>>)
788             gcc_cv_prog_$2_modern=yes;;
789     *)      gcc_cv_prog_$2_modern=no;;
790   esac
791 changequote([,])dnl
792 ])
793 else
794   gcc_cv_prog_$2_modern=no
795 fi
796 ])
797
798 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
799 dnl be either signed or unsigned.
800 dnl
801 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
802 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
803 [AC_TRY_RUN(#include <stdlib.h>
804 enum t { BLAH = 128 } ;
805 struct s_t { enum t member : 8; } s ;
806 int main(void)
807 {            
808         s.member = BLAH;
809         if (s.member < 0) exit(1);
810         exit(0);
811
812 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
813 if test $gcc_cv_enum_bf_unsigned = yes; then
814   AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
815     [Define if enumerated bitfields are treated as unsigned values.])
816 fi])
817
818 dnl Host type sizes probe.
819 dnl By Kaveh R. Ghazi.  One typo fixed since.
820 dnl
821 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
822 [changequote(<<, >>)dnl
823 dnl The name to #define.
824 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
825 dnl The cache variable name.
826 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
827 changequote([, ])dnl
828 AC_MSG_CHECKING(size of $1)
829 AC_CACHE_VAL(AC_CV_NAME,
830 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
831   AC_TRY_COMPILE([#include "confdefs.h"
832 #include <sys/types.h>
833 $2
834 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
835   if test x$AC_CV_NAME != x ; then break; fi
836 done
837 ])
838 if test x$AC_CV_NAME = x ; then
839   AC_MSG_ERROR([cannot determine a size for $1])
840 fi
841 AC_MSG_RESULT($AC_CV_NAME)
842 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
843 undefine([AC_TYPE_NAME])dnl
844 undefine([AC_CV_NAME])dnl
845 ])
846
847 dnl Probe number of bits in a byte.
848 dnl Note C89 requires CHAR_BIT >= 8.
849 dnl
850 AC_DEFUN(gcc_AC_C_CHAR_BIT,
851 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
852 [AC_EGREP_CPP(found,
853 [#ifdef HAVE_LIMITS_H
854 #include <limits.h>
855 #endif
856 #ifdef CHAR_BIT
857 found
858 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
859 ])
860 if test $gcc_cv_decl_char_bit = no; then
861   AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
862 [i=8
863  gcc_cv_c_nbby=
864  while test $i -lt 65; do
865    AC_TRY_COMPILE(,
866      [switch(0) {
867   case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
868   case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
869   ; }], 
870      [gcc_cv_c_nbby=$i; break])
871    i=`expr $i + 1`
872  done
873  test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
874 ])
875 if test $gcc_cv_c_nbby = failed; then
876   AC_MSG_ERROR(cannot determine number of bits in a byte)
877 else
878   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
879   [Define as the number of bits in a byte, if \`limits.h' doesn't.])
880 fi
881 fi])
882
883 dnl Checking for long long.
884 dnl By Caolan McNamara <caolan@skynet.ie>
885 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
886 dnl
887 AC_DEFUN([gcc_AC_C_LONG_LONG],
888 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
889   [AC_TRY_COMPILE(,[long long int i;],
890          ac_cv_c_long_long=yes,
891          ac_cv_c_long_long=no)])
892   if test $ac_cv_c_long_long = yes; then
893     AC_DEFINE(HAVE_LONG_LONG, 1,
894       [Define if your compiler supports the \`long long' type.])
895   fi
896 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
897   [AC_TRY_COMPILE(,[__int64 i;],
898         ac_cv_c___int64=yes,
899         ac_cv_c___int64=no)])
900   if test $ac_cv_c___int64 = yes; then
901     AC_DEFINE(HAVE___INT64, 1,
902       [Define if your compiler supports the \`__int64' type.])
903   fi
904 ])
905
906 dnl Host character set probe.
907 dnl The EBCDIC values match the table in config/i370/i370.c;
908 dnl there are other versions of EBCDIC but GCC won't work with them.
909 dnl
910 AC_DEFUN([gcc_AC_C_CHARSET],
911 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
912   [AC_EGREP_CPP(ASCII,
913 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
914    && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
915 ASCII
916 #endif], ac_cv_c_charset=ASCII)
917   if test x${ac_cv_c_charset+set} != xset; then
918     AC_EGREP_CPP(EBCDIC,
919 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
920    && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
921 EBCDIC
922 #endif], ac_cv_c_charset=EBCDIC)
923   fi
924   if test x${ac_cv_c_charset+set} != xset; then
925     ac_cv_c_charset=unknown
926   fi])
927 if test $ac_cv_c_charset = unknown; then
928   AC_MSG_ERROR([*** Cannot determine host character set.])
929 elif test $ac_cv_c_charset = EBCDIC; then
930   AC_DEFINE(HOST_EBCDIC, 1,
931   [Define if the host execution character set is EBCDIC.])
932 fi])
933
934 dnl Utility macro used by next two tests.
935 dnl AC_EXAMINE_OBJECT(C source code,
936 dnl     commands examining object file,
937 dnl     [commands to run if compile failed]):
938 dnl
939 dnl Compile the source code to an object file; then convert it into a
940 dnl printable representation.  All unprintable characters and
941 dnl asterisks (*) are replaced by dots (.).  All white space is
942 dnl deleted.  Newlines (ASCII 0x10) in the input are preserved in the
943 dnl output, but runs of newlines are compressed to a single newline.
944 dnl Finally, line breaks are forcibly inserted so that no line is
945 dnl longer than 80 columns and the file ends with a newline.  The
946 dnl result of all this processing is in the file conftest.dmp, which
947 dnl may be examined by the commands in the second argument.
948 dnl
949 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
950 [AC_LANG_SAVE
951 AC_LANG_C
952 dnl Next bit cribbed from AC_TRY_COMPILE.
953 cat > conftest.$ac_ext <<EOF
954 [#line __oline__ "configure"
955 #include "confdefs.h"
956 $1
957 ]EOF
958 if AC_TRY_EVAL(ac_compile); then
959   od -c conftest.o |
960     sed ['s/^[0-7]*[    ]*/ /
961           s/\*/./g
962           s/ \\n/*/g
963           s/ [0-9][0-9][0-9]/./g
964           s/  \\[^ ]/./g'] |
965     tr -d '
966  ' | tr -s '*' '
967 ' | fold | sed '$a\
968 ' > conftest.dmp
969   $2
970 ifelse($3, , , else
971   $3
972 )dnl
973 fi
974 rm -rf conftest*
975 AC_LANG_RESTORE])
976
977 dnl Host endianness probe.
978 dnl This tests byte-within-word endianness.  GCC actually needs
979 dnl to know word-within-larger-object endianness.  They are the
980 dnl same on all presently supported hosts.
981 dnl Differs from AC_C_BIGENDIAN in that it does not require
982 dnl running a program on the host, and it defines the macro we
983 dnl want to see.
984 dnl
985 AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
986 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
987 [ac_cv_c_compile_endian=unknown
988 gcc_AC_EXAMINE_OBJECT([
989 #ifdef HAVE_LIMITS_H
990 # include <limits.h>
991 #endif
992 /* This structure must have no internal padding.  */
993   struct {
994     char prefix[sizeof "\nendian:" - 1];
995     short word;
996     char postfix[2];
997  } tester = {
998     "\nendian:",
999 #if SIZEOF_SHORT == 4
1000     ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
1001 #endif
1002     ('A' << CHAR_BIT) | 'B',
1003     'X', '\n'
1004 };],
1005  [if   grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
1006     ac_cv_c_compile_endian=big-endian
1007   elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
1008     ac_cv_c_compile_endian=little-endian
1009   fi])
1010 ])
1011 if test $ac_cv_c_compile_endian = unknown; then
1012   AC_MSG_ERROR([*** unable to determine endianness])
1013 elif test $ac_cv_c_compile_endian = big-endian; then
1014   AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
1015   [Define if the host machine stores words of multi-word integers in
1016    big-endian order.])
1017 fi
1018 ])
1019
1020 dnl Floating point format probe.
1021 dnl The basic concept is the same as the above: grep the object
1022 dnl file for an interesting string.  We have to watch out for
1023 dnl rounding changing the values in the object, however; this is
1024 dnl handled by ignoring the least significant byte of the float.
1025 dnl
1026 dnl Does not know about VAX G-float or C4x idiosyncratic format.
1027 dnl It does know about PDP-10 idiosyncratic format, but this is
1028 dnl not presently supported by GCC.  S/390 "binary floating point"
1029 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1030 dnl as ASCII?)
1031 dnl
1032 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1033 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1034 [gcc_AC_EXAMINE_OBJECT(
1035 [/* This will not work unless sizeof(double) == 8.  */
1036 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1037
1038 /* This structure must have no internal padding.  */
1039 struct possibility {
1040   char prefix[8];
1041   double candidate;
1042   char postfix[8];
1043 };
1044
1045 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1046 struct possibility table [] =
1047 {
1048   C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1049   C( 3.53802595280598432000e+18), /* D__float - VAX */
1050   C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1051   C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1052   C(-5.22995989424860458374e+10)  /* IBMHEXFP - s/390 format, EBCDIC */
1053 };],
1054  [if   grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1055     ac_cv_c_float_format='IEEE (big-endian)'
1056   elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1057     ac_cv_c_float_format='IEEE (big-endian)'
1058   elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1059     ac_cv_c_float_format='IEEE (little-endian)'
1060   elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1061     ac_cv_c_float_format='IEEE (little-endian)'
1062   elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1063     ac_cv_c_float_format='VAX D-float'
1064   elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1065     ac_cv_c_float_format='PDP-10'
1066   elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1067     ac_cv_c_float_format='IBM 370 hex'
1068   else
1069     AC_MSG_ERROR(Unknown floating point format)
1070   fi],
1071   [AC_MSG_ERROR(compile failed)])
1072 ])
1073 # IEEE is the default format.  If the float endianness isn't the same
1074 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1075 # (which is a tristate: yes, no, default).  This is only an issue with
1076 # IEEE; the other formats are only supported by a few machines each,
1077 # all with the same endianness.
1078 format=
1079 fbigend=
1080 case $ac_cv_c_float_format in
1081     'IEEE (big-endian)' )
1082         if test $ac_cv_c_compile_endian = little-endian; then
1083             fbigend=1
1084         fi
1085         ;;
1086     'IEEE (little-endian)' )
1087         if test $ac_cv_c_compile_endian = big-endian; then
1088             fbigend=0
1089         fi
1090         ;;
1091     'VAX D-float' )
1092         format=VAX_FLOAT_FORMAT
1093         ;;
1094     'PDP-10' )
1095         format=PDP10_FLOAT_FORMAT
1096         ;;
1097     'IBM 370 hex' )
1098         format=IBM_FLOAT_FORMAT
1099         ;;
1100 esac
1101 if test -n "$format"; then
1102         AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1103   [Define to the floating point format of the host machine, if not IEEE.])
1104 fi
1105 if test -n "$fbigend"; then
1106         AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1107   [Define to 1 if the host machine stores floating point numbers in
1108    memory with the word containing the sign bit at the lowest address,
1109    or to 0 if it does it the other way around.
1110
1111    This macro should not be defined if the ordering is the same as for
1112    multi-word integers.])
1113 fi
1114 ])
1115
1116 #serial AM2
1117
1118 dnl From Bruno Haible.
1119
1120 AC_DEFUN([AM_ICONV],
1121 [
1122   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
1123   dnl those with the standalone portable GNU libiconv installed).
1124
1125   AC_ARG_WITH([libiconv-prefix],
1126 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
1127     for dir in `echo "$withval" | tr : ' '`; do
1128       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
1129       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
1130     done
1131    ])
1132
1133   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
1134     am_cv_func_iconv="no, consider installing GNU libiconv"
1135     am_cv_lib_iconv=no
1136     AC_TRY_LINK([#include <stdlib.h>
1137 #include <iconv.h>],
1138       [iconv_t cd = iconv_open("","");
1139        iconv(cd,NULL,NULL,NULL,NULL);
1140        iconv_close(cd);],
1141       am_cv_func_iconv=yes)
1142     if test "$am_cv_func_iconv" != yes; then
1143       am_save_LIBS="$LIBS"
1144       LIBS="$LIBS -liconv"
1145       AC_TRY_LINK([#include <stdlib.h>
1146 #include <iconv.h>],
1147         [iconv_t cd = iconv_open("","");
1148          iconv(cd,NULL,NULL,NULL,NULL);
1149          iconv_close(cd);],
1150         am_cv_lib_iconv=yes
1151         am_cv_func_iconv=yes)
1152       LIBS="$am_save_LIBS"
1153     fi
1154   ])
1155   if test "$am_cv_func_iconv" = yes; then
1156     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
1157     AC_MSG_CHECKING([for iconv declaration])
1158     AC_CACHE_VAL(am_cv_proto_iconv, [
1159       AC_TRY_COMPILE([
1160 #include <stdlib.h>
1161 #include <iconv.h>
1162 extern
1163 #ifdef __cplusplus
1164 "C"
1165 #endif
1166 #if defined(__STDC__) || defined(__cplusplus)
1167 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1168 #else
1169 size_t iconv();
1170 #endif
1171 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
1172       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
1173     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
1174     AC_MSG_RESULT([$]{ac_t:-
1175          }[$]am_cv_proto_iconv)
1176     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
1177       [Define as const if the declaration of iconv() needs const.])
1178   fi
1179   LIBICONV=
1180   if test "$am_cv_lib_iconv" = yes; then
1181     LIBICONV="-liconv"
1182   fi
1183   AC_SUBST(LIBICONV)
1184 ])
1185
1186 ### Gettext macros begin here.
1187 ### Changes for GCC marked by 'dnl GCC LOCAL'.
1188 ### Note iconv.m4 appears above, as it's used for other reasons.
1189
1190 #serial AM1
1191
1192 dnl From Bruno Haible.
1193
1194 AC_DEFUN([AM_LANGINFO_CODESET],
1195 [
1196   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
1197     [AC_TRY_LINK([#include <langinfo.h>],
1198       [char* cs = nl_langinfo(CODESET);],
1199       am_cv_langinfo_codeset=yes,
1200       am_cv_langinfo_codeset=no)
1201     ])
1202   if test $am_cv_langinfo_codeset = yes; then
1203     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
1204       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
1205   fi
1206 ])
1207
1208 #serial 1
1209 # This test replaces the one in autoconf.
1210 # Currently this macro should have the same name as the autoconf macro
1211 # because gettext's gettext.m4 (distributed in the automake package)
1212 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
1213 # give these diagnostics:
1214 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
1215 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
1216
1217 undefine([AC_ISC_POSIX])
1218
1219 AC_DEFUN([AC_ISC_POSIX],
1220   [
1221     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
1222     dnl GCC LOCAL: Use AC_SEARCH_LIBS.
1223     AC_SEARCH_LIBS(strerror, cposix)
1224   ]
1225 )
1226
1227 #serial 2
1228
1229 # Test for the GNU C Library, version 2.1 or newer.
1230 # From Bruno Haible.
1231
1232 AC_DEFUN([jm_GLIBC21],
1233   [
1234     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
1235       ac_cv_gnu_library_2_1,
1236       [AC_EGREP_CPP([Lucky GNU user],
1237         [
1238 #include <features.h>
1239 #ifdef __GNU_LIBRARY__
1240  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
1241   Lucky GNU user
1242  #endif
1243 #endif
1244         ],
1245         ac_cv_gnu_library_2_1=yes,
1246         ac_cv_gnu_library_2_1=no)
1247       ]
1248     )
1249     AC_SUBST(GLIBC21)
1250     GLIBC21="$ac_cv_gnu_library_2_1"
1251   ]
1252 )
1253
1254 # Check whether LC_MESSAGES is available in <locale.h>.
1255 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1256 #
1257 # This file can be copied and used freely without restrictions.  It can
1258 # be used in projects which are not available under the GNU General Public
1259 # License or the GNU Library General Public License but which still want
1260 # to provide support for the GNU gettext functionality.
1261 # Please note that the actual code of the GNU gettext library is covered
1262 # by the GNU Library General Public License, and the rest of the GNU
1263 # gettext package package is covered by the GNU General Public License.
1264 # They are *not* in the public domain.
1265
1266 # serial 2
1267
1268 AC_DEFUN([AM_LC_MESSAGES],
1269   [if test $ac_cv_header_locale_h = yes; then
1270     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1271       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1272        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1273     if test $am_cv_val_LC_MESSAGES = yes; then
1274       AC_DEFINE(HAVE_LC_MESSAGES, 1,
1275         [Define if your <locale.h> file defines LC_MESSAGES.])
1276     fi
1277   fi])
1278
1279 # Search path for a program which passes the given test.
1280 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1281 #
1282 # This file can be copied and used freely without restrictions.  It can
1283 # be used in projects which are not available under the GNU General Public
1284 # License or the GNU Library General Public License but which still want
1285 # to provide support for the GNU gettext functionality.
1286 # Please note that the actual code of the GNU gettext library is covered
1287 # by the GNU Library General Public License, and the rest of the GNU
1288 # gettext package package is covered by the GNU General Public License.
1289 # They are *not* in the public domain.
1290
1291 # serial 2
1292
1293 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1294 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1295 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
1296 [# Extract the first word of "$2", so it can be a program name with args.
1297 set dummy $2; ac_word=[$]2
1298 AC_MSG_CHECKING([for $ac_word])
1299 AC_CACHE_VAL(ac_cv_path_$1,
1300 [case "[$]$1" in
1301   /*)
1302   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1303   ;;
1304   *)
1305   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1306   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1307     test -z "$ac_dir" && ac_dir=.
1308     if test -f $ac_dir/$ac_word; then
1309       if [$3]; then
1310         ac_cv_path_$1="$ac_dir/$ac_word"
1311         break
1312       fi
1313     fi
1314   done
1315   IFS="$ac_save_ifs"
1316 dnl If no 4th arg is given, leave the cache variable unset,
1317 dnl so AC_PATH_PROGS will keep looking.
1318 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1319 ])dnl
1320   ;;
1321 esac])dnl
1322 $1="$ac_cv_path_$1"
1323 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1324   AC_MSG_RESULT([$]$1)
1325 else
1326   AC_MSG_RESULT(no)
1327 fi
1328 AC_SUBST($1)dnl
1329 ])
1330
1331 # Macro to add for using GNU gettext.
1332 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1333 #
1334 # This file can be copied and used freely without restrictions.  It can
1335 # be used in projects which are not available under the GNU General Public
1336 # License or the GNU Library General Public License but which still want
1337 # to provide support for the GNU gettext functionality.
1338 # Please note that the actual code of the GNU gettext library is covered
1339 # by the GNU Library General Public License, and the rest of the GNU
1340 # gettext package package is covered by the GNU General Public License.
1341 # They are *not* in the public domain.
1342
1343 # serial 10
1344
1345 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
1346 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
1347 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
1348 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
1349 dnl    AM-DISABLE-SHARED). Otherwise, a static library
1350 dnl    $(top_builddir)/intl/libintl.a will be created.
1351 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
1352 dnl    implementations (in libc or libintl) without the ngettext() function
1353 dnl    will be ignored.
1354 dnl LIBDIR is used to find the intl libraries.  If empty,
1355 dnl    the value `$(top_builddir)/intl/' is used.
1356 dnl
1357 dnl The result of the configuration is one of three cases:
1358 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
1359 dnl    and used.
1360 dnl    Catalog format: GNU --> install in $(datadir)
1361 dnl    Catalog extension: .mo after installation, .gmo in source tree
1362 dnl 2) GNU gettext has been found in the system's C library.
1363 dnl    Catalog format: GNU --> install in $(datadir)
1364 dnl    Catalog extension: .mo after installation, .gmo in source tree
1365 dnl 3) No internationalization, always use English msgid.
1366 dnl    Catalog format: none
1367 dnl    Catalog extension: none
1368 dnl The use of .gmo is historical (it was needed to avoid overwriting the
1369 dnl GNU format catalogs when building on a platform with an X/Open gettext),
1370 dnl but we keep it in order not to force irrelevant filename changes on the
1371 dnl maintainers.
1372 dnl
1373 AC_DEFUN([AM_WITH_NLS],
1374   [AC_MSG_CHECKING([whether NLS is requested])
1375     dnl Default is enabled NLS
1376     AC_ARG_ENABLE(nls,
1377       [  --disable-nls           do not use Native Language Support],
1378       USE_NLS=$enableval, USE_NLS=yes)
1379     AC_MSG_RESULT($USE_NLS)
1380     AC_SUBST(USE_NLS)
1381
1382     BUILD_INCLUDED_LIBINTL=no
1383     USE_INCLUDED_LIBINTL=no
1384 dnl GCC LOCAL: Separate concept of link command line from dependencies.
1385     INTLLIBS=
1386     INTLDEPS=
1387
1388     dnl If we use NLS figure out what method
1389     if test "$USE_NLS" = "yes"; then
1390       AC_DEFINE(ENABLE_NLS, 1,
1391         [Define to 1 if translation of program messages to the user's native language
1392    is requested.])
1393       AC_MSG_CHECKING([whether included gettext is requested])
1394       AC_ARG_WITH(included-gettext,
1395         [  --with-included-gettext use the GNU gettext library included here],
1396         nls_cv_force_use_gnu_gettext=$withval,
1397         nls_cv_force_use_gnu_gettext=no)
1398       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
1399
1400       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
1401       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
1402         dnl User does not insist on using GNU NLS library.  Figure out what
1403         dnl to use.  If GNU gettext is available we use this.  Else we have
1404         dnl to fall back to GNU NLS library.
1405         CATOBJEXT=NONE
1406
1407         dnl Add a version number to the cache macros.
1408         define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
1409         define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
1410
1411 dnl GCC LOCAL: Expose presence of libintl.h to C code.
1412         AC_CHECK_HEADER(libintl.h,
1413           [AC_DEFINE([HAVE_LIBINTL_H], 1,
1414                 [Define if you have the <libintl.h> header file.])
1415            AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
1416             [AC_TRY_LINK([#include <libintl.h>
1417 extern int _nl_msg_cat_cntr;],
1418                [bindtextdomain ("", "");
1419 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
1420                gt_cv_func_gnugettext_libc=yes,
1421                gt_cv_func_gnugettext_libc=no)])
1422
1423            if test "$gt_cv_func_gnugettext_libc" != "yes"; then
1424              AC_CACHE_CHECK([for GNU gettext in libintl],
1425                gt_cv_func_gnugettext_libintl,
1426                [gt_save_LIBS="$LIBS"
1427                 LIBS="$LIBS -lintl $LIBICONV"
1428                 AC_TRY_LINK([#include <libintl.h>
1429 extern int _nl_msg_cat_cntr;],
1430                   [bindtextdomain ("", "");
1431 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
1432                   gt_cv_func_gnugettext_libintl=yes,
1433                   gt_cv_func_gnugettext_libintl=no)
1434                 LIBS="$gt_save_LIBS"])
1435            fi
1436
1437            dnl If an already present or preinstalled GNU gettext() is found,
1438            dnl use it.  But if this macro is used in GNU gettext, and GNU
1439            dnl gettext is already preinstalled in libintl, we update this
1440            dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
1441            if test "$gt_cv_func_gnugettext_libc" = "yes" \
1442               || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
1443                    && test "$PACKAGE" != gettext; }; then
1444              AC_DEFINE(HAVE_GETTEXT, 1,
1445                [Define if the GNU gettext() function is already present or preinstalled.])
1446
1447              if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
1448                dnl If iconv() is in a separate libiconv library, then anyone
1449                dnl linking with libintl{.a,.so} also needs to link with
1450                dnl libiconv.
1451                INTLLIBS="-lintl $LIBICONV"
1452              fi
1453
1454              gt_save_LIBS="$LIBS"
1455              LIBS="$LIBS $INTLLIBS"
1456              AC_CHECK_FUNCS(dcgettext)
1457              LIBS="$gt_save_LIBS"
1458
1459              dnl Search for GNU msgfmt in the PATH.
1460              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1461                [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
1462              AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1463
1464              dnl Search for GNU xgettext in the PATH.
1465              AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1466                [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
1467
1468              CATOBJEXT=.gmo
1469            fi
1470         ])
1471
1472         if test "$CATOBJEXT" = "NONE"; then
1473           dnl GNU gettext is not found in the C library.
1474           dnl Fall back on GNU gettext library.
1475           nls_cv_use_gnu_gettext=yes
1476         fi
1477       fi
1478
1479       if test "$nls_cv_use_gnu_gettext" = "yes"; then
1480         dnl Mark actions used to generate GNU NLS library.
1481         INTLOBJS="\$(GETTOBJS)"
1482         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1483           [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
1484         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1485         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1486           [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
1487         AC_SUBST(MSGFMT)
1488         BUILD_INCLUDED_LIBINTL=yes
1489         USE_INCLUDED_LIBINTL=yes
1490         CATOBJEXT=.gmo
1491         INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
1492         INTLDEPS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a"
1493         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
1494       fi
1495
1496       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1497       dnl Test whether we really found GNU msgfmt.
1498       if test "$GMSGFMT" != ":"; then
1499         dnl If it is no GNU msgfmt we define it as : so that the
1500         dnl Makefiles still can work.
1501         if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
1502           : ;
1503         else
1504           AC_MSG_RESULT(
1505             [found msgfmt program is not GNU msgfmt; ignore it])
1506           GMSGFMT=":"
1507         fi
1508       fi
1509
1510       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1511       dnl Test whether we really found GNU xgettext.
1512       if test "$XGETTEXT" != ":"; then
1513         dnl If it is no GNU xgettext we define it as : so that the
1514         dnl Makefiles still can work.
1515         if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
1516           : ;
1517         else
1518           AC_MSG_RESULT(
1519             [found xgettext program is not GNU xgettext; ignore it])
1520           XGETTEXT=":"
1521         fi
1522       fi
1523
1524       dnl We need to process the po/ directory.
1525       POSUB=po
1526     fi
1527     AC_OUTPUT_COMMANDS(
1528      [for ac_file in $CONFIG_FILES; do
1529         # Support "outfile[:infile[:infile...]]"
1530         case "$ac_file" in
1531           *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
1532         esac
1533         # PO directories have a Makefile.in generated from Makefile.in.in.
1534         case "$ac_file" in */Makefile.in)
1535           # Adjust a relative srcdir.
1536           ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
1537           ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
1538           ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
1539           # In autoconf-2.13 it is called $ac_given_srcdir.
1540           # In autoconf-2.50 it is called $srcdir.
1541           test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
1542           case "$ac_given_srcdir" in
1543             .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
1544             /*) top_srcdir="$ac_given_srcdir" ;;
1545             *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
1546           esac
1547           if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
1548             rm -f "$ac_dir/POTFILES"
1549             test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
1550             sed -e "/^#/d" -e "/^[      ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
1551             test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
1552             sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
1553           fi
1554           ;;
1555         esac
1556       done])
1557
1558
1559     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
1560     dnl to 'yes' because some of the testsuite requires it.
1561     if test "$PACKAGE" = gettext; then
1562       BUILD_INCLUDED_LIBINTL=yes
1563     fi
1564
1565     dnl intl/plural.c is generated from intl/plural.y. It requires bison,
1566     dnl because plural.y uses bison specific features. It requires at least
1567     dnl bison-1.26 because earlier versions generate a plural.c that doesn't
1568     dnl compile.
1569     dnl bison is only needed for the maintainer (who touches plural.y). But in
1570     dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
1571     dnl the rule in general Makefile. Now, some people carelessly touch the
1572     dnl files or have a broken "make" program, hence the plural.c rule will
1573     dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
1574     dnl present or too old.
1575     AC_CHECK_PROGS([INTLBISON], [bison])
1576     if test -z "$INTLBISON"; then
1577       ac_verc_fail=yes
1578     else
1579       dnl Found it, now check the version.
1580       AC_MSG_CHECKING([version of bison])
1581 changequote(<<,>>)dnl
1582       ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
1583       case $ac_prog_version in
1584         '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1585         1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
1586 changequote([,])dnl
1587            ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
1588         *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
1589       esac
1590       AC_MSG_RESULT([$ac_prog_version])
1591     fi
1592     if test $ac_verc_fail = yes; then
1593       INTLBISON=:
1594     fi
1595
1596     dnl GCC LOCAL: GMOFILES/POFILES removed as unnecessary.
1597
1598     dnl Make all variables we use known to autoconf.
1599     AC_SUBST(BUILD_INCLUDED_LIBINTL)
1600     AC_SUBST(USE_INCLUDED_LIBINTL)
1601     AC_SUBST(CATALOGS)
1602     AC_SUBST(CATOBJEXT)
1603     AC_SUBST(INTLLIBS)
1604     AC_SUBST(INTLDEPS)
1605     AC_SUBST(INTLOBJS)
1606     AC_SUBST(POSUB)
1607 dnl GCC LOCAL: Make USE_INCLUDED_LIBINTL visible to C code.
1608     if test $USE_INCLUDED_LIBINTL = yes; then
1609       AC_DEFINE([USE_INCLUDED_LIBINTL], 1,
1610   [Define to use the libintl included with this package instead of any
1611    version in the system libraries.])
1612     fi
1613
1614     dnl For backward compatibility. Some configure.ins may be using this.
1615     nls_cv_header_intl=
1616     nls_cv_header_libgt=
1617
1618     dnl For backward compatibility. Some Makefiles may be using this.
1619     DATADIRNAME=share
1620     AC_SUBST(DATADIRNAME)
1621
1622     dnl For backward compatibility. Some Makefiles may be using this.
1623     INSTOBJEXT=.mo
1624     AC_SUBST(INSTOBJEXT)
1625
1626     dnl For backward compatibility. Some Makefiles may be using this.
1627     GENCAT=gencat
1628     AC_SUBST(GENCAT)
1629   ])
1630
1631 dnl Usage: Just like AM_WITH_NLS, which see.
1632 AC_DEFUN([AM_GNU_GETTEXT],
1633   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1634    AC_REQUIRE([AC_PROG_CC])dnl
1635    AC_REQUIRE([AC_CANONICAL_HOST])dnl
1636    AC_REQUIRE([AC_PROG_RANLIB])dnl
1637    AC_REQUIRE([AC_ISC_POSIX])dnl
1638    AC_REQUIRE([AC_HEADER_STDC])dnl
1639    AC_REQUIRE([AC_C_CONST])dnl
1640    AC_REQUIRE([AC_C_INLINE])dnl
1641    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1642    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1643    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1644 dnl GCC LOCAL: Do not refer to AC_FUNC_MMAP, we have special needs.
1645 dnl   AC_REQUIRE([AC_FUNC_MMAP])dnl
1646    AC_REQUIRE([jm_GLIBC21])dnl
1647
1648    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
1649 stdlib.h string.h unistd.h sys/param.h])
1650    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
1651 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
1652 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
1653
1654    AM_ICONV
1655    AM_LANGINFO_CODESET
1656    AM_LC_MESSAGES
1657    AM_WITH_NLS([$1],[$2],[$3])
1658
1659    dnl GCC LOCAL: The LINGUAS/ALL_LINGUAS/CATALOGS mess that was here
1660    dnl has been torn out and replaced with this more sensible scheme.
1661    if test "x$CATOBJEXT" != x; then
1662      AC_MSG_CHECKING(for catalogs to be installed)
1663      # Look for .po and .gmo files in the source directory.
1664      CATALOGS=
1665      XLINGUAS=
1666      for cat in $srcdir/po/*$CATOBJEXT $srcdir/po/*.po; do
1667         # If there aren't any .gmo files the shell will give us the
1668         # literal string "../path/to/srcdir/po/*.gmo" which has to be
1669         # weeded out.
1670         case "$cat" in *\**)
1671             continue;;
1672         esac
1673         # The quadruple backslash is collapsed to a double backslash
1674         # by the backticks, then collapsed again by the double quotes,
1675         # leaving us with one backslash in the sed expression (right
1676         # before the dot that mustn't act as a wildcard).  The dot to
1677         # be escaped in the second expression is hiding inside CATOBJEXT.
1678         cat=`echo $cat | sed -e "s!$srcdir/!!" -e "s!\\\\.po!$CATOBJEXT!"`
1679         lang=`echo $cat | sed -e 's!po/!!' -e "s!\\\\$CATOBJEXT!!"`
1680         # The user is allowed to set LINGUAS to a list of languages to
1681         # install catalogs for.  If it's empty that means "all of them."
1682         if test "x$LINGUAS" = x; then
1683             CATALOGS="$CATALOGS $cat"
1684             XLINGUAS="$XLINGUAS $lang"
1685         else
1686           case "$LINGUAS" in *$lang*)
1687             CATALOGS="$CATALOGS $cat"
1688             XLINGUAS="$XLINGUAS $lang"
1689             ;;
1690           esac
1691         fi
1692      done
1693      LINGUAS="$XLINGUAS"
1694      AC_MSG_RESULT($LINGUAS)
1695    fi
1696
1697    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1698    dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1699    dnl Try to locate is.
1700    MKINSTALLDIRS=
1701    if test -n "$ac_aux_dir"; then
1702      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1703    fi
1704    if test -z "$MKINSTALLDIRS"; then
1705      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1706    fi
1707    AC_SUBST(MKINSTALLDIRS)
1708
1709    dnl Enable libtool support if the surrounding package wishes it.
1710    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
1711    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
1712   ])