OSDN Git Service

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