]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/acinclude.m4
2012-03-14 Paolo Carlini <paolo.carlini@oracle.com>
[thirdparty/gcc.git] / gcc / acinclude.m4
CommitLineData
e992fc2e
RO
1dnl Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012
2dnl Free Software Foundation, Inc.
ad41bd84
JM
3dnl
4dnl This file is part of GCC.
5dnl
6dnl GCC is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 3, or (at your option)
9dnl any later version.
10dnl
11dnl GCC is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with GCC; see the file COPYING3. If not see
18dnl <http://www.gnu.org/licenses/>.
19
67da1534
KC
20dnl See whether we need a declaration for a function.
21dnl The result is highly dependent on the INCLUDES passed in, so make sure
22dnl to use a different cache variable name in this macro if it is invoked
23dnl in a different context somewhere else.
24dnl gcc_AC_CHECK_DECL(SYMBOL,
25dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
26AC_DEFUN([gcc_AC_CHECK_DECL],
27[AC_MSG_CHECKING([whether $1 is declared])
28AC_CACHE_VAL(gcc_cv_have_decl_$1,
29[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$4],
30[#ifndef $1
31char *(*pfn) = (char *(*)) $1 ;
32#endif])], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
33if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
34 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
35else
36 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
37fi
38])dnl
39
40dnl Check multiple functions to see whether each needs a declaration.
41dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
42dnl gcc_AC_CHECK_DECLS(SYMBOLS,
43dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
44AC_DEFUN([gcc_AC_CHECK_DECLS],
45[AC_FOREACH([gcc_AC_Func], [$1],
46 [AH_TEMPLATE(AS_TR_CPP(HAVE_DECL_[]gcc_AC_Func),
47 [Define to 1 if we found a declaration for ']gcc_AC_Func[', otherwise
48 define to 0.])])dnl
49for ac_func in $1
50do
51 ac_tr_decl=AS_TR_CPP([HAVE_DECL_$ac_func])
52gcc_AC_CHECK_DECL($ac_func,
53 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
54 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
55dnl It is possible that the include files passed in here are local headers
56dnl which supply a backup declaration for the relevant prototype based on
57dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
58dnl will always return success. E.g. see libiberty.h's handling of
59dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
60dnl 1 so that any local headers used do not provide their own prototype
61dnl during this test.
62#undef $ac_tr_decl
63#define $ac_tr_decl 1
64 $4
65)
66done
67])
68
69dnl 'make compare' can be significantly faster, if cmp itself can
70dnl skip bytes instead of using tail. The test being performed is
71dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
72dnl but we need to sink errors and handle broken shells. We also test
73dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
74dnl accepted by cmp on some systems.
75AC_DEFUN([gcc_AC_PROG_CMP_IGNORE_INITIAL],
76[AC_CACHE_CHECK([for cmp's capabilities], gcc_cv_prog_cmp_skip,
77[ echo abfoo >t1
78 echo cdfoo >t2
79 gcc_cv_prog_cmp_skip=slowcompare
80 if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
81 if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
82 :
83 else
84 gcc_cv_prog_cmp_skip=gnucompare
85 fi
86 fi
87 if test $gcc_cv_prog_cmp_skip = slowcompare ; then
88 if cmp t1 t2 2 2 > /dev/null 2>&1; then
89 if cmp t1 t2 1 1 > /dev/null 2>&1; then
90 :
91 else
92 gcc_cv_prog_cmp_skip=fastcompare
93 fi
94 fi
95 fi
96 rm t1 t2
97])
98make_compare_target=$gcc_cv_prog_cmp_skip
99AC_SUBST(make_compare_target)
100])
101
102dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
103AC_DEFUN([gcc_AC_PROG_LN_S],
104[AC_MSG_CHECKING(whether ln -s works)
105AC_CACHE_VAL(gcc_cv_prog_LN_S,
106[rm -f conftestdata_t
107echo >conftestdata_f
108if ln -s conftestdata_f conftestdata_t 2>/dev/null
109then
110 gcc_cv_prog_LN_S="ln -s"
111else
112 if ln conftestdata_f conftestdata_t 2>/dev/null
113 then
114 gcc_cv_prog_LN_S=ln
115 else
116 if cp -p conftestdata_f conftestdata_t 2>/dev/null
117 then
118 gcc_cv_prog_LN_S="cp -p"
119 else
120 gcc_cv_prog_LN_S=cp
121 fi
122 fi
123fi
124rm -f conftestdata_f conftestdata_t
125])dnl
126LN_S="$gcc_cv_prog_LN_S"
127if test "$gcc_cv_prog_LN_S" = "ln -s"; then
128 AC_MSG_RESULT(yes)
129else
130 if test "$gcc_cv_prog_LN_S" = "ln"; then
131 AC_MSG_RESULT([no, using ln])
132 else
133 AC_MSG_RESULT([no, and neither does ln, so using $gcc_cv_prog_LN_S])
134 fi
135fi
136AC_SUBST(LN_S)dnl
137])
138
139dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
140dnl of the usual 2.
141AC_DEFUN([gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG],
142[AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
143[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
144#include <sys/types.h>
145#ifdef HAVE_SYS_STAT_H
146# include <sys/stat.h>
147#endif
148#ifdef HAVE_UNISTD_H
149# include <unistd.h>
150#endif
151#ifdef HAVE_DIRECT_H
152# include <direct.h>
153#endif], [mkdir ("foo", 0);])],
154 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
155if test $gcc_cv_mkdir_takes_one_arg = yes ; then
156 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
157fi
158])
159
160AC_DEFUN([gcc_AC_PROG_INSTALL],
161[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
162# Find a good install program. We prefer a C program (faster),
163# so one script is as good as another. But avoid the broken or
164# incompatible versions:
165# SysV /etc/install, /usr/sbin/install
166# SunOS /usr/etc/install
167# IRIX /sbin/install
168# AIX /bin/install
169# AFS /usr/afsws/bin/install, which mishandles nonexistent args
170# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
171# ./install, which can be erroneously created by make from ./install.sh.
172AC_MSG_CHECKING(for a BSD compatible install)
173if test -z "$INSTALL"; then
174AC_CACHE_VAL(ac_cv_path_install,
175[ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
176 for ac_dir in $PATH; do
177 # Account for people who put trailing slashes in PATH elements.
178 case "$ac_dir/" in
179 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
180 *)
181 # OSF1 and SCO ODT 3.0 have their own names for install.
182 for ac_prog in ginstall scoinst install; do
183 if test -f $ac_dir/$ac_prog; then
184 if test $ac_prog = install &&
185 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
186 # AIX install. It has an incompatible calling convention.
187 # OSF/1 installbsd also uses dspmsg, but is usable.
188 :
189 else
190 ac_cv_path_install="$ac_dir/$ac_prog -c"
191 break 2
192 fi
193 fi
194 done
195 ;;
196 esac
197 done
198 IFS="$ac_save_IFS"
199])dnl
200 if test "${ac_cv_path_install+set}" = set; then
201 INSTALL="$ac_cv_path_install"
202 else
203 # As a last resort, use the slow shell script. We don't cache a
204 # path for INSTALL within a source directory, because that will
205 # break other packages using the cache if that directory is
206 # removed, or if the path is relative.
207 INSTALL="$ac_install_sh"
208 fi
209fi
210dnl We do special magic for INSTALL instead of AC_SUBST, to get
211dnl relative paths right.
212AC_MSG_RESULT($INSTALL)
213AC_SUBST(INSTALL)dnl
214
215# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
216# It thinks the first close brace ends the variable substitution.
217test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
218AC_SUBST(INSTALL_PROGRAM)dnl
219
220test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
221AC_SUBST(INSTALL_DATA)dnl
222])
223
224# mmap(2) blacklisting. Some platforms provide the mmap library routine
225# but don't support all of the features we need from it.
226AC_DEFUN([gcc_AC_FUNC_MMAP_BLACKLIST],
227[
228AC_CHECK_HEADER([sys/mman.h],
229 [gcc_header_sys_mman_h=yes], [gcc_header_sys_mman_h=no])
230AC_CHECK_FUNC([mmap], [gcc_func_mmap=yes], [gcc_func_mmap=no])
231if test "$gcc_header_sys_mman_h" != yes \
232 || test "$gcc_func_mmap" != yes; then
233 gcc_cv_func_mmap_file=no
234 gcc_cv_func_mmap_dev_zero=no
235 gcc_cv_func_mmap_anon=no
236else
237 AC_CACHE_CHECK([whether read-only mmap of a plain file works],
238 gcc_cv_func_mmap_file,
239 [# Add a system to this blacklist if
240 # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
241 # memory area containing the same data that you'd get if you applied
242 # read() to the same fd. The only system known to have a problem here
243 # is VMS, where text files have record structure.
244 case "$host_os" in
245 vms* | ultrix*)
246 gcc_cv_func_mmap_file=no ;;
247 *)
248 gcc_cv_func_mmap_file=yes;;
249 esac])
250 AC_CACHE_CHECK([whether mmap from /dev/zero works],
251 gcc_cv_func_mmap_dev_zero,
252 [# Add a system to this blacklist if it has mmap() but /dev/zero
253 # does not exist, or if mmapping /dev/zero does not give anonymous
254 # zeroed pages with both the following properties:
255 # 1. If you map N consecutive pages in with one call, and then
256 # unmap any subset of those pages, the pages that were not
257 # explicitly unmapped remain accessible.
258 # 2. If you map two adjacent blocks of memory and then unmap them
259 # both at once, they must both go away.
260 # Systems known to be in this category are Windows (all variants),
261 # VMS, and Darwin.
262 case "$host_os" in
263 vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
264 gcc_cv_func_mmap_dev_zero=no ;;
265 *)
266 gcc_cv_func_mmap_dev_zero=yes;;
267 esac])
268
269 # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
270 AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
271 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
272[#include <sys/types.h>
273#include <sys/mman.h>
274#include <unistd.h>
275
276#ifndef MAP_ANONYMOUS
277#define MAP_ANONYMOUS MAP_ANON
278#endif
279],
280[int n = MAP_ANONYMOUS;])],
281 gcc_cv_decl_map_anon=yes,
282 gcc_cv_decl_map_anon=no)])
283
284 if test $gcc_cv_decl_map_anon = no; then
285 gcc_cv_func_mmap_anon=no
286 else
287 AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
288 gcc_cv_func_mmap_anon,
289 [# Add a system to this blacklist if it has mmap() and MAP_ANON or
290 # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
291 # doesn't give anonymous zeroed pages with the same properties listed
292 # above for use of /dev/zero.
293 # Systems known to be in this category are Windows, VMS, and SCO Unix.
294 case "$host_os" in
295 vms* | cygwin* | pe | mingw* | sco* | udk* )
296 gcc_cv_func_mmap_anon=no ;;
297 *)
298 gcc_cv_func_mmap_anon=yes;;
299 esac])
300 fi
301fi
302
303if test $gcc_cv_func_mmap_file = yes; then
304 AC_DEFINE(HAVE_MMAP_FILE, 1,
305 [Define if read-only mmap of a plain file works.])
306fi
307if test $gcc_cv_func_mmap_dev_zero = yes; then
308 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
309 [Define if mmap of /dev/zero works.])
310fi
311if test $gcc_cv_func_mmap_anon = yes; then
312 AC_DEFINE(HAVE_MMAP_ANON, 1,
313 [Define if mmap with MAP_ANON(YMOUS) works.])
314fi
315])
316
67da1534
KC
317dnl Determine if enumerated bitfields are unsigned. ISO C says they can
318dnl be either signed or unsigned.
319dnl
320AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED],
321[AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
322[AC_RUN_IFELSE([AC_LANG_SOURCE([#include <stdlib.h>
323enum t { BLAH = 128 } ;
324struct s_t { enum t member : 8; } s ;
325int main(void)
326{
327 s.member = BLAH;
328 if (s.member < 0) exit(1);
329 exit(0);
330
331}])], gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
332if test $gcc_cv_enum_bf_unsigned = yes; then
333 AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
334 [Define if enumerated bitfields are treated as unsigned values.])
335fi])
336
337dnl Probe number of bits in a byte.
338dnl Note C89 requires CHAR_BIT >= 8.
339dnl
340AC_DEFUN([gcc_AC_C_CHAR_BIT],
341[AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
342[AC_EGREP_CPP(found,
343[#ifdef HAVE_LIMITS_H
344#include <limits.h>
345#endif
346#ifdef CHAR_BIT
347found
348#endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
349])
350if test $gcc_cv_decl_char_bit = no; then
351 AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
352[i=8
353 gcc_cv_c_nbby=
354 while test $i -lt 65; do
355 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
356 [switch(0) {
357 case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
358 case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
359 ; }])],
360 [gcc_cv_c_nbby=$i; break])
361 i=`expr $i + 1`
362 done
363 test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
364])
365if test $gcc_cv_c_nbby = failed; then
366 AC_MSG_ERROR(cannot determine number of bits in a byte)
367else
368 AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
236ec2d7 369 [Define as the number of bits in a byte, if `limits.h' doesn't.])
67da1534
KC
370fi
371fi])
372
373AC_DEFUN([gcc_AC_INITFINI_ARRAY],
e992fc2e
RO
374[AC_REQUIRE([gcc_SUN_LD_VERSION])dnl
375AC_ARG_ENABLE(initfini-array,
67da1534
KC
376 [ --enable-initfini-array use .init_array/.fini_array sections],
377 [], [
378AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
379 gcc_cv_initfini_array, [dnl
0c587260 380 if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
e9c9f128
JJ
381 case "${target}" in
382 ia64-*)
383 AC_RUN_IFELSE([AC_LANG_SOURCE([
b0894e1f
L
384#ifndef __ELF__
385#error Not an ELF OS
386#endif
0c587260
L
387/* We turn on .preinit_array/.init_array/.fini_array support for ia64
388 if it can be used. */
67da1534
KC
389static int x = -1;
390int main (void) { return x; }
391int foo (void) { x = 0; }
0c587260 392int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
0c587260 393])],
67da1534 394 [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
e9c9f128
JJ
395 [gcc_cv_initfini_array=no]);;
396 *)
397 gcc_cv_initfini_array=no
398 if test $in_tree_ld = yes ; then
399 if test "$gcc_cv_gld_major_version" -eq 2 \
400 -a "$gcc_cv_gld_minor_version" -ge 22 \
401 -o "$gcc_cv_gld_major_version" -gt 2 \
402 && test $in_tree_ld_is_elf = yes; then
403 gcc_cv_initfini_array=yes
404 fi
405 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
406 cat > conftest.s <<\EOF
407.section .dtors,"a",%progbits
408.balign 4
409.byte 'A', 'A', 'A', 'A'
410.section .ctors,"a",%progbits
411.balign 4
412.byte 'B', 'B', 'B', 'B'
413.section .fini_array.65530,"a",%progbits
414.balign 4
415.byte 'C', 'C', 'C', 'C'
416.section .init_array.65530,"a",%progbits
417.balign 4
418.byte 'D', 'D', 'D', 'D'
419.section .dtors.64528,"a",%progbits
420.balign 4
421.byte 'E', 'E', 'E', 'E'
422.section .ctors.64528,"a",%progbits
423.balign 4
424.byte 'F', 'F', 'F', 'F'
425.section .fini_array.01005,"a",%progbits
426.balign 4
427.byte 'G', 'G', 'G', 'G'
428.section .init_array.01005,"a",%progbits
429.balign 4
430.byte 'H', 'H', 'H', 'H'
431.text
e992fc2e
RO
432.globl _start
433_start:
e9c9f128
JJ
434EOF
435 if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
e992fc2e 436 && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
e9c9f128
JJ
437 && $gcc_cv_objdump -s -j .init_array conftest \
438 | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
439 && $gcc_cv_objdump -s -j .fini_array conftest \
440 | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
441 gcc_cv_initfini_array=yes
442 fi
443changequote(,)dnl
444 rm -f conftest conftest.*
445changequote([,])dnl
446 fi
447 AC_PREPROC_IFELSE([AC_LANG_SOURCE([
448#ifndef __ELF__
e992fc2e 449# error Not an ELF OS
e9c9f128
JJ
450#endif
451#include <stdlib.h>
e992fc2e
RO
452#if defined __GLIBC_PREREQ
453# if __GLIBC_PREREQ (2, 4)
454# else
455# error GLIBC 2.4 required
456# endif
e9c9f128 457#else
e992fc2e
RO
458# if defined __sun__ && defined __svr4__
459 /* Solaris ld.so.1 supports .init_array/.fini_array since Solaris 8. */
460# else
461# error The C library not known to support .init_array/.fini_array
462# endif
e9c9f128 463#endif
e992fc2e
RO
464])],[
465 case "${target}" in
466 *-*-solaris2.8*)
467 # .init_array/.fini_array support was introduced in Solaris 8
468 # patches 109147-08 (sparc) and 109148-08 (x86). Since ld.so.1 and
469 # ld are guaranteed to be updated in lockstep, we can check ld -V
470 # instead. Unfortunately, proper ld version numbers were only
471 # introduced in rev. -14, so we check for that.
472 if test "$gcc_cv_sun_ld_vers_minor" -lt 272; then
473 gcc_cv_initfini_array=no
474 fi
475 ;;
476 *-*-solaris2.9* | *-*-solaris2.1[[0-9]]*)
477 # .init_array/.fini_array support is present since Solaris 9 FCS.
478 ;;
479 esac
480], [gcc_cv_initfini_array=no]);;
e9c9f128
JJ
481 esac
482 else
483 AC_MSG_CHECKING(cross compile... guessing)
484 gcc_cv_initfini_array=no
485 fi])
67da1534
KC
486 enable_initfini_array=$gcc_cv_initfini_array
487])
488if test $enable_initfini_array = yes; then
e10e461e 489 AC_DEFINE(HAVE_INITFINI_ARRAY_SUPPORT, 1,
67da1534
KC
490 [Define .init_array/.fini_array sections are available and working.])
491fi])
492
493dnl # _gcc_COMPUTE_GAS_VERSION
494dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
495dnl #
496dnl # WARNING:
497dnl # gcc_cv_as_gas_srcdir must be defined before this.
498dnl # This gross requirement will go away eventually.
499AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
500[gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
501for f in $gcc_cv_as_bfd_srcdir/configure \
502 $gcc_cv_as_gas_srcdir/configure \
503 $gcc_cv_as_gas_srcdir/configure.in \
504 $gcc_cv_as_gas_srcdir/Makefile.in ; do
505 gcc_cv_gas_version=`sed -n -e 's/^[[ ]]*\(VERSION=[[0-9]]*\.[[0-9]]*.*\)/\1/p' < $f`
506 if test x$gcc_cv_gas_version != x; then
507 break
508 fi
509done
510gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
511gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
512gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
513case $gcc_cv_gas_patch_version in
514 "") gcc_cv_gas_patch_version="0" ;;
515esac
516gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
517 + $gcc_cv_gas_minor_version \) \* 1000 \
518 + $gcc_cv_gas_patch_version`
519]) []dnl # _gcc_COMPUTE_GAS_VERSION
520
521dnl # gcc_GAS_VERSION_GTE_IFELSE([elf,] major, minor, patchlevel,
522dnl # [command_if_true = :], [command_if_false = :])
523dnl # Check to see if the version of GAS is greater than or
524dnl # equal to the specified version.
525dnl #
526dnl # The first ifelse() shortens the shell code if the patchlevel
527dnl # is unimportant (the usual case). The others handle missing
528dnl # commands. Note that the tests are structured so that the most
529dnl # common version number cases are tested first.
530AC_DEFUN([_gcc_GAS_VERSION_GTE_IFELSE],
531[ifelse([$1], elf,
532 [if test $in_tree_gas_is_elf = yes \
533 &&],
534 [if]) test $gcc_cv_gas_vers -ge `expr \( \( $2 \* 1000 \) + $3 \) \* 1000 + $4`
535 then dnl
536ifelse([$5],,:,[$5])[]dnl
537ifelse([$6],,,[
538 else $6])
539fi])
540
541AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
542[AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION])dnl
543ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
544 [_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
545
e0b0fd74
L
546dnl # gcc_GAS_FLAGS
547dnl # Used by gcc_GAS_CHECK_FEATURE
548dnl #
549AC_DEFUN([gcc_GAS_FLAGS],
550[AC_CACHE_CHECK([assembler flags], gcc_cv_as_flags,
551[ case "$target" in
552 i[[34567]]86-*-linux*)
553 dnl Always pass --32 to ia32 Linux assembler.
554 gcc_cv_as_flags="--32"
555 ;;
88ee1fc7
MS
556 powerpc*-*-darwin*)
557 dnl Always pass -arch ppc to assembler.
558 gcc_cv_as_flags="-arch ppc"
559 ;;
e0b0fd74
L
560 *)
561 gcc_cv_as_flags=" "
562 ;;
563 esac])
564])
565
67da1534
KC
566dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
567dnl [extra switches to as], [assembler input],
568dnl [extra testing logic], [command if feature available])
569dnl
570dnl Checks for an assembler feature. If we are building an in-tree
571dnl gas, the feature is available if the associated assembler version
572dnl is greater than or equal to major.minor.patchlevel. If not, then
573dnl ASSEMBLER INPUT is fed to the assembler and the feature is available
574dnl if assembly succeeds. If EXTRA TESTING LOGIC is not the empty string,
575dnl then it is run instead of simply setting CV to "yes" - it is responsible
576dnl for doing so, if appropriate.
577AC_DEFUN([gcc_GAS_CHECK_FEATURE],
e0b0fd74
L
578[AC_REQUIRE([gcc_GAS_FLAGS])dnl
579AC_CACHE_CHECK([assembler for $1], [$2],
67da1534
KC
580 [[$2]=no
581 ifelse([$3],,,[dnl
582 if test $in_tree_gas = yes; then
583 gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
584 el])if test x$gcc_cv_as != x; then
dddc6762 585 AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
e0b0fd74 586 if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
67da1534
KC
587 then
588 ifelse([$6],, [$2]=yes, [$6])
589 else
590 echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
591 cat conftest.s >&AS_MESSAGE_LOG_FD
592 fi
593 rm -f conftest.o conftest.s
594 fi])
595ifelse([$7],,,[dnl
596if test $[$2] = yes; then
597 $7
598fi])])
599
e992fc2e
RO
600dnl gcc_SUN_LD_VERSION
601dnl
602dnl Determines Sun linker version numbers, setting gcc_cv_sun_ld_vers to
603dnl the complete version number and gcc_cv_sun_ld_vers_{major, minor} to
604dnl the corresponding fields.
605dnl
606dnl ld and ld.so.1 are guaranteed to be updated in lockstep, so ld version
607dnl numbers can be used in ld.so.1 feature checks even if a different
608dnl linker is configured.
609dnl
610AC_DEFUN([gcc_SUN_LD_VERSION],
611[changequote(,)dnl
612if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
613 case "${target}" in
614 *-*-solaris2*)
615 #
616 # Solaris 2 ld -V output looks like this for a regular version:
617 #
618 # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699
619 #
620 # but test versions add stuff at the end:
621 #
622 # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10
623 #
624 gcc_cv_sun_ld_ver=`/usr/ccs/bin/ld -V 2>&1`
625 if echo "$gcc_cv_sun_ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
626 gcc_cv_sun_ld_vers=`echo $gcc_cv_sun_ld_ver | sed -n \
627 -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'`
628 gcc_cv_sun_ld_vers_major=`expr "$gcc_cv_sun_ld_vers" : '\([0-9]*\)'`
629 gcc_cv_sun_ld_vers_minor=`expr "$gcc_cv_sun_ld_vers" : '[0-9]*\.\([0-9]*\)'`
630 fi
631 ;;
632 esac
633fi
634changequote([,])dnl
635])
636
67da1534
KC
637dnl GCC_TARGET_TEMPLATE(KEY)
638dnl ------------------------
639dnl Define KEY as a valid configure key on the target machine.
640
641m4_define([GCC_TARGET_TEMPLATE],
642[m4_define([GCC_TARGET_TEMPLATE($1)],[])])
643
644dnl AH_TEMPLATE(KEY, DESCRIPTION)
645dnl -----------------------------
646dnl Issue an autoheader template for KEY, i.e., a comment composed of
647dnl DESCRIPTION (properly wrapped), and then #undef KEY. Redefinition
648dnl of the macro in autoheader.m4, to support definition of only a few
649dnl keys while compiling target libraries.
650
651m4_define([AH_TEMPLATE],
652[AH_VERBATIM([$1],m4_text_wrap([$2 */], [ ], [/* ])
653m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[#ifndef USED_FOR_TARGET
654])[#undef $1]m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[
655#endif
656]))])
657
67da1534
KC
658dnl Make sure that build_exeext is looked for
659AC_DEFUN([gcc_AC_BUILD_EXEEXT], [
660ac_executable_extensions="$build_exeext"])
661