OSDN Git Service

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