OSDN Git Service

Cleanups after the update to Autoconf 2.64, Automake 1.11.
[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, 2005, 2006,
5 # 2007, 2008, 2009 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 3, 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 COPYING3.  If not see
21 #<http://www.gnu.org/licenses/>.
22
23 # --------------------------------
24 # Initialization and sanity checks
25 # --------------------------------
26
27 AC_PREREQ(2.59)
28 AC_INIT
29 AC_CONFIG_SRCDIR(tree.c)
30 AC_CONFIG_HEADER(auto-host.h:config.in)
31
32 gcc_version=`cat $srcdir/BASE-VER`
33
34 # Determine the host, build, and target systems
35 AC_CANONICAL_BUILD
36 AC_CANONICAL_HOST
37 AC_CANONICAL_TARGET
38
39 # Determine the noncanonical target name, for directory use.
40 ACX_NONCANONICAL_TARGET
41
42 # Determine the target- and build-specific subdirectories
43 GCC_TOPLEV_SUBDIRS
44
45 # Set program_transform_name
46 AC_ARG_PROGRAM
47
48 # Check for bogus environment variables.
49 # Test if LIBRARY_PATH contains the notation for the current directory
50 # since this would lead to problems installing/building glibc.
51 # LIBRARY_PATH contains the current directory if one of the following
52 # is true:
53 # - one of the terminals (":" and ";") is the first or last sign
54 # - two terminals occur directly after each other
55 # - the path contains an element with a dot in it
56 AC_MSG_CHECKING(LIBRARY_PATH variable)
57 changequote(,)dnl
58 case ${LIBRARY_PATH} in
59   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
60     library_path_setting="contains current directory"
61     ;;
62   *)
63     library_path_setting="ok"
64     ;;
65 esac
66 changequote([,])dnl
67 AC_MSG_RESULT($library_path_setting)
68 if test "$library_path_setting" != "ok"; then
69 AC_MSG_ERROR([
70 *** LIBRARY_PATH shouldn't contain the current directory when
71 *** building gcc. Please change the environment variable
72 *** and run configure again.])
73 fi
74
75 # Test if GCC_EXEC_PREFIX contains the notation for the current directory
76 # since this would lead to problems installing/building glibc.
77 # GCC_EXEC_PREFIX contains the current directory if one of the following
78 # is true:
79 # - one of the terminals (":" and ";") is the first or last sign
80 # - two terminals occur directly after each other
81 # - the path contains an element with a dot in it
82 AC_MSG_CHECKING(GCC_EXEC_PREFIX variable)
83 changequote(,)dnl
84 case ${GCC_EXEC_PREFIX} in
85   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
86     gcc_exec_prefix_setting="contains current directory"
87     ;;
88   *)
89     gcc_exec_prefix_setting="ok"
90     ;;
91 esac
92 changequote([,])dnl
93 AC_MSG_RESULT($gcc_exec_prefix_setting)
94 if test "$gcc_exec_prefix_setting" != "ok"; then
95 AC_MSG_ERROR([
96 *** GCC_EXEC_PREFIX shouldn't contain the current directory when
97 *** building gcc. Please change the environment variable
98 *** and run configure again.])
99 fi
100
101 # -----------
102 # Directories
103 # -----------
104
105 # Specify the local prefix
106 local_prefix=
107 AC_ARG_WITH(local-prefix,
108 [  --with-local-prefix=DIR specifies directory to put local include],
109 [case "${withval}" in
110 yes)    AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
111 no)     ;;
112 *)      local_prefix=$with_local_prefix ;;
113 esac])
114
115 # Default local prefix if it is empty
116 if test x$local_prefix = x; then
117         local_prefix=/usr/local
118 fi
119
120 # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only
121 # passed in by the toplevel make and thus we'd get different behavior
122 # depending on where we built the sources.
123 gcc_gxx_include_dir=
124 # Specify the g++ header file directory
125 AC_ARG_WITH(gxx-include-dir,
126 [  --with-gxx-include-dir=DIR
127                           specifies directory to put g++ header files],
128 [case "${withval}" in
129 yes)    AC_MSG_ERROR(bad value ${withval} given for g++ include directory) ;;
130 no)     ;;
131 *)      gcc_gxx_include_dir=$with_gxx_include_dir ;;
132 esac])
133
134 # This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
135 if test x${gcc_gxx_include_dir} = x; then
136   if test x${enable_version_specific_runtime_libs} = xyes; then
137     gcc_gxx_include_dir='${libsubdir}/include/c++'
138   else
139     libstdcxx_incdir='include/c++/$(version)'
140     if test x$host != x$target; then
141        libstdcxx_incdir="$target_alias/$libstdcxx_incdir"
142     fi
143     gcc_gxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libstdcxx_incdir"
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 gnu_ld=`if test x"$gnu_ld_flag" = x"yes"; then echo 1; else echo 0; fi`
207 AC_DEFINE_UNQUOTED(HAVE_GNU_LD, $gnu_ld, [Define if using GNU ld.])
208
209 AC_MSG_CHECKING([whether a default linker was specified])
210 if test x"${DEFAULT_LINKER+set}" = x"set"; then
211   if test x"$gnu_ld_flag" = x"no"; then
212     AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
213   else
214     AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
215   fi
216 else
217   AC_MSG_RESULT(no)
218 fi
219
220 # With demangler in GNU ld
221 AC_ARG_WITH(demangler-in-ld,
222 [  --with-demangler-in-ld  try to use demangler in GNU ld.],
223 demangler_in_ld="$with_demangler_in_ld",
224 demangler_in_ld=no)
225
226 # ----------------------
227 # Find default assembler
228 # ----------------------
229
230 # With GNU as
231 AC_ARG_WITH(gnu-as,
232 [  --with-gnu-as           arrange to work with GNU as],
233 gas_flag="$with_gnu_as",
234 gas_flag=no)
235
236 AC_ARG_WITH(as,
237 [  --with-as               arrange to use the specified as (full pathname)],
238 DEFAULT_ASSEMBLER="$with_as")
239 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
240   if test ! -x "$DEFAULT_ASSEMBLER"; then
241     AC_MSG_ERROR([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
242   elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
243     gas_flag=yes
244   fi
245   AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
246         [Define to enable the use of a default assembler.])
247 fi
248
249 gnu_as=`if test x"$gas_flag" = x"yes"; then echo 1; else echo 0; fi`
250 AC_DEFINE_UNQUOTED(HAVE_GNU_AS, $gnu_as, [Define if using GNU as.])
251
252 AC_MSG_CHECKING([whether a default assembler was specified])
253 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
254   if test x"$gas_flag" = x"no"; then
255     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
256   else
257     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
258   fi
259 else
260   AC_MSG_RESULT(no)
261 fi
262
263 # ---------------
264 # Find C compiler
265 # ---------------
266
267 # If a non-executable a.out is present (e.g. created by GNU as above even if
268 # invoked with -v only), the IRIX 6 native ld just overwrites the existing
269 # file, even when creating an executable, so an execution test fails.
270 # Remove possible default executable files to avoid this.
271 #
272 # FIXME: This really belongs into AC_PROG_CC and can be removed once
273 # Autoconf includes it.
274 rm -f a.out a.exe b.out
275
276 # Find the native compiler
277 AC_PROG_CC
278 AM_PROG_CC_C_O
279 AC_PROG_CXX
280 ACX_PROG_GNAT([-I"$srcdir"/ada])
281
282 # autoconf is lame and doesn't give us any substitution variable for this.
283 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
284   NO_MINUS_C_MINUS_O=yes
285 else
286   OUTPUT_OPTION='-o $@'
287 fi
288 AC_SUBST(NO_MINUS_C_MINUS_O)
289 AC_SUBST(OUTPUT_OPTION)
290
291 # Remove the -O2: for historical reasons, unless bootstrapping we prefer
292 # optimizations to be activated explicitly by the toplevel.
293 case "$CC" in
294   */prev-gcc/xgcc*) ;;
295   *) CFLAGS=`echo $CFLAGS | sed "s/-O[[s0-9]]* *//" ` ;;
296 esac
297 AC_SUBST(CFLAGS)
298
299 # -------------------------
300 # Check C compiler features
301 # -------------------------
302
303 AC_USE_SYSTEM_EXTENSIONS
304 AC_PROG_CPP
305 AC_C_INLINE
306
307 # sizeof(char) is 1 by definition.
308 AC_CHECK_SIZEOF(void *)
309 AC_CHECK_SIZEOF(short)
310 AC_CHECK_SIZEOF(int)
311 AC_CHECK_SIZEOF(long)
312 AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
313 AC_CHECK_TYPES([__int64], [AC_CHECK_SIZEOF(__int64)])
314
315 # ---------------------
316 # Warnings and checking
317 # ---------------------
318
319 # Check $CC warning features (if it's GCC).
320 # We want to use -pedantic, but we don't want warnings about
321 # * 'long long'
322 # * variadic macros
323 # * overlong strings
324 # So, we only use -pedantic if we can disable those warnings.
325
326 ACX_PROG_CC_WARNING_OPTS(
327         m4_quote(m4_do([-W -Wall -Wwrite-strings -Wcast-qual])), [loose_warn])
328 ACX_PROG_CC_WARNING_OPTS(
329         m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
330         [c_loose_warn])
331 ACX_PROG_CC_WARNING_OPTS(
332         m4_quote(m4_do([-Wmissing-format-attribute])), [strict_warn])
333 ACX_PROG_CC_WARNING_OPTS(
334         m4_quote(m4_do([-Wold-style-definition -Wc++-compat])), [c_strict_warn])
335 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(
336         m4_quote(m4_do([-Wno-long-long -Wno-variadic-macros ], 
337                        [-Wno-overlength-strings])), [strict_warn])
338 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual], [strict_warn])
339
340 # The above macros do nothing if the compiler is not GCC.  However, the
341 # Makefile has more goo to add other flags, so these variables are used
342 # to enable warnings only for GCC.
343 warn_cflags=
344 warn_cxxflags=
345 if test "x$GCC" = "xyes"; then
346   warn_cflags='$(GCC_WARN_CFLAGS)'
347   warn_cxxflags='$(GCC_WARN_CXXFLAGS)'
348 fi
349 AC_SUBST(warn_cflags)
350 AC_SUBST(warn_cxxflags)
351
352 # Enable expensive internal checks
353 is_release=
354 if test x"`cat $srcdir/DEV-PHASE`" != xexperimental; then
355   is_release=yes
356 fi
357
358 AC_ARG_ENABLE(checking,
359 [  --enable-checking[=LIST]
360                           enable expensive run-time checks.  With LIST,
361                           enable only specific categories of checks.
362                           Categories are: yes,no,all,none,release.
363                           Flags are: assert,df,fold,gc,gcac,gimple,misc,
364                           rtlflag,rtl,runtime,tree,valgrind,types.],
365 [ac_checking_flags="${enableval}"],[
366 # Determine the default checks.
367 if test x$is_release = x ; then
368   ac_checking_flags=yes
369 else
370   ac_checking_flags=release
371 fi])
372 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
373 for check in release $ac_checking_flags
374 do
375         case $check in
376         # these set all the flags to specific states
377         yes)            ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking= ;
378                         ac_fold_checking= ; ac_gc_checking=1 ;
379                         ac_gc_always_collect= ; ac_gimple_checking=1 ; ac_rtl_checking= ;
380                         ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
381                         ac_tree_checking=1 ; ac_valgrind_checking= ;
382                         ac_types_checking=1 ;;
383         no|none)        ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
384                         ac_fold_checking= ; ac_gc_checking= ;
385                         ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
386                         ac_rtlflag_checking= ; ac_runtime_checking= ;
387                         ac_tree_checking= ; ac_valgrind_checking= ;
388                         ac_types_checking= ;;
389         all)            ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ;
390                         ac_fold_checking=1 ; ac_gc_checking=1 ;
391                         ac_gc_always_collect=1 ; ac_gimple_checking=1 ; ac_rtl_checking=1 ;
392                         ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
393                         ac_tree_checking=1 ; ac_valgrind_checking= ;
394                         ac_types_checking=1 ;;
395         release)        ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ;
396                         ac_fold_checking= ; ac_gc_checking= ;
397                         ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
398                         ac_rtlflag_checking= ; ac_runtime_checking=1 ;
399                         ac_tree_checking= ; ac_valgrind_checking= ;
400                         ac_types_checking= ;;
401         # these enable particular checks
402         assert)         ac_assert_checking=1 ;;
403         df)             ac_df_checking=1 ;;
404         fold)           ac_fold_checking=1 ;;
405         gc)             ac_gc_checking=1 ;;
406         gcac)           ac_gc_always_collect=1 ;;
407         gimple)         ac_gimple_checking=1 ;;
408         misc)           ac_checking=1 ;;
409         rtl)            ac_rtl_checking=1 ;;
410         rtlflag)        ac_rtlflag_checking=1 ;;
411         runtime)        ac_runtime_checking=1 ;;
412         tree)           ac_tree_checking=1 ;;
413         types)          ac_types_checking=1 ;;
414         valgrind)       ac_valgrind_checking=1 ;;
415         *)      AC_MSG_ERROR(unknown check category $check) ;;
416         esac
417 done
418 IFS="$ac_save_IFS"
419
420 nocommon_flag=""
421 if test x$ac_checking != x ; then
422   AC_DEFINE(ENABLE_CHECKING, 1,
423 [Define if you want more run-time sanity checks.  This one gets a grab
424    bag of miscellaneous but relatively cheap checks.])
425   nocommon_flag=-fno-common
426 fi
427 AC_SUBST(nocommon_flag)
428 if test x$ac_df_checking != x ; then
429   AC_DEFINE(ENABLE_DF_CHECKING, 1,
430 [Define if you want more run-time sanity checks for dataflow.])
431 fi
432 if test x$ac_assert_checking != x ; then
433   AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
434 [Define if you want assertions enabled.  This is a cheap check.])
435 fi
436 if test x$ac_gimple_checking != x ; then
437   AC_DEFINE(ENABLE_GIMPLE_CHECKING, 1,
438 [Define if you want operations on GIMPLE (the basic data structure of
439 the high-level optimizers) to be checked for dynamic type safety at
440 runtime.  This is moderately expensive.])
441 fi
442 GCC_TARGET_TEMPLATE(ENABLE_RUNTIME_CHECKING)
443 if test x$ac_runtime_checking != x ; then
444   AC_DEFINE(ENABLE_RUNTIME_CHECKING, 1,
445 [Define if you want runtime assertions enabled.  This is a cheap check.])
446 fi
447 if test x$ac_tree_checking != x ; then
448   AC_DEFINE(ENABLE_TREE_CHECKING, 1,
449 [Define if you want all operations on trees (the basic data
450    structure of the front ends) to be checked for dynamic type safety
451    at runtime.  This is moderately expensive.  The tree browser debugging
452    routines will also be enabled by this option.
453    ])
454   TREEBROWSER=tree-browser.o
455 fi
456 if test x$ac_types_checking != x ; then
457   AC_DEFINE(ENABLE_TYPES_CHECKING, 1,
458 [Define if you want all gimple types to be verified after gimplifiation.
459    This is cheap.
460    ])
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_valgrind_checking != 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_PREPROC_IFELSE([AC_LANG_SOURCE(
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_PREPROC_IFELSE([AC_LANG_SOURCE(
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 # Enable code coverage collection
546 AC_ARG_ENABLE(coverage,
547 [  --enable-coverage[=LEVEL]
548                           enable compiler's code coverage collection.
549                           Use to measure compiler performance and locate
550                           unused parts of the compiler. With LEVEL, specify
551                           optimization. Values are opt, noopt,
552                           default is noopt],
553 [case "${enableval}" in
554   yes|noopt)
555     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O0"
556     ;;
557   opt)
558     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O2"
559     ;;
560   no)
561     # a.k.a. --disable-coverage
562     coverage_flags=""
563     ;;
564   *)
565     AC_MSG_ERROR(unknown coverage setting $enableval)
566     ;;
567 esac],
568 [coverage_flags=""])
569 AC_SUBST(coverage_flags)
570
571 AC_ARG_ENABLE(gather-detailed-mem-stats, 
572 [  --enable-gather-detailed-mem-stats         enable detailed memory allocation stats gathering], [],
573 [enable_gather_detailed_mem_stats=no])
574 if test x$enable_gather_detailed_mem_stats = xyes ; then
575   AC_DEFINE(GATHER_STATISTICS, 1,
576         [Define to enable detailed memory allocation stats gathering.])
577 fi
578
579 # -------------------------------
580 # Miscenalleous configure options
581 # -------------------------------
582
583 # See if we are building gcc with C++.
584 AC_ARG_ENABLE(build-with-cxx,
585 [  --enable-build-with-cxx build with C++ compiler instead of C compiler],
586 ENABLE_BUILD_WITH_CXX=$enableval,
587 ENABLE_BUILD_WITH_CXX=no)
588 AC_SUBST(ENABLE_BUILD_WITH_CXX)
589
590 # With stabs
591 AC_ARG_WITH(stabs,
592 [  --with-stabs            arrange to use stabs instead of host debug format],
593 stabs="$with_stabs",
594 stabs=no)
595
596 # Determine whether or not multilibs are enabled.
597 AC_ARG_ENABLE(multilib,
598 [  --enable-multilib       enable library support for multiple ABIs],
599 [], [enable_multilib=yes])
600 AC_SUBST(enable_multilib)
601
602 # Enable __cxa_atexit for C++.
603 AC_ARG_ENABLE(__cxa_atexit,
604 [  --enable-__cxa_atexit   enable __cxa_atexit for C++],
605 [], [])
606
607 # Enable C extension for decimal float if target supports it.
608 AC_ARG_ENABLE(decimal-float,
609 [  --enable-decimal-float={no,yes,bid,dpd}
610                         enable decimal float extension to C.  Selecting 'bid'
611                         or 'dpd' choses which decimal floating point format
612                         to use],
613 [
614   case $enable_decimal_float in
615     yes | no | bid | dpd) ;;
616     *) AC_MSG_ERROR(['$enable_decimal_float' is an invalid value for --enable-decimal-float.
617 Valid choices are 'yes', 'bid', 'dpd', and 'no'.]) ;;
618   esac
619 ],
620 [
621   case $target in
622     powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux*)
623       enable_decimal_float=yes
624       ;;
625     *)
626       AC_MSG_WARN(decimal float is not supported for this target, ignored)
627       enable_decimal_float=no
628       ;;
629   esac
630 ])
631
632 dfp=`if test $enable_decimal_float != no; then echo 1; else echo 0; fi`
633 AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_FLOAT, $dfp,
634 [Define to 1 to enable decimal float extension to C.])
635
636 # x86's use BID format instead of DPD
637 case x$enable_decimal_float in
638   xyes)
639     case $target in
640       i?86*-*-linux* | x86_64*-*-linux*)
641         enable_decimal_float=bid
642         ;;
643       *)
644         enable_decimal_float=dpd
645         ;;
646     esac
647     ;;
648   xno)
649     # ENABLE_DECIMAL_FLOAT is set to 0. But we have to have proper
650     # dependency on libdecnumber.
651     enable_decimal_float=dpd
652     ;;
653 esac
654 AC_SUBST(enable_decimal_float)
655
656 bid=`if test $enable_decimal_float = bid; then echo 1; else echo 0; fi`
657 AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_BID_FORMAT, $bid,
658 [Define to 1 to specify that we are using the BID decimal floating
659 point format instead of DPD])
660
661 # Enable C extension for fixed-point arithmetic.
662 AC_ARG_ENABLE(fixed-point,
663 [  --enable-fixed-point    enable fixed-point arithmetic extension to C],
664 [
665 ],
666 [
667   case $target in
668     mips*-*-*)
669       case $host in
670         mips*-sgi-irix*)
671           AC_MSG_WARN(fixed-point is not supported on IRIX, ignored)
672           enable_fixed_point=no
673           ;;
674         *)
675           enable_fixed_point=yes
676           ;;
677       esac
678       ;;
679     *)
680       AC_MSG_WARN(fixed-point is not supported for this target, ignored)
681       enable_fixed_point=no
682       ;;
683   esac
684 ])
685 AC_SUBST(enable_fixed_point)
686
687 fixedpoint=`if test $enable_fixed_point = yes; then echo 1; else echo 0; fi`
688 AC_DEFINE_UNQUOTED(ENABLE_FIXED_POINT, $fixedpoint,
689 [Define to 1 to enable fixed-point arithmetic extension to C.])
690
691 # Enable threads
692 # Pass with no value to take the default
693 # Pass with a value to specify a thread package
694 AC_ARG_ENABLE(threads,
695 [  --enable-threads        enable thread usage for target GCC
696   --enable-threads=LIB    use LIB thread package for target GCC],,
697 [enable_threads=''])
698
699 AC_ARG_ENABLE(tls,
700 [  --enable-tls            enable or disable generation of tls code
701                           overriding the assembler check for tls support],
702 [
703   case $enable_tls in
704     yes | no) ;;
705     *) AC_MSG_ERROR(['$enable_tls' is an invalid value for --enable-tls.
706 Valid choices are 'yes' and 'no'.]) ;;
707   esac
708 ], [enable_tls=''])
709
710 AC_ARG_ENABLE(objc-gc,
711 [  --enable-objc-gc       enable the use of Boehm's garbage collector with
712                           the GNU Objective-C runtime],
713 if test x$enable_objc_gc = xno; then
714         objc_boehm_gc=''
715 else
716         objc_boehm_gc=1
717 fi,
718 objc_boehm_gc='')
719
720 AC_ARG_WITH(dwarf2,
721 [  --with-dwarf2           force the default debug format to be DWARF 2],
722 dwarf2="$with_dwarf2",
723 dwarf2=no)
724
725 AC_ARG_ENABLE(shared,
726 [  --disable-shared        don't provide a shared libgcc],
727 [
728   case $enable_shared in
729   yes | no) ;;
730   *)
731     enable_shared=no
732     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
733     for pkg in $enableval; do
734       if test "X$pkg" = "Xgcc" || test "X$pkg" = "Xlibgcc"; then
735         enable_shared=yes
736       fi
737     done
738     IFS="$ac_save_ifs"
739     ;;
740   esac
741 ], [enable_shared=yes])
742 AC_SUBST(enable_shared)
743
744 AC_ARG_WITH(build-sysroot, 
745   [  --with-build-sysroot=sysroot
746                           use sysroot as the system root during the build])
747
748 AC_ARG_WITH(sysroot,
749 [  --with-sysroot[=DIR] Search for usr/lib, usr/include, et al, within DIR.],
750 [
751  case ${with_sysroot} in
752  yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
753  *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
754  esac
755    
756  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
757  CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
758         
759  if test "x$prefix" = xNONE; then
760   test_prefix=/usr/local
761  else
762   test_prefix=$prefix
763  fi
764  if test "x$exec_prefix" = xNONE; then
765   test_exec_prefix=$test_prefix
766  else
767   test_exec_prefix=$exec_prefix
768  fi
769  case ${TARGET_SYSTEM_ROOT} in
770  "${test_prefix}"|"${test_prefix}/"*|\
771  "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
772  '${prefix}'|'${prefix}/'*|\
773  '${exec_prefix}'|'${exec_prefix}/'*)
774    t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
775    TARGET_SYSTEM_ROOT_DEFINE="$t"
776    ;;
777  esac
778 ], [
779  TARGET_SYSTEM_ROOT=
780  TARGET_SYSTEM_ROOT_DEFINE=
781  CROSS_SYSTEM_HEADER_DIR='$(gcc_tooldir)/sys-include'
782 ])
783 AC_SUBST(TARGET_SYSTEM_ROOT)
784 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
785 AC_SUBST(CROSS_SYSTEM_HEADER_DIR)
786
787 # Build with intermodule optimisations
788 AC_ARG_ENABLE(intermodule,
789 [  --enable-intermodule    build the compiler in one step],
790 [case ${enable_intermodule} in
791   yes) onestep="-onestep";;
792   *) onestep="";;
793 esac],
794 [onestep=""])
795 AC_SUBST(onestep)
796
797 ACX_PKGVERSION([GCC])
798 ACX_BUGURL([http://gcc.gnu.org/bugs.html])
799
800 # Sanity check enable_languages in case someone does not run the toplevel
801 # configure # script.
802 AC_ARG_ENABLE(languages,
803 [  --enable-languages=LIST specify which front-ends to build],
804 [case ,${enable_languages}, in
805        ,,|,yes,)
806                 # go safe -- we cannot be much sure without the toplevel
807                 # configure's
808                 # analysis of which target libs are present and usable
809                 enable_languages=c
810                 ;;
811          *,all,*)
812                 AC_MSG_ERROR([only the toplevel supports --enable-languages=all])
813                 ;;
814         *,c,*)
815                 ;;
816         *)
817                 enable_languages=c,${enable_languages}
818                 ;;
819 esac],
820 [enable_languages=c])
821
822 AC_ARG_WITH(multilib-list,
823 [  --with-multilib-list    Select multilibs (SH only)],
824 :,
825 with_multilib_list=default)
826
827 # -------------------------
828 # Checks for other programs
829 # -------------------------
830
831 AC_PROG_MAKE_SET
832
833 # Find some useful tools
834 AC_PROG_AWK
835 # We need awk to create options.c and options.h.
836 # Bail out if it's missing.
837 case ${AWK} in
838   "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
839 esac
840
841 gcc_AC_PROG_LN_S
842 ACX_PROG_LN($LN_S)
843 AC_PROG_RANLIB
844 case "${host}" in
845 *-*-darwin*)
846   # By default, the Darwin ranlib will not treat common symbols as
847   # definitions when  building the archive table of contents.  Other 
848   # ranlibs do that; pass an option to the Darwin ranlib that makes
849   # it behave similarly.
850   ranlib_flags="-c" 
851   ;;
852 *)
853   ranlib_flags=""
854 esac
855 AC_SUBST(ranlib_flags)
856      
857 gcc_AC_PROG_INSTALL
858
859 # See if cmp has --ignore-initial.
860 gcc_AC_PROG_CMP_IGNORE_INITIAL
861
862 # See if we have the mktemp command.
863 AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
864
865 # See if makeinfo has been installed and is modern enough
866 # that we can use it.
867 ACX_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
868   [GNU texinfo.* \([0-9][0-9.]*\)],
869   [4.[7-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
870 if test $gcc_cv_prog_makeinfo_modern = no; then
871   AC_MSG_WARN([
872 *** Makeinfo is missing or too old.
873 *** Info documentation will not be built.])
874   BUILD_INFO=
875 else
876   BUILD_INFO=info
877 fi
878 AC_SUBST(BUILD_INFO)
879
880 # Is pod2man recent enough to regenerate manpages?
881 AC_MSG_CHECKING([for recent Pod::Man])
882 if (perl -e 'use 1.10 Pod::Man') >/dev/null 2>&1; then
883   AC_MSG_RESULT(yes)
884   GENERATED_MANPAGES=generated-manpages
885 else
886   AC_MSG_RESULT(no)
887   GENERATED_MANPAGES=
888 fi
889 AC_SUBST(GENERATED_MANPAGES)
890
891 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
892
893 # How about lex?
894 dnl Don't use AC_PROG_LEX; we insist on flex.
895 dnl LEXLIB is not useful in gcc.
896 AC_CHECK_PROGS([FLEX], flex, [$MISSING flex])
897
898 # Bison?
899 AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
900
901 # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
902 # check for build == host before using them.
903
904 # NM
905 if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \
906   && test -d ../binutils ; then
907   NM='$(objdir)/../binutils/nm-new'
908 else
909   AC_CHECK_PROG(NM, nm, nm, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing nm)
910 fi
911
912 # AR
913 if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \
914   && test -d ../binutils ; then
915   AR='$(objdir)/../binutils/ar'
916 else
917   AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar)
918 fi
919
920
921 # --------------------
922 # Checks for C headers
923 # --------------------
924
925 # Need to reject headers which give warnings, so that the -Werror bootstrap
926 # works later. *sigh*  This needs to come before all header checks.
927 AC_PROG_CPP_WERROR
928
929 AC_HEADER_STDC
930 AC_HEADER_TIME
931 ACX_HEADER_STRING
932 AC_HEADER_SYS_WAIT
933 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
934                  fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
935                  sys/resource.h sys/param.h sys/times.h sys/stat.h \
936                  direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
937
938 # Check for thread headers.
939 AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
940 AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
941
942 # These tests can't be done till we know if we have limits.h.
943 gcc_AC_C_CHAR_BIT
944 AC_C_BIGENDIAN
945
946 # --------
947 # UNSORTED
948 # --------
949
950
951 # These libraries may be used by collect2.
952 # We may need a special search path to get them linked.
953 AC_CACHE_CHECK(for collect2 libraries, gcc_cv_collect2_libs,
954 [save_LIBS="$LIBS"
955 for libs in '' -lld -lmld \
956                 '-L/usr/lib/cmplrs/cc2.11 -lmld' \
957                 '-L/usr/lib/cmplrs/cc3.11 -lmld'
958 do
959         LIBS="$libs"
960         AC_TRY_LINK_FUNC(ldopen,
961                 [gcc_cv_collect2_libs="$libs"; break])
962 done
963 LIBS="$save_LIBS"
964 test -z "$gcc_cv_collect2_libs" && gcc_cv_collect2_libs='none required'])
965 case $gcc_cv_collect2_libs in
966         "none required")        ;;
967         *)      COLLECT2_LIBS=$gcc_cv_collect2_libs ;;
968 esac
969 AC_SUBST(COLLECT2_LIBS)
970
971 # When building Ada code on Alpha, we need exc_resume which is usually in
972 # -lexc.  So test for it.
973 save_LIBS="$LIBS"
974 LIBS=
975 AC_SEARCH_LIBS(exc_resume, exc)
976 GNAT_LIBEXC="$LIBS"
977 LIBS="$save_LIBS"
978 AC_SUBST(GNAT_LIBEXC)
979
980 # Some systems put ldexp and frexp in libm instead of libc; assume
981 # they're both in the same place.  jcf-dump needs them.
982 save_LIBS="$LIBS"
983 LIBS=
984 AC_SEARCH_LIBS(ldexp, m)
985 LDEXP_LIB="$LIBS"
986 LIBS="$save_LIBS"
987 AC_SUBST(LDEXP_LIB)
988
989 # Use <inttypes.h> only if it exists,
990 # doesn't clash with <sys/types.h>, and declares intmax_t.
991 AC_MSG_CHECKING(for inttypes.h)
992 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
993 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
994 [[#include <sys/types.h>
995 #include <inttypes.h>]],
996   [[intmax_t i = -1;]])],
997   [gcc_cv_header_inttypes_h=yes],
998   [gcc_cv_header_inttypes_h=no])])
999 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
1000 if test $gcc_cv_header_inttypes_h = yes; then
1001   AC_DEFINE(HAVE_INTTYPES_H, 1,
1002         [Define if you have a working <inttypes.h> header file.])
1003 fi
1004
1005 dnl Disabled until we have a complete test for buggy enum bitfields.
1006 dnl gcc_AC_C_ENUM_BF_UNSIGNED
1007
1008 define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl
1009   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl
1010   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl
1011   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
1012   putchar_unlocked putc_unlocked)
1013 AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoll atoq \
1014         sysconf strsignal getrusage nl_langinfo \
1015         gettimeofday mbstowcs wcswidth mmap mincore setlocale \
1016         gcc_UNLOCKED_FUNCS)
1017
1018 if test x$ac_cv_func_mbstowcs = xyes; then
1019   AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
1020 [    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
1021 int main()
1022 {
1023   mbstowcs(0, "", 0);
1024   return 0;
1025 }]])],
1026     [gcc_cv_func_mbstowcs_works=yes],
1027     [gcc_cv_func_mbstowcs_works=no],
1028     [gcc_cv_func_mbstowcs_works=yes])])
1029   if test x$gcc_cv_func_mbstowcs_works = xyes; then
1030     AC_DEFINE(HAVE_WORKING_MBSTOWCS, 1,
1031   [Define this macro if mbstowcs does not crash when its
1032    first argument is NULL.])
1033   fi
1034 fi
1035
1036 AC_CHECK_TYPE(ssize_t, int)
1037 AC_CHECK_TYPE(caddr_t, char *)
1038
1039 gcc_AC_FUNC_MMAP_BLACKLIST
1040
1041 case "${host}" in
1042 *-*-*vms*)
1043   # Under VMS, vfork works very differently than on Unix. The standard test 
1044   # won't work, and it isn't easily adaptable. It makes more sense to
1045   # just force it.
1046   ac_cv_func_vfork_works=yes
1047   ;;
1048 esac
1049 AC_FUNC_FORK
1050
1051 AM_ICONV
1052 # Until we have in-tree GNU iconv:
1053 LIBICONV_DEP=
1054 AC_SUBST(LIBICONV_DEP)
1055
1056 AM_LC_MESSAGES
1057
1058 AM_LANGINFO_CODESET
1059
1060 # We will need to find libiberty.h and ansidecl.h
1061 saved_CFLAGS="$CFLAGS"
1062 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
1063 gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \
1064         strsignal strstr strverscmp \
1065         errno snprintf vsnprintf vasprintf malloc realloc calloc \
1066         free basename getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[
1067 #include "ansidecl.h"
1068 #include "system.h"])
1069
1070 gcc_AC_CHECK_DECLS(getrlimit setrlimit getrusage, , ,[
1071 #include "ansidecl.h"
1072 #include "system.h"
1073 #ifdef HAVE_SYS_RESOURCE_H
1074 #include <sys/resource.h>
1075 #endif
1076 ])
1077
1078 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1079 #include "ansidecl.h"
1080 #include "system.h"
1081 #ifdef HAVE_SYS_RESOURCE_H
1082 #include <sys/resource.h>
1083 #endif
1084 ]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
1085 [Define to `long' if <sys/resource.h> doesn't define.])])
1086
1087 # On AIX 5.2, <ldfcn.h> conflicts with <fcntl.h>, as both define incompatible
1088 # FREAD and FWRITE macros.  Fortunately, for GCC's single usage of ldgetname
1089 # in collect2.c, <fcntl.h> isn't visible, but the configure test below needs
1090 # to undef these macros to get the correct value for HAVE_DECL_LDGETNAME.
1091 gcc_AC_CHECK_DECLS(ldgetname, , ,[
1092 #include "ansidecl.h"
1093 #include "system.h"
1094 #ifdef HAVE_LDFCN_H
1095 #undef FREAD
1096 #undef FWRITE
1097 #include <ldfcn.h>
1098 #endif
1099 ])
1100
1101 gcc_AC_CHECK_DECLS(times, , ,[
1102 #include "ansidecl.h"
1103 #include "system.h"
1104 #ifdef HAVE_SYS_TIMES_H
1105 #include <sys/times.h>
1106 #endif
1107 ])
1108
1109 gcc_AC_CHECK_DECLS(sigaltstack, , ,[
1110 #include "ansidecl.h"
1111 #include "system.h"
1112 #include <signal.h>
1113 ])
1114
1115 # More time-related stuff.
1116 AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [
1117 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1118 #include "ansidecl.h"
1119 #include "system.h"
1120 #ifdef HAVE_SYS_TIMES_H
1121 #include <sys/times.h>
1122 #endif
1123 ]], [[struct tms tms;]])],[ac_cv_struct_tms=yes],[ac_cv_struct_tms=no])])
1124 if test $ac_cv_struct_tms = yes; then
1125   AC_DEFINE(HAVE_STRUCT_TMS, 1,
1126   [Define if <sys/times.h> defines struct tms.])
1127 fi
1128
1129 # use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
1130 # revisit after autoconf 2.50.
1131 AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
1132 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1133 #include "ansidecl.h"
1134 #include "system.h"
1135 ]], [[clock_t x;]])],[gcc_cv_type_clock_t=yes],[gcc_cv_type_clock_t=no])])
1136 if test $gcc_cv_type_clock_t = yes; then
1137   AC_DEFINE(HAVE_CLOCK_T, 1,
1138   [Define if <time.h> defines clock_t.])
1139 fi
1140
1141 # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
1142 CFLAGS="$saved_CFLAGS"
1143
1144 gcc_AC_INITFINI_ARRAY
1145
1146 # mkdir takes a single argument on some systems. 
1147 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
1148
1149 # File extensions
1150 manext='.1'
1151 objext='.o'
1152 AC_SUBST(manext)
1153 AC_SUBST(objext)
1154
1155 # With Setjmp/Longjmp based exception handling.
1156 AC_ARG_ENABLE(sjlj-exceptions,
1157 [  --enable-sjlj-exceptions
1158                           arrange to use setjmp/longjmp exception handling],
1159 [case $target in
1160   *-*-hpux10*)
1161     if test $enableval != yes; then
1162       AC_MSG_WARN([dwarf2 exceptions not supported, sjlj exceptions forced])
1163       enableval=yes
1164     fi
1165     ;;
1166 esac
1167 force_sjlj_exceptions=yes],
1168 [case $target in
1169   *-*-hpux10*)
1170     force_sjlj_exceptions=yes
1171     enableval=yes
1172     ;;
1173   *)
1174     force_sjlj_exceptions=no
1175     ;;
1176 esac])
1177 if test $force_sjlj_exceptions = yes; then
1178   sjlj=`if test $enableval = yes; then echo 1; else echo 0; fi`
1179   AC_DEFINE_UNQUOTED(CONFIG_SJLJ_EXCEPTIONS, $sjlj,
1180     [Define 0/1 to force the choice for exception handling model.])
1181 fi
1182
1183 # For platforms with the unwind ABI which includes an unwind library,
1184 # libunwind, we can choose to use the system libunwind.
1185 # config.gcc also contains tests of with_system_libunwind.
1186 GCC_CHECK_UNWIND_GETIPINFO
1187
1188 # --------------------------------------------------------
1189 # Build, host, and target specific configuration fragments
1190 # --------------------------------------------------------
1191
1192 # Collect build-machine-specific information.
1193 . ${srcdir}/config.build
1194
1195 # Collect host-machine-specific information.
1196 . ${srcdir}/config.host
1197
1198 target_gtfiles=
1199
1200 # Collect target-machine-specific information.
1201 . ${srcdir}/config.gcc
1202
1203 extra_objs="${host_extra_objs} ${extra_objs}"
1204 extra_gcc_objs="${host_extra_gcc_objs} ${extra_gcc_objs}"
1205
1206 # Default the target-machine variables that were not explicitly set.
1207 if test x"$tm_file" = x
1208 then tm_file=$cpu_type/$cpu_type.h; fi
1209
1210 if test x"$extra_headers" = x
1211 then extra_headers=; fi
1212
1213 if test x$md_file = x
1214 then md_file=$cpu_type/$cpu_type.md; fi
1215
1216 if test x$out_file = x
1217 then out_file=$cpu_type/$cpu_type.c; fi
1218
1219 if test x"$tmake_file" = x
1220 then tmake_file=$cpu_type/t-$cpu_type
1221 fi
1222
1223 if test x"$dwarf2" = xyes
1224 then tm_file="$tm_file tm-dwarf2.h"
1225 fi
1226
1227 # Say what files are being used for the output code and MD file.
1228 echo "Using \`$srcdir/config/$out_file' for machine-specific logic."
1229 echo "Using \`$srcdir/config/$md_file' as machine description file."
1230
1231 # If any of the xm_file variables contain nonexistent files, warn
1232 # about them and drop them.
1233
1234 bx=
1235 for x in $build_xm_file; do
1236   if    test -f $srcdir/config/$x
1237   then      bx="$bx $x"
1238   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1239   fi
1240 done
1241 build_xm_file="$bx"
1242
1243 hx=
1244 for x in $host_xm_file; do
1245   if    test -f $srcdir/config/$x
1246   then      hx="$hx $x"
1247   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1248   fi
1249 done
1250 host_xm_file="$hx"
1251
1252 tx=
1253 for x in $xm_file; do
1254   if    test -f $srcdir/config/$x
1255   then      tx="$tx $x"
1256   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1257   fi
1258 done
1259 xm_file="$tx"
1260
1261 count=a
1262 for f in $tm_file; do
1263         count=${count}x
1264 done
1265 if test $count = ax; then
1266         echo "Using \`$srcdir/config/$tm_file' as target machine macro file."
1267 else
1268         echo "Using the following target machine macro files:"
1269         for f in $tm_file; do
1270                 echo "  $srcdir/config/$f"
1271         done
1272 fi
1273
1274 if test x$need_64bit_hwint = xyes; then
1275         AC_DEFINE(NEED_64BIT_HOST_WIDE_INT, 1,
1276 [Define to 1 if HOST_WIDE_INT must be 64 bits wide (see hwint.h).])
1277 fi
1278
1279 if test x$use_long_long_for_widest_fast_int = xyes; then
1280         AC_DEFINE(USE_LONG_LONG_FOR_WIDEST_FAST_INT, 1,
1281 [Define to 1 if the 'long long' (or '__int64') is wider than 'long' but still
1282 efficiently supported by the host hardware.])
1283 fi
1284
1285 count=a
1286 for f in $host_xm_file; do
1287         count=${count}x
1288 done
1289 if test $count = a; then
1290         :
1291 elif test $count = ax; then
1292         echo "Using \`$srcdir/config/$host_xm_file' as host machine macro file."
1293 else
1294         echo "Using the following host machine macro files:"
1295         for f in $host_xm_file; do
1296                 echo "  $srcdir/config/$f"
1297         done
1298 fi
1299 echo "Using ${out_host_hook_obj} for host machine hooks."
1300
1301 if test "$host_xm_file" != "$build_xm_file"; then
1302         count=a
1303         for f in $build_xm_file; do
1304                 count=${count}x
1305         done
1306         if test $count = a; then
1307                 :
1308         elif test $count = ax; then
1309                 echo "Using \`$srcdir/config/$build_xm_file' as build machine macro file."
1310         else
1311                 echo "Using the following build machine macro files:"
1312                 for f in $build_xm_file; do
1313                         echo "  $srcdir/config/$f"
1314                 done
1315         fi
1316 fi
1317
1318 case ${host} in
1319   powerpc*-*-darwin*)
1320     AC_CACHE_CHECK([whether mcontext_t fields have underscores],
1321       gcc_cv_mcontext_underscores,
1322       AC_COMPILE_IFELSE([
1323 #include <sys/cdefs.h>
1324 #include <sys/signal.h>
1325 #include <ucontext.h>
1326 int main() { mcontext_t m; if (m->ss.srr0) return 0; return 0; }
1327 ],
1328         gcc_cv_mcontext_underscores=no, gcc_cv_mcontext_underscores=yes))
1329       if test $gcc_cv_mcontext_underscores = yes; then
1330         AC_DEFINE(HAS_MCONTEXT_T_UNDERSCORES,,dnl
1331           [mcontext_t fields start with __])
1332       fi
1333     ;;
1334 esac
1335
1336 # ---------
1337 # Threading
1338 # ---------
1339
1340 # Check if a valid thread package
1341 case ${enable_threads} in
1342   "" | no)
1343     # No threads
1344     target_thread_file='single'
1345     ;;
1346   yes)
1347     # default
1348     target_thread_file='single'
1349     ;;
1350   aix | dce | gnat | irix | posix | posix95 | rtems | \
1351   single | solaris | vxworks | win32 | mipssde)
1352     target_thread_file=${enable_threads}
1353     ;;
1354   *)
1355     echo "${enable_threads} is an unknown thread package" 1>&2
1356     exit 1
1357     ;;
1358 esac
1359
1360 if test x${thread_file} = x; then
1361   # No thread file set by target-specific clauses in config.gcc,
1362   # so use file chosen by default logic above
1363   thread_file=${target_thread_file}
1364 fi
1365
1366 # Make gthr-default.h if we have a thread file.
1367 gthread_flags=
1368 if test $thread_file != single; then
1369   echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h-t
1370   if diff gthr-default.h-t gthr-default.h 2>/dev/null; then
1371     rm -f gthr-default.h-t
1372   else
1373     mv -f gthr-default.h-t gthr-default.h
1374   fi
1375   gthread_flags=-DHAVE_GTHR_DEFAULT
1376 fi
1377 AC_SUBST(gthread_flags)
1378
1379 # --------
1380 # UNSORTED
1381 # --------
1382
1383 use_cxa_atexit=no
1384 if test x$enable___cxa_atexit = xyes || \
1385    test x$enable___cxa_atexit = x -a x$default_use_cxa_atexit = xyes; then
1386   if test x$host = x$target; then
1387     case $host in
1388       # mingw32 doesn't have __cxa_atexit but uses atexit registration
1389       # keyed to flag_use_cxa_atexit
1390       *-*-mingw32*)
1391         use_cxa_atexit=yes
1392         ;;
1393       *)
1394         AC_CHECK_FUNC(__cxa_atexit,[use_cxa_atexit=yes],
1395           [echo "__cxa_atexit can't be enabled on this target"])
1396         ;;
1397     esac
1398   else
1399     # We can't check for __cxa_atexit when building a cross, so assume
1400     # it is available 
1401     use_cxa_atexit=yes
1402   fi
1403   if test x$use_cxa_atexit = xyes; then
1404     AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 2,
1405       [Define if you want to use __cxa_atexit, rather than atexit, to
1406       register C++ destructors for local statics and global objects.
1407       This is essential for fully standards-compliant handling of
1408       destructors, but requires __cxa_atexit in libc.])
1409   fi
1410 fi
1411
1412 # Look for a file containing extra machine modes.
1413 if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
1414   extra_modes_file='$(srcdir)'/config/${extra_modes}
1415   AC_SUBST(extra_modes_file)
1416   AC_DEFINE_UNQUOTED(EXTRA_MODES_FILE, "config/$extra_modes",
1417   [Define to the name of a file containing a list of extra machine modes
1418    for this architecture.])
1419 fi
1420
1421 # Convert extra_options into a form suitable for Makefile use.
1422 extra_opt_files=
1423 for f in $extra_options; do
1424   extra_opt_files="$extra_opt_files \$(srcdir)/config/$f"
1425 done
1426 AC_SUBST(extra_opt_files)
1427
1428 # auto-host.h is the file containing items generated by autoconf and is
1429 # the first file included by config.h.
1430 # If host=build, it is correct to have bconfig include auto-host.h
1431 # as well.  If host!=build, we are in error and need to do more 
1432 # work to find out the build config parameters.
1433 if test x$host = x$build
1434 then
1435         build_auto=auto-host.h
1436 else
1437         # We create a subdir, then run autoconf in the subdir.
1438         # To prevent recursion we set host and build for the new
1439         # invocation of configure to the build for this invocation
1440         # of configure. 
1441         tempdir=build.$$
1442         rm -rf $tempdir
1443         mkdir $tempdir
1444         cd $tempdir
1445         case ${srcdir} in
1446         /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
1447         *) realsrcdir=../${srcdir};;
1448         esac
1449         saved_CFLAGS="${CFLAGS}"
1450         CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
1451         LDFLAGS="${LDFLAGS_FOR_BUILD}" \
1452         ${realsrcdir}/configure \
1453                 --enable-languages=${enable_languages-all} \
1454                 --target=$target_alias --host=$build_alias --build=$build_alias
1455         CFLAGS="${saved_CFLAGS}"
1456
1457         # We just finished tests for the build machine, so rename
1458         # the file auto-build.h in the gcc directory.
1459         mv auto-host.h ../auto-build.h
1460         cd ..
1461         rm -rf $tempdir
1462         build_auto=auto-build.h
1463 fi
1464 AC_SUBST(build_subdir)
1465
1466 tm_file="${tm_file} defaults.h"
1467 tm_p_file="${tm_p_file} tm-preds.h"
1468 host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
1469 build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
1470 # We don't want ansidecl.h in target files, write code there in ISO/GNU C.
1471 # put this back in temporarily.
1472 xm_file="auto-host.h ansidecl.h ${xm_file}"
1473
1474 # --------
1475 # UNSORTED
1476 # --------
1477
1478 changequote(,)dnl
1479 # Compile in configure arguments.
1480 if test -f configargs.h ; then
1481         # Being re-configured.
1482         gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
1483         gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
1484 else
1485         gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
1486 fi
1487
1488 # Double all backslashes and backslash all quotes to turn
1489 # gcc_config_arguments into a C string.
1490 sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
1491 $gcc_config_arguments
1492 EOF
1493 gcc_config_arguments_str=`cat conftest.out`
1494 rm -f conftest.out
1495
1496 cat > configargs.h <<EOF
1497 /* Generated automatically. */
1498 static const char configuration_arguments[] = "$gcc_config_arguments_str";
1499 static const char thread_model[] = "$thread_file";
1500
1501 static const struct {
1502   const char *name, *value;
1503 } configure_default_options[] = $configure_default_options;
1504 EOF
1505 changequote([,])dnl
1506
1507 changequote(,)dnl
1508 gcc_BASEVER=`cat $srcdir/BASE-VER`
1509 gcc_DEVPHASE=`cat $srcdir/DEV-PHASE`
1510 gcc_DATESTAMP=`cat $srcdir/DATESTAMP`
1511 if test -f $srcdir/REVISION ; then
1512         gcc_REVISION=`cat $srcdir/REVISION`
1513 else
1514         gcc_REVISION=""
1515 fi
1516 cat > plugin-version.h <<EOF
1517 #include "configargs.h"
1518
1519 static char basever[] = "$gcc_BASEVER";
1520 static char datestamp[] = "$gcc_DATESTAMP";
1521 static char devphase[] = "$gcc_DEVPHASE";
1522 static char revision[] = "$gcc_REVISION";
1523
1524 /* FIXME plugins: We should make the version information more precise.
1525    One way to do is to add a checksum. */
1526
1527 static struct plugin_gcc_version gcc_version = {basever, datestamp,
1528                                                 devphase, revision,
1529                                                 configuration_arguments};
1530 EOF
1531 changequote([,])dnl
1532
1533 # Internationalization
1534 ZW_GNU_GETTEXT_SISTER_DIR
1535
1536 # If LIBINTL contains LIBICONV, then clear LIBICONV so we don't get
1537 # -liconv on the link line twice.
1538 case "$LIBINTL" in *$LIBICONV*)
1539         LIBICONV= ;;
1540 esac
1541
1542 AC_ARG_ENABLE(secureplt,
1543 [  --enable-secureplt      enable -msecure-plt by default for PowerPC],
1544 [], [])
1545
1546 AC_ARG_ENABLE(cld,
1547 [  --enable-cld            enable -mcld by default for 32bit x86], [],
1548 [enable_cld=no])
1549
1550 # Windows32 Registry support for specifying GCC installation paths.
1551 AC_ARG_ENABLE(win32-registry,
1552 [  --disable-win32-registry
1553                           disable lookup of installation paths in the
1554                           Registry on Windows hosts
1555   --enable-win32-registry enable registry lookup (default)
1556   --enable-win32-registry=KEY
1557                           use KEY instead of GCC version as the last portion
1558                           of the registry key],,)
1559
1560 case $host_os in
1561   win32 | pe | cygwin* | mingw32* | uwin*)
1562     if test "x$enable_win32_registry" != xno; then
1563       AC_SEARCH_LIBS(RegOpenKeyExA, advapi32,, [enable_win32_registry=no])
1564     fi
1565
1566     if test "x$enable_win32_registry" != xno; then
1567       AC_DEFINE(ENABLE_WIN32_REGISTRY, 1,
1568   [Define to 1 if installation paths should be looked up in the Windows
1569    Registry. Ignored on non-Windows hosts.])
1570
1571       if test "x$enable_win32_registry" != xyes \
1572          && test "x$enable_win32_registry" != x; then
1573         AC_DEFINE_UNQUOTED(WIN32_REGISTRY_KEY, "$enable_win32_registry",
1574   [Define to be the last component of the Windows registry key under which
1575    to look for installation paths.  The full key used will be 
1576    HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
1577    The default is the GCC version number.])
1578       fi
1579     fi
1580   ;;
1581 esac
1582
1583 # Get an absolute path to the GCC top-level source directory
1584 holddir=`${PWDCMD-pwd}`
1585 cd $srcdir
1586 topdir=`${PWDCMD-pwd}`
1587 cd $holddir
1588
1589 # Conditionalize the makefile for this host machine.
1590 xmake_file=
1591 for f in ${host_xmake_file}
1592 do
1593         if test -f ${srcdir}/config/$f
1594         then
1595                 xmake_file="${xmake_file} \$(srcdir)/config/$f"
1596         fi
1597 done
1598
1599 # Conditionalize the makefile for this target machine.
1600 tmake_file_=
1601 for f in ${tmake_file}
1602 do
1603         if test -f ${srcdir}/config/$f
1604         then
1605                 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
1606         fi
1607 done
1608 tmake_file="${tmake_file_}"
1609
1610 out_object_file=`basename $out_file .c`.o
1611
1612 tm_file_list="options.h"
1613 tm_include_list="options.h"
1614 for f in $tm_file; do
1615   case $f in
1616     ./* )
1617        f=`echo $f | sed 's/^..//'`
1618        tm_file_list="${tm_file_list} $f"
1619        tm_include_list="${tm_include_list} $f"
1620        ;;
1621     defaults.h )
1622        tm_file_list="${tm_file_list} \$(srcdir)/$f"
1623        tm_include_list="${tm_include_list} $f"
1624        ;;
1625     * )
1626        tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
1627        tm_include_list="${tm_include_list} config/$f"
1628        ;;
1629   esac
1630 done
1631
1632 tm_p_file_list=
1633 tm_p_include_list=
1634 for f in $tm_p_file; do
1635   case $f in
1636     tm-preds.h )
1637        tm_p_file_list="${tm_p_file_list} $f"
1638        tm_p_include_list="${tm_p_include_list} $f"
1639        ;;
1640     * )
1641        tm_p_file_list="${tm_p_file_list} \$(srcdir)/config/$f"
1642        tm_p_include_list="${tm_p_include_list} config/$f"
1643   esac
1644 done
1645
1646 xm_file_list=
1647 xm_include_list=
1648 for f in $xm_file; do
1649   case $f in
1650     ansidecl.h )
1651        xm_file_list="${xm_file_list} \$(srcdir)/../include/$f"
1652        xm_include_list="${xm_include_list} $f"
1653        ;;
1654     auto-host.h )
1655        xm_file_list="${xm_file_list} $f"
1656        xm_include_list="${xm_include_list} $f"
1657        ;;
1658     * )
1659        xm_file_list="${xm_file_list} \$(srcdir)/config/$f"
1660        xm_include_list="${xm_include_list} config/$f"
1661        ;;
1662   esac
1663 done
1664
1665 host_xm_file_list=
1666 host_xm_include_list=
1667 for f in $host_xm_file; do
1668   case $f in
1669     ansidecl.h )
1670        host_xm_file_list="${host_xm_file_list} \$(srcdir)/../include/$f"
1671        host_xm_include_list="${host_xm_include_list} $f"
1672        ;;
1673     auto-host.h )
1674        host_xm_file_list="${host_xm_file_list} $f"
1675        host_xm_include_list="${host_xm_include_list} $f"
1676        ;;
1677     * )
1678        host_xm_file_list="${host_xm_file_list} \$(srcdir)/config/$f"
1679        host_xm_include_list="${host_xm_include_list} config/$f"
1680        ;;
1681   esac
1682 done
1683
1684 build_xm_file_list=
1685 for f in $build_xm_file; do
1686   case $f in
1687     ansidecl.h )
1688        build_xm_file_list="${build_xm_file_list} \$(srcdir)/../include/$f"
1689        build_xm_include_list="${build_xm_include_list} $f"
1690        ;;
1691     auto-build.h | auto-host.h )
1692        build_xm_file_list="${build_xm_file_list} $f"
1693        build_xm_include_list="${build_xm_include_list} $f"
1694        ;;
1695     * )
1696        build_xm_file_list="${build_xm_file_list} \$(srcdir)/config/$f"
1697        build_xm_include_list="${build_xm_include_list} config/$f"
1698        ;;
1699   esac
1700 done
1701
1702 # Define macro CROSS_DIRECTORY_STRUCTURE in compilation if this is a
1703 # cross-compiler which does not use the native headers and libraries.
1704 # Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
1705 CROSS=                                          AC_SUBST(CROSS)
1706 ALL=all.internal                                AC_SUBST(ALL)
1707 SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' AC_SUBST(SYSTEM_HEADER_DIR)
1708
1709 if test "x$with_build_sysroot" != x; then
1710   build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
1711 else
1712   # This value is used, even on a native system, because 
1713   # CROSS_SYSTEM_HEADER_DIR is just 
1714   # $(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR).
1715   build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)'
1716 fi
1717
1718 if test x$host != x$target
1719 then
1720         CROSS="-DCROSS_DIRECTORY_STRUCTURE"
1721         ALL=all.cross
1722         SYSTEM_HEADER_DIR=$build_system_header_dir
1723         case "$host","$target" in
1724         # Darwin crosses can use the host system's libraries and headers,
1725         # because of the fat library support.  Of course, it must be the
1726         # same version of Darwin on both sides.  Allow the user to
1727         # just say --target=foo-darwin without a version number to mean
1728         # "the version on this system".
1729             *-*-darwin*,*-*-darwin*)
1730                 hostos=`echo $host | sed 's/.*-darwin/darwin/'`
1731                 targetos=`echo $target | sed 's/.*-darwin/darwin/'`
1732                 if test $hostos = $targetos -o $targetos = darwin ; then
1733                     CROSS=
1734                     SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)'
1735                     with_headers=yes
1736                 fi
1737                 ;;
1738
1739             i?86-*-*,x86_64-*-* \
1740             | powerpc*-*-*,powerpc64*-*-*)
1741                 CROSS="$CROSS -DNATIVE_CROSS" ;;
1742         esac
1743 elif test "x$TARGET_SYSTEM_ROOT" != x; then
1744         SYSTEM_HEADER_DIR=$build_system_header_dir 
1745 fi
1746
1747 # If this is a cross-compiler that does not
1748 # have its own set of headers then define
1749 # inhibit_libc
1750
1751 # If this is using newlib, without having the headers available now,
1752 # then define inhibit_libc in LIBGCC2_CFLAGS.
1753 # This prevents libgcc2 from containing any code which requires libc
1754 # support.
1755 : ${inhibit_libc=false}
1756 if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
1757        test x$with_newlib = xyes ; } &&
1758      { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then
1759        inhibit_libc=true
1760 fi
1761 AC_SUBST(inhibit_libc)
1762
1763 # When building gcc with a cross-compiler, we need to adjust things so
1764 # that the generator programs are still built with the native compiler.
1765 # Also, we cannot run fixincludes.
1766
1767 # These are the normal (build=host) settings:
1768 CC_FOR_BUILD='$(CC)'            AC_SUBST(CC_FOR_BUILD)
1769 BUILD_CFLAGS='$(ALL_CFLAGS)'    AC_SUBST(BUILD_CFLAGS)
1770 BUILD_LDFLAGS='$(LDFLAGS)'      AC_SUBST(BUILD_LDFLAGS)
1771 STMP_FIXINC=stmp-fixinc         AC_SUBST(STMP_FIXINC)
1772
1773 # And these apply if build != host, or we are generating coverage data
1774 if test x$build != x$host || test "x$coverage_flags" != x
1775 then
1776     BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
1777     BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
1778 fi
1779
1780 # Expand extra_headers to include complete path.
1781 # This substitutes for lots of t-* files.
1782 extra_headers_list=
1783 # Prepend $(srcdir)/config/${cpu_type}/ to every entry in extra_headers.
1784 for file in ${extra_headers} ; do
1785   extra_headers_list="${extra_headers_list} \$(srcdir)/config/${cpu_type}/${file}"
1786 done
1787
1788 # If use_gcc_tgmath is set, append ginclude/tgmath.h.
1789 if test x"$use_gcc_tgmath" = xyes
1790 then extra_headers_list="${extra_headers_list} \$(srcdir)/ginclude/tgmath.h"
1791 fi
1792
1793 # Define collect2 in Makefile.
1794 case $host_can_use_collect2 in
1795   no) collect2= ;;
1796   *) collect2='collect2$(exeext)' ;;
1797 esac
1798 AC_SUBST([collect2])
1799
1800 # Add a definition of USE_COLLECT2 if system wants one.
1801 case $use_collect2 in
1802   no) use_collect2= ;;
1803   "") ;;
1804   *) 
1805     host_xm_defines="${host_xm_defines} USE_COLLECT2"
1806     xm_defines="${xm_defines} USE_COLLECT2"
1807     case $host_can_use_collect2 in
1808       no)
1809         AC_MSG_ERROR([collect2 is required but cannot be built on this system])
1810         ;;
1811     esac
1812     ;;
1813 esac
1814
1815 # ---------------------------
1816 # Assembler & linker features
1817 # ---------------------------
1818
1819 # During stage 2, ld is actually gcc/collect-ld, which is a small script to
1820 # discern between when to use prev-ld/ld-new and when to use ld/ld-new.
1821 # However when ld-new is first executed from the build tree, libtool will
1822 # relink it as .libs/lt-ld-new, so that it can give it an RPATH that refers
1823 # to the build tree.  While doing this we need to use the previous-stage
1824 # linker, or we have an infinite loop.  The presence of a shell script as
1825 # ld/ld-new, and the fact that the script *uses ld itself*, is what confuses
1826 # the gcc/collect-ld script.  So we need to know how libtool works, or
1827 # exec-tool will fail.
1828
1829 m4_defun([_LT_CONFIG_COMMANDS], [])
1830 AC_PROG_LIBTOOL
1831 AC_SUBST(objdir)
1832 AC_SUBST(enable_fast_install)
1833
1834 # Identify the assembler which will work hand-in-glove with the newly
1835 # built GCC, so that we can examine its features.  This is the assembler
1836 # which will be driven by the driver program.
1837 #
1838 # If build != host, and we aren't building gas in-tree, we identify a
1839 # build->target assembler and hope that it will have the same features
1840 # as the host->target assembler we'll be using.
1841 gcc_cv_gas_major_version=
1842 gcc_cv_gas_minor_version=
1843 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
1844
1845 m4_pattern_allow([AS_FOR_TARGET])dnl
1846 AS_VAR_SET_IF(gcc_cv_as,, [
1847 if test -x "$DEFAULT_ASSEMBLER"; then
1848         gcc_cv_as="$DEFAULT_ASSEMBLER"
1849 elif test -f $gcc_cv_as_gas_srcdir/configure.in \
1850      && test -f ../gas/Makefile \
1851      && test x$build = x$host; then
1852         gcc_cv_as=../gas/as-new$build_exeext
1853 elif test -x as$build_exeext; then
1854         # Build using assembler in the current directory.
1855         gcc_cv_as=./as$build_exeext
1856 elif test -x $AS_FOR_TARGET; then
1857         gcc_cv_as="$AS_FOR_TARGET"
1858 else
1859         AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET)
1860 fi])
1861
1862 ORIGINAL_AS_FOR_TARGET=$gcc_cv_as
1863 AC_SUBST(ORIGINAL_AS_FOR_TARGET)
1864 case "$ORIGINAL_AS_FOR_TARGET" in
1865   ./as | ./as$build_exeext) ;;
1866   *) AC_CONFIG_FILES(as:exec-tool.in, [chmod +x as]) ;;
1867 esac 
1868
1869 AC_MSG_CHECKING(what assembler to use)
1870 if test "$gcc_cv_as" = ../gas/as-new$build_exeext; then
1871   # Single tree build which includes gas.  We want to prefer it
1872   # over whatever linker top-level may have detected, since
1873   # we'll use what we're building after installation anyway.
1874   AC_MSG_RESULT(newly built gas)
1875   in_tree_gas=yes
1876   _gcc_COMPUTE_GAS_VERSION
1877   in_tree_gas_is_elf=no
1878   if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
1879      || (grep 'obj_format = multi' ../gas/Makefile \
1880          && grep 'extra_objects =.* obj-elf' ../gas/Makefile) > /dev/null
1881   then
1882     in_tree_gas_is_elf=yes
1883   fi
1884 else
1885   AC_MSG_RESULT($gcc_cv_as)
1886   in_tree_gas=no
1887 fi
1888
1889 # Identify the linker which will work hand-in-glove with the newly
1890 # built GCC, so that we can examine its features.  This is the linker
1891 # which will be driven by the driver program.
1892 #
1893 # If build != host, and we aren't building gas in-tree, we identify a
1894 # build->target linker and hope that it will have the same features
1895 # as the host->target linker we'll be using.
1896 gcc_cv_gld_major_version=
1897 gcc_cv_gld_minor_version=
1898 gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
1899 gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
1900
1901 AS_VAR_SET_IF(gcc_cv_ld,, [
1902 if test -x "$DEFAULT_LINKER"; then
1903         gcc_cv_ld="$DEFAULT_LINKER"
1904 elif test -f $gcc_cv_ld_gld_srcdir/configure.in \
1905      && test -f ../ld/Makefile \
1906      && test x$build = x$host; then
1907         gcc_cv_ld=../ld/ld-new$build_exeext
1908 elif test -x collect-ld$build_exeext; then
1909         # Build using linker in the current directory.
1910         gcc_cv_ld=./collect-ld$build_exeext
1911 elif test -x $LD_FOR_TARGET; then
1912         gcc_cv_ld="$LD_FOR_TARGET"
1913 else
1914         AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET)
1915 fi])
1916
1917 ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
1918 AC_SUBST(ORIGINAL_LD_FOR_TARGET)
1919 case "$ORIGINAL_LD_FOR_TARGET" in
1920   ./collect-ld | ./collect-ld$build_exeext) ;;
1921   *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
1922 esac 
1923
1924 AC_MSG_CHECKING(what linker to use)
1925 if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
1926         # Single tree build which includes ld.  We want to prefer it
1927         # over whatever linker top-level may have detected, since
1928         # we'll use what we're building after installation anyway.
1929         AC_MSG_RESULT(newly built ld)
1930         in_tree_ld=yes
1931         in_tree_ld_is_elf=no
1932         if (grep 'EMUL = .*elf' ../ld/Makefile \
1933             || grep 'EMUL = .*linux' ../ld/Makefile \
1934             || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then
1935           in_tree_ld_is_elf=yes
1936         fi
1937         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
1938         do
1939 changequote(,)dnl
1940                 gcc_cv_gld_version=`sed -n -e 's/^[     ]*\(VERSION=[0-9]*\.[0-9]*.*\)/\1/p' < $f`
1941                 if test x$gcc_cv_gld_version != x; then
1942                         break
1943                 fi
1944         done
1945         gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
1946         gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
1947 changequote([,])dnl
1948 else
1949         AC_MSG_RESULT($gcc_cv_ld)
1950         in_tree_ld=no
1951 fi
1952
1953 # Figure out what nm we will be using.
1954 gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
1955 AS_VAR_SET_IF(gcc_cv_nm,, [
1956 if test -f $gcc_cv_binutils_srcdir/configure.in \
1957      && test -f ../binutils/Makefile \
1958      && test x$build = x$host; then
1959         gcc_cv_nm=../binutils/nm-new$build_exeext
1960 elif test -x nm$build_exeext; then
1961         gcc_cv_nm=./nm$build_exeext
1962 elif test -x $NM_FOR_TARGET; then
1963         gcc_cv_nm="$NM_FOR_TARGET"
1964 else
1965         AC_PATH_PROG(gcc_cv_nm, $NM_FOR_TARGET)
1966 fi])
1967
1968 AC_MSG_CHECKING(what nm to use)
1969 if test "$gcc_cv_nm" = ../binutils/nm-new$build_exeext; then
1970         # Single tree build which includes binutils.
1971         AC_MSG_RESULT(newly built nm)
1972         in_tree_nm=yes
1973 else
1974         AC_MSG_RESULT($gcc_cv_nm)
1975         in_tree_nm=no
1976 fi
1977
1978 ORIGINAL_NM_FOR_TARGET=$gcc_cv_nm
1979 AC_SUBST(ORIGINAL_NM_FOR_TARGET)
1980 case "$ORIGINAL_NM_FOR_TARGET" in
1981   ./nm | ./nm$build_exeext) ;;
1982   *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;;
1983 esac
1984
1985
1986 # Figure out what objdump we will be using.
1987 AS_VAR_SET_IF(gcc_cv_objdump,, [
1988 if test -f $gcc_cv_binutils_srcdir/configure.in \
1989      && test -f ../binutils/Makefile \
1990      && test x$build = x$host; then
1991         # Single tree build which includes binutils.
1992         gcc_cv_objdump=../binutils/objdump$build_exeext
1993 elif test -x objdump$build_exeext; then
1994         gcc_cv_objdump=./objdump$build_exeext
1995 elif test -x $OBJDUMP_FOR_TARGET; then
1996         gcc_cv_objdump="$OBJDUMP_FOR_TARGET"
1997 else
1998         AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET)
1999 fi])
2000
2001 AC_MSG_CHECKING(what objdump to use)
2002 if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then
2003         # Single tree build which includes binutils.
2004         AC_MSG_RESULT(newly built objdump)
2005 elif test x$gcc_cv_objdump = x; then
2006         AC_MSG_RESULT(not found)
2007 else
2008         AC_MSG_RESULT($gcc_cv_objdump)
2009 fi
2010
2011 # Figure out what readelf we will be using.
2012 AS_VAR_SET_IF(gcc_cv_readelf,, [
2013 if test -f $gcc_cv_binutils_srcdir/configure.in \
2014      && test -f ../binutils/Makefile \
2015      && test x$build = x$host; then
2016         # Single tree build which includes binutils.
2017         gcc_cv_readelf=../binutils/readelf$build_exeext
2018 elif test -x readelf$build_exeext; then
2019         gcc_cv_readelf=./readelf$build_exeext
2020 else
2021         AC_PATH_PROG(gcc_cv_readelf, readelf)
2022 fi])
2023
2024 AC_MSG_CHECKING(what readelf to use)
2025 if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
2026         # Single tree build which includes binutils.
2027         AC_MSG_RESULT(newly built readelf)
2028 elif test x$gcc_cv_readelf = x; then
2029         AC_MSG_RESULT(not found)
2030 else
2031         AC_MSG_RESULT($gcc_cv_readelf)
2032 fi
2033
2034 # Figure out what assembler alignment features are present.
2035 gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,
2036  [2,6,0],,
2037 [.balign 4
2038 .p2align 2],,
2039 [AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
2040   [Define if your assembler supports .balign and .p2align.])])
2041
2042 gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,
2043  [2,8,0],,
2044  [.p2align 4,,7],,
2045 [AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
2046   [Define if your assembler supports specifying the maximum number
2047    of bytes to skip when using the GAS .p2align command.])])
2048
2049 gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,
2050  [2,8,0],,
2051  [.literal16],,
2052 [AC_DEFINE(HAVE_GAS_LITERAL16, 1,
2053   [Define if your assembler supports .literal16.])])
2054
2055 gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,
2056  [elf,2,9,0],,
2057  [conftest_label1: .word 0
2058 .subsection -1
2059 conftest_label2: .word 0
2060 .previous],
2061  [if test x$gcc_cv_nm != x; then
2062     $gcc_cv_nm conftest.o | grep conftest_label1 > conftest.nm1
2063     $gcc_cv_nm conftest.o | grep conftest_label2 | sed -e 's/label2/label1/' > conftest.nm2
2064     if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1
2065     then :
2066     else gcc_cv_as_subsection_m1=yes
2067     fi
2068     rm -f conftest.nm1 conftest.nm2
2069   fi],
2070  [AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
2071   [Define if your assembler supports .subsection and .subsection -1 starts
2072    emitting at the beginning of your section.])])
2073
2074 gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,
2075  [2,2,0],,
2076  [      .weak foobar],,
2077 [AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
2078
2079 gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,
2080  [2,17,0],,
2081  [      .weakref foobar, barfnot],,
2082 [AC_DEFINE(HAVE_GAS_WEAKREF, 1, [Define if your assembler supports .weakref.])])
2083
2084 gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,
2085  [2,15,91],,
2086  [      .SPACE $TEXT$
2087         .NSUBSPA $CODE$,COMDAT],,
2088 [AC_DEFINE(HAVE_GAS_NSUBSPA_COMDAT, 1, [Define if your assembler supports .nsubspa comdat option.])])
2089
2090 # .hidden needs to be supported in both the assembler and the linker,
2091 # because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
2092 # This is irritatingly difficult to feature test for; we have to check the
2093 # date string after the version number.  If we've got an in-tree
2094 # ld, we don't know its patchlevel version, so we set the baseline at 2.13
2095 # to be safe.
2096 # The gcc_GAS_CHECK_FEATURE call just sets a cache variable.
2097 gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
2098  [elf,2,13,0],,
2099 [       .hidden foobar
2100 foobar:])
2101
2102 AC_CACHE_CHECK(linker for .hidden support, gcc_cv_ld_hidden,
2103 [if test $in_tree_ld = yes ; then
2104   gcc_cv_ld_hidden=no
2105   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 \
2106      && test $in_tree_ld_is_elf = yes; then
2107      gcc_cv_ld_hidden=yes
2108   fi
2109 else
2110 changequote(,)dnl
2111   gcc_cv_ld_hidden=yes
2112   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
2113   if echo "$ld_ver" | grep GNU > /dev/null; then
2114     ld_vers=`echo $ld_ver | sed -n \
2115         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
2116     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'`
2117     ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
2118     ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
2119     ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
2120     if test 0"$ld_date" -lt 20020404; then
2121       if test -n "$ld_date"; then
2122         # If there was date string, but was earlier than 2002-04-04, fail
2123         gcc_cv_ld_hidden=no
2124       elif test -z "$ld_vers"; then
2125         # If there was no date string nor ld version number, something is wrong
2126         gcc_cv_ld_hidden=no
2127       else
2128         test -z "$ld_vers_patch" && ld_vers_patch=0
2129         if test "$ld_vers_major" -lt 2; then
2130           gcc_cv_ld_hidden=no
2131         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 12; then
2132           gcc_cv_ld_hidden="no"
2133         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 12 -a "$ld_vers_patch" -eq 0; then
2134           gcc_cv_ld_hidden=no
2135         fi
2136       fi
2137     fi
2138   else
2139     case "${target}" in
2140       hppa64*-*-hpux* | ia64*-*-hpux*)
2141         gcc_cv_ld_hidden=yes
2142         ;;
2143       *-*-solaris2.9* | *-*-solaris2.1[0-9]*)
2144         gcc_cv_ld_hidden=yes
2145         ;;
2146       *)
2147         gcc_cv_ld_hidden=no
2148         ;;
2149     esac
2150   fi
2151 changequote([,])dnl
2152 fi])
2153 libgcc_visibility=no
2154 AC_SUBST(libgcc_visibility)
2155 GCC_TARGET_TEMPLATE([HAVE_GAS_HIDDEN])
2156 if test $gcc_cv_as_hidden = yes && test $gcc_cv_ld_hidden = yes; then
2157   libgcc_visibility=yes
2158   AC_DEFINE(HAVE_GAS_HIDDEN, 1,
2159   [Define if your assembler and linker support .hidden.])
2160 fi
2161
2162 AC_MSG_CHECKING(linker read-only and read-write section mixing)
2163 gcc_cv_ld_ro_rw_mix=unknown
2164 if test $in_tree_ld = yes ; then
2165   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 \
2166      && test $in_tree_ld_is_elf = yes; then
2167     gcc_cv_ld_ro_rw_mix=read-write
2168   fi
2169 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
2170   echo '.section myfoosect, "a"' > conftest1.s
2171   echo '.section myfoosect, "aw"' > conftest2.s
2172   echo '.byte 1' >> conftest2.s
2173   echo '.section myfoosect, "a"' > conftest3.s
2174   echo '.byte 0' >> conftest3.s
2175   if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
2176      && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
2177      && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \
2178      && $gcc_cv_ld -shared -o conftest1.so conftest1.o \
2179         conftest2.o conftest3.o > /dev/null 2>&1; then
2180     gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
2181                          | sed -e '/myfoosect/!d' -e N`
2182     if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
2183       if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
2184         gcc_cv_ld_ro_rw_mix=read-only
2185       else
2186         gcc_cv_ld_ro_rw_mix=read-write
2187       fi
2188     fi
2189   fi
2190 changequote(,)dnl
2191   rm -f conftest.* conftest[123].*
2192 changequote([,])dnl
2193 fi
2194 if test x$gcc_cv_ld_ro_rw_mix = xread-write; then
2195         AC_DEFINE(HAVE_LD_RO_RW_SECTION_MIXING, 1,
2196   [Define if your linker links a mix of read-only
2197    and read-write sections into a read-write section.])
2198 fi
2199 AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix)
2200
2201 # Check if we have .[us]leb128, and support symbol arithmetic with it.
2202 gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
2203   [elf,2,11,0],,
2204 [       .data
2205         .uleb128 L2 - L1
2206 L1:
2207         .uleb128 1280
2208         .sleb128 -1010
2209 L2:],
2210  [# GAS versions before 2.11 do not support uleb128,
2211   # despite appearing to.
2212   # ??? There exists an elf-specific test that will crash
2213   # the assembler.  Perhaps it's better to figure out whether
2214   # arbitrary sections are supported and try the test.
2215   as_ver=`$gcc_cv_as --version 2>/dev/null | sed 1q`
2216   if echo "$as_ver" | grep GNU > /dev/null; then
2217 changequote(,)dnl
2218     as_vers=`echo $as_ver | sed -n \
2219         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
2220     as_major=`expr "$as_vers" : '\([0-9]*\)'`
2221     as_minor=`expr "$as_vers" : '[0-9]*\.\([0-9]*\)'`
2222 changequote([,])dnl
2223     if test $as_major -eq 2 && test $as_minor -lt 11
2224     then :
2225     else gcc_cv_as_leb128=yes
2226     fi
2227   fi],
2228   [AC_DEFINE(HAVE_AS_LEB128, 1,
2229     [Define if your assembler supports .sleb128 and .uleb128.])])
2230
2231 # Check if we have assembler support for unwind directives.
2232 gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,
2233   ,,
2234 [       .text
2235         .cfi_startproc
2236         .cfi_offset 0, 0
2237         .cfi_same_value 1
2238         .cfi_def_cfa 1, 2
2239         .cfi_escape 1, 2, 3, 4, 5
2240         .cfi_endproc],
2241 [case "$target" in
2242   *-*-solaris*)
2243     # If the linker used on Solaris (like Sun ld) isn't capable of merging
2244     # read-only and read-write sections, we need to make sure that the
2245     # assembler used emits read-write .eh_frame sections.
2246     if test "x$gcc_cv_ld_ro_rw_mix" != xread-write; then
2247       if test "x$gcc_cv_objdump" != x; then
2248         if $gcc_cv_objdump -h conftest.o 2>/dev/null | \
2249                 sed -e /.eh_frame/!d -e N | grep READONLY > /dev/null; then
2250           gcc_cv_as_cfi_directive=no
2251         else
2252           gcc_cv_as_cfi_directive=yes
2253         fi
2254       else
2255         # no objdump, err on the side of caution
2256         gcc_cv_as_cfi_directive=no
2257       fi
2258     else
2259       gcc_cv_as_cfi_directive=yes
2260     fi
2261     ;;
2262   *-*-*)
2263     gcc_cv_as_cfi_directive=yes
2264     ;;
2265 esac])
2266 if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_readelf != x; then
2267 gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,
2268   ,,
2269 [       .text
2270         .cfi_startproc
2271         .cfi_adjust_cfa_offset 64
2272         .skip 512, 0
2273         .cfi_adjust_cfa_offset 128
2274         .cfi_endproc],
2275 [
2276 changequote(,)dnl
2277 if $gcc_cv_readelf -wf conftest.o 2>/dev/null \
2278     | grep 'DW_CFA_advance_loc[12]:[    ][      ]*512[  ]' >/dev/null; then
2279    gcc_cv_as_cfi_advance_working=yes
2280 fi
2281 changequote([,])dnl
2282 ])
2283 else
2284   # no readelf, err on the side of caution
2285   gcc_cv_as_cfi_advance_working=no
2286 fi
2287 AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_DIRECTIVE,
2288   [`if test $gcc_cv_as_cfi_directive = yes \
2289        && test $gcc_cv_as_cfi_advance_working = yes; then echo 1; else echo 0; fi`],
2290   [Define 0/1 if your assembler supports CFI directives.])
2291
2292 gcc_GAS_CHECK_FEATURE([cfi personality directive],
2293   gcc_cv_as_cfi_personality_directive, ,,
2294 [       .text
2295         .cfi_startproc
2296         .cfi_personality 0, symbol
2297         .cfi_endproc])
2298 AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE,
2299   [`if test $gcc_cv_as_cfi_personality_directive = yes;
2300     then echo 1; else echo 0; fi`],
2301   [Define 0/1 if your assembler supports .cfi_personality.])
2302
2303 # GAS versions up to and including 2.11.0 may mis-optimize
2304 # .eh_frame data.
2305 gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,
2306   [elf,2,12,0],,
2307 [       .text
2308 .LFB1:
2309         .4byte  0
2310 .L1:
2311         .4byte  0
2312 .LFE1:
2313         .section        .eh_frame,"aw",@progbits
2314 __FRAME_BEGIN__:
2315         .4byte  .LECIE1-.LSCIE1
2316 .LSCIE1:
2317         .4byte  0x0
2318         .byte   0x1
2319         .ascii "z\0"
2320         .byte   0x1
2321         .byte   0x78
2322         .byte   0x1a
2323         .byte   0x0
2324         .byte   0x4
2325         .4byte  1
2326         .p2align 1
2327 .LECIE1:
2328 .LSFDE1:
2329         .4byte  .LEFDE1-.LASFDE1
2330 .LASFDE1:
2331         .4byte  .LASFDE1-__FRAME_BEGIN__
2332         .4byte  .LFB1
2333         .4byte  .LFE1-.LFB1
2334         .byte   0x4
2335         .4byte  .LFE1-.LFB1
2336         .byte   0x4
2337         .4byte  .L1-.LFB1
2338 .LEFDE1:],
2339 [  dnl # For autoconf 2.5x, must protect trailing spaces with @&t@.
2340 cat > conftest.lit <<EOF
2341  0000 10000000 00000000 017a0001 781a0004  .........z..x...
2342  0010 01000000 12000000 18000000 00000000  ................
2343  0020 08000000 04080000 0044               .........D      @&t@
2344 EOF
2345 cat > conftest.big <<EOF
2346  0000 00000010 00000000 017a0001 781a0004  .........z..x...
2347  0010 00000001 00000012 00000018 00000000  ................
2348  0020 00000008 04000000 0844               .........D      @&t@
2349 EOF
2350   # If the assembler didn't choke, and we can objdump,
2351   # and we got the correct data, then succeed.
2352   # The text in the here-document typically retains its unix-style line
2353   # endings, while the output of objdump will use host line endings.
2354   # Therefore, use diff -b for the comparisons.
2355   if test x$gcc_cv_objdump != x \
2356   && $gcc_cv_objdump -s -j .eh_frame conftest.o 2>/dev/null \
2357      | tail -3 > conftest.got \
2358   && { diff -b conftest.lit conftest.got > /dev/null 2>&1 \
2359     || diff -b conftest.big conftest.got > /dev/null 2>&1; }
2360   then
2361     gcc_cv_as_eh_frame=yes
2362   elif AC_TRY_COMMAND($gcc_cv_as -o conftest.o --traditional-format /dev/null); then
2363     gcc_cv_as_eh_frame=buggy
2364   else
2365     # Uh oh, what do we do now?
2366     gcc_cv_as_eh_frame=no
2367   fi])
2368
2369 if test $gcc_cv_as_eh_frame = buggy; then
2370   AC_DEFINE(USE_AS_TRADITIONAL_FORMAT, 1,
2371   [Define if your assembler mis-optimizes .eh_frame data.])
2372 fi
2373
2374 gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
2375  [elf,2,12,0], [--fatal-warnings],
2376  [.section .rodata.str, "aMS", @progbits, 1])
2377 if test $gcc_cv_as_shf_merge = no; then
2378   gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
2379     [elf,2,12,0], [--fatal-warnings],
2380     [.section .rodata.str, "aMS", %progbits, 1])
2381 fi
2382 AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
2383   [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
2384 [Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
2385
2386 gcc_GAS_CHECK_FEATURE(COMDAT group support, gcc_cv_as_comdat_group,
2387  [elf,2,16,0], [--fatal-warnings],
2388  [.section .text,"axG",@progbits,.foo,comdat])
2389 if test $gcc_cv_as_comdat_group = yes; then
2390   gcc_cv_as_comdat_group_percent=no
2391 else
2392  gcc_GAS_CHECK_FEATURE(COMDAT group support, gcc_cv_as_comdat_group_percent,
2393    [elf,2,16,0], [--fatal-warnings],
2394    [.section .text,"axG",%progbits,.foo,comdat])
2395 fi
2396 if test $in_tree_ld != yes && test x"$ld_vers" != x; then
2397   comdat_group=yes
2398   if test 0"$ld_date" -lt 20050308; then
2399     if test -n "$ld_date"; then
2400       # If there was date string, but was earlier than 2005-03-08, fail
2401       comdat_group=no
2402     elif test "$ld_vers_major" -lt 2; then
2403       comdat_group=no
2404     elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 16; then
2405       comdat_group=no
2406     fi
2407   fi
2408 else
2409   # assume linkers other than GNU ld don't support COMDAT group
2410   comdat_group=no
2411 fi
2412 if test $comdat_group = no; then
2413   gcc_cv_as_comdat_group=no
2414   gcc_cv_as_comdat_group_percent=no
2415 fi
2416 AC_DEFINE_UNQUOTED(HAVE_COMDAT_GROUP,
2417   [`if test $gcc_cv_as_comdat_group = yes || test $gcc_cv_as_comdat_group_percent = yes; then echo 1; else echo 0; fi`],
2418 [Define 0/1 if your assembler and linker support COMDAT groups.])
2419
2420 gcc_GAS_CHECK_FEATURE([line table discriminator support],
2421  gcc_cv_as_discriminator,
2422  [2,19,51],,
2423 [       .text
2424         .file 1 "conf.c"
2425         .loc 1 1 0 discriminator 1],,
2426 [AC_DEFINE(HAVE_GAS_DISCRIMINATOR, 1,
2427   [Define if your assembler supports the .loc discriminator sub-directive.])])
2428
2429 # Thread-local storage - the check is heavily parameterized.
2430 conftest_s=
2431 tls_first_major=
2432 tls_first_minor=
2433 tls_as_opt=
2434 case "$target" in
2435 changequote(,)dnl
2436   alpha*-*-*)
2437     conftest_s='
2438         .section ".tdata","awT",@progbits
2439 foo:    .long   25
2440         .text
2441         ldq     $27,__tls_get_addr($29)         !literal!1
2442         lda     $16,foo($29)                    !tlsgd!1
2443         jsr     $26,($27),__tls_get_addr        !lituse_tlsgd!1
2444         ldq     $27,__tls_get_addr($29)         !literal!2
2445         lda     $16,foo($29)                    !tlsldm!2
2446         jsr     $26,($27),__tls_get_addr        !lituse_tlsldm!2
2447         ldq     $1,foo($29)                     !gotdtprel
2448         ldah    $2,foo($29)                     !dtprelhi
2449         lda     $3,foo($2)                      !dtprello
2450         lda     $4,foo($29)                     !dtprel
2451         ldq     $1,foo($29)                     !gottprel
2452         ldah    $2,foo($29)                     !tprelhi
2453         lda     $3,foo($2)                      !tprello
2454         lda     $4,foo($29)                     !tprel'
2455         tls_first_major=2
2456         tls_first_minor=13
2457         tls_as_opt=--fatal-warnings
2458         ;;
2459   cris-*-*|crisv32-*-*)
2460     conftest_s='
2461         .section ".tdata","awT",@progbits
2462 x:      .long   25
2463         .text
2464         move.d x:IE,$r10
2465         nop'
2466         tls_first_major=2
2467         tls_first_minor=20
2468         tls_as_opt=--fatal-warnings
2469         ;;
2470   frv*-*-*)
2471     conftest_s='
2472         .section ".tdata","awT",@progbits
2473 x:      .long   25
2474         .text
2475         call    #gettlsoff(x)'
2476         tls_first_major=2
2477         tls_first_minor=14
2478         ;;
2479   hppa*-*-linux*)
2480     conftest_s='
2481 t1:     .reg    %r20
2482 t2:     .reg    %r21
2483 gp:     .reg    %r19
2484         .section ".tdata","awT",@progbits
2485 foo:    .long   25
2486         .text
2487         .align  4
2488         addil LT%foo-$tls_gdidx$,gp
2489         ldo RT%foo-$tls_gdidx$(%r1),%arg0
2490         b __tls_get_addr
2491         nop             
2492         addil LT%foo-$tls_ldidx$,gp
2493         b __tls_get_addr
2494         ldo RT%foo-$tls_ldidx$(%r1),%arg0
2495         addil LR%foo-$tls_dtpoff$,%ret0
2496         ldo RR%foo-$tls_dtpoff$(%r1),%t1
2497         mfctl %cr27,%t1                 
2498         addil LT%foo-$tls_ieoff$,gp
2499         ldw RT%foo-$tls_ieoff$(%r1),%t2
2500         add %t1,%t2,%t3                 
2501         mfctl %cr27,%t1                 
2502         addil LR%foo-$tls_leoff$,%t1
2503         ldo RR%foo-$tls_leoff$(%r1),%t2'
2504         tls_first_major=2
2505         tls_first_minor=15
2506         tls_as_opt=--fatal-warnings
2507         ;;
2508   arm*-*-*)
2509     conftest_s='
2510         .section ".tdata","awT",%progbits
2511 foo:    .long   25
2512         .text
2513 .word foo(gottpoff)
2514 .word foo(tpoff)
2515 .word foo(tlsgd)
2516 .word foo(tlsldm)
2517 .word foo(tlsldo)'
2518         tls_first_major=2
2519         tls_first_minor=17
2520         ;;
2521   i[34567]86-*-*)
2522     conftest_s='
2523         .section ".tdata","awT",@progbits
2524 foo:    .long   25
2525         .text
2526         movl    %gs:0, %eax
2527         leal    foo@TLSGD(,%ebx,1), %eax
2528         leal    foo@TLSLDM(%ebx), %eax
2529         leal    foo@DTPOFF(%eax), %edx
2530         movl    foo@GOTTPOFF(%ebx), %eax
2531         subl    foo@GOTTPOFF(%ebx), %eax
2532         addl    foo@GOTNTPOFF(%ebx), %eax
2533         movl    foo@INDNTPOFF, %eax
2534         movl    $foo@TPOFF, %eax
2535         subl    $foo@TPOFF, %eax
2536         leal    foo@NTPOFF(%ecx), %eax'
2537         tls_first_major=2
2538         tls_first_minor=14
2539         tls_as_opt=--fatal-warnings
2540         ;;
2541   x86_64-*-*)
2542     conftest_s='
2543         .section ".tdata","awT",@progbits
2544 foo:    .long   25
2545         .text
2546         movq    %fs:0, %rax
2547         leaq    foo@TLSGD(%rip), %rdi
2548         leaq    foo@TLSLD(%rip), %rdi
2549         leaq    foo@DTPOFF(%rax), %rdx
2550         movq    foo@GOTTPOFF(%rip), %rax
2551         movq    $foo@TPOFF, %rax'
2552         tls_first_major=2
2553         tls_first_minor=14
2554         tls_as_opt=--fatal-warnings
2555         ;;
2556   ia64-*-*)
2557     conftest_s='
2558         .section ".tdata","awT",@progbits
2559 foo:    data8   25
2560         .text
2561         addl    r16 = @ltoff(@dtpmod(foo#)), gp
2562         addl    r17 = @ltoff(@dtprel(foo#)), gp
2563         addl    r18 = @ltoff(@tprel(foo#)), gp
2564         addl    r19 = @dtprel(foo#), gp
2565         adds    r21 = @dtprel(foo#), r13
2566         movl    r23 = @dtprel(foo#)
2567         addl    r20 = @tprel(foo#), gp
2568         adds    r22 = @tprel(foo#), r13
2569         movl    r24 = @tprel(foo#)'
2570         tls_first_major=2
2571         tls_first_minor=13
2572         tls_as_opt=--fatal-warnings
2573         ;;
2574   mips*-*-*)
2575     conftest_s='
2576         .section .tdata,"awT",@progbits
2577 x:
2578         .word 2
2579         .text
2580         addiu $4, $28, %tlsgd(x)
2581         addiu $4, $28, %tlsldm(x)
2582         lui $4, %dtprel_hi(x)
2583         addiu $4, $4, %dtprel_lo(x)
2584         lw $4, %gottprel(x)($28)
2585         lui $4, %tprel_hi(x)
2586         addiu $4, $4, %tprel_lo(x)'
2587         tls_first_major=2
2588         tls_first_minor=16
2589         tls_as_opt='-32 --fatal-warnings'
2590         ;;
2591   m68k-*-*)
2592     conftest_s='
2593         .section .tdata,"awT",@progbits
2594 x:
2595         .word 2
2596         .text
2597 foo:
2598         move.l x@TLSGD(%a5),%a0
2599         move.l x@TLSLDM(%a5),%a0
2600         move.l x@TLSLDO(%a5),%a0
2601         move.l x@TLSIE(%a5),%a0
2602         move.l x@TLSLE(%a5),%a0'
2603         tls_first_major=2
2604         tls_first_minor=19
2605         tls_as_opt='--fatal-warnings'
2606         ;;
2607   powerpc-*-*)
2608     conftest_s='
2609         .section ".tdata","awT",@progbits
2610         .align 2
2611 ld0:    .space 4
2612 ld1:    .space 4
2613 x1:     .space 4
2614 x2:     .space 4
2615 x3:     .space 4
2616         .text
2617         addi 3,31,ld0@got@tlsgd
2618         bl __tls_get_addr
2619         addi 3,31,x1@got@tlsld
2620         bl __tls_get_addr
2621         addi 9,3,x1@dtprel
2622         addis 9,3,x2@dtprel@ha
2623         addi 9,9,x2@dtprel@l
2624         lwz 9,x3@got@tprel(31)
2625         add 9,9,x@tls
2626         addi 9,2,x1@tprel
2627         addis 9,2,x2@tprel@ha
2628         addi 9,9,x2@tprel@l'
2629         tls_first_major=2
2630         tls_first_minor=14
2631         tls_as_opt="-a32 --fatal-warnings"
2632         ;;
2633   powerpc64-*-*)
2634     conftest_s='
2635         .section ".tdata","awT",@progbits
2636         .align 3
2637 ld0:    .space 8
2638 ld1:    .space 8
2639 x1:     .space 8
2640 x2:     .space 8
2641 x3:     .space 8
2642         .text
2643         addi 3,2,ld0@got@tlsgd
2644         bl .__tls_get_addr
2645         nop
2646         addi 3,2,ld1@toc
2647         bl .__tls_get_addr
2648         nop
2649         addi 3,2,x1@got@tlsld
2650         bl .__tls_get_addr
2651         nop
2652         addi 9,3,x1@dtprel
2653         bl .__tls_get_addr
2654         nop
2655         addis 9,3,x2@dtprel@ha
2656         addi 9,9,x2@dtprel@l
2657         bl .__tls_get_addr
2658         nop
2659         ld 9,x3@got@dtprel(2)
2660         add 9,9,3
2661         bl .__tls_get_addr
2662         nop'
2663         tls_first_major=2
2664         tls_first_minor=14
2665         tls_as_opt="-a64 --fatal-warnings"
2666         ;;
2667   s390-*-*)
2668     conftest_s='
2669         .section ".tdata","awT",@progbits
2670 foo:    .long   25
2671         .text
2672         .long   foo@TLSGD
2673         .long   foo@TLSLDM
2674         .long   foo@DTPOFF
2675         .long   foo@NTPOFF
2676         .long   foo@GOTNTPOFF
2677         .long   foo@INDNTPOFF
2678         l       %r1,foo@GOTNTPOFF(%r12)
2679         l       %r1,0(%r1):tls_load:foo
2680         bas     %r14,0(%r1,%r13):tls_gdcall:foo
2681         bas     %r14,0(%r1,%r13):tls_ldcall:foo'
2682         tls_first_major=2
2683         tls_first_minor=14
2684         tls_as_opt="-m31 --fatal-warnings"
2685         ;;
2686   s390x-*-*)
2687     conftest_s='
2688         .section ".tdata","awT",@progbits
2689 foo:    .long   25
2690         .text
2691         .quad   foo@TLSGD
2692         .quad   foo@TLSLDM
2693         .quad   foo@DTPOFF
2694         .quad   foo@NTPOFF
2695         .quad   foo@GOTNTPOFF
2696         lg      %r1,foo@GOTNTPOFF(%r12)
2697         larl    %r1,foo@INDNTPOFF
2698         brasl   %r14,__tls_get_offset@PLT:tls_gdcall:foo
2699         brasl   %r14,__tls_get_offset@PLT:tls_ldcall:foo'
2700         tls_first_major=2
2701         tls_first_minor=14
2702         tls_as_opt="-m64 -Aesame --fatal-warnings"
2703         ;;
2704   sh-*-* | sh[34]-*-*)
2705     conftest_s='
2706         .section ".tdata","awT",@progbits
2707 foo:    .long   25
2708         .text
2709         .long   foo@TLSGD
2710         .long   foo@TLSLDM
2711         .long   foo@DTPOFF
2712         .long   foo@GOTTPOFF
2713         .long   foo@TPOFF'
2714         tls_first_major=2
2715         tls_first_minor=13
2716         tls_as_opt=--fatal-warnings
2717         ;;
2718   sparc*-*-*)
2719     case "$target" in
2720       sparc*-sun-solaris2.[56789]*)
2721         # TLS was introduced in the Solaris 9 4/04 release but
2722         # we do not enable it by default on Solaris 9 either.
2723         if test "x$enable_tls" = xyes ; then
2724           on_solaris=yes
2725         else
2726           enable_tls=no;
2727         fi
2728         ;;
2729       sparc*-sun-solaris2.*)
2730         on_solaris=yes
2731         ;;
2732       *)
2733         on_solaris=no
2734         ;;
2735     esac
2736     if test x$on_solaris = xyes && test x$gas_flag = xno; then
2737       conftest_s='
2738         .section ".tdata",#alloc,#write,#tls
2739 foo:    .long   25
2740         .text
2741         sethi   %tgd_hi22(foo), %o0
2742         add     %o0, %tgd_lo10(foo), %o1
2743         add     %l7, %o1, %o0, %tgd_add(foo)
2744         call    __tls_get_addr, %tgd_call(foo)
2745         sethi   %tldm_hi22(foo), %l1
2746         add     %l1, %tldm_lo10(foo), %l2
2747         add     %l7, %l2, %o0, %tldm_add(foo)
2748         call    __tls_get_addr, %tldm_call(foo)
2749         sethi   %tldo_hix22(foo), %l3
2750         xor     %l3, %tldo_lox10(foo), %l4
2751         add     %o0, %l4, %l5, %tldo_add(foo)
2752         sethi   %tie_hi22(foo), %o3
2753         add     %o3, %tie_lo10(foo), %o3
2754         ld      [%l7 + %o3], %o2, %tie_ld(foo)
2755         add     %g7, %o2, %o4, %tie_add(foo)
2756         sethi   %tle_hix22(foo), %l1
2757         xor     %l1, %tle_lox10(foo), %o5
2758         ld      [%g7 + %o5], %o1'
2759         tls_first_major=0
2760         tls_first_minor=0
2761     else
2762       conftest_s='
2763         .section ".tdata","awT",@progbits
2764 foo:    .long   25
2765         .text
2766         sethi   %tgd_hi22(foo), %o0
2767         add     %o0, %tgd_lo10(foo), %o1
2768         add     %l7, %o1, %o0, %tgd_add(foo)
2769         call    __tls_get_addr, %tgd_call(foo)
2770         sethi   %tldm_hi22(foo), %l1
2771         add     %l1, %tldm_lo10(foo), %l2
2772         add     %l7, %l2, %o0, %tldm_add(foo)
2773         call    __tls_get_addr, %tldm_call(foo)
2774         sethi   %tldo_hix22(foo), %l3
2775         xor     %l3, %tldo_lox10(foo), %l4
2776         add     %o0, %l4, %l5, %tldo_add(foo)
2777         sethi   %tie_hi22(foo), %o3
2778         add     %o3, %tie_lo10(foo), %o3
2779         ld      [%l7 + %o3], %o2, %tie_ld(foo)
2780         add     %g7, %o2, %o4, %tie_add(foo)
2781         sethi   %tle_hix22(foo), %l1
2782         xor     %l1, %tle_lox10(foo), %o5
2783         ld      [%g7 + %o5], %o1'
2784         tls_first_major=2
2785         tls_first_minor=14
2786         tls_as_opt="-32 --fatal-warnings"
2787       fi
2788         ;;
2789   xtensa*-*-*)
2790     conftest_s='
2791         .section ".tdata","awT",@progbits
2792 foo:    .long   25
2793         .text
2794         movi    a8, foo@TLSFUNC
2795         movi    a10, foo@TLSARG
2796         callx8.tls a8, foo@TLSCALL'
2797         tls_first_major=2
2798         tls_first_minor=19
2799         ;;
2800 changequote([,])dnl
2801 esac
2802 set_have_as_tls=no
2803 if test "x$enable_tls" = xno ; then
2804   : # TLS explicitly disabled.
2805 elif test "x$enable_tls" = xyes ; then
2806   set_have_as_tls=yes # TLS explicitly enabled.
2807 elif test -z "$tls_first_major"; then
2808   : # If we don't have a check, assume no support.
2809 else
2810   gcc_GAS_CHECK_FEATURE(thread-local storage support, gcc_cv_as_tls,
2811   [$tls_first_major,$tls_first_minor,0], [$tls_as_opt], [$conftest_s],,
2812   [set_have_as_tls=yes])
2813 fi
2814 if test $set_have_as_tls = yes ; then
2815   AC_DEFINE(HAVE_AS_TLS, 1,
2816             [Define if your assembler supports thread-local storage.])
2817 fi
2818
2819 # Target-specific assembler checks.
2820
2821 AC_MSG_CHECKING(linker -Bstatic/-Bdynamic option)
2822 gcc_cv_ld_static_dynamic=no
2823 if test $in_tree_ld = yes ; then
2824   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; then
2825     gcc_cv_ld_static_dynamic=yes
2826   fi
2827 elif test x$gcc_cv_ld != x; then
2828         # Check if linker supports -Bstatic/-Bdynamic option
2829         if $gcc_cv_ld --help 2>/dev/null | grep -- -Bstatic > /dev/null \
2830           && $gcc_cv_ld --help 2>/dev/null | grep -- -Bdynamic > /dev/null; then
2831                 gcc_cv_ld_static_dynamic=yes
2832         fi
2833 fi
2834 if test x"$gcc_cv_ld_static_dynamic" = xyes; then
2835         AC_DEFINE(HAVE_LD_STATIC_DYNAMIC, 1,
2836 [Define if your linker supports -Bstatic/-Bdynamic option.])
2837 fi
2838 AC_MSG_RESULT($gcc_cv_ld_static_dynamic)
2839
2840 if test x"$demangler_in_ld" = xyes; then
2841   AC_MSG_CHECKING(linker --demangle support)
2842   gcc_cv_ld_demangle=no
2843   if test $in_tree_ld = yes; then
2844     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 \
2845       gcc_cv_ld_demangle=yes
2846     fi
2847   elif test x$gcc_cv_ld != x -a x"$gnu_ld" = xyes; then
2848     # Check if the GNU linker supports --demangle option
2849     if $gcc_cv_ld --help 2>/dev/null | grep no-demangle > /dev/null; then
2850       gcc_cv_ld_demangle=yes
2851     fi
2852   fi
2853   if test x"$gcc_cv_ld_demangle" = xyes; then
2854     AC_DEFINE(HAVE_LD_DEMANGLE, 1,
2855 [Define if your linker supports --demangle option.])
2856   fi
2857   AC_MSG_RESULT($gcc_cv_ld_demangle)
2858 fi
2859
2860 case "$target" in
2861   # All TARGET_ABI_OSF targets.
2862   alpha*-*-osf* | alpha*-*-linux* | alpha*-*-*bsd*)
2863     gcc_GAS_CHECK_FEATURE([explicit relocation support],
2864         gcc_cv_as_alpha_explicit_relocs, [2,12,0],,
2865 [       .set nomacro
2866         .text
2867         extbl   $3, $2, $3      !lituse_bytoff!1
2868         ldq     $2, a($29)      !literal!1
2869         ldq     $4, b($29)      !literal!2
2870         ldq_u   $3, 0($2)       !lituse_base!1
2871         ldq     $27, f($29)     !literal!5
2872         jsr     $26, ($27), f   !lituse_jsr!5
2873         ldah    $29, 0($26)     !gpdisp!3
2874         lda     $0, c($29)      !gprel
2875         ldah    $1, d($29)      !gprelhigh
2876         lda     $1, d($1)       !gprellow
2877         lda     $29, 0($29)     !gpdisp!3],,
2878     [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1,
2879   [Define if your assembler supports explicit relocations.])])
2880     gcc_GAS_CHECK_FEATURE([jsrdirect relocation support],
2881         gcc_cv_as_alpha_jsrdirect_relocs, [2,16,90],,
2882 [       .set nomacro
2883         .text
2884         ldq     $27, a($29)     !literal!1
2885         jsr     $26, ($27), a   !lituse_jsrdirect!1],,
2886     [AC_DEFINE(HAVE_AS_JSRDIRECT_RELOCS, 1,
2887   [Define if your assembler supports the lituse_jsrdirect relocation.])])
2888     ;;
2889
2890   cris-*-*)
2891     gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option],
2892       gcc_cv_as_cris_no_mul_bug,[2,15,91],
2893       [-no-mul-bug-abort], [.text],,
2894       [AC_DEFINE(HAVE_AS_NO_MUL_BUG_ABORT_OPTION, 1,
2895                 [Define if your assembler supports the -no-mul-bug-abort option.])])
2896     ;;
2897
2898   sparc*-*-*)
2899     gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
2900       [.register %g2, #scratch],,
2901       [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
2902                 [Define if your assembler supports .register.])])
2903
2904     gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
2905       [-relax], [.text],,
2906       [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
2907                 [Define if your assembler supports -relax option.])])
2908
2909     gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs],
2910       gcc_cv_as_sparc_ua_pcrel,,
2911       [-K PIC],
2912 [.text
2913 foo:
2914         nop
2915 .data
2916 .align 4
2917 .byte 0
2918 .uaword %r_disp32(foo)],
2919       [if test x$gcc_cv_ld != x \
2920        && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
2921          gcc_cv_as_sparc_ua_pcrel=yes
2922        fi
2923        rm -f conftest],
2924       [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
2925                 [Define if your assembler and linker support unaligned PC relative relocs.])
2926
2927       gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs against hidden symbols],
2928         gcc_cv_as_sparc_ua_pcrel_hidden,,
2929         [-K PIC],
2930 [.data
2931 .align 4
2932 .byte 0x31
2933 .uaword %r_disp32(foo)
2934 .byte 0x32, 0x33, 0x34
2935 .global foo
2936 .hidden foo
2937 foo:
2938 .skip 4],
2939         [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
2940          && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1 \
2941          && $gcc_cv_objdump -s -j .data conftest 2> /dev/null \
2942             | grep ' 31000000 07323334' > /dev/null 2>&1; then
2943             if $gcc_cv_objdump -R conftest 2> /dev/null \
2944                | grep 'DISP32' > /dev/null 2>&1; then
2945                 :
2946             else
2947                 gcc_cv_as_sparc_ua_pcrel_hidden=yes
2948             fi
2949          fi
2950          rm -f conftest],
2951          [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL_HIDDEN, 1,
2952                    [Define if your assembler and linker support unaligned PC relative relocs against hidden symbols.])])
2953     ]) # unaligned pcrel relocs
2954
2955     gcc_GAS_CHECK_FEATURE([offsetable %lo()],
2956       gcc_cv_as_sparc_offsetable_lo10,,
2957       [-xarch=v9],
2958 [.text
2959         or %g1, %lo(ab) + 12, %g1
2960         or %g1, %lo(ab + 12), %g1],
2961       [if test x$gcc_cv_objdump != x \
2962        && $gcc_cv_objdump -s -j .text conftest.o 2> /dev/null \
2963           | grep ' 82106000 82106000' > /dev/null 2>&1; then
2964          gcc_cv_as_sparc_offsetable_lo10=yes
2965        fi],
2966        [AC_DEFINE(HAVE_AS_OFFSETABLE_LO10, 1,
2967                  [Define if your assembler supports offsetable %lo().])])
2968     ;;
2969
2970 changequote(,)dnl
2971   i[34567]86-*-* | x86_64-*-*)
2972 changequote([,])dnl
2973     case $target_os in
2974       cygwin* | pe | mingw32*)
2975         # Recent binutils allows the three-operand form of ".comm" on PE.  This
2976         # definition is used unconditionally to initialise the default state of
2977         # the target option variable that governs usage of the feature.
2978         gcc_GAS_CHECK_FEATURE([.comm with alignment], gcc_cv_as_comm_has_align,
2979          [2,19,52],,[.comm foo,1,32])
2980         AC_DEFINE_UNQUOTED(HAVE_GAS_ALIGNED_COMM,
2981           [`if test $gcc_cv_as_comm_has_align = yes; then echo 1; else echo 0; fi`],
2982           [Define if your assembler supports specifying the alignment
2983            of objects allocated using the GAS .comm command.])
2984         # Used for DWARF 2 in PE
2985         gcc_GAS_CHECK_FEATURE([.secrel32 relocs],
2986           gcc_cv_as_ix86_pe_secrel32,
2987           [2,15,91],,
2988 [.text
2989 foo:    nop
2990 .data
2991         .secrel32 foo],
2992           [if test x$gcc_cv_ld != x \
2993            && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1; then
2994              gcc_cv_as_ix86_pe_secrel32=yes
2995            fi
2996            rm -f conftest],
2997           [AC_DEFINE(HAVE_GAS_PE_SECREL32_RELOC, 1,
2998             [Define if your assembler and linker support 32-bit section relative relocs via '.secrel32 label'.])])
2999         ;;
3000     esac
3001
3002     gcc_GAS_CHECK_FEATURE([filds and fists mnemonics],
3003        gcc_cv_as_ix86_filds,,,
3004        [filds mem; fists mem],,
3005        [AC_DEFINE(HAVE_AS_IX86_FILDS, 1,
3006          [Define if your assembler uses filds and fists mnemonics.])])
3007
3008     gcc_GAS_CHECK_FEATURE([fildq and fistpq mnemonics],
3009        gcc_cv_as_ix86_fildq,,,
3010        [fildq mem; fistpq mem],,
3011        [AC_DEFINE(HAVE_AS_IX86_FILDQ, 1,
3012          [Define if your assembler uses fildq and fistq mnemonics.])])
3013
3014     gcc_GAS_CHECK_FEATURE([cmov syntax],
3015       gcc_cv_as_ix86_cmov_sun_syntax,,,
3016       [cmovl.l %edx, %eax],,
3017       [AC_DEFINE(HAVE_AS_IX86_CMOV_SUN_SYNTAX, 1,
3018         [Define if your assembler supports the Sun syntax for cmov.])])
3019
3020     gcc_GAS_CHECK_FEATURE([ffreep mnemonic],
3021       gcc_cv_as_ix86_ffreep,,,
3022       [ffreep %st(1)],,
3023       [AC_DEFINE(HAVE_AS_IX86_FFREEP, 1,
3024         [Define if your assembler supports the ffreep mnemonic.])])
3025
3026     gcc_GAS_CHECK_FEATURE([sahf mnemonic],
3027       gcc_cv_as_ix86_sahf,,,
3028       [sahf],,
3029       [AC_DEFINE(HAVE_AS_IX86_SAHF, 1,
3030         [Define if your assembler supports the sahf mnemonic.])])
3031
3032     gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
3033       gcc_cv_as_ix86_diff_sect_delta,,,
3034       [.section .rodata
3035 .L1:
3036         .long .L2-.L1
3037         .long .L3-.L1
3038         .text
3039 .L3:    nop
3040 .L2:    nop],,
3041       [AC_DEFINE(HAVE_AS_IX86_DIFF_SECT_DELTA, 1,
3042         [Define if your assembler supports the subtraction of symbols in different sections.])])
3043
3044     # This one is used unconditionally by i386.[ch]; it is to be defined
3045     # to 1 if the feature is present, 0 otherwise.
3046     gcc_GAS_CHECK_FEATURE([GOTOFF in data],
3047         gcc_cv_as_ix86_gotoff_in_data, [2,11,0],,
3048 [       .text
3049 .L0:
3050         nop
3051         .data
3052         .long .L0@GOTOFF])
3053     AC_DEFINE_UNQUOTED(HAVE_AS_GOTOFF_IN_DATA,
3054       [`if test $gcc_cv_as_ix86_gotoff_in_data = yes; then echo 1; else echo 0; fi`],
3055       [Define true if the assembler supports '.long foo@GOTOFF'.])
3056     ;;
3057
3058   ia64*-*-*)
3059     gcc_GAS_CHECK_FEATURE([ltoffx and ldxmov relocs],
3060         gcc_cv_as_ia64_ltoffx_ldxmov_relocs, [2,14,0],,
3061 [       .text
3062         addl r15 = @ltoffx(x#), gp
3063         ;;
3064         ld8.mov r16 = [[r15]], x#],,
3065     [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
3066           [Define if your assembler supports ltoffx and ldxmov relocations.])])
3067
3068     ;;
3069
3070   powerpc*-*-*)
3071     case $target in
3072       *-*-aix*) conftest_s='    .machine "pwr5"
3073         .csect .text[[PR]]
3074         mfcr 3,128';;
3075       *-*-darwin*)
3076         gcc_GAS_CHECK_FEATURE([.machine directive support],
3077           gcc_cv_as_machine_directive,,,
3078           [     .machine ppc7400])
3079         if test x$gcc_cv_as_machine_directive != xyes; then
3080           echo "*** This target requires an assembler supporting \".machine\"" >&2
3081           echo you can get it from: ftp://gcc.gnu.org/pub/gcc/infrastructure/cctools-528.5.dmg >&2
3082           test x$build = x$target && exit 1
3083         fi
3084         conftest_s='    .text
3085         mfcr r3,128';;
3086       *) conftest_s='   .machine power4
3087         .text
3088         mfcr 3,128';;
3089     esac
3090
3091     gcc_GAS_CHECK_FEATURE([mfcr field support],
3092       gcc_cv_as_powerpc_mfcrf, [2,14,0],,
3093       [$conftest_s],,
3094       [AC_DEFINE(HAVE_AS_MFCRF, 1,
3095           [Define if your assembler supports mfcr field.])])
3096
3097     case $target in
3098       *-*-aix*) conftest_s='    .machine "pwr5"
3099         .csect .text[[PR]]
3100         popcntb 3,3';;
3101       *) conftest_s='   .machine power5
3102         .text
3103         popcntb 3,3';;
3104     esac
3105
3106     gcc_GAS_CHECK_FEATURE([popcntb support],
3107       gcc_cv_as_powerpc_popcntb, [2,17,0],,
3108       [$conftest_s],,
3109       [AC_DEFINE(HAVE_AS_POPCNTB, 1,
3110           [Define if your assembler supports popcntb field.])])
3111
3112     case $target in
3113       *-*-aix*) conftest_s='    .machine "pwr5x"
3114         .csect .text[[PR]]
3115         frin 1,1';;
3116       *) conftest_s='   .machine power5
3117         .text
3118         frin 1,1';;
3119     esac
3120
3121     gcc_GAS_CHECK_FEATURE([fp round support],
3122       gcc_cv_as_powerpc_fprnd, [2,17,0],,
3123       [$conftest_s],,
3124       [AC_DEFINE(HAVE_AS_FPRND, 1,
3125           [Define if your assembler supports fprnd.])])
3126
3127     case $target in
3128       *-*-aix*) conftest_s='    .machine "pwr6"
3129         .csect .text[[PR]]
3130         mffgpr 1,3';;
3131       *) conftest_s='   .machine power6
3132         .text
3133         mffgpr 1,3';;
3134     esac
3135
3136     gcc_GAS_CHECK_FEATURE([move fp gpr support],
3137       gcc_cv_as_powerpc_mfpgpr, [2,19,2],,
3138       [$conftest_s],,
3139       [AC_DEFINE(HAVE_AS_MFPGPR, 1,
3140           [Define if your assembler supports mffgpr and mftgpr.])])
3141
3142     case $target in
3143       *-*-aix*) conftest_s='    .csect .text[[PR]]
3144 LCF..0:
3145         addis 11,30,_GLOBAL_OFFSET_TABLE_-LCF..0@ha';;
3146       *-*-darwin*)
3147         conftest_s='    .text
3148 LCF0:
3149         addis r11,r30,_GLOBAL_OFFSET_TABLE_-LCF0@ha';;
3150       *) conftest_s='   .text
3151 .LCF0:
3152         addis 11,30,_GLOBAL_OFFSET_TABLE_-.LCF0@ha';;
3153     esac
3154
3155     gcc_GAS_CHECK_FEATURE([rel16 relocs],
3156       gcc_cv_as_powerpc_rel16, [2,17,0], -a32,
3157       [$conftest_s],,
3158       [AC_DEFINE(HAVE_AS_REL16, 1,
3159           [Define if your assembler supports R_PPC_REL16 relocs.])])
3160
3161     case $target in
3162       *-*-aix*) conftest_s='    .machine "pwr6"
3163         .csect .text[[PR]]
3164         cmpb 3,4,5';;
3165       *) conftest_s='   .machine power6
3166         .text
3167         cmpb 3,4,5';;
3168     esac
3169
3170     gcc_GAS_CHECK_FEATURE([compare bytes support],
3171       gcc_cv_as_powerpc_cmpb, [2,19,2], -a32,
3172       [$conftest_s],,
3173       [AC_DEFINE(HAVE_AS_CMPB, 1,
3174           [Define if your assembler supports cmpb.])])
3175
3176     case $target in
3177       *-*-aix*) conftest_s='    .machine "pwr6"
3178         .csect .text[[PR]]
3179         dadd 1,2,3';;
3180       *) conftest_s='   .machine power6
3181         .text
3182         dadd 1,2,3';;
3183     esac
3184
3185     gcc_GAS_CHECK_FEATURE([decimal float support],
3186       gcc_cv_as_powerpc_dfp, [2,19,2], -a32,
3187       [$conftest_s],,
3188       [AC_DEFINE(HAVE_AS_DFP, 1,
3189           [Define if your assembler supports DFP instructions.])])
3190
3191     case $target in
3192       *-*-aix*) conftest_s='    .machine "pwr7"
3193         .csect .text[[PR]]
3194         lxvd2x 1,2,3';;
3195       *) conftest_s='   .machine power7
3196         .text
3197         lxvd2x 1,2,3';;
3198     esac
3199
3200     gcc_GAS_CHECK_FEATURE([vector-scalar support],
3201       gcc_cv_as_powerpc_vsx, [2,19,2], -a32,
3202       [$conftest_s],,
3203       [AC_DEFINE(HAVE_AS_VSX, 1,
3204           [Define if your assembler supports VSX instructions.])])
3205
3206     case $target in
3207       *-*-aix*) conftest_s='    .machine "pwr7"
3208         .csect .text[[PR]]
3209         popcntd 3,3';;
3210       *) conftest_s='   .machine power7
3211         .text
3212         popcntd 3,3';;
3213     esac
3214
3215     gcc_GAS_CHECK_FEATURE([popcntd support],
3216       gcc_cv_as_powerpc_popcntd, [2,19,2], -a32,
3217       [$conftest_s],,
3218       [AC_DEFINE(HAVE_AS_POPCNTD, 1,
3219           [Define if your assembler supports POPCNTD instructions.])])
3220
3221     case $target in
3222       *-*-aix*) conftest_s='    .csect .text[[PR]]
3223         lwsync';;
3224       *) conftest_s='   .text
3225         lwsync';;
3226     esac
3227
3228     gcc_GAS_CHECK_FEATURE([lwsync support],
3229       gcc_cv_as_powerpc_lwsync, [2,19,2], -a32,
3230       [$conftest_s],,
3231       [AC_DEFINE(HAVE_AS_LWSYNC, 1,
3232           [Define if your assembler supports LWSYNC instructions.])])
3233
3234     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
3235       gcc_cv_as_powerpc_gnu_attribute, [2,18,0],,
3236       [.gnu_attribute 4,1],,
3237       [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
3238           [Define if your assembler supports .gnu_attribute.])])
3239
3240     gcc_GAS_CHECK_FEATURE([tls marker support],
3241       gcc_cv_as_powerpc_tls_markers, [2,20,0],,
3242       [ bl __tls_get_addr(x@tlsgd)],,
3243       [AC_DEFINE(HAVE_AS_TLS_MARKERS, 1,
3244           [Define if your assembler supports arg info for __tls_get_addr.])])
3245     ;;
3246
3247   mips*-*-*)
3248     gcc_GAS_CHECK_FEATURE([explicit relocation support],
3249       gcc_cv_as_mips_explicit_relocs, [2,14,0],,
3250 [       lw $4,%gp_rel(foo)($4)],,
3251       [if test x$target_cpu_default = x
3252        then target_cpu_default=MASK_EXPLICIT_RELOCS
3253        else target_cpu_default="($target_cpu_default)|MASK_EXPLICIT_RELOCS"
3254        fi])
3255     gcc_GAS_CHECK_FEATURE([-mno-shared support],
3256       gcc_cv_as_mips_no_shared, [2,16,0], [-mno-shared], [nop],,
3257       [AC_DEFINE(HAVE_AS_NO_SHARED, 1,
3258                  [Define if the assembler understands -mno-shared.])])
3259
3260     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
3261       gcc_cv_as_mips_gnu_attribute, [2,18,0],,
3262       [.gnu_attribute 4,1],,
3263       [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
3264           [Define if your assembler supports .gnu_attribute.])])
3265
3266     gcc_GAS_CHECK_FEATURE([.dtprelword support],
3267       gcc_cv_as_mips_dtprelword, [2,18,0],,
3268       [.section .tdata,"awT",@progbits
3269 x:
3270         .word 2
3271         .text
3272         .dtprelword x+0x8000],,
3273       [AC_DEFINE(HAVE_AS_DTPRELWORD, 1,
3274           [Define if your assembler supports .dtprelword.])])
3275     ;;
3276 esac
3277
3278 # Mips and HP-UX need the GNU assembler.
3279 # Linux on IA64 might be able to use the Intel assembler.
3280
3281 case "$target" in
3282   mips*-*-* | *-*-hpux* )
3283     if test x$gas_flag = xyes \
3284        || test x"$host" != x"$build" \
3285        || test ! -x "$gcc_cv_as" \
3286        || "$gcc_cv_as" -v < /dev/null 2>&1 | grep GNU > /dev/null; then
3287       :
3288     else
3289       echo "*** This configuration requires the GNU assembler" >&2
3290       exit 1
3291     fi
3292     ;;
3293 esac
3294
3295 # ??? Not all targets support dwarf2 debug_line, even within a version
3296 # of gas.  Moreover, we need to emit a valid instruction to trigger any
3297 # info to the output file.  So, as supported targets are added to gas 2.11,
3298 # add some instruction here to (also) show we expect this might work.
3299 # ??? Once 2.11 is released, probably need to add first known working
3300 # version to the per-target configury.
3301 case "$target" in
3302   i?86*-*-* | mips*-*-* | alpha*-*-* | powerpc*-*-* | sparc*-*-* | m68*-*-* \
3303   | x86_64*-*-* | hppa*-*-* | arm*-*-* \
3304   | xstormy16*-*-* | cris-*-* | crisv32-*-* | xtensa*-*-* | bfin-*-* | score*-*-* \
3305   | spu-*-* | fido*-*-* | m32c-*-*)
3306     insn="nop"
3307     ;;
3308   ia64*-*-* | s390*-*-*)
3309     insn="nop 0"
3310     ;;
3311   mmix-*-*)
3312     insn="swym 0"
3313     ;;
3314 esac
3315 if test x"$insn" != x; then
3316  conftest_s="\
3317         .file 1 \"conftest.s\"
3318         .loc 1 3 0
3319         $insn"
3320  gcc_GAS_CHECK_FEATURE([dwarf2 debug_line support],
3321   gcc_cv_as_dwarf2_debug_line,
3322   [elf,2,11,0],, [$conftest_s],
3323   [if test x$gcc_cv_objdump != x \
3324    && $gcc_cv_objdump -h conftest.o 2> /dev/null \
3325       | grep debug_line > /dev/null 2>&1; then
3326      gcc_cv_as_dwarf2_debug_line=yes
3327    fi])
3328
3329 # The .debug_line file table must be in the exact order that
3330 # we specified the files, since these indices are also used
3331 # by DW_AT_decl_file.  Approximate this test by testing if
3332 # the assembler bitches if the same index is assigned twice.
3333  gcc_GAS_CHECK_FEATURE([buggy dwarf2 .file directive],
3334   gcc_cv_as_dwarf2_file_buggy,,,
3335 [       .file 1 "foo.s"
3336         .file 1 "bar.s"])
3337
3338  if test $gcc_cv_as_dwarf2_debug_line = yes \
3339  && test $gcc_cv_as_dwarf2_file_buggy = no; then
3340         AC_DEFINE(HAVE_AS_DWARF2_DEBUG_LINE, 1,
3341   [Define if your assembler supports dwarf2 .file/.loc directives,
3342    and preserves file table indices exactly as given.])
3343  fi
3344
3345  gcc_GAS_CHECK_FEATURE([--gdwarf2 option],
3346   gcc_cv_as_gdwarf2_flag,
3347   [elf,2,11,0], [--gdwarf2], [$insn],,
3348   [AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
3349 [Define if your assembler supports the --gdwarf2 option.])])
3350
3351  gcc_GAS_CHECK_FEATURE([--gstabs option],
3352   gcc_cv_as_gstabs_flag,
3353   [elf,2,11,0], [--gstabs], [$insn],
3354   [# The native Solaris 9/Intel assembler doesn't understand --gstabs
3355    # and warns about it, but still exits successfully.  So check for
3356    # this.
3357    if AC_TRY_COMMAND([$gcc_cv_as --gstabs -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null])
3358    then :
3359    else gcc_cv_as_gstabs_flag=yes
3360    fi],
3361   [AC_DEFINE(HAVE_AS_GSTABS_DEBUG_FLAG, 1,
3362 [Define if your assembler supports the --gstabs option.])])
3363
3364  gcc_GAS_CHECK_FEATURE([--debug-prefix-map option],
3365   gcc_cv_as_debug_prefix_map_flag,
3366   [2,18,0], [--debug-prefix-map /a=/b], [$insn],,
3367   [AC_DEFINE(HAVE_AS_DEBUG_PREFIX_MAP, 1,
3368 [Define if your assembler supports the --debug-prefix-map option.])])
3369 fi
3370
3371 gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment,
3372  ,,
3373 [.lcomm bar,4,16],,
3374 [AC_DEFINE(HAVE_GAS_LCOMM_WITH_ALIGNMENT, 1,
3375   [Define if your assembler supports .lcomm with an alignment field.])])
3376
3377 AC_ARG_ENABLE(gnu-unique-object,
3378  [  --enable-gnu-unique-object  enable the use of the @gnu_unique_object ELF extension on
3379                                 glibc systems],
3380  [case $enable_gnu_unique_object in
3381     yes | no) ;;
3382     *) AC_MSG_ERROR(['$enable_gnu_unique_object' is an invalid value for --enable-gnu-unique-object.
3383 Valid choices are 'yes' and 'no'.]) ;;
3384   esac],
3385  [gcc_GAS_CHECK_FEATURE([gnu_unique_object], gcc_cv_as_gnu_unique_object,
3386    [elf,2,19,52],,
3387    [.type foo, @gnu_unique_object],
3388 # Also check for ld.so support, i.e. glibc 2.11 or higher.
3389    [if test x$host = x$build -a x$host = x$target &&
3390        glibcver=`ldd --version 2>/dev/null`; then
3391       glibcmajor=`expr "$glibcver" : "ldd (GNU libc) \([[0-9]]*\)"`
3392       glibcminor=`expr "$glibcver" : "ldd (GNU libc) [[0-9]]*\.\([[0-9]]*\)"`
3393       glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
3394       if test "$glibcnum" -ge 2011 ; then
3395         gcc_cv_as_gnu_unique_object=yes
3396       fi
3397     fi],
3398    [enable_gnu_unique_object=yes])])
3399 if test x$enable_gnu_unique_object = xyes; then
3400   AC_DEFINE(HAVE_GAS_GNU_UNIQUE_OBJECT, 1,
3401    [Define if your assembler supports @gnu_unique_object.])
3402 fi
3403
3404 AC_CACHE_CHECK([assembler for tolerance to line number 0],
3405  [gcc_cv_as_line_zero],
3406  [gcc_cv_as_line_zero=no
3407   if test $in_tree_gas = yes; then
3408     gcc_GAS_VERSION_GTE_IFELSE(2, 16, 91, [gcc_cv_as_line_zero=yes])
3409   elif test "x$gcc_cv_as" != x; then
3410     { echo '# 1 "test.s" 1'; echo '# 0 "" 2'; } > conftest.s
3411     if AC_TRY_COMMAND([$gcc_cv_as -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD 2>conftest.out]) &&
3412        test "x`cat conftest.out`" = x
3413     then
3414       gcc_cv_as_line_zero=yes
3415     else
3416       echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
3417       cat conftest.s >&AS_MESSAGE_LOG_FD
3418       echo "configure: error output was" >&AS_MESSAGE_LOG_FD
3419       cat conftest.out >&AS_MESSAGE_LOG_FD
3420     fi
3421     rm -f conftest.o conftest.s conftest.out
3422   fi])
3423 if test "x$gcc_cv_as_line_zero" = xyes; then
3424   AC_DEFINE([HAVE_AS_LINE_ZERO], 1,
3425 [Define if the assembler won't complain about a line such as # 0 "" 2.])
3426 fi
3427
3428 AC_MSG_CHECKING(linker PT_GNU_EH_FRAME support)
3429 gcc_cv_ld_eh_frame_hdr=no
3430 if test $in_tree_ld = yes ; then
3431   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 \
3432      && test $in_tree_ld_is_elf = yes; then
3433     gcc_cv_ld_eh_frame_hdr=yes
3434   fi
3435 elif test x$gcc_cv_ld != x; then
3436         # Check if linker supports --eh-frame-hdr option
3437         if $gcc_cv_ld --help 2>/dev/null | grep eh-frame-hdr > /dev/null; then
3438                 gcc_cv_ld_eh_frame_hdr=yes
3439         fi
3440 fi
3441 GCC_TARGET_TEMPLATE([HAVE_LD_EH_FRAME_HDR])
3442 if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
3443         AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
3444 [Define if your linker supports --eh-frame-hdr option.])
3445 fi
3446 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
3447
3448 AC_MSG_CHECKING(linker position independent executable support)
3449 gcc_cv_ld_pie=no
3450 if test $in_tree_ld = yes ; then
3451   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 \
3452      && test $in_tree_ld_is_elf = yes; then
3453     gcc_cv_ld_pie=yes
3454   fi
3455 elif test x$gcc_cv_ld != x; then
3456         # Check if linker supports -pie option
3457         if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then
3458                 gcc_cv_ld_pie=yes
3459         fi
3460 fi
3461 if test x"$gcc_cv_ld_pie" = xyes; then
3462         AC_DEFINE(HAVE_LD_PIE, 1,
3463 [Define if your linker supports -pie option.])
3464 fi
3465 AC_MSG_RESULT($gcc_cv_ld_pie)
3466
3467 AC_MSG_CHECKING(linker EH-compatible garbage collection of sections)
3468 gcc_cv_ld_eh_gc_sections=no
3469 if test $in_tree_ld = yes ; then
3470   if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 17 -o "$gcc_cv_gld_major_version" -gt 2 \
3471      && test $in_tree_ld_is_elf = yes; then
3472     gcc_cv_ld_eh_gc_sections=yes
3473   fi
3474 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
3475   cat > conftest.s <<EOF
3476         .section        .text
3477 .globl _start
3478         .type _start, @function
3479 _start:
3480         .long foo
3481         .size _start, .-_start
3482         .section        .text.foo,"ax",@progbits
3483         .type foo, @function
3484 foo:
3485         .long 0
3486         .size foo, .-foo
3487         .section        .gcc_except_table.foo,"a",@progbits
3488 .L0:
3489         .long 0
3490         .section        .eh_frame,"a",@progbits
3491         .long .L0
3492 EOF
3493   if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
3494     if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
3495          | grep "gc-sections option ignored" > /dev/null; then
3496       gcc_cv_ld_eh_gc_sections=no
3497     elif $gcc_cv_objdump -h conftest | grep gcc_except_table > /dev/null; then
3498       gcc_cv_ld_eh_gc_sections=yes
3499       # If no COMDAT groups, the compiler will emit .gnu.linkonce.t. sections.
3500       if test x$gcc_cv_as_comdat_group != xyes; then
3501         gcc_cv_ld_eh_gc_sections=no
3502         cat > conftest.s <<EOF
3503         .section        .text
3504 .globl _start
3505         .type _start, @function
3506 _start:
3507         .long foo
3508         .size _start, .-_start
3509         .section        .gnu.linkonce.t.foo,"ax",@progbits
3510         .type foo, @function
3511 foo:
3512         .long 0
3513         .size foo, .-foo
3514         .section        .gcc_except_table.foo,"a",@progbits
3515 .L0:
3516         .long 0
3517         .section        .eh_frame,"a",@progbits
3518         .long .L0
3519 EOF
3520         if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
3521           if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
3522                | grep "gc-sections option ignored" > /dev/null; then
3523             gcc_cv_ld_eh_gc_sections=no
3524           elif $gcc_cv_objdump -h conftest | grep gcc_except_table > /dev/null; then
3525             gcc_cv_ld_eh_gc_sections=yes
3526           fi
3527         fi
3528       fi
3529     fi
3530   fi
3531   rm -f conftest.s conftest.o conftest
3532 fi
3533 case "$target" in
3534   hppa*-*-linux*)
3535     # ??? This apparently exposes a binutils bug with PC-relative relocations.
3536     gcc_cv_ld_eh_gc_sections=no
3537     ;;
3538 esac
3539 if test x$gcc_cv_ld_eh_gc_sections = xyes; then
3540         AC_DEFINE(HAVE_LD_EH_GC_SECTIONS, 1,
3541   [Define if your linker supports garbage collection of
3542    sections in presence of EH frames.])
3543 fi
3544 AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections)
3545
3546 # --------
3547 # UNSORTED
3548 # --------
3549
3550 AC_CACHE_CHECK(linker --as-needed support,
3551 gcc_cv_ld_as_needed,
3552 [gcc_cv_ld_as_needed=no
3553 if test $in_tree_ld = yes ; then
3554   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 \
3555      && test $in_tree_ld_is_elf = yes; then
3556     gcc_cv_ld_as_needed=yes
3557   fi
3558 elif test x$gcc_cv_ld != x; then
3559         # Check if linker supports --as-needed and --no-as-needed options
3560         if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then
3561                 gcc_cv_ld_as_needed=yes
3562         fi
3563 fi
3564 ])
3565 if test x"$gcc_cv_ld_as_needed" = xyes; then
3566         AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
3567 [Define if your linker supports --as-needed and --no-as-needed options.])
3568 fi
3569
3570 case "$target:$tm_file" in
3571   powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
3572     AC_CACHE_CHECK(linker support for omitting dot symbols,
3573     gcc_cv_ld_no_dot_syms,
3574     [gcc_cv_ld_no_dot_syms=no
3575     if test $in_tree_ld = yes ; then
3576       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
3577         gcc_cv_ld_no_dot_syms=yes
3578       fi
3579     elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
3580       cat > conftest1.s <<EOF
3581         .text
3582         bl .foo
3583 EOF
3584       cat > conftest2.s <<EOF
3585         .section ".opd","aw"
3586         .align 3
3587         .globl foo
3588         .type foo,@function
3589 foo:
3590         .quad .LEfoo,.TOC.@tocbase,0
3591         .text
3592 .LEfoo:
3593         blr
3594         .size foo,.-.LEfoo
3595 EOF
3596       if $gcc_cv_as -a64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
3597          && $gcc_cv_as -a64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
3598          && $gcc_cv_ld -melf64ppc -o conftest conftest1.o conftest2.o > /dev/null 2>&1; then
3599         gcc_cv_ld_no_dot_syms=yes
3600       fi
3601       rm -f conftest conftest1.o conftest2.o conftest1.s conftest2.s
3602     fi
3603     ])
3604     if test x"$gcc_cv_ld_no_dot_syms" = xyes; then
3605       AC_DEFINE(HAVE_LD_NO_DOT_SYMS, 1,
3606     [Define if your PowerPC64 linker only needs function descriptor syms.])
3607     fi
3608     ;;
3609 esac
3610
3611 AC_CACHE_CHECK(linker --build-id support,
3612   gcc_cv_ld_buildid,
3613   [gcc_cv_ld_buildid=no
3614   if test $in_tree_ld = yes ; then
3615     if test "$gcc_cv_gld_major_version" -eq 2 -a \
3616        "$gcc_cv_gld_minor_version" -ge 18 -o \
3617        "$gcc_cv_gld_major_version" -gt 2 \
3618        && test $in_tree_ld_is_elf = yes; then
3619       gcc_cv_ld_buildid=yes
3620     fi
3621   elif test x$gcc_cv_ld != x; then
3622     if $gcc_cv_ld --help 2>/dev/null | grep build-id > /dev/null; then
3623       gcc_cv_ld_buildid=yes
3624     fi
3625   fi])
3626 if test x"$gcc_cv_ld_buildid" = xyes; then
3627   AC_DEFINE(HAVE_LD_BUILDID, 1,
3628   [Define if your linker supports --build-id.])
3629 fi
3630
3631 AC_ARG_ENABLE(linker-build-id,
3632 [  --enable-linker-build-id
3633                           compiler will always pass --build-id to linker],
3634 [],
3635 enable_linker_build_id=no)
3636
3637 if test x"$enable_linker_build_id" = xyes; then
3638   if test x"$gcc_cv_ld_buildid" = xyes; then
3639     AC_DEFINE(ENABLE_LD_BUILDID, 1,
3640     [Define if gcc should always pass --build-id to linker.])
3641   else
3642     AC_MSG_WARN(--build-id is not supported by your linker; --enable-linker-build-id ignored)
3643   fi
3644 fi
3645
3646 AC_CACHE_CHECK(linker --sysroot support,
3647   gcc_cv_ld_sysroot,
3648   [gcc_cv_ld_sysroot=no
3649   if test $in_tree_ld = yes ; then
3650       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
3651         gcc_cv_ld_sysroot=yes
3652       fi
3653   elif test x$gcc_cv_ld != x; then 
3654     if $gcc_cv_ld --help 2>/dev/null | grep sysroot > /dev/null; then
3655       gcc_cv_ld_sysroot=yes
3656     fi
3657   fi])
3658 if test x"$gcc_cv_ld_sysroot" = xyes; then
3659   AC_DEFINE(HAVE_LD_SYSROOT, 1,
3660   [Define if your linker supports --sysroot.])
3661 fi        
3662
3663 if test x$with_sysroot = x && test x$host = x$target \
3664    && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" \
3665    && test "$prefix" != "NONE"; then
3666   AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include",
3667 [Define to PREFIX/include if cpp should also search that directory.])
3668 fi
3669
3670 # Test for stack protector support in target C library.
3671 AC_CACHE_CHECK(__stack_chk_fail in target C library,
3672       gcc_cv_libc_provides_ssp,
3673       [gcc_cv_libc_provides_ssp=no
3674     case "$target" in
3675        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
3676       if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
3677         if test "x$with_sysroot" = x; then
3678           glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
3679         elif test "x$with_build_sysroot" != "x"; then
3680           glibc_header_dir="${with_build_sysroot}/usr/include"
3681         elif test "x$with_sysroot" = xyes; then
3682           glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
3683         else
3684           glibc_header_dir="${with_sysroot}/usr/include"
3685         fi
3686       else
3687         glibc_header_dir=/usr/include
3688       fi
3689       # glibc 2.4 and later provides __stack_chk_fail and
3690       # either __stack_chk_guard, or TLS access to stack guard canary.
3691       if test -f $glibc_header_dir/features.h \
3692          && $EGREP '^@<:@       @:>@*#[         ]*define[       ]+__GNU_LIBRARY__[      ]+([1-9][0-9]|[6-9])' \
3693             $glibc_header_dir/features.h > /dev/null; then
3694         if $EGREP '^@<:@        @:>@*#[         ]*define[       ]+__GLIBC__[    ]+([1-9][0-9]|[3-9])' \
3695            $glibc_header_dir/features.h > /dev/null; then
3696           gcc_cv_libc_provides_ssp=yes
3697         elif $EGREP '^@<:@      @:>@*#[         ]*define[       ]+__GLIBC__[    ]+2' \
3698              $glibc_header_dir/features.h > /dev/null \
3699              && $EGREP '^@<:@   @:>@*#[         ]*define[       ]+__GLIBC_MINOR__[      ]+([1-9][0-9]|[4-9])' \
3700              $glibc_header_dir/features.h > /dev/null; then
3701           gcc_cv_libc_provides_ssp=yes
3702         elif $EGREP '^@<:@      @:>@*#[         ]*define[       ]+__UCLIBC__[   ]+1' \
3703              $glibc_header_dir/features.h > /dev/null && \
3704              test -f $glibc_header_dir/bits/uClibc_config.h && \
3705              $EGREP '^@<:@      @:>@*#[         ]*define[       ]+__UCLIBC_HAS_SSP__[   ]+1' \
3706              $glibc_header_dir/bits/uClibc_config.h > /dev/null; then
3707           gcc_cv_libc_provides_ssp=yes
3708         fi
3709       fi
3710         ;;
3711        *-*-gnu*)
3712          # Avoid complicated tests (see
3713          # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
3714          # simply assert that glibc does provide this, which is true for all
3715          # realistically usable GNU/Hurd configurations.
3716          gcc_cv_libc_provides_ssp=yes;;
3717        *-*-darwin*)
3718          AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
3719            [echo "no __stack_chk_fail on this target"])
3720         ;;
3721   *) gcc_cv_libc_provides_ssp=no ;;
3722     esac])
3723
3724 if test x$gcc_cv_libc_provides_ssp = xyes; then
3725   AC_DEFINE(TARGET_LIBC_PROVIDES_SSP, 1,
3726             [Define if your target C library provides stack protector support])
3727 fi
3728
3729 # Check if TFmode long double should be used by default or not.
3730 # Some glibc targets used DFmode long double, but with glibc 2.4
3731 # and later they can use TFmode.
3732 case "$target" in
3733   powerpc*-*-linux* | \
3734   powerpc*-*-gnu* | \
3735   sparc*-*-linux* | \
3736   s390*-*-linux* | \
3737   alpha*-*-linux*)
3738     AC_ARG_WITH(long-double-128,
3739 [  --with-long-double-128  Use 128-bit long double by default.],
3740       gcc_cv_target_ldbl128="$with_long_double_128",
3741       [gcc_cv_target_ldbl128=no
3742       if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
3743         if test "x$with_sysroot" = x; then
3744           glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
3745         elif test "x$with_build_sysroot" != "x"; then
3746           glibc_header_dir="${with_build_sysroot}/usr/include"
3747         elif test "x$with_sysroot" = xyes; then
3748           glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
3749         else
3750           glibc_header_dir="${with_sysroot}/usr/include"
3751         fi
3752       else
3753         glibc_header_dir=/usr/include
3754       fi
3755 changequote(,)dnl
3756       grep '^[  ]*#[    ]*define[       ][      ]*__LONG_DOUBLE_MATH_OPTIONAL' \
3757         $glibc_header_dir/bits/wordsize.h > /dev/null 2>&1 \
3758       && gcc_cv_target_ldbl128=yes
3759 changequote([,])dnl
3760       ])
3761     ;;
3762 esac
3763 if test x$gcc_cv_target_ldbl128 = xyes; then
3764   AC_DEFINE(TARGET_DEFAULT_LONG_DOUBLE_128, 1,
3765             [Define if TFmode long double should be the default])
3766 fi
3767
3768 # Find out what GC implementation we want, or may, use.
3769 AC_ARG_WITH(gc,
3770 [  --with-gc={page,zone}   choose the garbage collection mechanism to use
3771                           with the compiler],
3772 [case "$withval" in
3773   page)
3774     GGC=ggc-$withval
3775     ;;
3776   zone)
3777     GGC=ggc-$withval
3778     AC_DEFINE(GGC_ZONE, 1, [Define if the zone collector is in use])
3779     ;;
3780   *)
3781     AC_MSG_ERROR([$withval is an invalid option to --with-gc])
3782     ;;
3783 esac],
3784 [GGC=ggc-page])
3785 AC_SUBST(GGC)
3786 echo "Using $GGC for garbage collection."
3787
3788 # Libraries to use on the host.  This will normally be set by the top
3789 # level Makefile.  Here we simply capture the value for our Makefile.
3790 if test -z "${HOST_LIBS+set}"; then
3791   HOST_LIBS=
3792 fi
3793 AC_SUBST(HOST_LIBS)
3794
3795 # Use the system's zlib library.
3796 zlibdir=-L../zlib
3797 zlibinc="-I\$(srcdir)/../zlib"
3798 AC_ARG_WITH(system-zlib,
3799 [  --with-system-zlib      use installed libz],
3800 zlibdir=
3801 zlibinc=
3802 )
3803 AC_SUBST(zlibdir)
3804 AC_SUBST(zlibinc)
3805
3806 dnl Very limited version of automake's enable-maintainer-mode
3807
3808 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
3809   dnl maintainer-mode is disabled by default
3810   AC_ARG_ENABLE(maintainer-mode,
3811 [  --enable-maintainer-mode
3812                           enable make rules and dependencies not useful
3813                           (and sometimes confusing) to the casual installer],
3814       maintainer_mode=$enableval,
3815       maintainer_mode=no)
3816
3817 AC_MSG_RESULT($maintainer_mode)
3818
3819 if test "$maintainer_mode" = "yes"; then
3820   MAINT=''
3821 else
3822   MAINT='#'
3823 fi
3824 AC_SUBST(MAINT)dnl
3825
3826 # --------------
3827 # Language hooks
3828 # --------------
3829
3830 # Make empty files to contain the specs and options for each language.
3831 # Then add #include lines to for a compiler that has specs and/or options.
3832
3833 subdirs=
3834 lang_opt_files=
3835 lang_specs_files=
3836 lang_tree_files=
3837 # These (without "all_") are set in each config-lang.in.
3838 # `language' must be a single word so is spelled singularly.
3839 all_languages=
3840 all_compilers=
3841 all_outputs='Makefile gccbug'
3842 # List of language makefile fragments.
3843 all_lang_makefrags=
3844 # List of language subdirectory makefiles.  Deprecated.
3845 all_lang_makefiles=
3846 # Additional files for gengtype
3847 all_gtfiles="$target_gtfiles"
3848
3849 # These are the languages that are set in --enable-languages,
3850 # and are available in the GCC tree.
3851 all_selected_languages=
3852
3853 # Add the language fragments.
3854 # Languages are added via two mechanisms.  Some information must be
3855 # recorded in makefile variables, these are defined in config-lang.in.
3856 # We accumulate them and plug them into the main Makefile.
3857 # The other mechanism is a set of hooks for each of the main targets
3858 # like `clean', `install', etc.
3859
3860 language_hooks="Make-hooks"
3861
3862 for lang in ${srcdir}/*/config-lang.in
3863 do
3864 changequote(,)dnl
3865         test "$lang" = "${srcdir}/*/config-lang.in" && continue
3866
3867         lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^   ]*\).*$,\1,p' $lang`
3868         if test "x$lang_alias" = x
3869         then
3870               echo "$lang doesn't set \$language." 1>&2
3871               exit 1
3872         fi
3873         subdir="`echo $lang | sed -e 's,^.*/\([^/]*\)/config-lang.in$,\1,'`"
3874         subdirs="$subdirs $subdir"
3875
3876         # $gcc_subdir is where the gcc integration files are to be found
3877         # for a language, both for internal compiler purposes (compiler
3878         # sources implementing front-end to GCC tree converters), and for
3879         # build infrastructure purposes (Make-lang.in, etc.)
3880         #
3881         # This will be <subdir> (relative to $srcdir) if a line like 
3882         # gcc_subdir="<subdir>" or gcc_subdir=<subdir>
3883         # is found in <langdir>/config-lang.in, and will remain <langdir>
3884         # otherwise.
3885         #
3886         # Except for the language alias (fetched above), the regular
3887         # "config-lang.in" contents are always retrieved from $gcc_subdir,
3888         # so a <langdir>/config-lang.in setting gcc_subdir typically sets
3889         # only this and the language alias.
3890
3891         gcc_subdir=`sed -n -e 's,^gcc_subdir=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^gcc_subdir=\([^   ]*\).*$,\1,p' $lang`
3892         if [ "$gcc_subdir" = "" ]; then
3893            gcc_subdir="$subdir"
3894         fi
3895
3896         case ",$enable_languages," in
3897         *,$lang_alias,*)
3898             all_selected_languages="$all_selected_languages $lang_alias"
3899             if test -f $srcdir/$gcc_subdir/lang-specs.h; then
3900                 lang_specs_files="$lang_specs_files $srcdir/$gcc_subdir/lang-specs.h"
3901             fi
3902             ;;
3903         esac
3904 changequote([,])dnl
3905
3906         language=
3907         boot_language=
3908         compilers=
3909         outputs=
3910         gtfiles=
3911         subdir_requires=
3912         . ${srcdir}/$gcc_subdir/config-lang.in
3913         if test "x$language" = x
3914         then
3915                 echo "${srcdir}/$gcc_subdir/config-lang.in doesn't set \$language." 1>&2
3916                 exit 1
3917         fi
3918
3919         ok=:
3920         case ",$enable_languages," in
3921                 *,$lang_alias,*) ;;
3922                 *)
3923                         for i in $subdir_requires; do
3924                                 test -f "${srcdir}/$i/config-lang.in" && continue
3925                                 ok=false
3926                                 break
3927                         done
3928                 ;;
3929         esac
3930         $ok || continue
3931
3932         all_lang_makefrags="$all_lang_makefrags \$(srcdir)/$gcc_subdir/Make-lang.in"
3933         if test -f $srcdir/$gcc_subdir/lang.opt; then
3934             lang_opt_files="$lang_opt_files $srcdir/$gcc_subdir/lang.opt"
3935         fi
3936         if test -f $srcdir/$gcc_subdir/$subdir-tree.def; then
3937             lang_tree_files="$lang_tree_files $srcdir/$gcc_subdir/$subdir-tree.def"
3938         fi
3939         if test -f ${srcdir}/$gcc_subdir/Makefile.in
3940                 then all_lang_makefiles="$gcc_subdir/Makefile"
3941         fi
3942         all_languages="$all_languages $language"
3943         all_compilers="$all_compilers $compilers"
3944         all_outputs="$all_outputs $outputs"
3945         all_gtfiles="$all_gtfiles [[$subdir]] $gtfiles"
3946 done
3947
3948 # Pick up gtfiles for c
3949 gtfiles=
3950 . ${srcdir}/c-config-lang.in
3951 all_gtfiles="$all_gtfiles [[c]] $gtfiles"
3952
3953 check_languages=
3954 for language in $all_selected_languages
3955 do
3956         check_languages="$check_languages check-$language"
3957 done
3958
3959 # We link each language in with a set of hooks, reached indirectly via
3960 # lang.${target}.  Only do so for selected languages.
3961
3962 rm -f Make-hooks
3963 touch Make-hooks
3964 target_list="all.cross start.encap rest.encap tags \
3965         install-common install-man install-info install-pdf dvi pdf \
3966         html uninstall info man srcextra srcman srcinfo \
3967         mostlyclean clean distclean maintainer-clean install-plugin"
3968
3969 for t in $target_list
3970 do
3971         x=
3972         for lang in $all_selected_languages
3973         do
3974                 x="$x $lang.$t"
3975         done
3976         echo "lang.$t: $x" >> Make-hooks
3977 done
3978
3979 # --------
3980 # UNSORTED
3981 # --------
3982
3983 # Create .gdbinit.
3984
3985 echo "dir ." > .gdbinit
3986 echo "dir ${srcdir}" >> .gdbinit
3987 if test x$gdb_needs_out_file_path = xyes
3988 then
3989         echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
3990 fi
3991 if test "x$subdirs" != x; then
3992         for s in $subdirs
3993         do
3994                 echo "dir ${srcdir}/$s" >> .gdbinit
3995         done
3996 fi
3997 echo "source ${srcdir}/gdbinit.in" >> .gdbinit
3998
3999 gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
4000 AC_SUBST(gcc_tooldir)
4001 AC_SUBST(dollar)
4002
4003 # Find a directory in which to install a shared libgcc.
4004
4005 AC_ARG_ENABLE(version-specific-runtime-libs,
4006 [  --enable-version-specific-runtime-libs
4007                           specify that runtime libraries should be
4008                           installed in a compiler-specific directory])
4009
4010 AC_ARG_WITH(slibdir,
4011 [  --with-slibdir=DIR      shared libraries in DIR [[LIBDIR]]],
4012 slibdir="$with_slibdir",
4013 if test "${enable_version_specific_runtime_libs+set}" = set; then
4014   slibdir='$(libsubdir)'
4015 elif test "$host" != "$target"; then
4016   slibdir='$(build_tooldir)/lib'
4017 else
4018   slibdir='$(libdir)'
4019 fi)
4020 AC_SUBST(slibdir)
4021
4022 # Substitute configuration variables
4023 AC_SUBST(subdirs)
4024 AC_SUBST(srcdir)
4025 AC_SUBST(all_compilers)
4026 AC_SUBST(all_gtfiles)
4027 AC_SUBST(all_lang_makefrags)
4028 AC_SUBST(all_lang_makefiles)
4029 AC_SUBST(all_languages)
4030 AC_SUBST(all_selected_languages)
4031 AC_SUBST(build_exeext)
4032 AC_SUBST(build_install_headers_dir)
4033 AC_SUBST(build_xm_file_list)
4034 AC_SUBST(build_xm_include_list)
4035 AC_SUBST(build_xm_defines)
4036 AC_SUBST(build_file_translate)
4037 AC_SUBST(check_languages)
4038 AC_SUBST(cpp_install_dir)
4039 AC_SUBST(xmake_file)
4040 AC_SUBST(tmake_file)
4041 AC_SUBST(TM_ENDIAN_CONFIG)
4042 AC_SUBST(TM_MULTILIB_CONFIG)
4043 AC_SUBST(TM_MULTILIB_EXCEPTIONS_CONFIG)
4044 AC_SUBST(extra_gcc_objs)
4045 AC_SUBST(extra_headers_list)
4046 AC_SUBST(extra_objs)
4047 AC_SUBST(extra_parts)
4048 AC_SUBST(extra_passes)
4049 AC_SUBST(extra_programs)
4050 AC_SUBST(float_h_file)
4051 AC_SUBST(gcc_config_arguments)
4052 AC_SUBST(gcc_gxx_include_dir)
4053 AC_SUBST(host_exeext)
4054 AC_SUBST(host_xm_file_list)
4055 AC_SUBST(host_xm_include_list)
4056 AC_SUBST(host_xm_defines)
4057 AC_SUBST(out_host_hook_obj)
4058 AC_SUBST(install)
4059 AC_SUBST(lang_opt_files)
4060 AC_SUBST(lang_specs_files)
4061 AC_SUBST(lang_tree_files)
4062 AC_SUBST(local_prefix)
4063 AC_SUBST(md_file)
4064 AC_SUBST(objc_boehm_gc)
4065 AC_SUBST(out_file)
4066 AC_SUBST(out_object_file)
4067 AC_SUBST(thread_file)
4068 AC_SUBST(tm_file_list)
4069 AC_SUBST(tm_include_list)
4070 AC_SUBST(tm_defines)
4071 AC_SUBST(tm_p_file_list)
4072 AC_SUBST(tm_p_include_list)
4073 AC_SUBST(xm_file_list)
4074 AC_SUBST(xm_include_list)
4075 AC_SUBST(xm_defines)
4076 AC_SUBST(use_gcc_stdint)
4077 AC_SUBST(c_target_objs)
4078 AC_SUBST(cxx_target_objs)
4079 AC_SUBST(fortran_target_objs)
4080 AC_SUBST(target_cpu_default)
4081
4082 AC_SUBST_FILE(language_hooks)
4083
4084 # Echo link setup.
4085 if test x${build} = x${host} ; then
4086   if test x${host} = x${target} ; then
4087     echo "Links are now set up to build a native compiler for ${target}." 1>&2
4088   else
4089     echo "Links are now set up to build a cross-compiler" 1>&2
4090     echo " from ${host} to ${target}." 1>&2
4091   fi
4092 else
4093   if test x${host} = x${target} ; then
4094     echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
4095     echo " for ${target}." 1>&2
4096   else
4097     echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
4098     echo " from ${host} to ${target}." 1>&2
4099   fi
4100 fi
4101
4102 AC_ARG_VAR(GMPLIBS,[How to link GMP])
4103 AC_ARG_VAR(GMPINC,[How to find GMP include files])
4104
4105 case "${GMPLIBS}" in
4106   *-lmpc*) AC_DEFINE(HAVE_mpc, 1, [Define if mpc is in use.]) ;;
4107 esac
4108
4109 AC_ARG_VAR(PPLLIBS,[How to link PPL])
4110 AC_ARG_VAR(PPLINC,[How to find PPL include files])
4111
4112 AC_ARG_VAR(CLOOGLIBS,[How to link CLOOG])
4113 AC_ARG_VAR(CLOOGINC,[How to find CLOOG include files])
4114 if test "x${CLOOGLIBS}" != "x" ; then 
4115    AC_DEFINE(HAVE_cloog, 1, [Define if cloog is in use.])
4116 fi
4117
4118 # Check for plugin support
4119 AC_ARG_ENABLE(plugin,
4120 [  --enable-plugin         enable plugin support],
4121 enable_plugin=$enableval,
4122 enable_plugin=yes; default_plugin=yes)
4123
4124 pluginlibs=
4125 if test x"$enable_plugin" = x"yes"; then
4126   # Check that the host supports -rdynamic and -ldl
4127   have_rdynamic=no
4128   have_dl=no
4129   saved_LDFLAGS="$LDFLAGS"
4130   saved_LIBS="$LIBS"
4131   LIBS=
4132
4133   # Check -rdynamic
4134   LDFLAGS="$LDFLAGS -rdynamic"
4135   AC_MSG_CHECKING([for -rdynamic])
4136   AC_TRY_LINK([],[return 0;],
4137     [AC_MSG_RESULT([yes]); have_rdynamic=yes],
4138     [AC_MSG_RESULT([no])])
4139   if test x"$have_rdynamic" = x"yes" ; then
4140     pluginlibs="-rdynamic"
4141   fi
4142
4143   # Check -ldl
4144   LDFLAGS="$LDFLAGS -ldl"
4145   AC_MSG_CHECKING([for -ldl])
4146   AC_TRY_LINK(
4147     [#include <dlfcn.h>],
4148     [volatile int f = 0; if (f) dlopen ("dummy", 0);],
4149     [AC_MSG_RESULT([yes]); have_dl=yes],
4150     [AC_MSG_RESULT([no])])
4151   if test x"$have_dl" = x"yes"; then
4152     pluginlibs="$pluginlibs -ldl"
4153   fi
4154
4155   # Check that we can build shared objects with -fPIC -shared
4156   LDFLAGS="$LDFLAGS -fPIC -shared"
4157   AC_MSG_CHECKING([for -fPIC -shared])
4158   AC_TRY_LINK(
4159     [extern int X;],[return X == 0;],
4160     [AC_MSG_RESULT([yes]); have_pic_shared=yes],
4161     [AC_MSG_RESULT([no]); have_pic_shared=no])
4162   if test x"$have_pic_shared" != x"yes"; then
4163     pluginlibs=
4164     enable_plugin=no
4165   fi
4166
4167   # If plugin support had been requested but not available, fail.
4168   if test x"$enable_plugin" = x"no" ; then
4169     if test x"$default_plugin" != x"yes"; then
4170       AC_MSG_ERROR([
4171 Building GCC with plugin support requires a host that supports
4172 -fPIC, -shared, -ldl and -rdynamic.])
4173     fi
4174   fi
4175
4176   LDFLAGS="$saved_LDFLAGS"
4177   LIBS="$saved_LIBS"
4178 fi
4179
4180 AC_SUBST(pluginlibs)
4181 AC_SUBST(enable_plugin)
4182 if test x"$enable_plugin" = x"yes"; then
4183   AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
4184 fi
4185
4186 # Configure the subdirectories
4187 # AC_CONFIG_SUBDIRS($subdirs)
4188
4189 # Create the Makefile
4190 # and configure language subdirectories
4191 AC_CONFIG_FILES($all_outputs)
4192
4193 AC_CONFIG_COMMANDS([default],
4194 [
4195 case ${CONFIG_HEADERS} in
4196   *auto-host.h:config.in*)
4197   echo > cstamp-h ;;
4198 esac
4199 # Make sure all the subdirs exist.
4200 for d in $subdirs doc build
4201 do
4202     test -d $d || mkdir $d
4203 done
4204 ], 
4205 [subdirs='$subdirs'])
4206 AC_OUTPUT