OSDN Git Service

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