OSDN Git Service

2003-10-17 Kelley Cook <kcook@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
1 sinclude(../config/acx.m4)
2 sinclude(../config/accross.m4)
3 sinclude(../config/gettext.m4)
4 sinclude(../config/progtest.m4)
5
6 dnl See if stdbool.h properly defines bool and true/false.
7 AC_DEFUN([gcc_AC_HEADER_STDBOOL],
8 [AC_CACHE_CHECK([for working stdbool.h],
9   ac_cv_header_stdbool_h,
10 [AC_TRY_COMPILE([#include <stdbool.h>],
11 [bool foo = false;],
12 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
13 if test $ac_cv_header_stdbool_h = yes; then
14   AC_DEFINE(HAVE_STDBOOL_H, 1,
15   [Define if you have a working <stdbool.h> header file.])
16 fi
17 ])
18
19 dnl Fixed AC_CHECK_TYPE that doesn't need anything in acconfig.h.
20 dnl Remove after migrating to 2.5x.
21 AC_DEFUN([gcc_AC_CHECK_TYPE],
22 [AC_REQUIRE([AC_HEADER_STDC])dnl
23 AC_MSG_CHECKING(for $1)
24 AC_CACHE_VAL(ac_cv_type_$1,
25 [AC_EGREP_CPP(dnl
26 changequote(<<,>>)dnl
27 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
28 changequote([,]), [#include <sys/types.h>
29 #if STDC_HEADERS
30 #include <stdlib.h>
31 #include <stddef.h>
32 #endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
33 AC_MSG_RESULT($ac_cv_type_$1)
34 if test $ac_cv_type_$1 = no; then
35   AC_DEFINE($1, $2, [Define as \`$2' if <sys/types.h> doesn't define.])
36 fi
37 ])
38
39
40 dnl See whether we can include both string.h and strings.h.
41 AC_DEFUN([gcc_AC_HEADER_STRING],
42 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
43   gcc_cv_header_string,
44 [AC_TRY_COMPILE([#include <string.h>
45 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
46 if test $gcc_cv_header_string = yes; then
47   AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
48 fi
49 ])
50
51 dnl See whether we need a declaration for a function.
52 dnl The result is highly dependent on the INCLUDES passed in, so make sure
53 dnl to use a different cache variable name in this macro if it is invoked
54 dnl in a different context somewhere else.
55 dnl gcc_AC_CHECK_DECL(SYMBOL,
56 dnl     [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
57 AC_DEFUN([gcc_AC_CHECK_DECL],
58 [AC_MSG_CHECKING([whether $1 is declared])
59 AC_CACHE_VAL(gcc_cv_have_decl_$1,
60 [AC_TRY_COMPILE([$4],
61 [#ifndef $1
62 char *(*pfn) = (char *(*)) $1 ;
63 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
64 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
65   AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
66 else
67   AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
68 fi
69 ])dnl
70
71 dnl Check multiple functions to see whether each needs a declaration.
72 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
73 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
74 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
75 AC_DEFUN([gcc_AC_CHECK_DECLS],
76 [for ac_func in $1
77 do
78 changequote(, )dnl
79   ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
80 changequote([, ])dnl
81 gcc_AC_CHECK_DECL($ac_func,
82   [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
83   [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
84 dnl It is possible that the include files passed in here are local headers
85 dnl which supply a backup declaration for the relevant prototype based on
86 dnl the definition of (or lack of) the HAVE_DECL_ macro.  If so, this test
87 dnl will always return success.  E.g. see libiberty.h's handling of
88 dnl `basename'.  To avoid this, we define the relevant HAVE_DECL_ macro to
89 dnl 1 so that any local headers used do not provide their own prototype
90 dnl during this test.
91 #undef $ac_tr_decl
92 #define $ac_tr_decl 1
93   $4
94 )
95 done
96 dnl Automatically generate config.h entries via autoheader.
97 if test x = y ; then
98   patsubst(translit([$1], [a-z], [A-Z]), [\w+],
99     [AC_DEFINE([HAVE_DECL_\&], 1,
100       [Define to 1 if we found this declaration otherwise define to 0.])])dnl
101 fi
102 ])
103
104 dnl 'make compare' can be significantly faster, if cmp itself can
105 dnl skip bytes instead of using tail.  The test being performed is
106 dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
107 dnl but we need to sink errors and handle broken shells.  We also test
108 dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
109 dnl accepted by cmp on some systems.
110 AC_DEFUN([gcc_AC_PROG_CMP_IGNORE_INITIAL],
111 [AC_CACHE_CHECK([for cmp's capabilities], gcc_cv_prog_cmp_skip,
112 [ echo abfoo >t1
113   echo cdfoo >t2
114   gcc_cv_prog_cmp_skip=slowcompare
115   if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
116     if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
117       :
118     else
119       gcc_cv_prog_cmp_skip=gnucompare
120     fi
121   fi
122   if test $gcc_cv_prog_cmp_skip = slowcompare ; then
123     if cmp t1 t2 2 2 > /dev/null 2>&1; then
124       if cmp t1 t2 1 1 > /dev/null 2>&1; then
125         :
126       else
127         gcc_cv_prog_cmp_skip=fastcompare
128       fi
129     fi
130   fi
131   rm t1 t2
132 ])
133 make_compare_target=$gcc_cv_prog_cmp_skip
134 AC_SUBST(make_compare_target)
135 ])
136
137 dnl See if the printf functions in libc support %p in format strings.
138 AC_DEFUN([gcc_AC_FUNC_PRINTF_PTR],
139 [AC_CACHE_CHECK(whether the printf functions support %p,
140   gcc_cv_func_printf_ptr,
141 [AC_TRY_RUN([#include <stdio.h>
142
143 int main()
144 {
145   char buf[64];
146   char *p = buf, *q = NULL;
147   sprintf(buf, "%p", p);
148   sscanf(buf, "%p", &q);
149   return (p != q);
150 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
151         gcc_cv_func_printf_ptr=no)
152 rm -f core core.* *.core])
153 if test $gcc_cv_func_printf_ptr = yes ; then
154   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
155 fi
156 ])
157
158 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
159 AC_DEFUN([gcc_AC_PROG_LN_S],
160 [AC_MSG_CHECKING(whether ln -s works)
161 AC_CACHE_VAL(gcc_cv_prog_LN_S,
162 [rm -f conftestdata_t
163 echo >conftestdata_f
164 if ln -s conftestdata_f conftestdata_t 2>/dev/null
165 then
166   gcc_cv_prog_LN_S="ln -s"
167 else
168   if ln conftestdata_f conftestdata_t 2>/dev/null
169   then
170     gcc_cv_prog_LN_S=ln
171   else
172     gcc_cv_prog_LN_S=cp
173   fi
174 fi
175 rm -f conftestdata_f conftestdata_t
176 ])dnl
177 LN_S="$gcc_cv_prog_LN_S"
178 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
179   AC_MSG_RESULT(yes)
180 else
181   if test "$gcc_cv_prog_LN_S" = "ln"; then
182     AC_MSG_RESULT([no, using ln])
183   else
184     AC_MSG_RESULT([no, and neither does ln, so using cp])
185   fi
186 fi
187 AC_SUBST(LN_S)dnl
188 ])
189
190 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
191 AC_DEFUN([gcc_AC_PROG_LN],
192 [AC_MSG_CHECKING(whether ln works)
193 AC_CACHE_VAL(gcc_cv_prog_LN,
194 [rm -f conftestdata_t
195 echo >conftestdata_f
196 if ln conftestdata_f conftestdata_t 2>/dev/null
197 then
198   gcc_cv_prog_LN="ln"
199 else
200   if ln -s conftestdata_f conftestdata_t 2>/dev/null
201   then
202     gcc_cv_prog_LN="ln -s"
203   else
204     gcc_cv_prog_LN=cp
205   fi
206 fi
207 rm -f conftestdata_f conftestdata_t
208 ])dnl
209 LN="$gcc_cv_prog_LN"
210 if test "$gcc_cv_prog_LN" = "ln"; then
211   AC_MSG_RESULT(yes)
212 else
213   if test "$gcc_cv_prog_LN" = "ln -s"; then
214     AC_MSG_RESULT([no, using ln -s])
215   else
216     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
217   fi
218 fi
219 AC_SUBST(LN)dnl
220 ])
221
222 dnl Check whether _Bool is built-in.
223 AC_DEFUN([gcc_AC_C__BOOL],
224 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
225 [AC_TRY_COMPILE(,
226 [_Bool foo;],
227 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
228 ])
229 if test $gcc_cv_c__bool = yes; then
230   AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
231 fi
232 ])
233
234 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
235 dnl of the usual 2.
236 AC_DEFUN([gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG],
237 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
238 [AC_TRY_COMPILE([
239 #include <sys/types.h>
240 #ifdef HAVE_SYS_STAT_H
241 # include <sys/stat.h>
242 #endif
243 #ifdef HAVE_UNISTD_H
244 # include <unistd.h>
245 #endif
246 #ifdef HAVE_DIRECT_H
247 # include <direct.h>
248 #endif], [mkdir ("foo", 0);], 
249         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
250 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
251   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
252 fi
253 ])
254
255 AC_DEFUN([gcc_AC_PROG_INSTALL],
256 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
257 # Find a good install program.  We prefer a C program (faster),
258 # so one script is as good as another.  But avoid the broken or
259 # incompatible versions:
260 # SysV /etc/install, /usr/sbin/install
261 # SunOS /usr/etc/install
262 # IRIX /sbin/install
263 # AIX /bin/install
264 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
265 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
266 # ./install, which can be erroneously created by make from ./install.sh.
267 AC_MSG_CHECKING(for a BSD compatible install)
268 if test -z "$INSTALL"; then
269 AC_CACHE_VAL(ac_cv_path_install,
270 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
271   for ac_dir in $PATH; do
272     # Account for people who put trailing slashes in PATH elements.
273     case "$ac_dir/" in
274     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
275     *)
276       # OSF1 and SCO ODT 3.0 have their own names for install.
277       for ac_prog in ginstall scoinst install; do
278         if test -f $ac_dir/$ac_prog; then
279           if test $ac_prog = install &&
280             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
281             # AIX install.  It has an incompatible calling convention.
282             # OSF/1 installbsd also uses dspmsg, but is usable.
283             :
284           else
285             ac_cv_path_install="$ac_dir/$ac_prog -c"
286             break 2
287           fi
288         fi
289       done
290       ;;
291     esac
292   done
293   IFS="$ac_save_IFS"
294 ])dnl
295   if test "${ac_cv_path_install+set}" = set; then
296     INSTALL="$ac_cv_path_install"
297   else
298     # As a last resort, use the slow shell script.  We don't cache a
299     # path for INSTALL within a source directory, because that will
300     # break other packages using the cache if that directory is
301     # removed, or if the path is relative.
302     INSTALL="$ac_install_sh"
303   fi
304 fi
305 dnl We do special magic for INSTALL instead of AC_SUBST, to get
306 dnl relative paths right.
307 AC_MSG_RESULT($INSTALL)
308 AC_SUBST(INSTALL)dnl
309
310 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
311 # It thinks the first close brace ends the variable substitution.
312 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
313 AC_SUBST(INSTALL_PROGRAM)dnl
314
315 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
316 AC_SUBST(INSTALL_DATA)dnl
317 ])
318
319 dnl Test for GNAT.
320 dnl We require the gnatbind program, and a compiler driver that
321 dnl understands Ada.  The user may set the driver name explicitly
322 dnl with ADAC; also, the user's CC setting is tried.  Failing that,
323 dnl we try gcc and cc, then a sampling of names known to be used for
324 dnl the Ada driver on various systems.
325 dnl
326 dnl Sets the shell variable have_gnat to yes or no as appropriate, and
327 dnl substitutes GNATBIND and ADAC.
328 AC_DEFUN([gcc_AC_PROG_GNAT],
329 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
330 AC_CHECK_TOOL(GNATBIND, gnatbind, no)
331 AC_CACHE_CHECK([for compiler driver that understands Ada],
332                  gcc_cv_prog_adac,
333 [cat >conftest.adb <<EOF
334 procedure conftest is begin null; end conftest;
335 EOF
336 gcc_cv_prog_adac=no
337 # Have to do ac_tool_prefix and user overrides by hand.
338 for cand in ${ADAC+"$ADAC"} ${CC+"$CC"} \
339             ${ac_tool_prefix}gcc        gcc             \
340             ${ac_tool_prefix}cc         cc              \
341             ${ac_tool_prefix}gnatgcc    gnatgcc         \
342             ${ac_tool_prefix}gnatcc     gnatcc          \
343             ${ac_tool_prefix}adagcc     adagcc          \
344             ${ac_tool_prefix}adacc      adacc           ; do
345   # There is a bug in all released versions of GCC which causes the
346   # driver to exit successfully when the appropriate language module
347   # has not been installed.  This is fixed in 2.95.4, 3.0.2, and 3.1.
348   # Therefore we must check for the error message as well as an
349   # unsuccessful exit.
350   errors=`($cand -c conftest.adb) 2>&1 || echo failure`
351   if test x"$errors" = x; then
352     gcc_cv_prog_adac=$cand
353     break
354   fi
355 done
356 rm -f conftest.*])
357 ADAC=$gcc_cv_prog_adac
358 AC_SUBST(ADAC)
359
360 if test x$GNATBIND != xno && test x$ADAC != xno; then
361   have_gnat=yes
362 else
363   have_gnat=no
364 fi
365 ])
366
367 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
368 dnl like AC_PATH_PROG but use other cache variables
369 AC_DEFUN([GCC_PATH_PROG],
370 [# Extract the first word of "$2", so it can be a program name with args.
371 set dummy $2; ac_word=[$]2
372 AC_MSG_CHECKING([for $ac_word])
373 AC_CACHE_VAL(gcc_cv_path_$1,
374 [case "[$]$1" in
375   /*)
376   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
377   ;;
378   ?:/*)                  
379   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
380   ;;
381   *)
382   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
383 dnl $ac_dummy forces splitting on constant user-supplied paths.
384 dnl POSIX.2 word splitting is done only on the output of word expansions,
385 dnl not every word.  This closes a longstanding sh security hole.
386   ac_dummy="ifelse([$4], , $PATH, [$4])"
387   for ac_dir in $ac_dummy; do 
388     test -z "$ac_dir" && ac_dir=.
389     if test -f $ac_dir/$ac_word; then
390       gcc_cv_path_$1="$ac_dir/$ac_word"
391       break
392     fi
393   done
394   IFS="$ac_save_ifs"
395 dnl If no 3rd arg is given, leave the cache variable unset,
396 dnl so GCC_PATH_PROGS will keep looking.
397 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
398 ])dnl
399   ;;
400 esac])dnl
401 $1="$gcc_cv_path_$1"
402 if test -n "[$]$1"; then
403   AC_MSG_RESULT([$]$1)
404 else
405   AC_MSG_RESULT(no)
406 fi
407 AC_SUBST($1)dnl
408 ])
409
410 # mmap(2) blacklisting.  Some platforms provide the mmap library routine
411 # but don't support all of the features we need from it.
412 AC_DEFUN([gcc_AC_FUNC_MMAP_BLACKLIST],
413 [if test $ac_cv_header_sys_mman_h != yes \
414  || test $ac_cv_func_mmap != yes; then
415    gcc_cv_func_mmap_file=no
416    gcc_cv_func_mmap_dev_zero=no
417    gcc_cv_func_mmap_anon=no
418 else
419    AC_CACHE_CHECK([whether read-only mmap of a plain file works], 
420   gcc_cv_func_mmap_file,
421   [# Add a system to this blacklist if 
422    # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
423    # memory area containing the same data that you'd get if you applied
424    # read() to the same fd.  The only system known to have a problem here
425    # is VMS, where text files have record structure.
426    case "$host_os" in
427      vms*) 
428         gcc_cv_func_mmap_file=no ;;
429      *)
430         gcc_cv_func_mmap_file=yes;;
431    esac])
432    AC_CACHE_CHECK([whether mmap from /dev/zero works],
433   gcc_cv_func_mmap_dev_zero,
434   [# Add a system to this blacklist if it has mmap() but /dev/zero
435    # does not exist, or if mmapping /dev/zero does not give anonymous
436    # zeroed pages with both the following properties:
437    # 1. If you map N consecutive pages in with one call, and then
438    #    unmap any subset of those pages, the pages that were not
439    #    explicitly unmapped remain accessible.
440    # 2. If you map two adjacent blocks of memory and then unmap them
441    #    both at once, they must both go away.
442    # Systems known to be in this category are Windows (all variants),
443    # VMS, and Darwin.
444    case "$host_os" in
445      vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
446         gcc_cv_func_mmap_dev_zero=no ;;
447      *)
448         gcc_cv_func_mmap_dev_zero=yes;;
449    esac])
450
451    # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
452    AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
453     [AC_TRY_COMPILE(
454 [#include <sys/types.h>
455 #include <sys/mman.h>
456 #include <unistd.h>
457
458 #ifndef MAP_ANONYMOUS
459 #define MAP_ANONYMOUS MAP_ANON
460 #endif
461 ],
462 [int n = MAP_ANONYMOUS;],
463     gcc_cv_decl_map_anon=yes,
464     gcc_cv_decl_map_anon=no)])
465
466    if test $gcc_cv_decl_map_anon = no; then
467      gcc_cv_func_mmap_anon=no
468    else
469      AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
470      gcc_cv_func_mmap_anon,
471   [# Add a system to this blacklist if it has mmap() and MAP_ANON or
472    # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
473    # doesn't give anonymous zeroed pages with the same properties listed
474    # above for use of /dev/zero.
475    # Systems known to be in this category are Windows, VMS, and SCO Unix.
476    case "$host_os" in
477      vms* | cygwin* | pe | mingw* | sco* | udk* )
478         gcc_cv_func_mmap_anon=no ;;
479      *)
480         gcc_cv_func_mmap_anon=yes;;
481    esac])
482    fi
483 fi
484
485 if test $gcc_cv_func_mmap_file = yes; then
486   AC_DEFINE(HAVE_MMAP_FILE, 1,
487             [Define if read-only mmap of a plain file works.])
488 fi
489 if test $gcc_cv_func_mmap_dev_zero = yes; then
490   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
491             [Define if mmap of /dev/zero works.])
492 fi
493 if test $gcc_cv_func_mmap_anon = yes; then
494   AC_DEFINE(HAVE_MMAP_ANON, 1,
495             [Define if mmap with MAP_ANON(YMOUS) works.])
496 fi
497 ])
498
499 dnl Locate a program and check that its version is acceptable.
500 dnl AC_PROG_CHECK_VER(var, name, version-switch,
501 dnl                  version-extract-regexp, version-glob)
502 AC_DEFUN([gcc_AC_CHECK_PROG_VER],
503 [AC_CHECK_PROG([$1], [$2], [$2])
504 if test -n "[$]$1"; then
505   # Found it, now check the version.
506   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
507 [changequote(<<,>>)dnl
508   ac_prog_version=`<<$>>$1 $3 2>&1 |
509                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
510 changequote([,])dnl
511   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
512 changequote(<<,>>)dnl
513   case $ac_prog_version in
514     '')     gcc_cv_prog_$2_modern=no;;
515     <<$5>>)
516             gcc_cv_prog_$2_modern=yes;;
517     *)      gcc_cv_prog_$2_modern=no;;
518   esac
519 changequote([,])dnl
520 ])
521 else
522   gcc_cv_prog_$2_modern=no
523 fi
524 ])
525
526 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
527 dnl be either signed or unsigned.
528 dnl
529 AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED],
530 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
531 [AC_TRY_RUN(#include <stdlib.h>
532 enum t { BLAH = 128 } ;
533 struct s_t { enum t member : 8; } s ;
534 int main(void)
535 {            
536         s.member = BLAH;
537         if (s.member < 0) exit(1);
538         exit(0);
539
540 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
541 if test $gcc_cv_enum_bf_unsigned = yes; then
542   AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
543     [Define if enumerated bitfields are treated as unsigned values.])
544 fi])
545
546 dnl Probe number of bits in a byte.
547 dnl Note C89 requires CHAR_BIT >= 8.
548 dnl
549 AC_DEFUN([gcc_AC_C_CHAR_BIT],
550 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
551 [AC_EGREP_CPP(found,
552 [#ifdef HAVE_LIMITS_H
553 #include <limits.h>
554 #endif
555 #ifdef CHAR_BIT
556 found
557 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
558 ])
559 if test $gcc_cv_decl_char_bit = no; then
560   AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
561 [i=8
562  gcc_cv_c_nbby=
563  while test $i -lt 65; do
564    AC_TRY_COMPILE(,
565      [switch(0) {
566   case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
567   case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
568   ; }], 
569      [gcc_cv_c_nbby=$i; break])
570    i=`expr $i + 1`
571  done
572  test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
573 ])
574 if test $gcc_cv_c_nbby = failed; then
575   AC_MSG_ERROR(cannot determine number of bits in a byte)
576 else
577   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
578   [Define as the number of bits in a byte, if \`limits.h' doesn't.])
579 fi
580 fi])
581
582 dnl Checking for long long.
583 dnl By Caolan McNamara <caolan@skynet.ie>
584 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
585 dnl
586 AC_DEFUN([gcc_AC_C_LONG_LONG],
587 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
588   [AC_TRY_COMPILE(,[long long int i;],
589          ac_cv_c_long_long=yes,
590          ac_cv_c_long_long=no)])
591   if test $ac_cv_c_long_long = yes; then
592     AC_DEFINE(HAVE_LONG_LONG, 1,
593       [Define if your compiler supports the \`long long' type.])
594   fi
595 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
596   [AC_TRY_COMPILE(,[__int64 i;],
597         ac_cv_c___int64=yes,
598         ac_cv_c___int64=no)])
599   if test $ac_cv_c___int64 = yes; then
600     AC_DEFINE(HAVE___INT64, 1,
601       [Define if your compiler supports the \`__int64' type.])
602   fi
603 ])
604
605 #serial AM2
606
607 dnl From Bruno Haible.
608
609 AC_DEFUN([AM_ICONV],
610 [
611   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
612   dnl those with the standalone portable GNU libiconv installed).
613
614   am_cv_lib_iconv_ldpath=
615   AC_ARG_WITH([libiconv-prefix],
616 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
617     for dir in `echo "$withval" | tr : ' '`; do
618       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
619       if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
620     done
621    ])
622
623   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
624     am_cv_func_iconv="no, consider installing GNU libiconv"
625     am_cv_lib_iconv=no
626     AC_TRY_LINK([#include <stdlib.h>
627 #include <iconv.h>],
628       [iconv_t cd = iconv_open("","");
629        iconv(cd,NULL,NULL,NULL,NULL);
630        iconv_close(cd);],
631       am_cv_func_iconv=yes)
632     if test "$am_cv_func_iconv" != yes; then
633       am_save_LIBS="$LIBS"
634       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
635       AC_TRY_LINK([#include <stdlib.h>
636 #include <iconv.h>],
637         [iconv_t cd = iconv_open("","");
638          iconv(cd,NULL,NULL,NULL,NULL);
639          iconv_close(cd);],
640         am_cv_lib_iconv=yes
641         am_cv_func_iconv=yes)
642       LIBS="$am_save_LIBS"
643     fi
644   ])
645   if test "$am_cv_func_iconv" = yes; then
646     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
647     AC_MSG_CHECKING([for iconv declaration])
648     AC_CACHE_VAL(am_cv_proto_iconv, [
649       AC_TRY_COMPILE([
650 #include <stdlib.h>
651 #include <iconv.h>
652 extern
653 #ifdef __cplusplus
654 "C"
655 #endif
656 #if defined(__STDC__) || defined(__cplusplus)
657 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
658 #else
659 size_t iconv();
660 #endif
661 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
662       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);"])
663     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
664     AC_MSG_RESULT([$]{ac_t:-
665          }[$]am_cv_proto_iconv)
666     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
667       [Define as const if the declaration of iconv() needs const.])
668   fi
669   LIBICONV=
670   if test "$am_cv_lib_iconv" = yes; then
671     LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
672   fi
673   AC_SUBST(LIBICONV)
674 ])
675
676 AC_DEFUN([gcc_AC_INITFINI_ARRAY],
677 [AC_ARG_ENABLE(initfini-array,
678         [  --enable-initfini-array      use .init_array/.fini_array sections],
679         [], [
680 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
681                  gcc_cv_initfini_array, [dnl
682   AC_TRY_RUN([
683 static int x = -1;
684 int main (void) { return x; }
685 int foo (void) { x = 0; }
686 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;],
687              [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
688              [gcc_cv_initfini_array=no])])
689   enable_initfini_array=$gcc_cv_initfini_array
690 ])
691 if test $enable_initfini_array = yes; then
692   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
693     [Define .init_array/.fini_array sections are available and working.])
694 fi])
695
696 dnl # _gcc_COMPUTE_GAS_VERSION
697 dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
698 dnl #
699 dnl # WARNING:
700 dnl # gcc_cv_as_gas_srcdir must be defined before this.
701 dnl # This gross requirement will go away eventually.
702 AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
703 [gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
704 for f in $gcc_cv_as_bfd_srcdir/configure \
705          $gcc_cv_as_gas_srcdir/configure \
706          $gcc_cv_as_gas_srcdir/configure.in \
707          $gcc_cv_as_gas_srcdir/Makefile.in ; do
708   gcc_cv_gas_version=`grep '^VERSION=[[0-9]]*\.[[0-9]]*' $f`
709   if test x$gcc_cv_gas_version != x; then
710     break
711   fi
712 done
713 gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
714 gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
715 gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
716 case $gcc_cv_gas_patch_version in
717   "") gcc_cv_gas_patch_version="0" ;;
718 esac
719 gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
720                             + $gcc_cv_gas_minor_version \) \* 1000 \
721                             + $gcc_cv_gas_patch_version`
722 ]) []dnl # _gcc_COMPUTE_GAS_VERSION
723
724 dnl # gcc_GAS_VERSION_GTE_IFELSE([elf,] major, minor, patchlevel,
725 dnl #                     [command_if_true = :], [command_if_false = :])
726 dnl # Check to see if the version of GAS is greater than or
727 dnl # equal to the specified version.
728 dnl #
729 dnl # The first ifelse() shortens the shell code if the patchlevel
730 dnl # is unimportant (the usual case).  The others handle missing
731 dnl # commands.  Note that the tests are structured so that the most
732 dnl # common version number cases are tested first.
733 AC_DEFUN([_gcc_GAS_VERSION_GTE_IFELSE],
734 [ifelse([$1], elf,
735  [if test $in_tree_gas_is_elf = yes \
736   &&],
737  [if]) test $gcc_cv_gas_vers -ge `expr \( \( $2 \* 1000 \) + $3 \) \* 1000 + $4`
738   then dnl
739 ifelse([$5],,:,[$5])[]dnl
740 ifelse([$6],,,[
741   else $6])
742 fi])
743
744 AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
745 [AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION])dnl
746 ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
747                   [_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
748
749 dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
750 dnl [extra switches to as], [assembler input],
751 dnl [extra testing logic], [command if feature available])
752 dnl
753 dnl Checks for an assembler feature.  If we are building an in-tree
754 dnl gas, the feature is available if the associated assembler version
755 dnl is greater than or equal to major.minor.patchlevel.  If not, then
756 dnl ASSEMBLER INPUT is fed to the assembler and the feature is available
757 dnl if assembly succeeds.  If EXTRA TESTING LOGIC is not the empty string,
758 dnl then it is run instead of simply setting CV to "yes" - it is responsible
759 dnl for doing so, if appropriate.
760 AC_DEFUN([gcc_GAS_CHECK_FEATURE],
761 [AC_CACHE_CHECK([assembler for $1], [$2],
762  [[$2]=no
763   ifelse([$3],,,[dnl
764   if test $in_tree_gas = yes; then
765     gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
766   el])if test x$gcc_cv_as != x; then
767     echo ifelse(substr([$5],0,1),[$], "[$5]", '[$5]') > conftest.s
768     if AC_TRY_COMMAND([$gcc_cv_as $4 -o conftest.o conftest.s >&AC_FD_CC])
769     then
770         ifelse([$6],, [$2]=yes, [$6])
771     else
772       echo "configure: failed program was" >&AC_FD_CC
773       cat conftest.s >&AC_FD_CC
774     fi
775     rm -f conftest.o conftest.s
776   fi])
777 ifelse([$7],,,[dnl
778 if test $[$2] = yes; then
779   $7
780 fi])])
781
782 # lcmessage.m4 serial 3 (gettext-0.11.3)
783 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
784 dnl This file is free software, distributed under the terms of the GNU
785 dnl General Public License.  As a special exception to the GNU General
786 dnl Public License, this file may be distributed as part of a program
787 dnl that contains a configuration script generated by Autoconf, under
788 dnl the same distribution terms as the rest of that program.
789 dnl
790 dnl This file can can be used in projects which are not available under
791 dnl the GNU General Public License or the GNU Library General Public
792 dnl License but which still want to provide support for the GNU gettext
793 dnl functionality.
794 dnl Please note that the actual code of the GNU gettext library is covered
795 dnl by the GNU Library General Public License, and the rest of the GNU
796 dnl gettext package package is covered by the GNU General Public License.
797 dnl They are *not* in the public domain.
798
799 dnl Authors:
800 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
801
802 # Check whether LC_MESSAGES is available in <locale.h>.
803
804 AC_DEFUN([AM_LC_MESSAGES],
805 [
806   AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
807     [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
808        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
809   if test $am_cv_val_LC_MESSAGES = yes; then
810     AC_DEFINE(HAVE_LC_MESSAGES, 1,
811       [Define if your <locale.h> file defines LC_MESSAGES.])
812   fi
813 ])