OSDN Git Service

* configure.ac: Add ENABLE_ASSERT_CHECKING control.
[pf3gnuchains/gcc-fork.git] / gcc / configure.ac
1 # configure.ac for GCC
2 # Process this file with autoconf to generate a configuration script.
3
4 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
5 # Free Software Foundation, Inc.
6
7 #This file is part of GCC.
8
9 #GCC is free software; you can redistribute it and/or modify it under
10 #the terms of the GNU General Public License as published by the Free
11 #Software Foundation; either version 2, or (at your option) any later
12 #version.
13
14 #GCC is distributed in the hope that it will be useful, but WITHOUT
15 #ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 #FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 #for more details.
18
19 #You should have received a copy of the GNU General Public License
20 #along with GCC; see the file COPYING.  If not, write to the Free
21 #Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #02111-1307, USA.
23
24 # --------------------------------
25 # Initialization and sanity checks
26 # --------------------------------
27
28 AC_PREREQ(2.59)
29 AC_INIT
30 AC_CONFIG_SRCDIR(tree.c)
31 AC_CONFIG_HEADER(auto-host.h:config.in)
32
33 #Set to 1 on a release branch
34 is_release=
35
36 # Determine the host, build, and target systems
37 AC_CANONICAL_BUILD
38 AC_CANONICAL_HOST
39 AC_CANONICAL_TARGET
40
41 # Determine the noncanonical target name, for directory use.
42 ACX_NONCANONICAL_TARGET
43
44 # Determine the target- and build-specific subdirectories
45 GCC_TOPLEV_SUBDIRS
46
47 # Set program_transform_name
48 AC_ARG_PROGRAM
49
50 # Check for bogus environment variables.
51 # Test if LIBRARY_PATH contains the notation for the current directory
52 # since this would lead to problems installing/building glibc.
53 # LIBRARY_PATH contains the current directory if one of the following
54 # is true:
55 # - one of the terminals (":" and ";") is the first or last sign
56 # - two terminals occur directly after each other
57 # - the path contains an element with a dot in it
58 AC_MSG_CHECKING(LIBRARY_PATH variable)
59 changequote(,)dnl
60 case ${LIBRARY_PATH} in
61   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
62     library_path_setting="contains current directory"
63     ;;
64   *)
65     library_path_setting="ok"
66     ;;
67 esac
68 changequote([,])dnl
69 AC_MSG_RESULT($library_path_setting)
70 if test "$library_path_setting" != "ok"; then
71 AC_MSG_ERROR([
72 *** LIBRARY_PATH shouldn't contain the current directory when
73 *** building gcc. Please change the environment variable
74 *** and run configure again.])
75 fi
76
77 # Test if GCC_EXEC_PREFIX contains the notation for the current directory
78 # since this would lead to problems installing/building glibc.
79 # GCC_EXEC_PREFIX contains the current directory if one of the following
80 # is true:
81 # - one of the terminals (":" and ";") is the first or last sign
82 # - two terminals occur directly after each other
83 # - the path contains an element with a dot in it
84 AC_MSG_CHECKING(GCC_EXEC_PREFIX variable)
85 changequote(,)dnl
86 case ${GCC_EXEC_PREFIX} in
87   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
88     gcc_exec_prefix_setting="contains current directory"
89     ;;
90   *)
91     gcc_exec_prefix_setting="ok"
92     ;;
93 esac
94 changequote([,])dnl
95 AC_MSG_RESULT($gcc_exec_prefix_setting)
96 if test "$gcc_exec_prefix_setting" != "ok"; then
97 AC_MSG_ERROR([
98 *** GCC_EXEC_PREFIX shouldn't contain the current directory when
99 *** building gcc. Please change the environment variable
100 *** and run configure again.])
101 fi
102
103 # -----------
104 # Directories
105 # -----------
106
107 # Specify the local prefix
108 local_prefix=
109 AC_ARG_WITH(local-prefix,
110 [  --with-local-prefix=DIR specifies directory to put local include],
111 [case "${withval}" in
112 yes)    AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
113 no)     ;;
114 *)      local_prefix=$with_local_prefix ;;
115 esac])
116
117 # Default local prefix if it is empty
118 if test x$local_prefix = x; then
119         local_prefix=/usr/local
120 fi
121
122 # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only
123 # passed in by the toplevel make and thus we'd get different behavior
124 # depending on where we built the sources.
125 gcc_gxx_include_dir=
126 # Specify the g++ header file directory
127 AC_ARG_WITH(gxx-include-dir,
128 [  --with-gxx-include-dir=DIR
129                           specifies directory to put g++ header files],
130 [case "${withval}" in
131 yes)    AC_MSG_ERROR(bad value ${withval} given for g++ include directory) ;;
132 no)     ;;
133 *)      gcc_gxx_include_dir=$with_gxx_include_dir ;;
134 esac])
135
136 if test x${gcc_gxx_include_dir} = x; then
137   if test x${enable_version_specific_runtime_libs} = xyes; then
138     gcc_gxx_include_dir='${libsubdir}/include/c++'
139   else
140     topsrcdir=${srcdir}/.. . ${srcdir}/../config.if
141 changequote(<<, >>)dnl
142     gcc_gxx_include_dir="\$(libsubdir)/\$(unlibsubdir)/..\`echo \$(exec_prefix) | sed -e 's|^\$(prefix)||' -e 's|/[^/]*|/..|g'\`/include/"${libstdcxx_incdir}
143 changequote([, ])dnl
144   fi
145 fi
146
147 AC_ARG_WITH(cpp_install_dir,
148 [  --with-cpp-install-dir=DIR
149                           install the user visible C preprocessor in DIR
150                           (relative to PREFIX) as well as PREFIX/bin],
151 [if test x$withval = xyes; then
152   AC_MSG_ERROR([option --with-cpp-install-dir requires an argument])
153 elif test x$withval != xno; then
154   cpp_install_dir=$withval
155 fi])
156
157 # We would like to our source tree to be readonly.  However when releases or
158 # pre-releases are generated, the flex/bison generated files as well as the 
159 # various formats of manuals need to be included along with the rest of the
160 # sources.  Therefore we have --enable-generated-files-in-srcdir to do 
161 # just that.
162
163 AC_MSG_CHECKING([whether to place generated files in the source directory])
164   dnl generated-files-in-srcdir is disabled by default
165   AC_ARG_ENABLE(generated-files-in-srcdir, 
166 [  --enable-generated-files-in-srcdir
167                           put copies of generated files in source dir
168                           intended for creating source tarballs for users
169                           without texinfo bison or flex.],
170       generated_files_in_srcdir=$enableval,
171       generated_files_in_srcdir=no)
172
173 AC_MSG_RESULT($generated_files_in_srcdir)
174
175 if test "$generated_files_in_srcdir" = "yes"; then
176   GENINSRC=''
177 else
178   GENINSRC='#'
179 fi
180 AC_SUBST(GENINSRC)
181
182 # -------------------
183 # Find default linker
184 # -------------------
185
186 # With GNU ld
187 AC_ARG_WITH(gnu-ld,
188 [  --with-gnu-ld           arrange to work with GNU ld.],
189 gnu_ld_flag="$with_gnu_ld",
190 gnu_ld_flag=no)
191
192 # With pre-defined ld
193 AC_ARG_WITH(ld,
194 [  --with-ld               arrange to use the specified ld (full pathname)],
195 DEFAULT_LINKER="$with_ld")
196 if test x"${DEFAULT_LINKER+set}" = x"set"; then
197   if test ! -x "$DEFAULT_LINKER"; then
198     AC_MSG_ERROR([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
199   elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
200     gnu_ld_flag=yes
201   fi
202   AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
203         [Define to enable the use of a default linker.])
204 fi
205
206 AC_MSG_CHECKING([whether a default linker was specified])
207 if test x"${DEFAULT_LINKER+set}" = x"set"; then
208   if test x"$gnu_ld_flag" = x"no"; then
209     AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
210   else
211     AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
212   fi
213 else
214   AC_MSG_RESULT(no)
215 fi
216
217 # With demangler in GNU ld
218 AC_ARG_WITH(demangler-in-ld,
219 [  --with-demangler-in-ld  try to use demangler in GNU ld.],
220 demangler_in_ld="$with_demangler_in_ld",
221 demangler_in_ld=no)
222
223 # ----------------------
224 # Find default assembler
225 # ----------------------
226
227 # With GNU as
228 AC_ARG_WITH(gnu-as,
229 [  --with-gnu-as           arrange to work with GNU as],
230 gas_flag="$with_gnu_as",
231 gas_flag=no)
232
233 AC_ARG_WITH(as,
234 [  --with-as               arrange to use the specified as (full pathname)],
235 DEFAULT_ASSEMBLER="$with_as")
236 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
237   if test ! -x "$DEFAULT_ASSEMBLER"; then
238     AC_MSG_ERROR([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
239   elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
240     gas_flag=yes
241   fi
242   AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
243         [Define to enable the use of a default assembler.])
244 fi
245
246 AC_MSG_CHECKING([whether a default assembler was specified])
247 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
248   if test x"$gas_flag" = x"no"; then
249     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
250   else
251     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
252   fi
253 else
254   AC_MSG_RESULT(no)
255 fi
256
257 # ---------------
258 # Find C compiler
259 # ---------------
260
261 # If a non-executable a.out is present (e.g. created by GNU as above even if
262 # invoked with -v only), the IRIX 6 native ld just overwrites the existing
263 # file, even when creating an executable, so an execution test fails.
264 # Remove possible default executable files to avoid this.
265 #
266 # FIXME: This really belongs into AC_PROG_CC and can be removed once
267 # Autoconf includes it.
268 rm -f a.out a.exe b.out
269
270 # Find the native compiler
271 AC_PROG_CC
272 AC_PROG_CC_C_O
273 # autoconf is lame and doesn't give us any substitution variable for this.
274 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
275   NO_MINUS_C_MINUS_O=yes
276 else
277   OUTPUT_OPTION='-o $@'
278 fi
279 AC_SUBST(NO_MINUS_C_MINUS_O)
280 AC_SUBST(OUTPUT_OPTION)
281
282 # -------------------------
283 # Check C compiler features
284 # -------------------------
285
286 AC_PROG_CPP
287 AC_C_INLINE
288
289 gcc_AC_C_LONG_LONG
290
291 # sizeof(char) is 1 by definition.
292 AC_COMPILE_CHECK_SIZEOF(void *)
293 AC_COMPILE_CHECK_SIZEOF(short)
294 AC_COMPILE_CHECK_SIZEOF(int)
295 AC_COMPILE_CHECK_SIZEOF(long)
296 if test $ac_cv_c_long_long = yes; then
297   AC_COMPILE_CHECK_SIZEOF(long long)
298 fi
299 if test $ac_cv_c___int64 = yes; then
300   AC_COMPILE_CHECK_SIZEOF(__int64)
301 fi
302
303 # ---------------------
304 # Warnings and checking
305 # ---------------------
306
307 # Check $CC warning features (if it's GCC).
308 # We want to use -pedantic, but we don't want warnings about
309 # * 'long long'
310 # * variadic macros
311 # So, we only use -pedantic if we can disable those warnings.
312
313 AC_CACHE_CHECK(
314   [whether ${CC} accepts -Wno-long-long],
315   [ac_cv_prog_cc_w_no_long_long],
316   [save_CFLAGS="$CFLAGS"
317   CFLAGS="-Wno-long-long"
318   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
319                     [ac_cv_prog_cc_w_no_long_long=yes],
320                     [ac_cv_prog_cc_w_no_long_long=no])
321   CFLAGS="$save_CFLAGS"
322   ])
323
324 AC_CACHE_CHECK(
325   [whether ${CC} accepts -Wno-variadic-macros],
326   [ac_cv_prog_cc_w_no_variadic_macros],
327   [save_CFLAGS="$CFLAGS"
328   CFLAGS="-Wno-variadic-macros"
329   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
330                     [ac_cv_prog_cc_w_no_variadic_macros=yes],
331                     [ac_cv_prog_cc_w_no_variadic_macros=no])
332   CFLAGS="$save_CFLAGS"
333   ])
334
335 strict1_warn=
336 if test $ac_cv_prog_cc_w_no_long_long = yes \
337    && test $ac_cv_prog_cc_w_no_variadic_macros = yes ; then
338   strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros"
339 fi
340 AC_SUBST(strict1_warn)
341
342 # Add -Wold-style-definition if it's accepted
343 AC_CACHE_CHECK(
344   [whether ${CC} accepts -Wold-style-definition],
345   [ac_cv_prog_cc_w_old_style_definition],
346   [save_CFLAGS="$CFLAGS"
347   CFLAGS="-Wold-style-definition"
348   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
349                     [ac_cv_prog_cc_w_old_style_definition=yes],
350                     [ac_cv_prog_cc_w_old_style_definition=no])
351   CFLAGS="$save_CFLAGS"
352   ])
353 if test $ac_cv_prog_cc_w_old_style_definition = yes ; then
354   strict1_warn="${strict1_warn} -Wold-style-definition"
355 fi
356
357 # Enable -Werror, period.
358 AC_ARG_ENABLE(werror_always, 
359 [  --enable-werror-always         enable -Werror always], [],
360 [enable_werror_always=no])
361 if test x${enable_werror_always} = xyes ; then
362   strict1_warn="${strict1_warn} -Werror"
363   WERROR=-Werror
364 fi
365
366 # If the native compiler is GCC, we can enable warnings even in stage1.  
367 # That's useful for people building cross-compilers, or just running a
368 # quick `make'.
369 warn_cflags=
370 if test "x$GCC" = "xyes"; then
371   warn_cflags='$(GCC_WARN_CFLAGS)'
372 fi
373 AC_SUBST(warn_cflags)
374
375 # Enable -Werror in bootstrap stage2 and later.
376 AC_ARG_ENABLE(werror, 
377 [  --enable-werror         enable -Werror in bootstrap stage2 and later], [],
378 [if test x$is_release = x ; then
379   # Default to "yes" on development branches.
380   enable_werror=yes
381 else
382   # Default to "no" on release branches.
383   enable_werror=no
384 fi])
385 if test x$enable_werror = xyes ; then
386   WERROR=-Werror
387 fi
388 AC_SUBST(WERROR)
389
390 # Enable expensive internal checks
391 AC_ARG_ENABLE(checking,
392 [  --enable-checking[=LIST]
393                           enable expensive run-time checks.  With LIST,
394                           enable only specific categories of checks.
395                           Categories are: none,assert,fold,gc,gcac,misc,
396                           rtlflag,rtl,tree,valgrind;
397                           default is assert,gc,misc,rtlflag,tree],
398 [ac_checking=
399 ac_tree_checking=
400 ac_rtl_checking=
401 ac_rtlflag_checking=
402 ac_gc_checking=
403 ac_gc_always_collect=
404 ac_fold_checking=
405 ac_assert_checking=
406 case "${enableval}" in
407 yes)    ac_checking=1 ; ac_tree_checking=1 ; ac_gc_checking=1 ;
408         ac_rtlflag_checking=1 ; ac_assert_checking=1 ;;
409 no)     ;;
410 *)      IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
411         set fnord $enableval; shift
412         IFS="$ac_save_IFS"
413         ac_assert_checking=1
414         for check
415         do
416                 case $check in
417                 assert) ac_assert_checking=1 ;;
418                 fold)   ac_fold_checking=1 ;;
419                 gc)     ac_gc_checking=1 ;;
420                 gcac)   ac_gc_always_collect=1 ;;
421                 misc)   ac_checking=1 ;;
422                 rtlflag)        ac_rtlflag_checking=1 ;;
423                 rtl)    ac_rtl_checking=1 ;;
424                 tree)   ac_tree_checking=1 ;;
425                 valgrind)       ac_checking_valgrind=1 ;;
426                 *)      AC_MSG_ERROR(unknown check category $check) ;;
427                 esac
428         done
429         ;;
430 esac
431 ], [
432 # Determine the default checks.
433 if test x$is_release = x ; then
434   # Enable some checks for development versions of GCC
435   ac_assert_checking=1;
436   ac_checking=1; ac_tree_checking=1; ac_gc_checking=1; ac_rtlflag_checking=1;
437 else
438   # Disable all but assertions for release versions of GCC.
439   ac_assert_checking=1;
440 fi])
441 nocommon_flag=""
442 if test x$ac_checking != x ; then
443   AC_DEFINE(ENABLE_CHECKING, 1,
444 [Define if you want more run-time sanity checks.  This one gets a grab
445    bag of miscellaneous but relatively cheap checks.])
446   nocommon_flag=-fno-common
447 fi
448 AC_SUBST(nocommon_flag)
449 if test x$ac_assert_checking != x ; then
450   AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
451 [Define if you want assertions enabled.  This is a cheap check.])
452 fi
453 if test x$ac_tree_checking != x ; then
454   AC_DEFINE(ENABLE_TREE_CHECKING, 1,
455 [Define if you want all operations on trees (the basic data
456    structure of the front ends) to be checked for dynamic type safety
457    at runtime.  This is moderately expensive.  The tree browser debugging
458    routines will also be enabled by this option.
459    ])
460   TREEBROWSER=tree-browser.o
461 fi
462 AC_SUBST(TREEBROWSER)
463 if test x$ac_rtl_checking != x ; then
464   AC_DEFINE(ENABLE_RTL_CHECKING, 1,
465 [Define if you want all operations on RTL (the basic data structure
466    of the optimizer and back end) to be checked for dynamic type safety
467    at runtime.  This is quite expensive.])
468 fi
469 if test x$ac_rtlflag_checking != x ; then
470   AC_DEFINE(ENABLE_RTL_FLAG_CHECKING, 1,
471 [Define if you want RTL flag accesses to be checked against the RTL
472    codes that are supported for each access macro.  This is relatively
473    cheap.])
474 fi
475 if test x$ac_gc_checking != x ; then
476   AC_DEFINE(ENABLE_GC_CHECKING, 1,
477 [Define if you want the garbage collector to do object poisoning and
478    other memory allocation checks.  This is quite expensive.])
479 fi
480 if test x$ac_gc_always_collect != x ; then
481   AC_DEFINE(ENABLE_GC_ALWAYS_COLLECT, 1,
482 [Define if you want the garbage collector to operate in maximally
483    paranoid mode, validating the entire heap and collecting garbage at
484    every opportunity.  This is extremely expensive.])
485 fi
486 if test x$ac_fold_checking != x ; then
487   AC_DEFINE(ENABLE_FOLD_CHECKING, 1,
488 [Define if you want fold checked that it never destructs its argument.
489    This is quite expensive.])
490 fi
491 valgrind_path_defines=
492 valgrind_command=
493
494 dnl # This check AC_REQUIREs various stuff, so it *must not* be inside
495 dnl # an if statement.  This was the source of very frustrating bugs
496 dnl # in converting to autoconf 2.5x!
497 AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
498
499 if test x$ac_checking_valgrind != x ; then
500   # It is certainly possible that there's valgrind but no valgrind.h.
501   # GCC relies on making annotations so we must have both.
502   AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
503   AC_TRY_CPP(
504     [#include <valgrind/memcheck.h>
505 #ifndef VALGRIND_DISCARD
506 #error VALGRIND_DISCARD not defined
507 #endif],
508   [gcc_cv_header_valgrind_memcheck_h=yes],
509   [gcc_cv_header_valgrind_memcheck_h=no])
510   AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
511   AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
512   AC_TRY_CPP(
513     [#include <memcheck.h>
514 #ifndef VALGRIND_DISCARD
515 #error VALGRIND_DISCARD not defined
516 #endif],
517   [gcc_cv_header_memcheck_h=yes], 
518   gcc_cv_header_memcheck_h=no)
519   AC_MSG_RESULT($gcc_cv_header_memcheck_h)
520   AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
521         [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
522   if test "x$valgrind_path" = "x" \
523     || (test $have_valgrind_h = no \
524         && test $gcc_cv_header_memcheck_h = no \
525         && test $gcc_cv_header_valgrind_memcheck_h = no); then
526         AC_MSG_ERROR([*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h])
527   fi
528   valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
529   valgrind_command="$valgrind_path -q"
530   AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
531 [Define if you want to run subprograms and generated programs
532    through valgrind (a memory checker).  This is extremely expensive.])
533   if test $gcc_cv_header_valgrind_memcheck_h = yes; then
534     AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
535         [Define if valgrind's valgrind/memcheck.h header is installed.])
536   fi
537   if test $gcc_cv_header_memcheck_h = yes; then
538     AC_DEFINE(HAVE_MEMCHECK_H, 1,
539         [Define if valgrind's memcheck.h header is installed.])
540   fi
541 fi
542 AC_SUBST(valgrind_path_defines)
543 AC_SUBST(valgrind_command)
544
545 AC_ARG_ENABLE(mapped-location,
546 [  --enable-mapped-location   location_t is fileline integer cookie],,
547 enable_mapped_location=no)
548
549 if test "$enable_mapped_location" = yes ; then
550   AC_DEFINE(USE_MAPPED_LOCATION, 1,
551 [Define if location_t is fileline integer cookie.])
552 fi
553
554 # Enable code coverage collection
555 AC_ARG_ENABLE(coverage,
556 [  --enable-coverage[=LEVEL]
557                           enable compiler's code coverage collection.
558                           Use to measure compiler performance and locate
559                           unused parts of the compiler. With LEVEL, specify
560                           optimization. Values are opt, noopt,
561                           default is noopt],
562 [case "${enableval}" in
563   yes|noopt)
564     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O0"
565     ;;
566   opt)
567     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O2"
568     ;;
569   no)
570     # a.k.a. --disable-coverage
571     coverage_flags=""
572     ;;
573   *)
574     AC_MSG_ERROR(unknown coverage setting $enableval)
575     ;;
576 esac],
577 [coverage_flags=""])
578 AC_SUBST(coverage_flags)
579
580 AC_ARG_ENABLE(gather-detailed-mem-stats, 
581 [  --enable-gather-detailed-mem-stats         enable detailed memory allocation stats gathering], [],
582 [enable_gather_detailed_mem_stats=no])
583 if test x$enable_gather_detailed_mem_stats = xyes ; then
584   AC_DEFINE(GATHER_STATISTICS, 1,
585         [Define to enable detailed memory allocation stats gathering.])
586 fi
587
588 # -------------------------------
589 # Miscenalleous configure options
590 # -------------------------------
591
592 # With stabs
593 AC_ARG_WITH(stabs,
594 [  --with-stabs            arrange to use stabs instead of host debug format],
595 stabs="$with_stabs",
596 stabs=no)
597
598 # Determine whether or not multilibs are enabled.
599 AC_ARG_ENABLE(multilib,
600 [  --enable-multilib       enable library support for multiple ABIs],
601 [], [enable_multilib=yes])
602 AC_SUBST(enable_multilib)
603
604 # Enable __cxa_atexit for C++.
605 AC_ARG_ENABLE(__cxa_atexit,
606 [  --enable-__cxa_atexit   enable __cxa_atexit for C++],
607 [], [])
608
609 # Enable threads
610 # Pass with no value to take the default
611 # Pass with a value to specify a thread package
612 AC_ARG_ENABLE(threads,
613 [  --enable-threads        enable thread usage for target GCC
614   --enable-threads=LIB    use LIB thread package for target GCC],,
615 [enable_threads=''])
616
617 AC_ARG_ENABLE(objc-gc,
618 [  --enable-objc-gc       enable the use of Boehm's garbage collector with
619                           the GNU Objective-C runtime],
620 if test x$enable_objc_gc = xno; then
621         objc_boehm_gc=''
622 else
623         objc_boehm_gc=1
624 fi,
625 objc_boehm_gc='')
626
627 AC_ARG_WITH(dwarf2,
628 [  --with-dwarf2           force the default debug format to be DWARF 2],
629 dwarf2="$with_dwarf2",
630 dwarf2=no)
631
632 AC_ARG_ENABLE(shared,
633 [  --disable-shared        don't provide a shared libgcc],
634 [
635   case $enable_shared in
636   yes | no) ;;
637   *)
638     enable_shared=no
639     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
640     for pkg in $enableval; do
641       if test "X$pkg" = "Xgcc" || test "X$pkg" = "Xlibgcc"; then
642         enable_shared=yes
643       fi
644     done
645     IFS="$ac_save_ifs"
646     ;;
647   esac
648 ], [enable_shared=yes])
649 AC_SUBST(enable_shared)
650
651 AC_ARG_WITH(sysroot,
652 [  --with-sysroot[=DIR] Search for usr/lib, usr/include, et al, within DIR.],
653 [
654  case ${with_sysroot} in
655  yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
656  *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
657  esac
658    
659  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
660  CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)'
661
662  if test "x$exec_prefix" = xNONE; then
663   if test "x$prefix" = xNONE; then
664    test_prefix=/usr/local
665   else
666    test_prefix=$prefix
667   fi
668  else
669   test_prefix=$exec_prefix
670  fi
671  case ${TARGET_SYSTEM_ROOT} in
672  "${test_prefix}"|"${test_prefix}/"*|\
673  '${exec_prefix}'|'${exec_prefix}/'*)
674    t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
675    TARGET_SYSTEM_ROOT_DEFINE="$t"
676    ;;
677  esac
678 ], [
679  TARGET_SYSTEM_ROOT=
680  TARGET_SYSTEM_ROOT_DEFINE=
681  CROSS_SYSTEM_HEADER_DIR='$(gcc_tooldir)/sys-include'
682 ])
683 AC_SUBST(TARGET_SYSTEM_ROOT)
684 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
685 AC_SUBST(CROSS_SYSTEM_HEADER_DIR)
686
687 # Build with intermodule optimisations
688 AC_ARG_ENABLE(intermodule,
689 [  --enable-intermodule    build the compiler in one step],
690 [case ${enable_intermodule} in
691   yes) onestep="-onestep";;
692   *) onestep="";;
693 esac],
694 [onestep=""])
695 AC_SUBST(onestep)
696
697 # Sanity check enable_languages in case someone does not run the toplevel
698 # configure # script.
699 AC_ARG_ENABLE(languages,
700 [  --enable-languages=LIST specify which front-ends to build],
701 [case ,${enable_languages}, in
702        ,,|,yes,)
703                 # go safe -- we cannot be much sure without the toplevel
704                 # configure's
705                 # analysis of which target libs are present and usable
706                 enable_languages=c
707                 ;;
708          *,all,*)
709                 AC_MSG_ERROR([only the toplevel supports --enable-languages=all])
710                 ;;
711         *,c,*)
712                 ;;
713         *)
714                 enable_languages=c,${enable_languages}
715                 ;;
716 esac],
717 [enable_languages=c])
718
719 subdirs=
720 for lang in ${srcdir}/*/config-lang.in
721 do
722         case $lang in
723         # The odd quoting in the next line works around
724         # an apparent bug in bash 1.12 on linux.
725 changequote(,)dnl
726         ${srcdir}/[*]/config-lang.in) ;;
727         *)
728           lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^   ]*\).*$,\1,p' $lang`
729           if test "x$lang_alias" = x
730           then
731                 echo "$lang doesn't set \$language." 1>&2
732                 exit 1
733           fi
734           case ",$enable_languages," in
735           *,$lang_alias,*)
736             subdirs="$subdirs `echo $lang | sed -e 's,^.*/\([^/]*\)/config-lang.in$,\1,'`" ;;
737           esac
738           ;;
739 changequote([,])dnl
740         esac
741 done
742
743
744 # -------------------------
745 # Checks for other programs
746 # -------------------------
747
748 AC_PROG_MAKE_SET
749
750 # Find some useful tools
751 AC_PROG_AWK
752 # We need awk to create options.c and options.h.
753 # Bail out if it's missing.
754 case ${AWK} in
755   "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
756 esac
757
758 gcc_AC_PROG_LN_S
759 ACX_PROG_LN($LN_S)
760 AC_PROG_RANLIB
761 case "${host}" in
762 *-*-darwin*)
763   # By default, the Darwin ranlib will not treat common symbols as
764   # definitions when  building the archive table of contents.  Other 
765   # ranlibs do that; pass an option to the Darwin ranlib that makes
766   # it behave similarly.
767   ranlib_flags="-c" 
768   ;;
769 *)
770   ranlib_flags=""
771 esac
772 AC_SUBST(ranlib_flags)
773      
774 gcc_AC_PROG_INSTALL
775
776 # See if cmp has --ignore-initial.
777 gcc_AC_PROG_CMP_IGNORE_INITIAL
778
779 # See if we have the mktemp command.
780 AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
781
782 MISSING="${CONFIG_SHELL-/bin/sh} $srcdir/../missing"
783
784 # See if makeinfo has been installed and is modern enough
785 # that we can use it.
786 gcc_AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
787   [GNU texinfo.* \([0-9][0-9.]*\)],
788   [4.[2-9]*])
789 if test $gcc_cv_prog_makeinfo_modern = no; then
790   MAKEINFO="$MISSING makeinfo"
791   AC_MSG_WARN([
792 *** Makeinfo is missing or too old.
793 *** Info documentation will not be built.])
794   BUILD_INFO=
795 else
796   BUILD_INFO=info
797 fi
798 AC_SUBST(BUILD_INFO)
799
800 # Is pod2man recent enough to regenerate manpages?
801 AC_MSG_CHECKING([for recent Pod::Man])
802 if (perl -e 'use 1.10 Pod::Man') >/dev/null 2>&1; then
803   AC_MSG_RESULT(yes)
804   GENERATED_MANPAGES=generated-manpages
805 else
806   AC_MSG_RESULT(no)
807   GENERATED_MANPAGES=
808 fi
809 AC_SUBST(GENERATED_MANPAGES)
810
811 # How about lex?
812 dnl Don't use AC_PROG_LEX; we insist on flex.
813 dnl LEXLIB is not useful in gcc.
814 AC_CHECK_PROGS([FLEX], flex, [$MISSING flex])
815
816 # Bison?
817 AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
818
819 # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
820 # check for build == host before using them.
821
822 # NM
823 if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \
824   && test -d ../binutils ; then
825   NM='$(objdir)/../binutils/nm-new'
826 else
827   AC_CHECK_PROG(NM, nm, nm, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing nm)
828 fi
829
830 # AR
831 if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \
832   && test -d ../binutils ; then
833   AR='$(objdir)/../binutils/ar'
834 else
835   AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar)
836 fi
837
838
839 # --------------------
840 # Checks for C headers
841 # --------------------
842
843 AC_MSG_CHECKING(for GNU C library)
844 AC_CACHE_VAL(gcc_cv_glibc,
845 [AC_TRY_COMPILE(
846   [#include <features.h>],[
847 #if ! (defined __GLIBC__ || defined __GNU_LIBRARY__)
848 #error Not a GNU C library system
849 #endif], 
850   [gcc_cv_glibc=yes], 
851   gcc_cv_glibc=no)])
852 AC_MSG_RESULT($gcc_cv_glibc)
853 if test $gcc_cv_glibc = yes; then
854   AC_DEFINE(_GNU_SOURCE, 1, [Always define this when using the GNU C Library])
855 fi
856
857 # Need to reject headers which give warnings, so that the -Werror bootstrap
858 # works later. *sigh*  This needs to come before all header checks.
859 AC_PROG_CPP_WERROR
860
861 AC_HEADER_STDC
862 AC_HEADER_TIME
863 ACX_HEADER_STRING
864 AC_HEADER_SYS_WAIT
865 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
866                  fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
867                  sys/resource.h sys/param.h sys/times.h sys/stat.h \
868                  direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
869
870 # Check for thread headers.
871 AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
872 AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
873
874 # These tests can't be done till we know if we have limits.h.
875 gcc_AC_C_CHAR_BIT
876 AC_C_BIGENDIAN_CROSS
877
878 # --------
879 # UNSORTED
880 # --------
881
882 # Stage specific cflags for build.
883 stage1_cflags=
884 case $build in
885 vax-*-*)
886   if test x$GCC = xyes
887   then
888     stage1_cflags="-Wa,-J"
889   else
890     stage1_cflags="-J"
891   fi
892   ;;
893 powerpc-*-darwin*)
894   # The spiffy cpp-precomp chokes on some legitimate constructs in GCC
895   # sources; use -no-cpp-precomp to get to GNU cpp.
896   # Apple's GCC has bugs in designated initializer handling, so disable
897   # that too.
898   stage1_cflags="-no-cpp-precomp -DHAVE_DESIGNATED_INITIALIZERS=0"
899   ;;
900 esac
901 AC_SUBST(stage1_cflags)
902
903 # These libraries may be used by collect2.
904 # We may need a special search path to get them linked.
905 AC_CACHE_CHECK(for collect2 libraries, gcc_cv_collect2_libs,
906 [save_LIBS="$LIBS"
907 for libs in '' -lld -lmld \
908                 '-L/usr/lib/cmplrs/cc2.11 -lmld' \
909                 '-L/usr/lib/cmplrs/cc3.11 -lmld'
910 do
911         LIBS="$libs"
912         AC_TRY_LINK_FUNC(ldopen,
913                 [gcc_cv_collect2_libs="$libs"; break])
914 done
915 LIBS="$save_LIBS"
916 test -z "$gcc_cv_collect2_libs" && gcc_cv_collect2_libs='none required'])
917 case $gcc_cv_collect2_libs in
918         "none required")        ;;
919         *)      COLLECT2_LIBS=$gcc_cv_collect2_libs ;;
920 esac
921 AC_SUBST(COLLECT2_LIBS)
922
923 # When building Ada code on Alpha, we need exc_resume which is usually in
924 # -lexc.  So test for it.
925 save_LIBS="$LIBS"
926 LIBS=
927 AC_SEARCH_LIBS(exc_resume, exc)
928 GNAT_LIBEXC="$LIBS"
929 LIBS="$save_LIBS"
930 AC_SUBST(GNAT_LIBEXC)
931
932 # Some systems put ldexp and frexp in libm instead of libc; assume
933 # they're both in the same place.  jcf-dump needs them.
934 save_LIBS="$LIBS"
935 LIBS=
936 AC_SEARCH_LIBS(ldexp, m)
937 LDEXP_LIB="$LIBS"
938 LIBS="$save_LIBS"
939 AC_SUBST(LDEXP_LIB)
940
941 # Use <inttypes.h> only if it exists,
942 # doesn't clash with <sys/types.h>, and declares intmax_t.
943 AC_MSG_CHECKING(for inttypes.h)
944 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
945 [AC_TRY_COMPILE(
946   [#include <sys/types.h>
947 #include <inttypes.h>],
948   [intmax_t i = -1;],
949   [gcc_cv_header_inttypes_h=yes],
950   gcc_cv_header_inttypes_h=no)])
951 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
952 if test $gcc_cv_header_inttypes_h = yes; then
953   AC_DEFINE(HAVE_INTTYPES_H, 1,
954         [Define if you have a working <inttypes.h> header file.])
955 fi
956
957 dnl Disabled until we have a complete test for buggy enum bitfields.
958 dnl gcc_AC_C_ENUM_BF_UNSIGNED
959
960 AC_CHECK_FUNCS(times clock dup2 kill getrlimit setrlimit atoll atoq \
961         sysconf strsignal putc_unlocked fputc_unlocked fputs_unlocked \
962         fwrite_unlocked fprintf_unlocked getrusage nl_langinfo \
963         scandir alphasort gettimeofday mbstowcs wcswidth mmap mincore \
964         setlocale)
965
966 if test x$ac_cv_func_mbstowcs = xyes; then
967   AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
968 [    AC_TRY_RUN([#include <stdlib.h>
969 int main()
970 {
971   mbstowcs(0, "", 0);
972   return 0;
973 }],
974     gcc_cv_func_mbstowcs_works=yes,
975     gcc_cv_func_mbstowcs_works=no,
976     gcc_cv_func_mbstowcs_works=yes)])
977   if test x$gcc_cv_func_mbstowcs_works = xyes; then
978     AC_DEFINE(HAVE_WORKING_MBSTOWCS, 1,
979   [Define this macro if mbstowcs does not crash when its
980    first argument is NULL.])
981   fi
982 fi
983
984 AC_CHECK_TYPE(ssize_t, int)
985
986 # Try to determine the array type of the second argument of getgroups
987 # for the target system (int or gid_t).
988 AC_TYPE_GETGROUPS
989 if test "${target}" = "${build}"; then
990   TARGET_GETGROUPS_T=$ac_cv_type_getgroups
991 else
992   case "${target}" in
993         # This condition may need some tweaking.  It should include all
994         # targets where the array type of the second argument of getgroups
995         # is int and the type of gid_t is not equivalent to int.
996         *-*-sunos* | *-*-ultrix*)
997                 TARGET_GETGROUPS_T=int
998                 ;;
999         *)
1000                 TARGET_GETGROUPS_T=gid_t
1001                 ;;
1002   esac
1003 fi
1004 AC_SUBST(TARGET_GETGROUPS_T)
1005
1006 gcc_AC_FUNC_PRINTF_PTR
1007 gcc_AC_FUNC_MMAP_BLACKLIST
1008
1009 case "${host}" in
1010 *-*-*vms*)
1011   # Under VMS, vfork works very differently than on Unix. The standard test 
1012   # won't work, and it isn't easily adaptable. It makes more sense to
1013   # just force it.
1014   ac_cv_func_vfork_works=yes
1015   ;;
1016 esac
1017 AC_FUNC_VFORK
1018
1019 AM_ICONV
1020 # Until we have in-tree GNU iconv:
1021 LIBICONV_DEP=
1022 AC_SUBST(LIBICONV_DEP)
1023
1024 AM_LC_MESSAGES
1025
1026 # We will need to find libiberty.h and ansidecl.h
1027 saved_CFLAGS="$CFLAGS"
1028 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
1029 gcc_AC_CHECK_DECLS(getenv atol sbrk abort atof getcwd getwd \
1030         strsignal putc_unlocked fputs_unlocked fwrite_unlocked \
1031         fprintf_unlocked strstr errno snprintf vasprintf \
1032         malloc realloc calloc free basename getopt clock getpagesize, , ,[
1033 #include "ansidecl.h"
1034 #include "system.h"])
1035
1036 gcc_AC_CHECK_DECLS(getrlimit setrlimit getrusage, , ,[
1037 #include "ansidecl.h"
1038 #include "system.h"
1039 #ifdef HAVE_SYS_RESOURCE_H
1040 #include <sys/resource.h>
1041 #endif
1042 ])
1043
1044 AC_TRY_COMPILE([
1045 #include "ansidecl.h"
1046 #include "system.h"
1047 #ifdef HAVE_SYS_RESOURCE_H
1048 #include <sys/resource.h>
1049 #endif
1050 ],[rlim_t l = 0;],,[AC_DEFINE([rlim_t],[long],
1051 [Define to \`long' if <sys/resource.h> doesn't define.])])
1052
1053 gcc_AC_CHECK_DECLS(ldgetname, , ,[
1054 #include "ansidecl.h"
1055 #include "system.h"
1056 #ifdef HAVE_LDFCN_H
1057 #include <ldfcn.h>
1058 #endif
1059 ])
1060
1061 gcc_AC_CHECK_DECLS(times, , ,[
1062 #include "ansidecl.h"
1063 #include "system.h"
1064 #ifdef HAVE_SYS_TIMES_H
1065 #include <sys/times.h>
1066 #endif
1067 ])
1068
1069 # More time-related stuff.
1070 AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [
1071 AC_TRY_COMPILE([
1072 #include "ansidecl.h"
1073 #include "system.h"
1074 #ifdef HAVE_SYS_TIMES_H
1075 #include <sys/times.h>
1076 #endif
1077 ], [struct tms tms;], ac_cv_struct_tms=yes, ac_cv_struct_tms=no)])
1078 if test $ac_cv_struct_tms = yes; then
1079   AC_DEFINE(HAVE_STRUCT_TMS, 1,
1080   [Define if <sys/times.h> defines struct tms.])
1081 fi
1082
1083 # use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
1084 # revisit after autoconf 2.50.
1085 AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
1086 AC_TRY_COMPILE([
1087 #include "ansidecl.h"
1088 #include "system.h"
1089 ], [clock_t x;], gcc_cv_type_clock_t=yes, gcc_cv_type_clock_t=no)])
1090 if test $gcc_cv_type_clock_t = yes; then
1091   AC_DEFINE(HAVE_CLOCK_T, 1,
1092   [Define if <time.h> defines clock_t.])
1093 fi
1094
1095 # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
1096 CFLAGS="$saved_CFLAGS"
1097
1098 gcc_AC_INITFINI_ARRAY
1099
1100 # mkdir takes a single argument on some systems. 
1101 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
1102
1103 # File extensions
1104 manext='.1'
1105 objext='.o'
1106 AC_SUBST(manext)
1107 AC_SUBST(objext)
1108
1109 # With Setjmp/Longjmp based exception handling.
1110 AC_ARG_ENABLE(sjlj-exceptions,
1111 [  --enable-sjlj-exceptions
1112                           arrange to use setjmp/longjmp exception handling],
1113 [sjlj=`if test $enableval = yes; then echo 1; else echo 0; fi`
1114 AC_DEFINE_UNQUOTED(CONFIG_SJLJ_EXCEPTIONS, $sjlj,
1115   [Define 0/1 to force the choice for exception handling model.])])
1116
1117 if test x$host = x$target; then
1118    AC_CHECK_LIB(unwind, main, use_libunwind_default=yes, use_libunwind_default=no)
1119 else
1120    use_libunwind_default=no
1121 fi
1122 # Use libunwind based exception handling.
1123 AC_ARG_ENABLE(libunwind-exceptions,
1124 [  --enable-libunwind-exceptions  force use libunwind for exceptions],
1125 use_libunwind_exceptions=$enableval,
1126 use_libunwind_exceptions=$use_libunwind_default)
1127 if test x"$use_libunwind_exceptions" = xyes; then
1128    AC_DEFINE(USE_LIBUNWIND_EXCEPTIONS, 1,
1129         [Define if gcc should use -lunwind.])
1130 fi
1131
1132 # --------------------------------------------------------
1133 # Build, host, and target specific configuration fragments
1134 # --------------------------------------------------------
1135
1136 # Collect build-machine-specific information.
1137 . ${srcdir}/config.build
1138
1139 # Collect host-machine-specific information.
1140 . ${srcdir}/config.host
1141
1142 target_gtfiles=
1143
1144 # Collect target-machine-specific information.
1145 . ${srcdir}/config.gcc
1146
1147 extra_objs="${host_extra_objs} ${extra_objs}"
1148 extra_gcc_objs="${host_extra_gcc_objs} ${extra_gcc_objs}"
1149
1150 # Default the target-machine variables that were not explicitly set.
1151 if test x"$tm_file" = x
1152 then tm_file=$cpu_type/$cpu_type.h; fi
1153
1154 if test x"$extra_headers" = x
1155 then extra_headers=; fi
1156
1157 if test x$md_file = x
1158 then md_file=$cpu_type/$cpu_type.md; fi
1159
1160 if test x$out_file = x
1161 then out_file=$cpu_type/$cpu_type.c; fi
1162
1163 if test x"$tmake_file" = x
1164 then tmake_file=$cpu_type/t-$cpu_type
1165 fi
1166
1167 if test x"$dwarf2" = xyes
1168 then tm_file="$tm_file tm-dwarf2.h"
1169 fi
1170
1171 # Say what files are being used for the output code and MD file.
1172 echo "Using \`$srcdir/config/$out_file' for machine-specific logic."
1173 echo "Using \`$srcdir/config/$md_file' as machine description file."
1174
1175 # If any of the xm_file variables contain nonexistent files, warn
1176 # about them and drop them.
1177
1178 bx=
1179 for x in $build_xm_file; do
1180   if    test -f $srcdir/config/$x
1181   then      bx="$bx $x"
1182   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1183   fi
1184 done
1185 build_xm_file="$bx"
1186
1187 hx=
1188 for x in $host_xm_file; do
1189   if    test -f $srcdir/config/$x
1190   then      hx="$hx $x"
1191   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1192   fi
1193 done
1194 host_xm_file="$hx"
1195
1196 tx=
1197 for x in $xm_file; do
1198   if    test -f $srcdir/config/$x
1199   then      tx="$tx $x"
1200   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1201   fi
1202 done
1203 xm_file="$tx"
1204
1205 count=a
1206 for f in $tm_file; do
1207         count=${count}x
1208 done
1209 if test $count = ax; then
1210         echo "Using \`$srcdir/config/$tm_file' as target machine macro file."
1211 else
1212         echo "Using the following target machine macro files:"
1213         for f in $tm_file; do
1214                 echo "  $srcdir/config/$f"
1215         done
1216 fi
1217
1218 if test x$need_64bit_hwint = xyes; then
1219         AC_DEFINE(NEED_64BIT_HOST_WIDE_INT, 1,
1220 [Define to 1 if HOST_WIDE_INT must be 64 bits wide (see hwint.h).])
1221 fi
1222
1223 count=a
1224 for f in $host_xm_file; do
1225         count=${count}x
1226 done
1227 if test $count = a; then
1228         :
1229 elif test $count = ax; then
1230         echo "Using \`$srcdir/config/$host_xm_file' as host machine macro file."
1231 else
1232         echo "Using the following host machine macro files:"
1233         for f in $host_xm_file; do
1234                 echo "  $srcdir/config/$f"
1235         done
1236 fi
1237 echo "Using ${out_host_hook_obj} for host machine hooks."
1238
1239 if test "$host_xm_file" != "$build_xm_file"; then
1240         count=a
1241         for f in $build_xm_file; do
1242                 count=${count}x
1243         done
1244         if test $count = a; then
1245                 :
1246         elif test $count = ax; then
1247                 echo "Using \`$srcdir/config/$build_xm_file' as build machine macro file."
1248         else
1249                 echo "Using the following build machine macro files:"
1250                 for f in $build_xm_file; do
1251                         echo "  $srcdir/config/$f"
1252                 done
1253         fi
1254 fi
1255
1256 # ---------
1257 # Threading
1258 # ---------
1259
1260 # Check if a valid thread package
1261 case ${enable_threads} in
1262   "" | no)
1263     # No threads
1264     target_thread_file='single'
1265     ;;
1266   yes)
1267     # default
1268     target_thread_file='single'
1269     ;;
1270   aix | dce | gnat | irix | posix | rtems | \
1271   single | solaris | vxworks | win32 )
1272     target_thread_file=${enable_threads}
1273     ;;
1274   *)
1275     echo "${enable_threads} is an unknown thread package" 1>&2
1276     exit 1
1277     ;;
1278 esac
1279
1280 if test x${thread_file} = x; then
1281   # No thread file set by target-specific clauses in config.gcc,
1282   # so use file chosen by default logic above
1283   thread_file=${target_thread_file}
1284 fi
1285
1286 # Make gthr-default.h if we have a thread file.
1287 gthread_flags=
1288 if test $thread_file != single; then
1289   rm -f gthr-default.h
1290   echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h
1291   gthread_flags=-DHAVE_GTHR_DEFAULT
1292 fi
1293 AC_SUBST(gthread_flags)
1294
1295 # --------
1296 # UNSORTED
1297 # --------
1298
1299 if test x$enable___cxa_atexit = xyes || \
1300    test x$enable___cxa_atexit = x -a x$default_use_cxa_atexit = xyes; then
1301    AC_CHECK_FUNC(__cxa_atexit,
1302         [AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 1,
1303         [Define if you want to use __cxa_atexit, rather than atexit, to
1304         register C++ destructors for local statics and global objects.
1305         This is essential for fully standards-compliant handling of
1306         destructors, but requires __cxa_atexit in libc.])],
1307         echo "__cxa_atexit can't be enabled on this target")
1308 fi
1309
1310 # Look for a file containing extra machine modes.
1311 if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
1312   extra_modes_file='$(srcdir)'/config/${extra_modes}
1313   AC_SUBST(extra_modes_file)
1314   AC_DEFINE_UNQUOTED(EXTRA_MODES_FILE, "config/$extra_modes",
1315   [Define to the name of a file containing a list of extra machine modes
1316    for this architecture.])
1317 fi
1318
1319 # auto-host.h is the file containing items generated by autoconf and is
1320 # the first file included by config.h.
1321 # If host=build, it is correct to have bconfig include auto-host.h
1322 # as well.  If host!=build, we are in error and need to do more 
1323 # work to find out the build config parameters.
1324 if test x$host = x$build
1325 then
1326         build_auto=auto-host.h
1327         FORBUILD=..
1328 else
1329         # We create a subdir, then run autoconf in the subdir.
1330         # To prevent recursion we set host and build for the new
1331         # invocation of configure to the build for this invocation
1332         # of configure. 
1333         tempdir=build.$$
1334         rm -rf $tempdir
1335         mkdir $tempdir
1336         cd $tempdir
1337         case ${srcdir} in
1338         /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
1339         *) realsrcdir=../${srcdir};;
1340         esac
1341         saved_CFLAGS="${CFLAGS}"
1342         CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
1343         ${realsrcdir}/configure \
1344                 --enable-languages=${enable_languages-all} \
1345                 --target=$target_alias --host=$build_alias --build=$build_alias
1346         CFLAGS="${saved_CFLAGS}"
1347
1348         # We just finished tests for the build machine, so rename
1349         # the file auto-build.h in the gcc directory.
1350         mv auto-host.h ../auto-build.h
1351         cd ..
1352         rm -rf $tempdir
1353         build_auto=auto-build.h
1354         FORBUILD=../${build_subdir}
1355 fi
1356 AC_SUBST(FORBUILD)
1357
1358 tm_file="${tm_file} defaults.h"
1359 tm_p_file="${tm_p_file} tm-preds.h"
1360 host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
1361 build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
1362 # We don't want ansidecl.h in target files, write code there in ISO/GNU C.
1363 # put this back in temporarily.
1364 xm_file="ansidecl.h ${xm_file}"
1365
1366 # --------
1367 # UNSORTED
1368 # --------
1369
1370 # Get the version trigger filename from the toplevel
1371 if test "${with_gcc_version_trigger+set}" = set; then
1372         gcc_version_trigger=$with_gcc_version_trigger
1373 else
1374         gcc_version_trigger=${srcdir}/version.c
1375 fi
1376 changequote(,)dnl
1377 gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'`
1378 gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1379
1380 # Compile in configure arguments.
1381 if test -f configargs.h ; then
1382         # Being re-configured.
1383         gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
1384         gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
1385 else
1386         gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
1387 fi
1388
1389 # Double all backslashes and backslash all quotes to turn
1390 # gcc_config_arguments into a C string.
1391 sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
1392 $gcc_config_arguments
1393 EOF
1394 gcc_config_arguments_str=`cat conftest.out`
1395 rm -f conftest.out
1396
1397 cat > configargs.h <<EOF
1398 /* Generated automatically. */
1399 static const char configuration_arguments[] = "$gcc_config_arguments_str";
1400 static const char thread_model[] = "$thread_file";
1401
1402 static const struct {
1403   const char *name, *value;
1404 } configure_default_options[] = $configure_default_options;
1405 EOF
1406 changequote([,])dnl
1407
1408 # Internationalization
1409 PACKAGE=gcc
1410 VERSION="$gcc_version"
1411 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",
1412   [The name of this program for internationalization purposes.])
1413 AC_SUBST(PACKAGE)
1414 AC_SUBST(VERSION)
1415
1416 ZW_GNU_GETTEXT_SISTER_DIR
1417
1418 # If LIBINTL contains LIBICONV, then clear LIBICONV so we don't get
1419 # -liconv on the link line twice.
1420 case "$LIBINTL" in *$LIBICONV*)
1421         LIBICONV= ;;
1422 esac
1423
1424 # Windows32 Registry support for specifying GCC installation paths.
1425 AC_ARG_ENABLE(win32-registry,
1426 [  --disable-win32-registry
1427                           disable lookup of installation paths in the
1428                           Registry on Windows hosts
1429   --enable-win32-registry enable registry lookup (default)
1430   --enable-win32-registry=KEY
1431                           use KEY instead of GCC version as the last portion
1432                           of the registry key],,)
1433 case $host_os in
1434         win32 | pe | cygwin* | mingw32* | uwin*)
1435 AC_MSG_CHECKING(whether windows registry support is requested)
1436 if test "x$enable_win32_registry" != xno; then
1437   AC_DEFINE(ENABLE_WIN32_REGISTRY, 1,
1438 [Define to 1 if installation paths should be looked up in Windows32
1439    Registry. Ignored on non windows32 hosts.])
1440   AC_MSG_RESULT(yes)
1441   AC_SEARCH_LIBS(RegOpenKeyExA, advapi32)
1442 else
1443   AC_MSG_RESULT(no)
1444 fi
1445
1446 # Check if user specified a different registry key.
1447 case "x${enable_win32_registry}" in
1448 x | xyes)
1449   # default.
1450   gcc_cv_win32_registry_key="$VERSION"
1451   ;;
1452 xno)
1453   # no registry lookup.
1454   gcc_cv_win32_registry_key=''
1455   ;;
1456 *)
1457   # user-specified key.
1458   gcc_cv_win32_registry_key="$enable_win32_registry"
1459   ;;
1460 esac
1461
1462 if test "x$enable_win32_registry" != xno; then
1463   AC_MSG_CHECKING(registry key on windows hosts)
1464   AC_DEFINE_UNQUOTED(WIN32_REGISTRY_KEY, "$gcc_cv_win32_registry_key",
1465         [Define to be the last portion of registry key on windows hosts.])
1466   AC_MSG_RESULT($gcc_cv_win32_registry_key)
1467 fi
1468 ;;
1469 esac
1470
1471 # Get an absolute path to the GCC top-level source directory
1472 holddir=`${PWDCMD-pwd}`
1473 cd $srcdir
1474 topdir=`${PWDCMD-pwd}`
1475 cd $holddir
1476
1477 # Conditionalize the makefile for this host machine.
1478 xmake_file=
1479 for f in ${host_xmake_file}
1480 do
1481         if test -f ${srcdir}/config/$f
1482         then
1483                 xmake_file="${xmake_file} \$(srcdir)/config/$f"
1484         fi
1485 done
1486
1487 # Conditionalize the makefile for this target machine.
1488 tmake_file_=
1489 for f in ${tmake_file}
1490 do
1491         if test -f ${srcdir}/config/$f
1492         then
1493                 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
1494         fi
1495 done
1496 tmake_file="${tmake_file_}"
1497
1498 symbolic_link='ln -s'
1499
1500 # If the host doesn't support symlinks, modify CC in
1501 # FLAGS_TO_PASS so CC="stage1/xgcc -Bstage1/" works.
1502 # Otherwise, we can use "CC=$(CC)".
1503 rm -f symtest.tem
1504 if $symbolic_link $srcdir/gcc.c symtest.tem 2>/dev/null
1505 then
1506         cc_set_by_configure="\$(CC)"
1507         quoted_cc_set_by_configure="\$(CC)"
1508         stage_prefix_set_by_configure="\$(STAGE_PREFIX)"
1509         quoted_stage_prefix_set_by_configure="\$(STAGE_PREFIX)"
1510 else
1511         rm -f symtest.tem
1512         if cp -p $srcdir/gcc.c symtest.tem 2>/dev/null
1513         then
1514                 symbolic_link="cp -p"
1515         else
1516                 symbolic_link="cp"
1517         fi
1518         cc_set_by_configure="\`case '\$(CC)' in stage*) echo '\$(CC)' | sed -e 's|stage|../stage|g';; *) echo '\$(CC)';; esac\`"
1519         quoted_cc_set_by_configure="\\\`case '\\\$(CC)' in stage*) echo '\\\$(CC)' | sed -e 's|stage|../stage|g';; *) echo '\\\$(CC)';; esac\\\`"
1520         stage_prefix_set_by_configure="\`case '\$(STAGE_PREFIX)' in stage*) echo '\$(STAGE_PREFIX)' | sed -e 's|stage|../stage|g';; *) echo '\$(STAGE_PREFIX)';; esac\`"
1521         quoted_stage_prefix_set_by_configure="\\\`case '\\\$(STAGE_PREFIX)' in stage*) echo '\\\$(STAGE_PREFIX)' | sed -e 's|stage|../stage|g';; *) echo '\\\$(STAGE_PREFIX)';; esac\\\`"
1522 fi
1523 rm -f symtest.tem
1524
1525 out_object_file=`basename $out_file .c`.o
1526
1527 tm_file_list=
1528 tm_include_list=
1529 for f in $tm_file; do
1530   case $f in
1531     defaults.h )
1532        tm_file_list="${tm_file_list} \$(srcdir)/$f"
1533        tm_include_list="${tm_include_list} $f"
1534        ;;
1535     * )
1536        tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
1537        tm_include_list="${tm_include_list} config/$f"
1538        ;;
1539   esac
1540 done
1541
1542 tm_p_file_list=
1543 tm_p_include_list=
1544 for f in $tm_p_file; do
1545   case $f in
1546     tm-preds.h )
1547        tm_p_file_list="${tm_p_file_list} $f"
1548        tm_p_include_list="${tm_p_include_list} $f"
1549        ;;
1550     * )
1551        tm_p_file_list="${tm_p_file_list} \$(srcdir)/config/$f"
1552        tm_p_include_list="${tm_p_include_list} config/$f"
1553   esac
1554 done
1555
1556 xm_file_list=
1557 xm_include_list=
1558 for f in $xm_file; do
1559   case $f in
1560     ansidecl.h )
1561        xm_file_list="${xm_file_list} \$(srcdir)/../include/$f"
1562        xm_include_list="${xm_include_list} $f"
1563        ;;
1564     auto-host.h )
1565        xm_file_list="${xm_file_list} $f"
1566        xm_include_list="${xm_include_list} $f"
1567        ;;
1568     * )
1569        xm_file_list="${xm_file_list} \$(srcdir)/config/$f"
1570        xm_include_list="${xm_include_list} config/$f"
1571        ;;
1572   esac
1573 done
1574
1575 host_xm_file_list=
1576 host_xm_include_list=
1577 for f in $host_xm_file; do
1578   case $f in
1579     ansidecl.h )
1580        host_xm_file_list="${host_xm_file_list} \$(srcdir)/../include/$f"
1581        host_xm_include_list="${host_xm_include_list} $f"
1582        ;;
1583     auto-host.h )
1584        host_xm_file_list="${host_xm_file_list} $f"
1585        host_xm_include_list="${host_xm_include_list} $f"
1586        ;;
1587     * )
1588        host_xm_file_list="${host_xm_file_list} \$(srcdir)/config/$f"
1589        host_xm_include_list="${host_xm_include_list} config/$f"
1590        ;;
1591   esac
1592 done
1593
1594 build_xm_file_list=
1595 for f in $build_xm_file; do
1596   case $f in
1597     ansidecl.h )
1598        build_xm_file_list="${build_xm_file_list} \$(srcdir)/../include/$f"
1599        build_xm_include_list="${build_xm_include_list} $f"
1600        ;;
1601     auto-build.h | auto-host.h )
1602        build_xm_file_list="${build_xm_file_list} $f"
1603        build_xm_include_list="${build_xm_include_list} $f"
1604        ;;
1605     * )
1606        build_xm_file_list="${build_xm_file_list} \$(srcdir)/config/$f"
1607        build_xm_include_list="${build_xm_include_list} config/$f"
1608        ;;
1609   esac
1610 done
1611
1612 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
1613 # Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
1614 CROSS=                                          AC_SUBST(CROSS)
1615 ALL=all.internal                                AC_SUBST(ALL)
1616 SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' AC_SUBST(SYSTEM_HEADER_DIR)
1617 if test x$host != x$target
1618 then
1619         CROSS="-DCROSS_COMPILE"
1620         ALL=all.cross
1621         SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
1622         case "$host","$target" in
1623         # Darwin crosses can use the host system's libraries and headers,
1624         # because of the fat library support.  Of course, it must be the
1625         # same version of Darwin on both sides.  Allow the user to
1626         # just say --target=foo-darwin without a version number to mean
1627         # "the version on this system".
1628             *-*-darwin*,*-*-darwin*)
1629                 hostos=`echo $host | sed 's/.*-darwin/darwin/'`
1630                 targetos=`echo $target | sed 's/.*-darwin/darwin/'`
1631                 if test $hostos = $targetos -o $targetos = darwin ; then
1632                     CROSS=
1633                     SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)'
1634                     with_headers=yes
1635                 fi
1636                 ;;
1637
1638             i?86-*-*,x86_64-*-* \
1639             | powerpc*-*-*,powerpc64*-*-*)
1640                 CROSS="$CROSS -DNATIVE_CROSS" ;;
1641         esac
1642 elif test "x$TARGET_SYSTEM_ROOT" != x; then
1643         # This is just $(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)
1644         SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
1645 fi
1646
1647 # If this is a cross-compiler that does not
1648 # have its own set of headers then define
1649 # inhibit_libc
1650
1651 # If this is using newlib, without having the headers available now,
1652 # then define inhibit_libc in LIBGCC2_CFLAGS.
1653 # This prevents libgcc2 from containing any code which requires libc
1654 # support.
1655 inhibit_libc=
1656 if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
1657        test x$with_newlib = xyes ; } &&
1658      { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then
1659        inhibit_libc=-Dinhibit_libc
1660 fi
1661 AC_SUBST(inhibit_libc)
1662
1663 # When building gcc with a cross-compiler, we need to adjust things so
1664 # that the generator programs are still built with the native compiler.
1665 # Also, we cannot run fixincludes or fix-header.
1666
1667 # These are the normal (build=host) settings:
1668 CC_FOR_BUILD='$(CC)'            AC_SUBST(CC_FOR_BUILD)
1669 BUILD_CFLAGS='$(ALL_CFLAGS)'    AC_SUBST(BUILD_CFLAGS)
1670 STMP_FIXINC=stmp-fixinc         AC_SUBST(STMP_FIXINC)
1671
1672 # Possibly disable fixproto, on a per-target basis.
1673 case ${use_fixproto} in
1674   no)
1675     STMP_FIXPROTO=
1676     ;;
1677   yes)
1678     STMP_FIXPROTO=stmp-fixproto
1679     ;;
1680 esac
1681 AC_SUBST(STMP_FIXPROTO)
1682
1683 # And these apply if build != host, or we are generating coverage data
1684 if test x$build != x$host || test "x$coverage_flags" != x
1685 then
1686     BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
1687
1688     if test "x$TARGET_SYSTEM_ROOT" = x; then
1689         STMP_FIXINC=
1690         STMP_FIXPROTO=
1691     fi
1692 fi
1693
1694 # Expand extra_headers to include complete path.
1695 # This substitutes for lots of t-* files.
1696 extra_headers_list=
1697 # Prepend $(srcdir)/config/${cpu_type}/ to every entry in extra_headers.
1698 for file in ${extra_headers} ; do
1699   extra_headers_list="${extra_headers_list} \$(srcdir)/config/${cpu_type}/${file}"
1700 done
1701
1702 # Define collect2 in Makefile.
1703 case $host_can_use_collect2 in
1704   no) collect2= ;;
1705   *) collect2='collect2$(exeext)' ;;
1706 esac
1707 AC_SUBST([collect2])
1708
1709 # Add a definition of USE_COLLECT2 if system wants one.
1710 case $use_collect2 in
1711   no) use_collect2= ;;
1712   "") ;;
1713   *) 
1714     host_xm_defines="${host_xm_defines} USE_COLLECT2"
1715     xm_defines="${xm_defines} USE_COLLECT2"
1716     case $host_can_use_collect2 in
1717       no)
1718         AC_MSG_ERROR([collect2 is required but cannot be built on this system])
1719         ;;
1720     esac
1721     ;;
1722 esac
1723
1724 # ---------------------------
1725 # Assembler & linker features
1726 # ---------------------------
1727
1728 # Identify the assembler which will work hand-in-glove with the newly
1729 # built GCC, so that we can examine its features.  This is the assembler
1730 # which will be driven by the driver program.
1731 #
1732 # If build != host, and we aren't building gas in-tree, we identify a
1733 # build->target assembler and hope that it will have the same features
1734 # as the host->target assembler we'll be using.
1735 AC_MSG_CHECKING(what assembler to use)
1736 in_tree_gas=no
1737 gcc_cv_as=
1738 gcc_cv_gas_major_version=
1739 gcc_cv_gas_minor_version=
1740 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
1741 if test -x "$DEFAULT_ASSEMBLER"; then
1742         gcc_cv_as="$DEFAULT_ASSEMBLER"
1743 elif test -x as$host_exeext; then
1744         # Build using assembler in the current directory.
1745         gcc_cv_as=./as$host_exeext
1746 elif test -f $gcc_cv_as_gas_srcdir/configure.in \
1747      && test -f ../gas/Makefile \
1748      && test x$build = x$host; then
1749   # Single tree build which includes gas.  We want to prefer it
1750   # over whatever linker top-level may have detected, since
1751   # we'll use what we're building after installation anyway.
1752   in_tree_gas=yes
1753   _gcc_COMPUTE_GAS_VERSION
1754   rm -f as$host_exeext
1755   $symbolic_link ../gas/as-new$host_exeext as$host_exeext 2>/dev/null
1756   in_tree_gas_is_elf=no
1757   if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
1758      || (grep 'obj_format = multi' ../gas/Makefile \
1759          && grep 'extra_objects =.* obj-elf' ../gas/Makefile) > /dev/null
1760   then
1761     in_tree_gas_is_elf=yes
1762   fi
1763 m4_pattern_allow([AS_FOR_TARGET])dnl
1764 elif test -x "$AS_FOR_TARGET"; then
1765         gcc_cv_as="$AS_FOR_TARGET"
1766 elif test -x "$AS" && test x$host = x$target; then
1767         gcc_cv_as="$AS"
1768 fi
1769
1770 if test "x$gcc_cv_as" = x; then
1771         # Search the same directories that the installed compiler will
1772         # search.  Else we may find the wrong assembler and lose.  If we
1773         # do not find a suitable assembler binary, then try the user's
1774         # path.
1775         #
1776         # Also note we have to check MD_EXEC_PREFIX before checking the
1777         # user's path.  Unfortunately, there is no good way to get at the
1778         # value of MD_EXEC_PREFIX here.  So we do a brute force search
1779         # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
1780         # to be fixed as part of the make/configure rewrite too.
1781
1782         if test "x$exec_prefix" = xNONE; then
1783                 if test "x$prefix" = xNONE; then
1784                         test_prefix=/usr/local
1785                 else
1786                         test_prefix=$prefix
1787                 fi
1788         else
1789                 test_prefix=$exec_prefix
1790         fi
1791
1792         # If the loop below does not find an assembler, then use whatever
1793         # one we can find in the users's path.
1794         # user's path.
1795         if test "x$program_prefix" != xNONE; then
1796                 gcc_cv_as=${program_prefix}as$host_exeext
1797         else
1798                 gcc_cv_as=`echo as | sed "${program_transform_name}"`$host_exeext
1799         fi
1800
1801         test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
1802                    $test_prefix/libexec/gcc/$target_noncanonical \
1803                    /usr/lib/gcc/$target_noncanonical/$gcc_version \
1804                    /usr/lib/gcc/$target_noncanonical \
1805                    $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
1806                    $test_prefix/$target_noncanonical/bin"
1807
1808         if test x$host = x$target; then
1809             test_dirs="$test_dirs \
1810                    /usr/libexec \
1811                    /usr/ccs/gcc \
1812                    /usr/ccs/bin \
1813                    /udk/usr/ccs/bin \
1814                    /bsd43/usr/lib/cmplrs/cc \
1815                    /usr/cross64/usr/bin \
1816                    /usr/lib/cmplrs/cc \
1817                    /sysv/usr/lib/cmplrs/cc \
1818                    /svr4/usr/lib/cmplrs/cc \
1819                    /usr/bin"
1820         fi
1821
1822         for dir in $test_dirs; do
1823                 if test -x $dir/as$host_exeext; then
1824                         gcc_cv_as=$dir/as$host_exeext
1825                         break;
1826                 fi
1827         done
1828 fi
1829 case $in_tree_gas in
1830   yes)
1831     AC_MSG_RESULT("newly built gas")
1832     ;;
1833   no)
1834     AC_MSG_RESULT($gcc_cv_as)
1835     ;;
1836 esac
1837
1838 # Identify the linker which will work hand-in-glove with the newly
1839 # built GCC, so that we can examine its features.  This is the linker
1840 # which will be driven by the driver program.
1841 #
1842 # If build != host, and we aren't building gas in-tree, we identify a
1843 # build->target linker and hope that it will have the same features
1844 # as the host->target linker we'll be using.
1845 AC_MSG_CHECKING(what linker to use)
1846 in_tree_ld=no
1847 gcc_cv_ld=
1848 gcc_cv_gld_major_version=
1849 gcc_cv_gld_minor_version=
1850 gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
1851 gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
1852 if test -x "$DEFAULT_LINKER"; then
1853         gcc_cv_ld="$DEFAULT_LINKER"
1854 elif test -x collect-ld$host_exeext; then
1855         # Build using linker in the current directory.
1856         gcc_cv_ld=./collect-ld$host_exeext
1857 elif test -f $gcc_cv_ld_gld_srcdir/configure.in \
1858      && test -f ../ld/Makefile \
1859      && test x$build = x$host; then
1860         # Single tree build which includes ld.  We want to prefer it
1861         # over whatever linker top-level may have detected, since
1862         # we'll use what we're building after installation anyway.
1863         in_tree_ld=yes
1864         in_tree_ld_is_elf=no
1865         if (grep 'EMUL = .*elf' ../ld/Makefile \
1866             || grep 'EMUL = .*linux' ../ld/Makefile) > /dev/null; then
1867           in_tree_ld_is_elf=yes
1868         fi
1869         for f in $gcc_cv_ld_bfd_srcdir/configure $gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.in $gcc_cv_ld_gld_srcdir/Makefile.in
1870         do
1871 changequote(,)dnl
1872                 gcc_cv_gld_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f`
1873 changequote([,])dnl
1874                 if test x$gcc_cv_gld_version != x; then
1875                         break
1876                 fi
1877         done
1878 changequote(,)dnl
1879         gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
1880         gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
1881 changequote([,])dnl
1882         rm -f collect-ld$host_exeext
1883         $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext \
1884                 2>/dev/null
1885 elif test -x "$LD_FOR_TARGET"; then
1886         gcc_cv_ld="$LD_FOR_TARGET"
1887 elif test -x "$LD" && test x$host = x$target; then
1888         gcc_cv_ld="$LD"
1889 fi
1890
1891 if test "x$gcc_cv_ld" = x; then
1892         # Search the same directories that the installed compiler will
1893         # search.  Else we may find the wrong linker and lose.  If we
1894         # do not find a suitable linker binary, then try the user's
1895         # path.
1896         #
1897         # Also note we have to check MD_EXEC_PREFIX before checking the
1898         # user's path.  Unfortunately, there is no good way to get at the
1899         # value of MD_EXEC_PREFIX here.  So we do a brute force search
1900         # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
1901         # to be fixed as part of the make/configure rewrite too.
1902
1903         if test "x$exec_prefix" = xNONE; then
1904                 if test "x$prefix" = xNONE; then
1905                         test_prefix=/usr/local
1906                 else
1907                         test_prefix=$prefix
1908                 fi
1909         else
1910                 test_prefix=$exec_prefix
1911         fi
1912
1913         # If the loop below does not find an linker, then use whatever
1914         # one we can find in the users's path.
1915         # user's path.
1916         if test "x$program_prefix" != xNONE; then
1917                 gcc_cv_ld=${program_prefix}ld$host_exeext
1918         else
1919                 gcc_cv_ld=`echo ld | sed "${program_transform_name}"`$host_exeext
1920         fi
1921
1922         test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
1923                    $test_prefix/libexec/gcc/$target_noncanonical \
1924                    /usr/lib/gcc/$target_noncanonical/$gcc_version \
1925                    /usr/lib/gcc/$target_noncanonical \
1926                    $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
1927                    $test_prefix/$target_noncanonical/bin"
1928
1929         if test x$host = x$target; then
1930             test_dirs="$test_dirs \
1931                    /usr/libexec \
1932                    /usr/ccs/gcc \
1933                    /usr/ccs/bin \
1934                    /udk/usr/ccs/bin \
1935                    /bsd43/usr/lib/cmplrs/cc \
1936                    /usr/cross64/usr/bin \
1937                    /usr/lib/cmplrs/cc \
1938                    /sysv/usr/lib/cmplrs/cc \
1939                    /svr4/usr/lib/cmplrs/cc \
1940                    /usr/bin"
1941         fi
1942
1943         for dir in $test_dirs; do
1944                 if test -x $dir/ld$host_exeext; then
1945                         gcc_cv_ld=$dir/ld$host_exeext
1946                         break;
1947                 fi
1948         done
1949 fi
1950 case $in_tree_ld in
1951   yes)
1952     AC_MSG_RESULT("newly built ld")
1953     ;;
1954   no)
1955     AC_MSG_RESULT($gcc_cv_ld)
1956     ;;
1957 esac
1958
1959 # Figure out what nm we will be using.
1960 gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
1961 AC_MSG_CHECKING(what nm to use)
1962 in_tree_nm=no
1963 if test -x nm$host_exeext; then
1964         gcc_cv_nm=./nm$host_exeext
1965 elif test -f $gcc_cv_binutils_srcdir/configure.in \
1966      && test -f ../binutils/Makefile; then
1967         # Single tree build which includes binutils.
1968         in_tree_nm=yes
1969         gcc_cv_nm=./nm$host_exeext
1970         rm -f nm$host_exeext
1971         $symbolic_link ../binutils/nm-new$host_exeext nm$host_exeext 2>/dev/null
1972 elif test "x$program_prefix" != xNONE; then
1973         gcc_cv_nm=${program_prefix}nm$host_exeext
1974 else
1975         gcc_cv_nm=`echo nm | sed "${program_transform_name}"`$host_exeext
1976 fi
1977 case $in_tree_nm in
1978   yes) AC_MSG_RESULT("newly built nm") ;;
1979   no)  AC_MSG_RESULT($gcc_cv_nm) ;;
1980 esac
1981
1982 # Figure out what objdump we will be using.
1983 AC_MSG_CHECKING(what objdump to use)
1984 in_tree_objdump=no
1985 if test -x objdump$host_exeext; then
1986         gcc_cv_objdump=./objdump$host_exeext
1987 elif test -f $gcc_cv_binutils_srcdir/configure.in \
1988      && test -f ../binutils/Makefile; then
1989         # Single tree build which includes binutils.
1990         in_tree_objdump=yes
1991         gcc_cv_objdump=./objdump$host_exeext
1992         rm -f objdump$host_exeext
1993         $symbolic_link ../binutils/objdump$host_exeext \
1994                 objdump$host_exeext 2>/dev/null
1995 elif test "x$program_prefix" != xNONE; then
1996         gcc_cv_objdump=${program_prefix}objdump$host_exeext
1997 else
1998         gcc_cv_objdump=`echo objdump | \
1999                 sed "${program_transform_name}"`$host_exeext
2000 fi
2001 case $in_tree_objdump in
2002   yes) AC_MSG_RESULT("newly built objdump") ;;
2003   no)  AC_MSG_RESULT($gcc_cv_objdump) ;;
2004 esac
2005
2006 # Figure out what assembler alignment features are present.
2007 gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,
2008  [2,6,0],,
2009 [.balign 4
2010 .p2align 2],,
2011 [AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
2012   [Define if your assembler supports .balign and .p2align.])])
2013
2014 gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,
2015  [2,8,0],,
2016  [.p2align 4,,7],,
2017 [AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
2018   [Define if your assembler supports specifying the maximum number
2019    of bytes to skip when using the GAS .p2align command.])])
2020
2021 gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,
2022  [elf,2,9,0],,
2023  [conftest_label1: .word 0
2024 .subsection -1
2025 conftest_label2: .word 0
2026 .previous],
2027  [if test x$gcc_cv_nm != x; then
2028     $gcc_cv_nm conftest.o | grep conftest_label1 > conftest.nm1
2029     $gcc_cv_nm conftest.o | grep conftest_label2 | sed -e 's/label2/label1/' > conftest.nm2
2030     if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1
2031     then :
2032     else gcc_cv_as_subsection_m1=yes
2033     fi
2034     rm -f conftest.nm1 conftest.nm2
2035   fi],
2036  [AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
2037   [Define if your assembler supports .subsection and .subsection -1 starts
2038    emitting at the beginning of your section.])])
2039
2040 gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,
2041  [2,2,0],,
2042  [      .weak foobar],,
2043 [AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
2044
2045 # .hidden needs to be supported in both the assembler and the linker,
2046 # because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
2047 # This is irritatingly difficult to feature test for; we have to check the
2048 # date string after the version number.  If we've got an in-tree
2049 # ld, we don't know its patchlevel version, so we set the baseline at 2.13
2050 # to be safe.
2051 # The gcc_GAS_CHECK_FEATURE call just sets a cache variable.
2052 gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
2053  [elf,2,13,0],,
2054 [       .hidden foobar
2055 foobar:])
2056
2057 AC_CACHE_CHECK(linker for .hidden support, gcc_cv_ld_hidden,
2058 [if test $in_tree_ld = yes ; then
2059   gcc_cv_ld_hidden=no
2060   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 13 -o "$gcc_cv_gld_major_version" -gt 2 \
2061      && test $in_tree_ld_is_elf = yes; then
2062      gcc_cv_ld_hidden=yes
2063   fi
2064 else
2065   gcc_cv_ld_hidden=yes
2066   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
2067   if echo "$ld_ver" | grep GNU > /dev/null; then
2068 changequote(,)dnl
2069     ld_vers=`echo $ld_ver | sed -n \
2070         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
2071         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
2072         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
2073         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\)[  ].*$,\1,p' \
2074         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[     ].*$,\1,p' \
2075         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[        ].*$,\1,p'`
2076     ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
2077     if test 0"$ld_date" -lt 20020404; then
2078       if test -n "$ld_date"; then
2079         # If there was date string, but was earlier than 2002-04-04, fail
2080         gcc_cv_ld_hidden=no
2081       elif test -z "$ld_vers"; then
2082         # If there was no date string nor ld version number, something is wrong
2083         gcc_cv_ld_hidden=no
2084       else
2085         ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
2086         ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
2087         ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
2088         test -z "$ld_vers_patch" && ld_vers_patch=0
2089         if test "$ld_vers_major" -lt 2; then
2090           gcc_cv_ld_hidden=no
2091         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 12; then
2092           gcc_cv_ld_hidden="no"
2093         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 12 -a "$ld_vers_patch" -eq 0; then
2094           gcc_cv_ld_hidden=no
2095         fi
2096       fi
2097 changequote([,])dnl
2098     fi
2099   else
2100     case "${target}" in
2101       hppa64*-*-hpux* | ia64*-*-hpux*)
2102         gcc_cv_ld_hidden=yes
2103         ;;
2104       *)
2105         gcc_cv_ld_hidden=no
2106         ;;
2107     esac
2108   fi
2109 fi])
2110 libgcc_visibility=no
2111 AC_SUBST(libgcc_visibility)
2112 if test $gcc_cv_as_hidden = yes && test $gcc_cv_ld_hidden = yes; then
2113   libgcc_visibility=yes
2114   AC_DEFINE(HAVE_GAS_HIDDEN, 1,
2115   [Define if your assembler and linker support .hidden.])
2116 fi
2117
2118 # Check if we have .[us]leb128, and support symbol arithmetic with it.
2119 gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
2120   [elf,2,11,0],,
2121 [       .data
2122         .uleb128 L2 - L1
2123 L1:
2124         .uleb128 1280
2125         .sleb128 -1010
2126 L2:],
2127  [# GAS versions before 2.11 do not support uleb128,
2128   # despite appearing to.
2129   # ??? There exists an elf-specific test that will crash
2130   # the assembler.  Perhaps it's better to figure out whether
2131   # arbitrary sections are supported and try the test.
2132   as_ver=`$gcc_cv_as --version 2>/dev/null | sed 1q`
2133   if echo "$as_ver" | grep GNU > /dev/null; then
2134 changequote(,)dnl
2135     as_ver=`echo $as_ver | sed -e 's/GNU assembler \([0-9.][0-9.]*\).*/\1/'`
2136     as_major=`echo $as_ver | sed 's/\..*//'`
2137     as_minor=`echo $as_ver | sed 's/[^.]*\.\([0-9]*\).*/\1/'`
2138 changequote([,])dnl
2139     if test $as_major -eq 2 && test $as_minor -lt 11
2140     then :
2141     else gcc_cv_as_leb128=yes
2142     fi
2143   fi],
2144   [AC_DEFINE(HAVE_AS_LEB128, 1,
2145     [Define if your assembler supports .sleb128 and .uleb128.])])
2146
2147 # GAS versions up to and including 2.11.0 may mis-optimize
2148 # .eh_frame data.
2149 gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,
2150   [elf,2,12,0],,
2151 [       .text
2152 .LFB1:
2153         .4byte  0
2154 .L1:
2155         .4byte  0
2156 .LFE1:
2157         .section        .eh_frame,"aw",@progbits
2158 __FRAME_BEGIN__:
2159         .4byte  .LECIE1-.LSCIE1
2160 .LSCIE1:
2161         .4byte  0x0
2162         .byte   0x1
2163         .ascii "z\0"
2164         .byte   0x1
2165         .byte   0x78
2166         .byte   0x1a
2167         .byte   0x0
2168         .byte   0x4
2169         .4byte  1
2170         .p2align 1
2171 .LECIE1:
2172 .LSFDE1:
2173         .4byte  .LEFDE1-.LASFDE1
2174 .LASFDE1:
2175         .4byte  .LASFDE1-__FRAME_BEGIN__
2176         .4byte  .LFB1
2177         .4byte  .LFE1-.LFB1
2178         .byte   0x4
2179         .4byte  .LFE1-.LFB1
2180         .byte   0x4
2181         .4byte  .L1-.LFB1
2182 .LEFDE1:],
2183 [  dnl # For autoconf 2.5x, must protect trailing spaces with @&t@.
2184 cat > conftest.lit <<EOF
2185  0000 10000000 00000000 017a0001 781a0004  .........z..x...
2186  0010 01000000 12000000 18000000 00000000  ................
2187  0020 08000000 04080000 0044               .........D      @&t@
2188 EOF
2189 cat > conftest.big <<EOF
2190  0000 00000010 00000000 017a0001 781a0004  .........z..x...
2191  0010 00000001 00000012 00000018 00000000  ................
2192  0020 00000008 04000000 0844               .........D      @&t@
2193 EOF
2194   # If the assembler didn't choke, and we can objdump,
2195   # and we got the correct data, then succeed.
2196   if test x$gcc_cv_objdump != x \
2197   && $gcc_cv_objdump -s -j .eh_frame conftest.o 2>/dev/null \
2198      | tail -3 > conftest.got \
2199   && { cmp conftest.lit conftest.got > /dev/null 2>&1 \
2200     || cmp conftest.big conftest.got > /dev/null 2>&1; }
2201   then
2202     gcc_cv_as_eh_frame=yes
2203   elif AC_TRY_COMMAND($gcc_cv_as -o conftest.o --traditional-format /dev/null); then
2204     gcc_cv_as_eh_frame=buggy
2205   else
2206     # Uh oh, what do we do now?
2207     gcc_cv_as_eh_frame=no
2208   fi])
2209
2210 if test $gcc_cv_as_eh_frame = buggy; then
2211   AC_DEFINE(USE_AS_TRADITIONAL_FORMAT, 1,
2212   [Define if your assembler mis-optimizes .eh_frame data.])
2213 fi
2214
2215 gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
2216  [elf,2,12,0], [--fatal-warnings],
2217  [.section .rodata.str, "aMS", @progbits, 1])
2218 AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
2219   [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
2220 [Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
2221
2222 # Thread-local storage - the check is heavily parametrized.
2223 conftest_s=
2224 tls_first_major=
2225 tls_first_minor=
2226 tls_as_opt=
2227 case "$target" in
2228 changequote(,)dnl
2229   alpha*-*-*)
2230     conftest_s='
2231         .section ".tdata","awT",@progbits
2232 foo:    .long   25
2233         .text
2234         ldq     $27,__tls_get_addr($29)         !literal!1
2235         lda     $16,foo($29)                    !tlsgd!1
2236         jsr     $26,($27),__tls_get_addr        !lituse_tlsgd!1
2237         ldq     $27,__tls_get_addr($29)         !literal!2
2238         lda     $16,foo($29)                    !tlsldm!2
2239         jsr     $26,($27),__tls_get_addr        !lituse_tlsldm!2
2240         ldq     $1,foo($29)                     !gotdtprel
2241         ldah    $2,foo($29)                     !dtprelhi
2242         lda     $3,foo($2)                      !dtprello
2243         lda     $4,foo($29)                     !dtprel
2244         ldq     $1,foo($29)                     !gottprel
2245         ldah    $2,foo($29)                     !tprelhi
2246         lda     $3,foo($2)                      !tprello
2247         lda     $4,foo($29)                     !tprel'
2248         tls_first_major=2
2249         tls_first_minor=13
2250         tls_as_opt=--fatal-warnings
2251         ;;
2252   i[34567]86-*-*)
2253     conftest_s='
2254         .section ".tdata","awT",@progbits
2255 foo:    .long   25
2256         .text
2257         movl    %gs:0, %eax
2258         leal    foo@TLSGD(,%ebx,1), %eax
2259         leal    foo@TLSLDM(%ebx), %eax
2260         leal    foo@DTPOFF(%eax), %edx
2261         movl    foo@GOTTPOFF(%ebx), %eax
2262         subl    foo@GOTTPOFF(%ebx), %eax
2263         addl    foo@GOTNTPOFF(%ebx), %eax
2264         movl    foo@INDNTPOFF, %eax
2265         movl    $foo@TPOFF, %eax
2266         subl    $foo@TPOFF, %eax
2267         leal    foo@NTPOFF(%ecx), %eax'
2268         tls_first_major=2
2269         tls_first_minor=14
2270         tls_as_opt=--fatal-warnings
2271         ;;
2272   x86_64-*-*)
2273     conftest_s='
2274         .section ".tdata","awT",@progbits
2275 foo:    .long   25
2276         .text
2277         movq    %fs:0, %rax
2278         leaq    foo@TLSGD(%rip), %rdi
2279         leaq    foo@TLSLD(%rip), %rdi
2280         leaq    foo@DTPOFF(%rax), %rdx
2281         movq    foo@GOTTPOFF(%rip), %rax
2282         movq    $foo@TPOFF, %rax'
2283         tls_first_major=2
2284         tls_first_minor=14
2285         tls_as_opt=--fatal-warnings
2286         ;;
2287   ia64-*-*)
2288     conftest_s='
2289         .section ".tdata","awT",@progbits
2290 foo:    data8   25
2291         .text
2292         addl    r16 = @ltoff(@dtpmod(foo#)), gp
2293         addl    r17 = @ltoff(@dtprel(foo#)), gp
2294         addl    r18 = @ltoff(@tprel(foo#)), gp
2295         addl    r19 = @dtprel(foo#), gp
2296         adds    r21 = @dtprel(foo#), r13
2297         movl    r23 = @dtprel(foo#)
2298         addl    r20 = @tprel(foo#), gp
2299         adds    r22 = @tprel(foo#), r13
2300         movl    r24 = @tprel(foo#)'
2301         tls_first_major=2
2302         tls_first_minor=13
2303         tls_as_opt=--fatal-warnings
2304         ;;
2305   powerpc-*-*)
2306     conftest_s='
2307         .section ".tdata","awT",@progbits
2308         .align 2
2309 ld0:    .space 4
2310 ld1:    .space 4
2311 x1:     .space 4
2312 x2:     .space 4
2313 x3:     .space 4
2314         .text
2315         addi 3,31,ld0@got@tlsgd
2316         bl __tls_get_addr
2317         addi 3,31,x1@got@tlsld
2318         bl __tls_get_addr
2319         addi 9,3,x1@dtprel
2320         addis 9,3,x2@dtprel@ha
2321         addi 9,9,x2@dtprel@l
2322         lwz 9,x3@got@tprel(31)
2323         add 9,9,x@tls
2324         addi 9,2,x1@tprel
2325         addis 9,2,x2@tprel@ha
2326         addi 9,9,x2@tprel@l'
2327         tls_first_major=2
2328         tls_first_minor=14
2329         tls_as_opt="-a32 --fatal-warnings"
2330         ;;
2331   powerpc64-*-*)
2332     conftest_s='
2333         .section ".tdata","awT",@progbits
2334         .align 3
2335 ld0:    .space 8
2336 ld1:    .space 8
2337 x1:     .space 8
2338 x2:     .space 8
2339 x3:     .space 8
2340         .text
2341         addi 3,2,ld0@got@tlsgd
2342         bl .__tls_get_addr
2343         nop
2344         addi 3,2,ld1@toc
2345         bl .__tls_get_addr
2346         nop
2347         addi 3,2,x1@got@tlsld
2348         bl .__tls_get_addr
2349         nop
2350         addi 9,3,x1@dtprel
2351         bl .__tls_get_addr
2352         nop
2353         addis 9,3,x2@dtprel@ha
2354         addi 9,9,x2@dtprel@l
2355         bl .__tls_get_addr
2356         nop
2357         ld 9,x3@got@dtprel(2)
2358         add 9,9,3
2359         bl .__tls_get_addr
2360         nop'
2361         tls_first_major=2
2362         tls_first_minor=14
2363         tls_as_opt="-a64 --fatal-warnings"
2364         ;;
2365   s390-*-*)
2366     conftest_s='
2367         .section ".tdata","awT",@progbits
2368 foo:    .long   25
2369         .text
2370         .long   foo@TLSGD
2371         .long   foo@TLSLDM
2372         .long   foo@DTPOFF
2373         .long   foo@NTPOFF
2374         .long   foo@GOTNTPOFF
2375         .long   foo@INDNTPOFF
2376         l       %r1,foo@GOTNTPOFF(%r12)
2377         l       %r1,0(%r1):tls_load:foo
2378         bas     %r14,0(%r1,%r13):tls_gdcall:foo
2379         bas     %r14,0(%r1,%r13):tls_ldcall:foo'
2380         tls_first_major=2
2381         tls_first_minor=14
2382         tls_as_opt="-m31 --fatal-warnings"
2383         ;;
2384   s390x-*-*)
2385     conftest_s='
2386         .section ".tdata","awT",@progbits
2387 foo:    .long   25
2388         .text
2389         .quad   foo@TLSGD
2390         .quad   foo@TLSLDM
2391         .quad   foo@DTPOFF
2392         .quad   foo@NTPOFF
2393         .quad   foo@GOTNTPOFF
2394         lg      %r1,foo@GOTNTPOFF(%r12)
2395         larl    %r1,foo@INDNTPOFF
2396         brasl   %r14,__tls_get_offset@PLT:tls_gdcall:foo
2397         brasl   %r14,__tls_get_offset@PLT:tls_ldcall:foo'
2398         tls_first_major=2
2399         tls_first_minor=14
2400         tls_as_opt="-m64 -Aesame --fatal-warnings"
2401         ;;
2402   sh-*-* | sh[34]-*-*)
2403     conftest_s='
2404         .section ".tdata","awT",@progbits
2405 foo:    .long   25
2406         .text
2407         .long   foo@TLSGD
2408         .long   foo@TLSLDM
2409         .long   foo@DTPOFF
2410         .long   foo@GOTTPOFF
2411         .long   foo@TPOFF'
2412         tls_first_major=2
2413         tls_first_minor=13
2414         tls_as_opt=--fatal-warnings
2415         ;;
2416   sparc*-*-*)
2417     case "$target" in
2418       sparc*-sun-solaris2.*)
2419         on_solaris=yes
2420         ;;
2421       *)
2422         on_solaris=no
2423         ;;
2424     esac
2425     if test x$on_solaris = xyes && test x$gas_flag = xno; then
2426       conftest_s='
2427         .section ".tdata",#alloc,#write,#tls
2428 foo:    .long   25
2429         .text
2430         sethi   %tgd_hi22(foo), %o0
2431         add     %o0, %tgd_lo10(foo), %o1
2432         add     %l7, %o1, %o0, %tgd_add(foo)
2433         call    __tls_get_addr, %tgd_call(foo)
2434         sethi   %tldm_hi22(foo), %l1
2435         add     %l1, %tldm_lo10(foo), %l2
2436         add     %l7, %l2, %o0, %tldm_add(foo)
2437         call    __tls_get_addr, %tldm_call(foo)
2438         sethi   %tldo_hix22(foo), %l3
2439         xor     %l3, %tldo_lox10(foo), %l4
2440         add     %o0, %l4, %l5, %tldo_add(foo)
2441         sethi   %tie_hi22(foo), %o3
2442         add     %o3, %tie_lo10(foo), %o3
2443         ld      [%l7 + %o3], %o2, %tie_ld(foo)
2444         add     %g7, %o2, %o4, %tie_add(foo)
2445         sethi   %tle_hix22(foo), %l1
2446         xor     %l1, %tle_lox10(foo), %o5
2447         ld      [%g7 + %o5], %o1'
2448         tls_first_major=0
2449         tls_first_minor=0
2450     else
2451       conftest_s='
2452         .section ".tdata","awT",@progbits
2453 foo:    .long   25
2454         .text
2455         sethi   %tgd_hi22(foo), %o0
2456         add     %o0, %tgd_lo10(foo), %o1
2457         add     %l7, %o1, %o0, %tgd_add(foo)
2458         call    __tls_get_addr, %tgd_call(foo)
2459         sethi   %tldm_hi22(foo), %l1
2460         add     %l1, %tldm_lo10(foo), %l2
2461         add     %l7, %l2, %o0, %tldm_add(foo)
2462         call    __tls_get_addr, %tldm_call(foo)
2463         sethi   %tldo_hix22(foo), %l3
2464         xor     %l3, %tldo_lox10(foo), %l4
2465         add     %o0, %l4, %l5, %tldo_add(foo)
2466         sethi   %tie_hi22(foo), %o3
2467         add     %o3, %tie_lo10(foo), %o3
2468         ld      [%l7 + %o3], %o2, %tie_ld(foo)
2469         add     %g7, %o2, %o4, %tie_add(foo)
2470         sethi   %tle_hix22(foo), %l1
2471         xor     %l1, %tle_lox10(foo), %o5
2472         ld      [%g7 + %o5], %o1'
2473         tls_first_major=2
2474         tls_first_minor=14
2475         tls_as_opt="-32 --fatal-warnings"
2476       fi
2477         ;;
2478 changequote([,])dnl
2479 esac
2480 if test -z "$tls_first_major"; then
2481   : # If we don't have a check, assume no support.
2482 else
2483   gcc_GAS_CHECK_FEATURE(thread-local storage support, gcc_cv_as_tls,
2484   [$tls_first_major,$tls_first_minor,0], [$tls_as_opt], [$conftest_s],,
2485   [AC_DEFINE(HAVE_AS_TLS, 1,
2486             [Define if your assembler supports thread-local storage.])])
2487 fi
2488
2489 # Target-specific assembler checks.
2490
2491 if test x"$demangler_in_ld" = xyes; then
2492   AC_MSG_CHECKING(linker --demangle support)
2493   gcc_cv_ld_demangle=no
2494   if test $in_tree_ld = yes; then
2495     if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 14 -o "$gcc_cv_gld_major_version" -gt 2; then \
2496       gcc_cv_ld_demangle=yes
2497     fi
2498   elif test x$gcc_cv_ld != x -a x"$gnu_ld" = xyes; then
2499     # Check if the GNU linker supports --demangle option
2500     if $gcc_cv_ld --help 2>/dev/null | grep no-demangle > /dev/null; then
2501       gcc_cv_ld_demangle=yes
2502     fi
2503   fi
2504   if test x"$gcc_cv_ld_demangle" = xyes; then
2505     AC_DEFINE(HAVE_LD_DEMANGLE, 1,
2506 [Define if your linker supports --demangle option.])
2507   fi
2508   AC_MSG_RESULT($gcc_cv_ld_demangle)
2509 fi
2510
2511 case "$target" in
2512   # All TARGET_ABI_OSF targets.
2513   alpha*-*-osf* | alpha*-*-linux* | alpha*-*-*bsd*)
2514     gcc_GAS_CHECK_FEATURE([explicit relocation support],
2515         gcc_cv_as_alpha_explicit_relocs, [2,12,0],,
2516 [       .set nomacro
2517         .text
2518         extbl   $3, $2, $3      !lituse_bytoff!1
2519         ldq     $2, a($29)      !literal!1
2520         ldq     $4, b($29)      !literal!2
2521         ldq_u   $3, 0($2)       !lituse_base!1
2522         ldq     $27, f($29)     !literal!5
2523         jsr     $26, ($27), f   !lituse_jsr!5
2524         ldah    $29, 0($26)     !gpdisp!3
2525         lda     $0, c($29)      !gprel
2526         ldah    $1, d($29)      !gprelhigh
2527         lda     $1, d($1)       !gprellow
2528         lda     $29, 0($29)     !gpdisp!3],,
2529     [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1,
2530   [Define if your assembler supports explicit relocations.])])
2531     ;;
2532
2533   cris-*-*)
2534     gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option],
2535       gcc_cv_as_cris_no_mul_bug,[2,15,91],
2536       [-no-mul-bug-abort], [.text],,
2537       [AC_DEFINE(HAVE_AS_NO_MUL_BUG_ABORT_OPTION, 1,
2538                 [Define if your assembler supports the -no-mul-bug-abort option.])])
2539     ;;
2540
2541   sparc*-*-*)
2542     gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
2543       [.register %g2, #scratch],,
2544       [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
2545                 [Define if your assembler supports .register.])])
2546
2547     gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
2548       [-relax], [.text],,
2549       [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
2550                 [Define if your assembler supports -relax option.])])
2551
2552     gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs],
2553       gcc_cv_as_sparc_ua_pcrel,,
2554       [-K PIC],
2555 [.text
2556 foo:
2557         nop
2558 .data
2559 .align 4
2560 .byte 0
2561 .uaword %r_disp32(foo)],
2562       [if test x$gcc_cv_ld != x \
2563        && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
2564          gcc_cv_as_sparc_ua_pcrel=yes
2565        fi
2566        rm -f conftest],
2567       [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
2568                 [Define if your assembler and linker support unaligned PC relative relocs.])
2569
2570       gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs against hidden symbols],
2571         gcc_cv_as_sparc_ua_pcrel_hidden,,
2572         [-K PIC],
2573 [.data
2574 .align 4
2575 .byte 0x31
2576 .uaword %r_disp32(foo)
2577 .byte 0x32, 0x33, 0x34
2578 .global foo
2579 .hidden foo
2580 foo:
2581 .skip 4],
2582         [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
2583          && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1 \
2584          && $gcc_cv_objdump -s -j .data conftest 2> /dev/null \
2585             | grep ' 31000000 07323334' > /dev/null 2>&1; then
2586             if $gcc_cv_objdump -R conftest 2> /dev/null \
2587                | grep 'DISP32' > /dev/null 2>&1; then
2588                 :
2589             else
2590                 gcc_cv_as_sparc_ua_pcrel_hidden=yes
2591             fi
2592          fi
2593          rm -f conftest],
2594          [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL_HIDDEN, 1,
2595                    [Define if your assembler and linker support unaligned PC relative relocs against hidden symbols.])])
2596     ]) # unaligned pcrel relocs
2597
2598     gcc_GAS_CHECK_FEATURE([offsetable %lo()],
2599       gcc_cv_as_sparc_offsetable_lo10,,
2600       [-xarch=v9],
2601 [.text
2602         or %g1, %lo(ab) + 12, %g1
2603         or %g1, %lo(ab + 12), %g1],
2604       [if test x$gcc_cv_objdump != x \
2605        && $gcc_cv_objdump -s -j .text conftest.o 2> /dev/null \
2606           | grep ' 82106000 82106000' > /dev/null 2>&1; then
2607          gcc_cv_as_offsetable_lo10=yes
2608        fi],
2609        [AC_DEFINE(HAVE_AS_OFFSETABLE_LO10, 1,
2610                  [Define if your assembler supports offsetable %lo().])])
2611     ;;
2612
2613 changequote(,)dnl
2614   i[34567]86-*-* | x86_64-*-*)
2615 changequote([,])dnl
2616     case $target_os in
2617       cygwin* | pe | mingw32*)
2618         # Used for DWARF 2 in PE
2619         gcc_GAS_CHECK_FEATURE([.secrel32 relocs],
2620           gcc_cv_as_ix86_pe_secrel32,
2621           [2,15,91],,
2622 [.text
2623 foo:    nop
2624 .data
2625         .secrel32 foo],
2626           [if test x$gcc_cv_ld != x \
2627            && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1; then
2628              gcc_cv_as_ix86_pe_secrel32=yes
2629            fi
2630            rm -f conftest],
2631           [AC_DEFINE(HAVE_GAS_PE_SECREL32_RELOC, 1,
2632             [Define if your assembler and linker support 32-bit section relative relocs via '.secrel32 label'.])])
2633         ;;
2634     esac
2635
2636     gcc_GAS_CHECK_FEATURE([filds and fists mnemonics],
2637        gcc_cv_as_ix86_filds_fists,
2638       [2,9,0],, [filds mem; fists mem],,
2639       [AC_DEFINE(HAVE_GAS_FILDS_FISTS, 1,
2640         [Define if your assembler uses the new HImode fild and fist notation.])])
2641
2642     gcc_GAS_CHECK_FEATURE([cmov syntax],
2643       gcc_cv_as_ix86_cmov_sun_syntax,,,
2644       [cmovl.l %edx, %eax],,
2645       [AC_DEFINE(HAVE_AS_IX86_CMOV_SUN_SYNTAX, 1,
2646         [Define if your assembler supports the Sun syntax for cmov.])])
2647
2648     # This one is used unconditionally by i386.[ch]; it is to be defined
2649     # to 1 if the feature is present, 0 otherwise.
2650     gcc_GAS_CHECK_FEATURE([GOTOFF in data],
2651         gcc_cv_as_ix86_gotoff_in_data, [2,11,0],,
2652 [       .text
2653 .L0:
2654         nop
2655         .data
2656         .long .L0@GOTOFF])
2657     AC_DEFINE_UNQUOTED(HAVE_AS_GOTOFF_IN_DATA,
2658       [`if test $gcc_cv_as_ix86_gotoff_in_data = yes; then echo 1; else echo 0; fi`],
2659       [Define true if the assembler supports '.long foo@GOTOFF'.])
2660     ;;
2661
2662   ia64*-*-*)
2663     gcc_GAS_CHECK_FEATURE([ltoffx and ldxmov relocs],
2664         gcc_cv_as_ia64_ltoffx_ldxmov_relocs, [2,14,0],,
2665 [       .text
2666         addl r15 = @ltoffx(x#), gp
2667         ;;
2668         ld8.mov r16 = [[r15]], x#],,
2669     [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
2670           [Define if your assembler supports ltoffx and ldxmov relocations.])])
2671
2672     ;;
2673
2674   powerpc*-*-*)
2675     case $target in
2676       *-*-aix*) conftest_s='    .csect .text[[PR]]
2677         mfcr 3,128';;
2678       *-*-darwin*) conftest_s=' .text
2679         mfcr r3,128';;
2680       *)       conftest_s='     .text
2681         mfcr 3,128';;
2682     esac
2683
2684     gcc_GAS_CHECK_FEATURE([mfcr field support],
2685       gcc_cv_as_powerpc_mfcrf, [2,14,0],,
2686       [$conftest_s],,
2687       [AC_DEFINE(HAVE_AS_MFCRF, 1,
2688           [Define if your assembler supports mfcr field.])])
2689     ;;
2690
2691   mips*-*-*)
2692     gcc_GAS_CHECK_FEATURE([explicit relocation support],
2693       gcc_cv_as_mips_explicit_relocs, [2,14,0],,
2694 [       lw $4,%gp_rel(foo)($4)],,
2695       [if test x$target_cpu_default = x
2696        then target_cpu_default=MASK_EXPLICIT_RELOCS
2697        else target_cpu_default="($target_cpu_default)|MASK_EXPLICIT_RELOCS"
2698        fi])
2699
2700     if test x$gas_flag = xyes \
2701        || test x"$host" != x"$build" \
2702        || test ! -x "$gcc_cv_as" \
2703        || "$gcc_cv_as" -v < /dev/null 2>&1 | grep GNU > /dev/null; then
2704       :
2705     else
2706       echo "*** This configuration requires the GNU assembler" >&2
2707       exit 1
2708     fi
2709     ;;
2710 esac
2711 # ??? Not all targets support dwarf2 debug_line, even within a version
2712 # of gas.  Moreover, we need to emit a valid instruction to trigger any
2713 # info to the output file.  So, as supported targets are added to gas 2.11,
2714 # add some instruction here to (also) show we expect this might work.
2715 # ??? Once 2.11 is released, probably need to add first known working
2716 # version to the per-target configury.
2717 case "$target" in
2718   i?86*-*-* | mips*-*-* | alpha*-*-* | powerpc*-*-* | sparc*-*-* | m68*-*-* \
2719   | x86_64*-*-* | hppa*-*-* | arm*-*-* | strongarm*-*-* | xscale*-*-* \
2720   | xstormy16*-*-* | cris-*-* | xtensa-*-*)
2721     insn="nop"
2722     ;;
2723   ia64*-*-* | s390*-*-*)
2724     insn="nop 0"
2725     ;;
2726   mmix-*-*)
2727     insn="swym 0"
2728     ;;
2729 esac
2730 if test x"$insn" != x; then
2731  conftest_s="\
2732         .file 1 \"conftest.s\"
2733         .loc 1 3 0
2734         $insn"
2735  gcc_GAS_CHECK_FEATURE([dwarf2 debug_line support],
2736   gcc_cv_as_dwarf2_debug_line,
2737   [elf,2,11,0],, [$conftest_s],
2738   [# ??? This fails with non-gnu grep.  Maybe use objdump?
2739    if grep debug_line conftest.o > /dev/null 2>&1; then
2740      gcc_cv_as_dwarf2_debug_line=yes
2741    fi])
2742
2743 # The .debug_line file table must be in the exact order that
2744 # we specified the files, since these indices are also used
2745 # by DW_AT_decl_file.  Approximate this test by testing if
2746 # the assembler bitches if the same index is assigned twice.
2747  gcc_GAS_CHECK_FEATURE([buggy dwarf2 .file directive],
2748   gcc_cv_as_dwarf2_file_buggy,,,
2749 [       .file 1 "foo.s"
2750         .file 1 "bar.s"])
2751
2752  if test $gcc_cv_as_dwarf2_debug_line = yes \
2753  && test $gcc_cv_as_dwarf2_file_buggy = no; then
2754         AC_DEFINE(HAVE_AS_DWARF2_DEBUG_LINE, 1,
2755   [Define if your assembler supports dwarf2 .file/.loc directives,
2756    and preserves file table indices exactly as given.])
2757  fi
2758
2759  gcc_GAS_CHECK_FEATURE([--gdwarf2 option],
2760   gcc_cv_as_gdwarf2_flag,
2761   [elf,2,11,0], [--gdwarf2], [$insn],,
2762   [AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
2763 [Define if your assembler supports the --gdwarf2 option.])])
2764
2765  gcc_GAS_CHECK_FEATURE([--gstabs option],
2766   gcc_cv_as_gstabs_flag,
2767   [elf,2,11,0], [--gstabs], [$insn],
2768   [# The native Solaris 9/Intel assembler doesn't understand --gstabs
2769    # and warns about it, but still exits successfully.  So check for
2770    # this.
2771    if AC_TRY_COMMAND([$gcc_cv_as --gstabs -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null])
2772    then :
2773    else gcc_cv_as_gstabs_flag=yes
2774    fi],
2775   [AC_DEFINE(HAVE_AS_GSTABS_DEBUG_FLAG, 1,
2776 [Define if your assembler supports the --gstabs option.])])
2777 fi
2778
2779 AC_MSG_CHECKING(linker read-only and read-write section mixing)
2780 gcc_cv_ld_ro_rw_mix=unknown
2781 if test $in_tree_ld = yes ; then
2782   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 10 -o "$gcc_cv_gld_major_version" -gt 2 \
2783      && test $in_tree_ld_is_elf = yes; then
2784     gcc_cv_ld_ro_rw_mix=read-write
2785   fi
2786 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
2787   echo '.section myfoosect, "a"' > conftest1.s
2788   echo '.section myfoosect, "aw"' > conftest2.s
2789   echo '.byte 1' >> conftest2.s
2790   echo '.section myfoosect, "a"' > conftest3.s
2791   echo '.byte 0' >> conftest3.s
2792   if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
2793      && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
2794      && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \
2795      && $gcc_cv_ld -shared -o conftest1.so conftest1.o \
2796         conftest2.o conftest3.o > /dev/null 2>&1; then
2797     gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
2798                          | sed -e '/myfoosect/!d' -e N`
2799     if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
2800       if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
2801         gcc_cv_ld_ro_rw_mix=read-only
2802       else
2803         gcc_cv_ld_ro_rw_mix=read-write
2804       fi
2805     fi
2806   fi
2807 changequote(,)dnl
2808   rm -f conftest.* conftest[123].*
2809 changequote([,])dnl
2810 fi
2811 if test x$gcc_cv_ld_ro_rw_mix = xread-write; then
2812         AC_DEFINE(HAVE_LD_RO_RW_SECTION_MIXING, 1,
2813   [Define if your linker links a mix of read-only
2814    and read-write sections into a read-write section.])
2815 fi
2816 AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix)
2817
2818 AC_MSG_CHECKING(linker PT_GNU_EH_FRAME support)
2819 gcc_cv_ld_eh_frame_hdr=no
2820 if test $in_tree_ld = yes ; then
2821   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 12 -o "$gcc_cv_gld_major_version" -gt 2 \
2822      && test $in_tree_ld_is_elf = yes; then
2823     gcc_cv_ld_eh_frame_hdr=yes
2824   fi
2825 elif test x$gcc_cv_ld != x; then
2826         # Check if linker supports --eh-frame-hdr option
2827         if $gcc_cv_ld --help 2>/dev/null | grep eh-frame-hdr > /dev/null; then
2828                 gcc_cv_ld_eh_frame_hdr=yes
2829         fi
2830 fi
2831 if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
2832         AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
2833 [Define if your linker supports --eh-frame-hdr option.])
2834 fi
2835 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
2836
2837 AC_MSG_CHECKING(linker position independent executable support)
2838 gcc_cv_ld_pie=no
2839 if test $in_tree_ld = yes ; then
2840   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 \
2841      && test $in_tree_ld_is_elf = yes; then
2842     gcc_cv_ld_pie=yes
2843   fi
2844 elif test x$gcc_cv_ld != x; then
2845         # Check if linker supports -pie option
2846         if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then
2847                 gcc_cv_ld_pie=yes
2848         fi
2849 fi
2850 if test x"$gcc_cv_ld_pie" = xyes; then
2851         AC_DEFINE(HAVE_LD_PIE, 1,
2852 [Define if your linker supports -pie option.])
2853 fi
2854 AC_MSG_RESULT($gcc_cv_ld_pie)
2855
2856 # --------
2857 # UNSORTED
2858 # --------
2859
2860 AC_CACHE_CHECK(linker --as-needed support,
2861 gcc_cv_ld_as_needed,
2862 [gcc_cv_ld_as_needed=no
2863 if test $in_tree_ld = yes ; then
2864   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \
2865      && test $in_tree_ld_is_elf = yes; then
2866     gcc_cv_ld_as_needed=yes
2867   fi
2868 elif test x$gcc_cv_ld != x; then
2869         # Check if linker supports --as-needed and --no-as-needed options
2870         if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then
2871                 gcc_cv_ld_as_needed=yes
2872         fi
2873 fi
2874 ])
2875 if test x"$gcc_cv_ld_as_needed" = xyes; then
2876         AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
2877 [Define if your linker supports --as-needed and --no-as-needed options.])
2878 fi
2879
2880 case "$target" in
2881   powerpc64*-*-linux*)
2882     AC_CACHE_CHECK(linker support for omitting dot symbols,
2883     gcc_cv_ld_no_dot_syms,
2884     [gcc_cv_ld_no_dot_syms=no
2885     if test $in_tree_ld = yes ; then
2886       if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2; then
2887         gcc_cv_ld_no_dot_syms=yes
2888       fi
2889     elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
2890       cat > conftest1.s <<EOF
2891         .text
2892         bl .foo
2893 EOF
2894       cat > conftest2.s <<EOF
2895         .section ".opd","aw"
2896         .align 3
2897         .globl foo
2898         .type foo,@function
2899 foo:
2900         .quad .LEfoo,.TOC.@tocbase,0
2901         .text
2902 .LEfoo:
2903         blr
2904         .size foo,.-.LEfoo
2905 EOF
2906       if $gcc_cv_as -a64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
2907          && $gcc_cv_as -a64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
2908          && $gcc_cv_ld -melf64ppc -o conftest conftest1.o conftest2.o > /dev/null 2>&1; then
2909         gcc_cv_ld_no_dot_syms=yes
2910       fi
2911       rm -f conftest conftest1.o conftest2.o conftest1.s conftest2.s
2912     fi
2913     ])
2914     if test x"$gcc_cv_ld_no_dot_syms" = xyes; then
2915       AC_DEFINE(HAVE_LD_NO_DOT_SYMS, 1,
2916     [Define if your PowerPC64 linker only needs function descriptor syms.])
2917     fi
2918     ;;
2919 esac
2920
2921 if test x$with_sysroot = x && test x$host = x$target \
2922    && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then
2923   AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include",
2924 [Define to PREFIX/include if cpp should also search that directory.])
2925 fi
2926
2927 # Find out what GC implementation we want, or may, use.
2928 AC_ARG_WITH(gc,
2929 [  --with-gc={page,zone}   choose the garbage collection mechanism to use
2930                           with the compiler],
2931 [case "$withval" in
2932   page | zone)
2933     GGC=ggc-$withval
2934     ;;
2935   *)
2936     AC_MSG_ERROR([$withval is an invalid option to --with-gc])
2937     ;;
2938 esac],
2939 [GGC=ggc-page])
2940 AC_SUBST(GGC)
2941 echo "Using $GGC for garbage collection."
2942
2943 # Use the system's zlib library.
2944 zlibdir=-L../zlib
2945 zlibinc="-I\$(srcdir)/../zlib"
2946 AC_ARG_WITH(system-zlib,
2947 [  --with-system-zlib      use installed libz],
2948 zlibdir=
2949 zlibinc=
2950 )
2951 AC_SUBST(zlibdir)
2952 AC_SUBST(zlibinc)
2953
2954 dnl Very limited version of automake's enable-maintainer-mode
2955
2956 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
2957   dnl maintainer-mode is disabled by default
2958   AC_ARG_ENABLE(maintainer-mode,
2959 [  --enable-maintainer-mode
2960                           enable make rules and dependencies not useful
2961                           (and sometimes confusing) to the casual installer],
2962       maintainer_mode=$enableval,
2963       maintainer_mode=no)
2964
2965 AC_MSG_RESULT($maintainer_mode)
2966
2967 if test "$maintainer_mode" = "yes"; then
2968   MAINT=''
2969 else
2970   MAINT='#'
2971 fi
2972 AC_SUBST(MAINT)dnl
2973
2974 AC_MSG_CHECKING([whether to use libbanshee for points-to alias analysis])
2975 AC_ARG_WITH(libbanshee,
2976 [  --with-libbanshee      enable libbanshee],
2977 libbanshee="$with_libbanshee",
2978 libbanshee=no)
2979
2980 if test x"$libbanshee" = xyes; then
2981         BANSHEELIB="../libbanshee/points-to/libandersen.a ../libbanshee/engine/libbansheeengine.a ../libbanshee/libcompat/libbansheecompat.a "
2982         BANSHEEINC="-I\$(srcdir)/../libbanshee/libcompat -I\$(srcdir)/../libbanshee -I\$(srcdir)/../libbanshee/points-to"
2983         ANDER="tree-alias-ander.o"
2984         AC_DEFINE(HAVE_BANSHEE, 1, [Define if BANSHEE is available])
2985 else
2986         BANSHEELIB=""
2987         BANSHEEINC=""
2988         ANDER=""
2989 fi
2990 AC_MSG_RESULT($with_libbanshee)
2991
2992 AC_SUBST(ANDER)
2993 AC_SUBST(BANSHEEINC)
2994 AC_SUBST(BANSHEELIB)
2995
2996 # --------------
2997 # Language hooks
2998 # --------------
2999
3000 # Make empty files to contain the specs and options for each language.
3001 # Then add #include lines to for a compiler that has specs and/or options.
3002
3003 lang_opt_files=
3004 lang_specs_files=
3005 lang_tree_files=
3006 for subdir in . $subdirs
3007 do
3008         if test -f $srcdir/$subdir/lang.opt; then
3009             lang_opt_files="$lang_opt_files $srcdir/$subdir/lang.opt"
3010         fi
3011         if test -f $srcdir/$subdir/lang-specs.h; then
3012             lang_specs_files="$lang_specs_files $srcdir/$subdir/lang-specs.h"
3013         fi
3014         if test -f $srcdir/$subdir/$subdir-tree.def; then
3015             lang_tree_files="$lang_tree_files $srcdir/$subdir/$subdir-tree.def"
3016         fi
3017 done
3018
3019 # These (without "all_") are set in each config-lang.in.
3020 # `language' must be a single word so is spelled singularly.
3021 all_languages=
3022 all_boot_languages=
3023 all_compilers=
3024 all_stagestuff=
3025 all_outputs='Makefile fixinc/Makefile gccbug mklibgcc mkheaders libada-mk'
3026 # List of language makefile fragments.
3027 all_lang_makefrags=
3028 # List of language subdirectory makefiles.  Deprecated.
3029 all_lang_makefiles=
3030 # Files for gengtype
3031 all_gtfiles="$target_gtfiles"
3032 # Files for gengtype with language
3033 all_gtfiles_files_langs=
3034 all_gtfiles_files_files=
3035
3036 # Add the language fragments.
3037 # Languages are added via two mechanisms.  Some information must be
3038 # recorded in makefile variables, these are defined in config-lang.in.
3039 # We accumulate them and plug them into the main Makefile.
3040 # The other mechanism is a set of hooks for each of the main targets
3041 # like `clean', `install', etc.
3042
3043 language_hooks="Make-hooks"
3044
3045 for s in $subdirs
3046 do
3047                 language=
3048                 boot_language=
3049                 compilers=
3050                 stagestuff=
3051                 outputs=
3052                 gtfiles=
3053                 . ${srcdir}/$s/config-lang.in
3054                 if test "x$language" = x
3055                 then
3056                         echo "${srcdir}/$s/config-lang.in doesn't set \$language." 1>&2
3057                         exit 1
3058                 fi
3059                 all_lang_makefrags="$all_lang_makefrags \$(srcdir)/$s/Make-lang.in"
3060                 if test -f ${srcdir}/$s/Makefile.in
3061                 then all_lang_makefiles="$s/Makefile"
3062                 fi
3063                 all_languages="$all_languages $language"
3064                 if test "x$boot_language" = xyes
3065                 then
3066                         all_boot_languages="$all_boot_languages $language"
3067                 fi
3068                 all_compilers="$all_compilers $compilers"
3069                 all_stagestuff="$all_stagestuff $stagestuff"
3070                 all_outputs="$all_outputs $outputs"
3071                 all_gtfiles="$all_gtfiles $gtfiles"
3072                 for f in $gtfiles
3073                 do
3074                          all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
3075                          all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
3076                 done
3077 done
3078
3079 # Pick up gtfiles for c
3080 gtfiles=
3081 s="c"
3082 . ${srcdir}/c-config-lang.in
3083 all_gtfiles="$all_gtfiles $gtfiles"
3084 for f in $gtfiles
3085 do
3086         all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
3087         all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
3088 done
3089
3090 check_languages=
3091 for language in $all_languages
3092 do
3093                 check_languages="$check_languages check-$language"
3094 done
3095
3096 # We link each language in with a set of hooks, reached indirectly via
3097 # lang.${target}.
3098
3099 rm -f Make-hooks
3100 touch Make-hooks
3101 target_list="all.build all.cross start.encap rest.encap tags \
3102         install-normal install-common install-man \
3103         uninstall info man srcextra srcman srcinfo \
3104         mostlyclean clean distclean maintainer-clean \
3105         stage1 stage2 stage3 stage4 stageprofile stagefeedback"
3106 for t in $target_list
3107 do
3108         x=
3109         for lang in $all_languages
3110         do
3111                         x="$x $lang.$t"
3112         done
3113         echo "lang.$t: $x" >> Make-hooks
3114 done
3115
3116 # --------
3117 # UNSORTED
3118 # --------
3119
3120 # Create .gdbinit.
3121
3122 echo "dir ." > .gdbinit
3123 echo "dir ${srcdir}" >> .gdbinit
3124 if test x$gdb_needs_out_file_path = xyes
3125 then
3126         echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
3127 fi
3128 if test "x$subdirs" != x; then
3129         for s in $subdirs
3130         do
3131                 echo "dir ${srcdir}/$s" >> .gdbinit
3132         done
3133 fi
3134 echo "source ${srcdir}/gdbinit.in" >> .gdbinit
3135
3136 # If $(exec_prefix) exists and is not the same as $(prefix), then compute an
3137 # absolute path for gcc_tooldir based on inserting the number of up-directory
3138 # movements required to get from $(exec_prefix) to $(prefix) into the basic
3139 # $(libsubdir)/@(unlibsubdir) based path.
3140 # Don't set gcc_tooldir to tooldir since that's only passed in by the toplevel
3141 # make and thus we'd get different behavior depending on where we built the
3142 # sources.
3143 if test x$exec_prefix = xNONE -o x$exec_prefix = x$prefix; then
3144     gcc_tooldir='$(libsubdir)/$(unlibsubdir)/../$(target_noncanonical)'
3145 else
3146 changequote(<<, >>)dnl
3147 # An explanation of the sed strings:
3148 #  -e 's|^\$(prefix)||'   matches and eliminates 'prefix' from 'exec_prefix'
3149 #  -e 's|/$||'            match a trailing forward slash and eliminates it
3150 #  -e 's|^[^/]|/|'        forces the string to start with a forward slash (*)
3151 #  -e 's|/[^/]*|../|g'    replaces each occurrence of /<directory> with ../
3152 #
3153 # (*) Note this pattern overwrites the first character of the string
3154 # with a forward slash if one is not already present.  This is not a
3155 # problem because the exact names of the sub-directories concerned is
3156 # unimportant, just the number of them matters.
3157 #
3158 # The practical upshot of these patterns is like this:
3159 #
3160 #  prefix     exec_prefix        result
3161 #  ------     -----------        ------
3162 #   /foo        /foo/bar          ../
3163 #   /foo/       /foo/bar          ../
3164 #   /foo        /foo/bar/         ../
3165 #   /foo/       /foo/bar/         ../
3166 #   /foo        /foo/bar/ugg      ../../
3167 #
3168     dollar='$$'
3169     gcc_tooldir="\$(libsubdir)/\$(unlibsubdir)/\`echo \$(exec_prefix) | sed -e 's|^\$(prefix)||' -e 's|/\$(dollar)||' -e 's|^[^/]|/|' -e 's|/[^/]*|../|g'\`\$(target_noncanonical)"
3170 changequote([, ])dnl
3171 fi
3172 AC_SUBST(gcc_tooldir)
3173 AC_SUBST(dollar)
3174
3175 # Find a directory in which to install a shared libgcc.
3176
3177 AC_ARG_ENABLE(version-specific-runtime-libs,
3178 [  --enable-version-specific-runtime-libs
3179                           specify that runtime libraries should be
3180                           installed in a compiler-specific directory])
3181
3182 AC_ARG_WITH(slibdir,
3183 [  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
3184 slibdir="$with_slibdir",
3185 if test "${enable_version_specific_runtime_libs+set}" = set; then
3186   slibdir='$(libsubdir)'
3187 elif test "$host" != "$target"; then
3188   slibdir='$(build_tooldir)/lib'
3189 else
3190   slibdir='$(libdir)'
3191 fi)
3192 AC_SUBST(slibdir)
3193
3194 objdir=`${PWDCMD-pwd}`
3195 AC_SUBST(objdir)
3196
3197 # Substitute configuration variables
3198 AC_SUBST(subdirs)
3199 AC_SUBST(srcdir)
3200 AC_SUBST(all_boot_languages)
3201 AC_SUBST(all_compilers)
3202 AC_SUBST(all_gtfiles)
3203 AC_SUBST(all_gtfiles_files_langs)
3204 AC_SUBST(all_gtfiles_files_files)
3205 AC_SUBST(all_lang_makefrags)
3206 AC_SUBST(all_lang_makefiles)
3207 AC_SUBST(all_languages)
3208 AC_SUBST(all_stagestuff)
3209 AC_SUBST(build_exeext)
3210 AC_SUBST(build_install_headers_dir)
3211 AC_SUBST(build_xm_file_list)
3212 AC_SUBST(build_xm_include_list)
3213 AC_SUBST(build_xm_defines)
3214 AC_SUBST(check_languages)
3215 AC_SUBST(cc_set_by_configure)
3216 AC_SUBST(quoted_cc_set_by_configure)
3217 AC_SUBST(cpp_install_dir)
3218 AC_SUBST(xmake_file)
3219 AC_SUBST(tmake_file)
3220 AC_SUBST(extra_gcc_objs)
3221 AC_SUBST(extra_headers_list)
3222 AC_SUBST(extra_objs)
3223 AC_SUBST(extra_parts)
3224 AC_SUBST(extra_passes)
3225 AC_SUBST(extra_programs)
3226 AC_SUBST(float_h_file)
3227 AC_SUBST(gcc_config_arguments)
3228 AC_SUBST(gcc_gxx_include_dir)
3229 AC_SUBST(libstdcxx_incdir)
3230 AC_SUBST(gcc_version)
3231 AC_SUBST(gcc_version_full)
3232 AC_SUBST(gcc_version_trigger)
3233 AC_SUBST(host_exeext)
3234 AC_SUBST(host_xm_file_list)
3235 AC_SUBST(host_xm_include_list)
3236 AC_SUBST(host_xm_defines)
3237 AC_SUBST(out_host_hook_obj)
3238 AC_SUBST(install)
3239 AC_SUBST(lang_opt_files)
3240 AC_SUBST(lang_specs_files)
3241 AC_SUBST(lang_tree_files)
3242 AC_SUBST(local_prefix)
3243 AC_SUBST(md_file)
3244 AC_SUBST(objc_boehm_gc)
3245 AC_SUBST(out_file)
3246 AC_SUBST(out_object_file)
3247 AC_SUBST(stage_prefix_set_by_configure)
3248 AC_SUBST(quoted_stage_prefix_set_by_configure)
3249 AC_SUBST(symbolic_link)
3250 AC_SUBST(thread_file)
3251 AC_SUBST(tm_file_list)
3252 AC_SUBST(tm_include_list)
3253 AC_SUBST(tm_defines)
3254 AC_SUBST(tm_p_file_list)
3255 AC_SUBST(tm_p_include_list)
3256 AC_SUBST(xm_file_list)
3257 AC_SUBST(xm_include_list)
3258 AC_SUBST(xm_defines)
3259 AC_SUBST(c_target_objs)
3260 AC_SUBST(cxx_target_objs)
3261 AC_SUBST(target_cpu_default)
3262
3263 AC_SUBST_FILE(language_hooks)
3264
3265 # If it doesn't already exist, create document directory
3266 echo "checking for the document directory." 1>&2
3267 if test -d doc ; then
3268   true
3269 else
3270   mkdir doc 
3271 fi
3272
3273 # Echo link setup.
3274 if test x${build} = x${host} ; then
3275   if test x${host} = x${target} ; then
3276     echo "Links are now set up to build a native compiler for ${target}." 1>&2
3277   else
3278     echo "Links are now set up to build a cross-compiler" 1>&2
3279     echo " from ${host} to ${target}." 1>&2
3280   fi
3281 else
3282   if test x${host} = x${target} ; then
3283     echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
3284     echo " for ${target}." 1>&2
3285   else
3286     echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
3287     echo " from ${host} to ${target}." 1>&2
3288   fi
3289 fi
3290
3291 AC_ARG_VAR(GMPLIBS,[How to link GMP])
3292 AC_ARG_VAR(GMPINC,[How to find GMP include files])
3293
3294 # Configure the subdirectories
3295 # AC_CONFIG_SUBDIRS($subdirs)
3296
3297 # Create the Makefile
3298 # and configure language subdirectories
3299 AC_CONFIG_FILES($all_outputs)
3300
3301 AC_CONFIG_COMMANDS([default],
3302 [
3303 case ${CONFIG_HEADERS} in
3304   *auto-host.h:config.in*)
3305   echo > cstamp-h ;;
3306 esac
3307 # Make sure all the subdirs exist.
3308 for d in $subdirs
3309 do
3310     test -d $d || mkdir $d
3311 done
3312 # If the host supports symlinks, point stage[1234] at ../stage[1234] so
3313 # bootstrapping and the installation procedure can still use
3314 # CC="stage1/xgcc -Bstage1/".  If the host doesn't support symlinks,
3315 # FLAGS_TO_PASS has been modified to solve the problem there.
3316 # This is virtually a duplicate of what happens in configure.lang; we do
3317 # an extra check to make sure this only happens if ln -s can be used.
3318 if test "$symbolic_link" = "ln -s"; then
3319  for d in ${subdirs} fixinc ; do
3320         STARTDIR=`${PWDCMD-pwd}`
3321         cd $d
3322         for t in stage1 stage2 stage3 stage4 stageprofile stagefeedback include
3323         do
3324                 rm -f $t
3325                 $symbolic_link ../$t $t 2>/dev/null
3326         done
3327         cd $STARTDIR
3328  done
3329 else true ; fi
3330 ], 
3331 [subdirs='$subdirs'
3332 symbolic_link='$symbolic_link'
3333 ])
3334 AC_OUTPUT