OSDN Git Service

12848de9f4ebfe81b86d6f150386f842385cde50
[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 for cand in ${ADAC+"$ADAC"} ${CC+"$CC"} \
312             ${ac_tool_prefix}gcc        gcc             \
313             ${ac_tool_prefix}cc         cc              \
314             ${ac_tool_prefix}gnatgcc    gnatgcc         \
315             ${ac_tool_prefix}gnatcc     gnatcc          \
316             ${ac_tool_prefix}adagcc     adagcc          \
317             ${ac_tool_prefix}adacc      adacc           ; do
318   # There is a bug in all released versions of GCC which causes the
319   # driver to exit successfully when the appropriate language module
320   # has not been installed.  This is fixed in 2.95.4, 3.0.2, and 3.1.
321   # Therefore we must check for the error message as well as an
322   # unsuccessful exit.
323   errors=`($cand -c conftest.adb) 2>&1 || echo failure`
324   if test x"$errors" = x; then
325     gcc_cv_prog_adac=$cand
326     break
327   fi
328 done
329 rm -f conftest.*])
330 ADAC=$gcc_cv_prog_adac
331 AC_SUBST(ADAC)
332
333 if test x$GNATBIND != xno && test x$ADAC != xno; then
334   have_gnat=yes
335 else
336   have_gnat=no
337 fi
338 ])
339
340 #serial 1
341 dnl This test replaces the one in autoconf.
342 dnl Currently this macro should have the same name as the autoconf macro
343 dnl because gettext's gettext.m4 (distributed in the automake package)
344 dnl still uses it.  Otherwise, the use in gettext.m4 makes autoheader
345 dnl give these diagnostics:
346 dnl   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
347 dnl   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
348
349 undefine([AC_ISC_POSIX])
350 AC_DEFUN(AC_ISC_POSIX,
351   [
352     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
353     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
354   ]
355 )
356
357
358 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
359 dnl like AC_PATH_PROG but use other cache variables
360 AC_DEFUN(GCC_PATH_PROG,
361 [# Extract the first word of "$2", so it can be a program name with args.
362 set dummy $2; ac_word=[$]2
363 AC_MSG_CHECKING([for $ac_word])
364 AC_CACHE_VAL(gcc_cv_path_$1,
365 [case "[$]$1" in
366   /*)
367   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
368   ;;
369   ?:/*)                  
370   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
371   ;;
372   *)
373   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
374 dnl $ac_dummy forces splitting on constant user-supplied paths.
375 dnl POSIX.2 word splitting is done only on the output of word expansions,
376 dnl not every word.  This closes a longstanding sh security hole.
377   ac_dummy="ifelse([$4], , $PATH, [$4])"
378   for ac_dir in $ac_dummy; do 
379     test -z "$ac_dir" && ac_dir=.
380     if test -f $ac_dir/$ac_word; then
381       gcc_cv_path_$1="$ac_dir/$ac_word"
382       break
383     fi
384   done
385   IFS="$ac_save_ifs"
386 dnl If no 3rd arg is given, leave the cache variable unset,
387 dnl so GCC_PATH_PROGS will keep looking.
388 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
389 ])dnl
390   ;;
391 esac])dnl
392 $1="$gcc_cv_path_$1"
393 if test -n "[$]$1"; then
394   AC_MSG_RESULT([$]$1)
395 else
396   AC_MSG_RESULT(no)
397 fi
398 AC_SUBST($1)dnl
399 ])
400
401 # mmap(2) blacklisting.  Some platforms provide the mmap library routine
402 # but don't support all of the features we need from it.
403 AC_DEFUN([gcc_AC_FUNC_MMAP_BLACKLIST],
404 [if test $ac_cv_header_sys_mman_h != yes \
405  || test $ac_cv_func_mmap != yes; then
406    gcc_cv_func_mmap_file=no
407    gcc_cv_func_mmap_dev_zero=no
408    gcc_cv_func_mmap_anon=no
409 else
410    AC_CACHE_CHECK([whether read-only mmap of a plain file works], 
411   gcc_cv_func_mmap_file,
412   [# Add a system to this blacklist if 
413    # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
414    # memory area containing the same data that you'd get if you applied
415    # read() to the same fd.  The only system known to have a problem here
416    # is VMS, where text files have record structure.
417    case "$host_os" in
418      vms*) 
419         gcc_cv_func_mmap_file=no ;;
420      *)
421         gcc_cv_func_mmap_file=yes;;
422    esac])
423    AC_CACHE_CHECK([whether mmap from /dev/zero works],
424   gcc_cv_func_mmap_dev_zero,
425   [# Add a system to this blacklist if it has mmap() but /dev/zero
426    # does not exist, or if mmapping /dev/zero does not give anonymous
427    # zeroed pages with both the following properties:
428    # 1. If you map N consecutive pages in with one call, and then
429    #    unmap any subset of those pages, the pages that were not
430    #    explicitly unmapped remain accessible.
431    # 2. If you map two adjacent blocks of memory and then unmap them
432    #    both at once, they must both go away.
433    # Systems known to be in this category are Windows (all variants),
434    # VMS, and Darwin.
435    case "$host_os" in
436      vms* | cygwin* | pe | mingw* | darwin*)
437         gcc_cv_func_mmap_dev_zero=no ;;
438      *)
439         gcc_cv_func_mmap_dev_zero=yes;;
440    esac])
441
442    # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
443    AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
444     [AC_TRY_COMPILE(
445 [#include <sys/types.h>
446 #include <sys/mman.h>
447 #include <unistd.h>
448
449 #ifndef MAP_ANONYMOUS
450 #define MAP_ANONYMOUS MAP_ANON
451 #endif
452 ],
453 [int n = MAP_ANONYMOUS;],
454     gcc_cv_decl_map_anon=yes,
455     gcc_cv_decl_map_anon=no)])
456
457    if test $gcc_cv_decl_map_anon = no; then
458      gcc_cv_func_mmap_anon=no
459    else
460      AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
461      gcc_cv_func_mmap_anon,
462   [# Add a system to this blacklist if it has mmap() and MAP_ANON or
463    # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
464    # doesn't give anonymous zeroed pages with the same properties listed
465    # above for use of /dev/zero.
466    # Systems known to be in this category are Windows, VMS, and SCO Unix.
467    case "$host_os" in
468      vms* | cygwin* | pe | mingw* | sco* | udk* )
469         gcc_cv_func_mmap_anon=no ;;
470      *)
471         gcc_cv_func_mmap_anon=yes;;
472    esac])
473    fi
474 fi
475
476 if test $gcc_cv_func_mmap_file = yes; then
477   AC_DEFINE(HAVE_MMAP_FILE, 1,
478             [Define if read-only mmap of a plain file works.])
479 fi
480 if test $gcc_cv_func_mmap_dev_zero = yes; then
481   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
482             [Define if mmap of /dev/zero works.])
483 fi
484 if test $gcc_cv_func_mmap_anon = yes; then
485   AC_DEFINE(HAVE_MMAP_ANON, 1,
486             [Define if mmap with MAP_ANON(YMOUS) works.])
487 fi
488 ])
489
490 dnl Locate a program and check that its version is acceptable.
491 dnl AC_PROG_CHECK_VER(var, name, version-switch,
492 dnl                  version-extract-regexp, version-glob)
493 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
494 [AC_CHECK_PROG([$1], [$2], [$2])
495 if test -n "[$]$1"; then
496   # Found it, now check the version.
497   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
498 [changequote(<<,>>)dnl
499   ac_prog_version=`<<$>>$1 $3 2>&1 |
500                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
501 changequote([,])dnl
502   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
503 changequote(<<,>>)dnl
504   case $ac_prog_version in
505     '')     gcc_cv_prog_$2_modern=no;;
506     <<$5>>)
507             gcc_cv_prog_$2_modern=yes;;
508     *)      gcc_cv_prog_$2_modern=no;;
509   esac
510 changequote([,])dnl
511 ])
512 else
513   gcc_cv_prog_$2_modern=no
514 fi
515 ])
516
517 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
518 dnl be either signed or unsigned.
519 dnl
520 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
521 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
522 [AC_TRY_RUN(#include <stdlib.h>
523 enum t { BLAH = 128 } ;
524 struct s_t { enum t member : 8; } s ;
525 int main(void)
526 {            
527         s.member = BLAH;
528         if (s.member < 0) exit(1);
529         exit(0);
530
531 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
532 if test $gcc_cv_enum_bf_unsigned = yes; then
533   AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
534     [Define if enumerated bitfields are treated as unsigned values.])
535 fi])
536
537 dnl Probe number of bits in a byte.
538 dnl Note C89 requires CHAR_BIT >= 8.
539 dnl
540 AC_DEFUN(gcc_AC_C_CHAR_BIT,
541 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
542 [AC_EGREP_CPP(found,
543 [#ifdef HAVE_LIMITS_H
544 #include <limits.h>
545 #endif
546 #ifdef CHAR_BIT
547 found
548 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
549 ])
550 if test $gcc_cv_decl_char_bit = no; then
551   AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
552 [i=8
553  gcc_cv_c_nbby=
554  while test $i -lt 65; do
555    AC_TRY_COMPILE(,
556      [switch(0) {
557   case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
558   case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
559   ; }], 
560      [gcc_cv_c_nbby=$i; break])
561    i=`expr $i + 1`
562  done
563  test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
564 ])
565 if test $gcc_cv_c_nbby = failed; then
566   AC_MSG_ERROR(cannot determine number of bits in a byte)
567 else
568   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
569   [Define as the number of bits in a byte, if \`limits.h' doesn't.])
570 fi
571 fi])
572
573 dnl Checking for long long.
574 dnl By Caolan McNamara <caolan@skynet.ie>
575 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
576 dnl
577 AC_DEFUN([gcc_AC_C_LONG_LONG],
578 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
579   [AC_TRY_COMPILE(,[long long int i;],
580          ac_cv_c_long_long=yes,
581          ac_cv_c_long_long=no)])
582   if test $ac_cv_c_long_long = yes; then
583     AC_DEFINE(HAVE_LONG_LONG, 1,
584       [Define if your compiler supports the \`long long' type.])
585   fi
586 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
587   [AC_TRY_COMPILE(,[__int64 i;],
588         ac_cv_c___int64=yes,
589         ac_cv_c___int64=no)])
590   if test $ac_cv_c___int64 = yes; then
591     AC_DEFINE(HAVE___INT64, 1,
592       [Define if your compiler supports the \`__int64' type.])
593   fi
594 ])
595
596 dnl Host character set probe.
597 dnl The EBCDIC values match the table in config/i370/i370.c;
598 dnl there are other versions of EBCDIC but GCC won't work with them.
599 dnl
600 AC_DEFUN([gcc_AC_C_CHARSET],
601 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
602   [AC_EGREP_CPP(ASCII,
603 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
604    && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
605 ASCII
606 #endif], ac_cv_c_charset=ASCII)
607   if test x${ac_cv_c_charset+set} != xset; then
608     AC_EGREP_CPP(EBCDIC,
609 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
610    && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
611 EBCDIC
612 #endif], ac_cv_c_charset=EBCDIC)
613   fi
614   if test x${ac_cv_c_charset+set} != xset; then
615     ac_cv_c_charset=unknown
616   fi])
617 if test $ac_cv_c_charset = unknown; then
618   AC_MSG_ERROR([*** Cannot determine host character set.])
619 elif test $ac_cv_c_charset = EBCDIC; then
620   AC_DEFINE(HOST_EBCDIC, 1,
621   [Define if the host execution character set is EBCDIC.])
622 fi])
623
624 #serial AM2
625
626 dnl From Bruno Haible.
627
628 AC_DEFUN([AM_ICONV],
629 [
630   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
631   dnl those with the standalone portable GNU libiconv installed).
632
633   am_cv_lib_iconv_ldpath=
634   AC_ARG_WITH([libiconv-prefix],
635 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
636     for dir in `echo "$withval" | tr : ' '`; do
637       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
638       if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
639     done
640    ])
641
642   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
643     am_cv_func_iconv="no, consider installing GNU libiconv"
644     am_cv_lib_iconv=no
645     AC_TRY_LINK([#include <stdlib.h>
646 #include <iconv.h>],
647       [iconv_t cd = iconv_open("","");
648        iconv(cd,NULL,NULL,NULL,NULL);
649        iconv_close(cd);],
650       am_cv_func_iconv=yes)
651     if test "$am_cv_func_iconv" != yes; then
652       am_save_LIBS="$LIBS"
653       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
654       AC_TRY_LINK([#include <stdlib.h>
655 #include <iconv.h>],
656         [iconv_t cd = iconv_open("","");
657          iconv(cd,NULL,NULL,NULL,NULL);
658          iconv_close(cd);],
659         am_cv_lib_iconv=yes
660         am_cv_func_iconv=yes)
661       LIBS="$am_save_LIBS"
662     fi
663   ])
664   if test "$am_cv_func_iconv" = yes; then
665     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
666     AC_MSG_CHECKING([for iconv declaration])
667     AC_CACHE_VAL(am_cv_proto_iconv, [
668       AC_TRY_COMPILE([
669 #include <stdlib.h>
670 #include <iconv.h>
671 extern
672 #ifdef __cplusplus
673 "C"
674 #endif
675 #if defined(__STDC__) || defined(__cplusplus)
676 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
677 #else
678 size_t iconv();
679 #endif
680 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
681       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);"])
682     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
683     AC_MSG_RESULT([$]{ac_t:-
684          }[$]am_cv_proto_iconv)
685     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
686       [Define as const if the declaration of iconv() needs const.])
687   fi
688   LIBICONV=
689   if test "$am_cv_lib_iconv" = yes; then
690     LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
691   fi
692   AC_SUBST(LIBICONV)
693 ])
694
695 ### Gettext macros begin here.
696 ### Changes for GCC marked by 'dnl GCC LOCAL'.
697 ### Note iconv.m4 appears above, as it's used for other reasons.
698
699 #serial AM1
700
701 dnl From Bruno Haible.
702
703 AC_DEFUN([AM_LANGINFO_CODESET],
704 [
705   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
706     [AC_TRY_LINK([#include <langinfo.h>],
707       [char* cs = nl_langinfo(CODESET);],
708       am_cv_langinfo_codeset=yes,
709       am_cv_langinfo_codeset=no)
710     ])
711   if test $am_cv_langinfo_codeset = yes; then
712     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
713       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
714   fi
715 ])
716
717 #serial 1
718 # This test replaces the one in autoconf.
719 # Currently this macro should have the same name as the autoconf macro
720 # because gettext's gettext.m4 (distributed in the automake package)
721 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
722 # give these diagnostics:
723 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
724 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
725
726 undefine([AC_ISC_POSIX])
727
728 AC_DEFUN([AC_ISC_POSIX],
729   [
730     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
731     dnl GCC LOCAL: Use AC_SEARCH_LIBS.
732     AC_SEARCH_LIBS(strerror, cposix)
733   ]
734 )
735
736 #serial 2
737
738 # Test for the GNU C Library, version 2.1 or newer.
739 # From Bruno Haible.
740
741 AC_DEFUN([jm_GLIBC21],
742   [
743     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
744       ac_cv_gnu_library_2_1,
745       [AC_EGREP_CPP([Lucky GNU user],
746         [
747 #include <features.h>
748 #ifdef __GNU_LIBRARY__
749  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
750   Lucky GNU user
751  #endif
752 #endif
753         ],
754         ac_cv_gnu_library_2_1=yes,
755         ac_cv_gnu_library_2_1=no)
756       ]
757     )
758     AC_SUBST(GLIBC21)
759     GLIBC21="$ac_cv_gnu_library_2_1"
760   ]
761 )
762
763 # Check whether LC_MESSAGES is available in <locale.h>.
764 # Ulrich Drepper <drepper@cygnus.com>, 1995.
765 #
766 # This file can be copied and used freely without restrictions.  It can
767 # be used in projects which are not available under the GNU General Public
768 # License or the GNU Library General Public License but which still want
769 # to provide support for the GNU gettext functionality.
770 # Please note that the actual code of the GNU gettext library is covered
771 # by the GNU Library General Public License, and the rest of the GNU
772 # gettext package package is covered by the GNU General Public License.
773 # They are *not* in the public domain.
774
775 # serial 2
776
777 AC_DEFUN([AM_LC_MESSAGES],
778   [if test $ac_cv_header_locale_h = yes; then
779     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
780       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
781        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
782     if test $am_cv_val_LC_MESSAGES = yes; then
783       AC_DEFINE(HAVE_LC_MESSAGES, 1,
784         [Define if your <locale.h> file defines LC_MESSAGES.])
785     fi
786   fi])
787
788 # Search path for a program which passes the given test.
789 # Ulrich Drepper <drepper@cygnus.com>, 1996.
790 #
791 # This file can be copied and used freely without restrictions.  It can
792 # be used in projects which are not available under the GNU General Public
793 # License or the GNU Library General Public License but which still want
794 # to provide support for the GNU gettext functionality.
795 # Please note that the actual code of the GNU gettext library is covered
796 # by the GNU Library General Public License, and the rest of the GNU
797 # gettext package package is covered by the GNU General Public License.
798 # They are *not* in the public domain.
799
800 # serial 2
801
802 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
803 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
804 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
805 [# Extract the first word of "$2", so it can be a program name with args.
806 set dummy $2; ac_word=[$]2
807 AC_MSG_CHECKING([for $ac_word])
808 AC_CACHE_VAL(ac_cv_path_$1,
809 [case "[$]$1" in
810   /*)
811   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
812   ;;
813   *)
814   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
815   for ac_dir in ifelse([$5], , $PATH, [$5]); do
816     test -z "$ac_dir" && ac_dir=.
817     if test -f $ac_dir/$ac_word; then
818       if [$3]; then
819         ac_cv_path_$1="$ac_dir/$ac_word"
820         break
821       fi
822     fi
823   done
824   IFS="$ac_save_ifs"
825 dnl If no 4th arg is given, leave the cache variable unset,
826 dnl so AC_PATH_PROGS will keep looking.
827 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
828 ])dnl
829   ;;
830 esac])dnl
831 $1="$ac_cv_path_$1"
832 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
833   AC_MSG_RESULT([$]$1)
834 else
835   AC_MSG_RESULT(no)
836 fi
837 AC_SUBST($1)dnl
838 ])
839
840 # Macro to add for using GNU gettext.
841 # Ulrich Drepper <drepper@cygnus.com>, 1995.
842 #
843 # This file can be copied and used freely without restrictions.  It can
844 # be used in projects which are not available under the GNU General Public
845 # License or the GNU Library General Public License but which still want
846 # to provide support for the GNU gettext functionality.
847 # Please note that the actual code of the GNU gettext library is covered
848 # by the GNU Library General Public License, and the rest of the GNU
849 # gettext package package is covered by the GNU General Public License.
850 # They are *not* in the public domain.
851
852 # serial 10
853
854 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
855 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
856 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
857 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
858 dnl    AM-DISABLE-SHARED). Otherwise, a static library
859 dnl    $(top_builddir)/intl/libintl.a will be created.
860 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
861 dnl    implementations (in libc or libintl) without the ngettext() function
862 dnl    will be ignored.
863 dnl LIBDIR is used to find the intl libraries.  If empty,
864 dnl    the value `$(top_builddir)/intl/' is used.
865 dnl
866 dnl The result of the configuration is one of three cases:
867 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
868 dnl    and used.
869 dnl    Catalog format: GNU --> install in $(datadir)
870 dnl    Catalog extension: .mo after installation, .gmo in source tree
871 dnl 2) GNU gettext has been found in the system's C library.
872 dnl    Catalog format: GNU --> install in $(datadir)
873 dnl    Catalog extension: .mo after installation, .gmo in source tree
874 dnl 3) No internationalization, always use English msgid.
875 dnl    Catalog format: none
876 dnl    Catalog extension: none
877 dnl The use of .gmo is historical (it was needed to avoid overwriting the
878 dnl GNU format catalogs when building on a platform with an X/Open gettext),
879 dnl but we keep it in order not to force irrelevant filename changes on the
880 dnl maintainers.
881 dnl
882 AC_DEFUN([AM_WITH_NLS],
883   [AC_MSG_CHECKING([whether NLS is requested])
884     dnl Default is enabled NLS
885     AC_ARG_ENABLE(nls,
886       [  --disable-nls           do not use Native Language Support],
887       USE_NLS=$enableval, USE_NLS=yes)
888     AC_MSG_RESULT($USE_NLS)
889     AC_SUBST(USE_NLS)
890
891     BUILD_INCLUDED_LIBINTL=no
892     USE_INCLUDED_LIBINTL=no
893 dnl GCC LOCAL: Separate concept of link command line from dependencies.
894     INTLLIBS=
895     INTLDEPS=
896
897     dnl If we use NLS figure out what method
898     if test "$USE_NLS" = "yes"; then
899       AC_DEFINE(ENABLE_NLS, 1,
900         [Define to 1 if translation of program messages to the user's native language
901    is requested.])
902       AC_MSG_CHECKING([whether included gettext is requested])
903       AC_ARG_WITH(included-gettext,
904         [  --with-included-gettext use the GNU gettext library included here],
905         nls_cv_force_use_gnu_gettext=$withval,
906         nls_cv_force_use_gnu_gettext=no)
907       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
908
909       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
910       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
911         dnl User does not insist on using GNU NLS library.  Figure out what
912         dnl to use.  If GNU gettext is available we use this.  Else we have
913         dnl to fall back to GNU NLS library.
914         CATOBJEXT=NONE
915
916         dnl Add a version number to the cache macros.
917         define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
918         define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
919
920 dnl GCC LOCAL: Expose presence of libintl.h to C code.
921         AC_CHECK_HEADER(libintl.h,
922           [AC_DEFINE([HAVE_LIBINTL_H], 1,
923                 [Define if you have the <libintl.h> header file.])
924            AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
925             [AC_TRY_LINK([#include <libintl.h>
926 extern int _nl_msg_cat_cntr;],
927                [bindtextdomain ("", "");
928 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
929                gt_cv_func_gnugettext_libc=yes,
930                gt_cv_func_gnugettext_libc=no)])
931
932            if test "$gt_cv_func_gnugettext_libc" != "yes"; then
933              AC_CACHE_CHECK([for GNU gettext in libintl],
934                gt_cv_func_gnugettext_libintl,
935                [gt_save_LIBS="$LIBS"
936                 LIBS="$LIBS -lintl $LIBICONV"
937                 AC_TRY_LINK([#include <libintl.h>
938 extern int _nl_msg_cat_cntr;],
939                   [bindtextdomain ("", "");
940 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
941                   gt_cv_func_gnugettext_libintl=yes,
942                   gt_cv_func_gnugettext_libintl=no)
943                 LIBS="$gt_save_LIBS"])
944            fi
945
946            dnl If an already present or preinstalled GNU gettext() is found,
947            dnl use it.  But if this macro is used in GNU gettext, and GNU
948            dnl gettext is already preinstalled in libintl, we update this
949            dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
950            if test "$gt_cv_func_gnugettext_libc" = "yes" \
951               || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
952                    && test "$PACKAGE" != gettext; }; then
953              AC_DEFINE(HAVE_GETTEXT, 1,
954                [Define if the GNU gettext() function is already present or preinstalled.])
955
956              if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
957                dnl If iconv() is in a separate libiconv library, then anyone
958                dnl linking with libintl{.a,.so} also needs to link with
959                dnl libiconv.
960                INTLLIBS="-lintl $LIBICONV"
961              fi
962
963              gt_save_LIBS="$LIBS"
964              LIBS="$LIBS $INTLLIBS"
965              AC_CHECK_FUNCS(dcgettext)
966              LIBS="$gt_save_LIBS"
967
968              dnl Search for GNU msgfmt in the PATH.
969              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
970                [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
971              AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
972
973              dnl Search for GNU xgettext in the PATH.
974              AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
975                [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
976
977              CATOBJEXT=.gmo
978            fi
979         ])
980
981         if test "$CATOBJEXT" = "NONE"; then
982           dnl GNU gettext is not found in the C library.
983           dnl Fall back on GNU gettext library.
984           nls_cv_use_gnu_gettext=yes
985         fi
986       fi
987
988       if test "$nls_cv_use_gnu_gettext" = "yes"; then
989         dnl Mark actions used to generate GNU NLS library.
990         INTLOBJS="\$(GETTOBJS)"
991         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
992           [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
993         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
994         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
995           [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
996         AC_SUBST(MSGFMT)
997         BUILD_INCLUDED_LIBINTL=yes
998         USE_INCLUDED_LIBINTL=yes
999         CATOBJEXT=.gmo
1000         INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
1001         INTLDEPS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a"
1002         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
1003       fi
1004
1005       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1006       dnl Test whether we really found GNU msgfmt.
1007       if test "$GMSGFMT" != ":"; then
1008         dnl If it is no GNU msgfmt we define it as : so that the
1009         dnl Makefiles still can work.
1010         if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
1011           : ;
1012         else
1013           AC_MSG_RESULT(
1014             [found msgfmt program is not GNU msgfmt; ignore it])
1015           GMSGFMT=":"
1016         fi
1017       fi
1018
1019       dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1020       dnl Test whether we really found GNU xgettext.
1021       if test "$XGETTEXT" != ":"; then
1022         dnl If it is no GNU xgettext we define it as : so that the
1023         dnl Makefiles still can work.
1024         if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
1025           : ;
1026         else
1027           AC_MSG_RESULT(
1028             [found xgettext program is not GNU xgettext; ignore it])
1029           XGETTEXT=":"
1030         fi
1031       fi
1032
1033       dnl We need to process the po/ directory.
1034       POSUB=po
1035     fi
1036     AC_OUTPUT_COMMANDS(
1037      [for ac_file in $CONFIG_FILES; do
1038         # Support "outfile[:infile[:infile...]]"
1039         case "$ac_file" in
1040           *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
1041         esac
1042         # PO directories have a Makefile.in generated from Makefile.in.in.
1043         case "$ac_file" in */Makefile.in)
1044           # Adjust a relative srcdir.
1045           ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
1046           ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
1047           ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
1048           # In autoconf-2.13 it is called $ac_given_srcdir.
1049           # In autoconf-2.50 it is called $srcdir.
1050           test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
1051           case "$ac_given_srcdir" in
1052             .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
1053             /*) top_srcdir="$ac_given_srcdir" ;;
1054             *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
1055           esac
1056           if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
1057             rm -f "$ac_dir/POTFILES"
1058             test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
1059             sed -e "/^#/d" -e "/^[      ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
1060             test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
1061             sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
1062           fi
1063           ;;
1064         esac
1065       done])
1066
1067
1068     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
1069     dnl to 'yes' because some of the testsuite requires it.
1070     if test "$PACKAGE" = gettext; then
1071       BUILD_INCLUDED_LIBINTL=yes
1072     fi
1073
1074     dnl intl/plural.c is generated from intl/plural.y. It requires bison,
1075     dnl because plural.y uses bison specific features. It requires at least
1076     dnl bison-1.26 because earlier versions generate a plural.c that doesn't
1077     dnl compile.
1078     dnl bison is only needed for the maintainer (who touches plural.y). But in
1079     dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
1080     dnl the rule in general Makefile. Now, some people carelessly touch the
1081     dnl files or have a broken "make" program, hence the plural.c rule will
1082     dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
1083     dnl present or too old.
1084     AC_CHECK_PROGS([INTLBISON], [bison])
1085     if test -z "$INTLBISON"; then
1086       ac_verc_fail=yes
1087     else
1088       dnl Found it, now check the version.
1089       AC_MSG_CHECKING([version of bison])
1090 changequote(<<,>>)dnl
1091       ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
1092       case $ac_prog_version in
1093         '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1094         1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
1095 changequote([,])dnl
1096            ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
1097         *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
1098       esac
1099       AC_MSG_RESULT([$ac_prog_version])
1100     fi
1101     if test $ac_verc_fail = yes; then
1102       INTLBISON=:
1103     fi
1104
1105     dnl GCC LOCAL: GMOFILES/POFILES removed as unnecessary.
1106
1107     dnl Make all variables we use known to autoconf.
1108     AC_SUBST(BUILD_INCLUDED_LIBINTL)
1109     AC_SUBST(USE_INCLUDED_LIBINTL)
1110     AC_SUBST(CATALOGS)
1111     AC_SUBST(CATOBJEXT)
1112     AC_SUBST(INTLLIBS)
1113     AC_SUBST(INTLDEPS)
1114     AC_SUBST(INTLOBJS)
1115     AC_SUBST(POSUB)
1116 dnl GCC LOCAL: Make USE_INCLUDED_LIBINTL visible to C code.
1117     if test $USE_INCLUDED_LIBINTL = yes; then
1118       AC_DEFINE([USE_INCLUDED_LIBINTL], 1,
1119   [Define to use the libintl included with this package instead of any
1120    version in the system libraries.])
1121     fi
1122
1123     dnl For backward compatibility. Some configure.ins may be using this.
1124     nls_cv_header_intl=
1125     nls_cv_header_libgt=
1126
1127     dnl For backward compatibility. Some Makefiles may be using this.
1128     DATADIRNAME=share
1129     AC_SUBST(DATADIRNAME)
1130
1131     dnl For backward compatibility. Some Makefiles may be using this.
1132     INSTOBJEXT=.mo
1133     AC_SUBST(INSTOBJEXT)
1134
1135     dnl For backward compatibility. Some Makefiles may be using this.
1136     GENCAT=gencat
1137     AC_SUBST(GENCAT)
1138   ])
1139
1140 dnl Usage: Just like AM_WITH_NLS, which see.
1141 AC_DEFUN([AM_GNU_GETTEXT],
1142   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1143    AC_REQUIRE([AC_PROG_CC])dnl
1144    AC_REQUIRE([AC_CANONICAL_HOST])dnl
1145    AC_REQUIRE([AC_PROG_RANLIB])dnl
1146    AC_REQUIRE([AC_ISC_POSIX])dnl
1147    AC_REQUIRE([AC_HEADER_STDC])dnl
1148    AC_REQUIRE([AC_C_CONST])dnl
1149    AC_REQUIRE([AC_C_INLINE])dnl
1150    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1151    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1152    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1153 dnl GCC LOCAL: Do not refer to AC_FUNC_MMAP, we have special needs.
1154 dnl   AC_REQUIRE([AC_FUNC_MMAP])dnl
1155    AC_REQUIRE([jm_GLIBC21])dnl
1156
1157    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
1158 stdlib.h string.h unistd.h sys/param.h])
1159    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
1160 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
1161 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
1162
1163    AM_ICONV
1164    AM_LANGINFO_CODESET
1165    AM_LC_MESSAGES
1166    AM_WITH_NLS([$1],[$2],[$3])
1167
1168    dnl GCC LOCAL: The LINGUAS/ALL_LINGUAS/CATALOGS mess that was here
1169    dnl has been torn out and replaced with this more sensible scheme.
1170    if test "x$CATOBJEXT" != x; then
1171      AC_MSG_CHECKING(for catalogs to be installed)
1172      # Look for .po and .gmo files in the source directory.
1173      CATALOGS=
1174      XLINGUAS=
1175      for cat in $srcdir/po/*$CATOBJEXT $srcdir/po/*.po; do
1176         # If there aren't any .gmo files the shell will give us the
1177         # literal string "../path/to/srcdir/po/*.gmo" which has to be
1178         # weeded out.
1179         case "$cat" in *\**)
1180             continue;;
1181         esac
1182         # The quadruple backslash is collapsed to a double backslash
1183         # by the backticks, then collapsed again by the double quotes,
1184         # leaving us with one backslash in the sed expression (right
1185         # before the dot that mustn't act as a wildcard).  The dot to
1186         # be escaped in the second expression is hiding inside CATOBJEXT.
1187         cat=`echo $cat | sed -e "s!$srcdir/!!" -e "s!\\\\.po!$CATOBJEXT!"`
1188         lang=`echo $cat | sed -e 's!po/!!' -e "s!\\\\$CATOBJEXT!!"`
1189         # The user is allowed to set LINGUAS to a list of languages to
1190         # install catalogs for.  If it's empty that means "all of them."
1191         if test "x$LINGUAS" = x; then
1192             CATALOGS="$CATALOGS $cat"
1193             XLINGUAS="$XLINGUAS $lang"
1194         else
1195           case "$LINGUAS" in *$lang*)
1196             CATALOGS="$CATALOGS $cat"
1197             XLINGUAS="$XLINGUAS $lang"
1198             ;;
1199           esac
1200         fi
1201      done
1202      LINGUAS="$XLINGUAS"
1203      AC_MSG_RESULT($LINGUAS)
1204    fi
1205
1206    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1207    dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1208    dnl Try to locate is.
1209    MKINSTALLDIRS=
1210    if test -n "$ac_aux_dir"; then
1211      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1212    fi
1213    if test -z "$MKINSTALLDIRS"; then
1214      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1215    fi
1216    AC_SUBST(MKINSTALLDIRS)
1217
1218    dnl Enable libtool support if the surrounding package wishes it.
1219    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
1220    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
1221   ])
1222
1223 AC_DEFUN(gcc_AC_INITFINI_ARRAY,
1224 [AC_ARG_ENABLE(initfini-array,
1225         [  --enable-initfini-array      use .init_array/.fini_array sections],
1226         [], [
1227 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
1228                  gcc_cv_initfini_array, [dnl
1229   AC_TRY_RUN([
1230 static int x = -1;
1231 int main (void) { return x; }
1232 int foo (void) { x = 0; }
1233 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;],
1234              [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
1235              [gcc_cv_initfini_array=no])])
1236   enable_initfini_array=$gcc_cv_initfini_array
1237 ])
1238 if test $enable_initfini_array = yes; then
1239   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
1240     [Define .init_array/.fini_array sections are available and working.])
1241 fi])
1242
1243 dnl # _gcc_COMPUTE_GAS_VERSION
1244 dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
1245 dnl #
1246 dnl # WARNING:
1247 dnl # gcc_cv_as_gas_srcdir must be defined before this.
1248 dnl # This gross requirement will go away eventually.
1249 AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
1250 [gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
1251 for f in $gcc_cv_as_bfd_srcdir/configure \
1252          $gcc_cv_as_gas_srcdir/configure \
1253          $gcc_cv_as_gas_srcdir/configure.in \
1254          $gcc_cv_as_gas_srcdir/Makefile.in ; do
1255   gcc_cv_gas_version=`grep '^VERSION=[[0-9]]*\.[[0-9]]*' $f`
1256   if test x$gcc_cv_gas_version != x; then
1257     break
1258   fi
1259 done
1260 gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
1261 gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
1262 gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
1263 ]) []dnl # _gcc_COMPUTE_GAS_VERSION
1264
1265 dnl # gcc_GAS_VERSION_GTE_IFELSE(major, minor, patchlevel,
1266 dnl #                     [command_if_true = :], [command_if_false = :])
1267 dnl # Check to see if the version of GAS is greater than or
1268 dnl # equal to the specified version.
1269 dnl #
1270 dnl # The first ifelse() shortens the shell code if the patchlevel
1271 dnl # is unimportant (the usual case).  The others handle missing
1272 dnl # commands.  Note that the tests are structured so that the most
1273 dnl # common version number cases are tested first.
1274 AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
1275 [AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION]) []dnl
1276 ifelse([$3],[0],
1277 [if test $gcc_cv_gas_major_version -eq $1 \
1278 && test $gcc_cv_gas_minor_version -ge $2 \
1279 || test $gcc_cv_gas_major_version -gt $1 ; then
1280 ],
1281 [if test $gcc_cv_gas_major_version -eq $1 \
1282 && (test $gcc_cv_gas_minor_version -gt $2 \
1283     || (test $gcc_cv_gas_minor_version -eq $2 \
1284         && test $gcc_cv_gas_patch_version -ge $3 )) \
1285 || test $gcc_cv_gas_major_version -gt $1 ; then
1286 ])
1287 ifelse([$4],[],[:],[$4])
1288 ifelse([$5],[],[],[else $5])
1289 fi
1290 ]) []dnl # gcc_GAS_VERSION_GTE_IFELSE
1291