OSDN Git Service

2005-06-16 Paolo Bonzini <bonzini@gnu.org>
authorbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Jun 2005 12:49:06 +0000 (12:49 +0000)
committerbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Jun 2005 12:49:06 +0000 (12:49 +0000)
            Daniel Jacobowitz  <dan@codesourcery.com>
    Alan Modra <amodra.bigpond.net.au>

        * configure.ac (gcc_version): Set near the beginning.
        (as, ld, nm): Do not link in-tree tools.  Set gcc_cv_* if tools are
        found in the tree.  Use gcc_AC_PROG to find the tools in the system.
        (objdump): Do not look for it.
        * Makefile.in (NM_FOR_TARGET): Point to ./nm.
        (ORIGINAL_AS_FOR_TARGET, ORIGINAL_LD_FOR_TARGET,
        ORIGINAL_NM_FOR_TARGET): Substitute from autoconf.
        (as, ld, nm): New rules.
        (libgcc.mk): Depend on them.
        * aclocal.m4 (gcc_AC_TOOL_DIRS, gcc_AC_CHECK_TOOL,
        gcc_AC_BUILD_EXEEXT): New.
        (gcc_AC_CHECK_PROG_VER): Use gcc_AC_BUILD_EXEEXT.
        * configure: Regenerate.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101084 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/aclocal.m4
gcc/configure
gcc/configure.ac

index 05f5280..4a6bae3 100644 (file)
@@ -1,3 +1,21 @@
+2005-06-16  Paolo Bonzini  <bonzini@gnu.org>
+            Daniel Jacobowitz  <dan@codesourcery.com>
+           Alan Modra <amodra.bigpond.net.au>
+
+        * configure.ac (gcc_version): Set near the beginning.
+        (as, ld, nm): Do not link in-tree tools.  Set gcc_cv_* if tools are
+        found in the tree.  Use gcc_AC_PROG to find the tools in the system.
+        (objdump): Do not look for it.
+        * Makefile.in (NM_FOR_TARGET): Point to ./nm
+        (ORIGINAL_AS_FOR_TARGET, ORIGINAL_LD_FOR_TARGET,
+        ORIGINAL_NM_FOR_TARGET): Substitute from autoconf.
+        (as, ld, nm): New rules.
+        (libgcc.mk): Depend on them.
+        * aclocal.m4 (gcc_AC_TOOL_DIRS, gcc_AC_CHECK_TOOL,
+        gcc_AC_BUILD_EXEEXT): New.
+        (gcc_AC_CHECK_PROG_VER): Use gcc_AC_BUILD_EXEEXT.
+        * configure: Regenerate.
+
 2005-06-16  Jan Hubicka  <jh@suse.cz>
 
        * basic-block.h (rtl_bb_info): Break out head_, end_,
 
 2005-05-17  Paolo Bonzini  <bonzini@gnu.org>
 
-       * tree-ssa-math-opts.c: New file.
-
-2005-05-17  Paolo Bonzini  <bonzini@gnu.org>
-
        * Makefile.in: Add tree-ssa-math-opts.c.
        * expr.c (expand_expr_real_1) <case RDIV_EXPR>: Never emit as a*(1/b).
        * fold-const.c (distribute_real_division): New.
index b54ddf3..5328f37 100644 (file)
@@ -343,6 +343,7 @@ AR_FOR_TARGET := $(shell \
 AR_FLAGS_FOR_TARGET =
 AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
 AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
+ORIGINAL_AS_FOR_TARGET = @ORIGINAL_AS_FOR_TARGET@
 RANLIB_FOR_TARGET := $(shell \
   if [ -f $(objdir)/../binutils/ranlib ] ; then \
     echo $(objdir)/../binutils/ranlib ; \
@@ -353,18 +354,9 @@ RANLIB_FOR_TARGET := $(shell \
        t='$(program_transform_name)'; echo ranlib | sed -e $$t ; \
     fi; \
   fi)
-NM_FOR_TARGET := $(shell \
-  if [ -f ./nm ] ; then \
-    echo ./nm ; \
-  elif [ -f $(objdir)/../binutils/nm-new ] ; then \
-    echo $(objdir)/../binutils/nm-new ; \
-  else \
-    if [ "$(host)" = "$(target)" ] ; then \
-      echo $(NM); \
-    else \
-       t='$(program_transform_name)'; echo nm | sed -e $$t ; \
-    fi; \
-  fi)
+ORIGINAL_LD_FOR_TARGET = @ORIGINAL_LD_FOR_TARGET@
+ORIGINAL_NM_FOR_TARGET = @ORIGINAL_NM_FOR_TARGET@
+NM_FOR_TARGET = ./nm
 
 # --------
 # UNSORTED
@@ -1207,6 +1199,49 @@ cpp$(exeext): gcc.o cppspec.o version.o intl.o prefix.o \
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gcc.o cppspec.o intl.o \
          prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
+# Create links to binutils, especially for in-tree builds, to make -B.
+# use them.  We need hard links so that directories can be shuffled
+# during toplevel bootstrap.
+# Go through an additional indirection, because the file we create
+# can be either `sometool' (if it is a script) or `sometool$(exeext)'
+# (if it is a hard link).
+stamp-as: $(ORIGINAL_AS_FOR_TARGET)
+       @echo creating as; rm -f as; \
+       case "$<" in \
+         ./*) ;; \
+         ../*) \
+            echo $(LN) $< as$(exeext); \
+            $(LN) $< as$(exeext) || cp $< as$(exeext) ;; \
+         *) echo '#!$(SHELL)' > as; echo 'exec $< "$$@"' >> as ; \
+            chmod +x as ;; \
+       esac
+       echo timestamp > $@
+       
+
+stamp-collect-ld: $(ORIGINAL_LD_FOR_TARGET)
+       @echo creating collect-ld; rm -f collect-ld; \
+       case "$<" in \
+         ./*) ;; \
+         ../*) \
+            echo $(LN) $< collect-ld$(exeext); \
+            $(LN) $< collect-ld$(exeext) || cp $< collect-ld$(exeext) ;; \
+         *) echo '#!$(SHELL)' > collect-ld; echo 'exec $< "$$@"' >> collect-ld ; \
+            chmod +x collect-ld ;; \
+       esac
+       echo timestamp > $@
+
+stamp-nm: $(ORIGINAL_NM_FOR_TARGET)
+       @echo creating nm; rm -f nm; \
+       case "$<" in \
+         ./*) ;; \
+         ../*) \
+            echo $(LN) $< nm$(exeext); \
+            $(LN) $< nm$(exeext) || cp $< nm$(exeext) ;; \
+         *) echo '#!$(SHELL)' > nm; echo 'exec $< "$$@"' >> nm ; \
+            chmod +x nm ;; \
+       esac
+       echo timestamp > $@
+
 # Dump a specs file to make -B./ read these specs over installed ones.
 $(SPECS): xgcc$(exeext)
        $(GCC_FOR_TARGET) -dumpspecs > tmp-specs
@@ -1245,7 +1280,8 @@ xlimits.h: glimits.h limitx.h limity.h
 LIB2ADD = $(LIB2FUNCS_EXTRA)
 LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
 
-libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) $(LIB2ADD_ST) xgcc$(exeext) specs
+libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) $(LIB2ADD_ST) specs \
+               xgcc$(exeext) stamp-as stamp-collect-ld stamp-nm
        objext='$(objext)' \
        LIB1ASMFUNCS='$(LIB1ASMFUNCS)' \
        LIB2FUNCS_ST='$(LIB2FUNCS_ST)' \
@@ -4031,7 +4067,7 @@ bootstrap4 bootstrap4-lean: stage4_build
 unstage1 unstage2 unstage3 unstage4 unstageprofile unstagefeedback:
        -set -vx; stage=`echo $@ | sed -e 's/un//'`; \
        rm -f $$stage/as$(exeext); \
-       rm -f $$stage/ld$(exeext); \
+       rm -f $$stage/nm$(exeext); \
        rm -f $$stage/collect-ld$(exeext); \
        if test -d $$stage; then \
          mv $$stage/specs $(SPECS) 2>/dev/null || :; \
index 9e7da1f..b180c1b 100644 (file)
@@ -329,7 +329,8 @@ dnl Locate a program and check that its version is acceptable.
 dnl AC_PROG_CHECK_VER(var, name, version-switch,
 dnl                  version-extract-regexp, version-glob)
 AC_DEFUN([gcc_AC_CHECK_PROG_VER],
-[AC_CHECK_PROG([$1], [$2], [$2])
+[AC_REQUIRE([gcc_AC_BUILD_EXEEXT])
+AC_CHECK_PROG([$1], [$2], [$2])
 if test -n "[$]$1"; then
   # Found it, now check the version.
   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
@@ -653,3 +654,78 @@ m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[#ifndef USED_FOR_TARGET
 ])[#undef $1]m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[
 #endif
 ]))])
+
+AC_DEFUN([gcc_AC_TOOL_DIRS], [
+# When searching for the assembler or linker, search the same directories
+# that the installed compiler will search.  Else we may find the wrong
+# assembler or linker and lose.  If we do not find a suitable binary,
+# then try the user's path.
+#
+# Also note we have to check MD_EXEC_PREFIX before checking the user's path.
+if test "x$exec_prefix" = xNONE; then
+       if test "x$prefix" = xNONE; then
+               gcc_cv_tool_prefix=/usr/local
+       else
+               gcc_cv_tool_prefix=$prefix
+       fi
+else
+       gcc_cv_tool_prefix=$exec_prefix
+fi
+
+if test x$host = x$build; then
+    gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin"
+else
+    gcc_cv_tool_dirs=
+fi
+
+if test x$build = x$target; then
+    # Rummage through tm_files looking for MD_EXEC_PREFIX
+    md_dirs=
+    for f in ${tm_file_list}; do
+       if test -f $f; then
+           if grep '^#[        ]*undef[        ]*MD_EXEC_PREFIX' $f > /dev/null; then
+               md_dirs=
+           fi
+           md_dirs="$md_dirs "`sed -n -e 's@^#[        ]*define[       ]*MD_EXEC_PREFIX[       ]*"\(.*\)/"@\1@p' < $f`
+       fi
+    done
+    for f in ${md_dirs}; do
+        gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$f"
+    done
+fi])
+
+dnl Make sure that build_exeext is looked for
+AC_DEFUN([gcc_AC_BUILD_EXEEXT], [
+ac_executable_extensions="$build_exeext"])
+
+AC_DEFUN([gcc_AC_CHECK_TOOL], [
+AC_REQUIRE([gcc_AC_TOOL_DIRS])
+AC_REQUIRE([gcc_AC_BUILD_EXEEXT])
+
+dnl shut up useless "checking for..." messages
+dnl we can still read them in config.log
+exec AS_MESSAGE_FD([])>/dev/null
+AC_PATH_PROGS($1, $2, , $gcc_cv_tool_dirs)
+if test "x[$]$1" = x; then
+       # If the loop above did not find a tool, then use whatever
+       # one we can find in the users's path.  We are looking for a
+       # ${build} -> ${target} tool.
+       if test "x$program_prefix" != xNONE; then
+               default_tool_name=${program_prefix}$2
+       elif test x$build != x$host && test x$build != x$target; then
+               default_tool_name=${target_noncanonical}-$2
+       else
+               default_tool_name=`echo $2 | sed "${program_transform_name}"`
+       fi
+       AC_PATH_PROGS($1, $default_tool_name,
+               $gcc_cv_tool_prefix/$default_tool_name$build_exeext)
+fi
+test "$silent" != yes && exec AS_MESSAGE_FD([])>&1
+
+$3="[$]$1"
+AC_SUBST($3)])
index d258e44..a5e04ec 100755 (executable)
@@ -309,7 +309,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS host_cc_for_libada CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS host_cc_for_libada CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 gcc_cv_as ORIGINAL_AS_FOR_TARGET gcc_cv_ld ORIGINAL_LD_FOR_TARGET gcc_cv_nm ORIGINAL_NM_FOR_TARGET libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
 ac_subst_files='language_hooks'
 
 # Initialize some variables set by options.
@@ -1385,6 +1385,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
           ac_config_headers="$ac_config_headers auto-host.h:config.in"
 
 
+gcc_version=`cat $srcdir/BASE-VER`
+
 # Determine the host, build, and target systems
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
@@ -7359,6 +7361,9 @@ MISSING="${CONFIG_SHELL-/bin/sh} $srcdir/../missing"
 
 # See if makeinfo has been installed and is modern enough
 # that we can use it.
+
+ac_executable_extensions="$build_exeext"
+
 # Extract the first word of "makeinfo", so it can be a program name with args.
 set dummy makeinfo; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -7403,7 +7408,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then
 else
     ac_prog_version=`$MAKEINFO --version 2>&1 |
                    sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
-  echo "configure:7406: version of makeinfo is $ac_prog_version" >&5
+  echo "configure:7411: version of makeinfo is $ac_prog_version" >&5
   case $ac_prog_version in
     '')     gcc_cv_prog_makeinfo_modern=no;;
     4.[2-9]*)
@@ -12791,8 +12796,6 @@ esac
 # If build != host, and we aren't building gas in-tree, we identify a
 # build->target assembler and hope that it will have the same features
 # as the host->target assembler we'll be using.
-echo "$as_me:$LINENO: checking what assembler to use" >&5
-echo $ECHO_N "checking what assembler to use... $ECHO_C" >&6
 in_tree_gas=no
 gcc_cv_as=
 gcc_cv_gas_major_version=
@@ -12800,9 +12803,6 @@ gcc_cv_gas_minor_version=
 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
 if test -x "$DEFAULT_ASSEMBLER"; then
        gcc_cv_as="$DEFAULT_ASSEMBLER"
-elif test -x as$build_exeext; then
-       # Build using assembler in the current directory.
-       gcc_cv_as=./as$build_exeext
 elif test -f $gcc_cv_as_gas_srcdir/configure.in \
      && test -f ../gas/Makefile \
      && test x$build = x$host; then
@@ -12830,8 +12830,7 @@ gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
                            + $gcc_cv_gas_minor_version \) \* 1000 \
                            + $gcc_cv_gas_patch_version`
 
-  rm -f as$build_exeext
-  $LN_S ../gas/as-new$build_exeext as$build_exeext 2>/dev/null
+  gcc_cv_as=../gas/as-new$build_exeext
   in_tree_gas_is_elf=no
   if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
      || (grep 'obj_format = multi' ../gas/Makefile \
@@ -12839,79 +12838,170 @@ gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
   then
     in_tree_gas_is_elf=yes
   fi
+elif test -x as$build_exeext; then
+       # Build using assembler in the current directory.
+       gcc_cv_as=./as$build_exeext
 elif test -x "$AS_FOR_TARGET"; then
         gcc_cv_as="$AS_FOR_TARGET"
 elif test -x "$AS" && test x$host = x$target; then
        gcc_cv_as="$AS"
 fi
 
-gcc_version=`cat $srcdir/BASE-VER`
 
-if test "x$gcc_cv_as" = x; then
-       # Search the same directories that the installed compiler will
-       # search.  Else we may find the wrong assembler and lose.  If we
-       # do not find a suitable assembler binary, then try the user's
-       # path.
-       #
-       # Also note we have to check MD_EXEC_PREFIX before checking the
-       # user's path.  Unfortunately, there is no good way to get at the
-       # value of MD_EXEC_PREFIX here.  So we do a brute force search
-       # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
-       # to be fixed as part of the make/configure rewrite too.
-
-       if test "x$exec_prefix" = xNONE; then
-               if test "x$prefix" = xNONE; then
-                       test_prefix=/usr/local
-               else
-                       test_prefix=$prefix
-               fi
+# When searching for the assembler or linker, search the same directories
+# that the installed compiler will search.  Else we may find the wrong
+# assembler or linker and lose.  If we do not find a suitable binary,
+# then try the user's path.
+#
+# Also note we have to check MD_EXEC_PREFIX before checking the user's path.
+if test "x$exec_prefix" = xNONE; then
+       if test "x$prefix" = xNONE; then
+               gcc_cv_tool_prefix=/usr/local
        else
-               test_prefix=$exec_prefix
+               gcc_cv_tool_prefix=$prefix
        fi
+else
+       gcc_cv_tool_prefix=$exec_prefix
+fi
+
+if test x$host = x$build; then
+    gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR/usr/lib/gcc/$target_noncanonical"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version"
+    gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$gcc_cv_tool_prefix/$target_noncanonical/bin"
+else
+    gcc_cv_tool_dirs=
+fi
+
+if test x$build = x$target; then
+    # Rummage through tm_files looking for MD_EXEC_PREFIX
+    md_dirs=
+    for f in ${tm_file_list}; do
+       if test -f $f; then
+           if grep '^#[        ]*undef[        ]*MD_EXEC_PREFIX' $f > /dev/null; then
+               md_dirs=
+           fi
+           md_dirs="$md_dirs "`sed -n -e 's@^#[        ]*define[       ]*MD_EXEC_PREFIX[       ]*"\(.*\)/"@\1@p' < $f`
+       fi
+    done
+    for f in ${md_dirs}; do
+        gcc_cv_tool_dirs="$gcc_cv_tool_dirs$PATH_SEPARATOR$f"
+    done
+fi
+
+
+
+
+exec 6>/dev/null
+for ac_prog in as
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_as+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $gcc_cv_as in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_as="$gcc_cv_as" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $gcc_cv_tool_dirs
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_as="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-       # If the loop below does not find an assembler, then use whatever
+  ;;
+esac
+fi
+gcc_cv_as=$ac_cv_path_gcc_cv_as
+
+if test -n "$gcc_cv_as"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_as" >&5
+echo "${ECHO_T}$gcc_cv_as" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_as" && break
+done
+
+if test "x$gcc_cv_as" = x; then
+       # If the loop above did not find a tool, then use whatever
        # one we can find in the users's path.  We are looking for a
-       # ${build} -> ${target} assembler.
+       # ${build} -> ${target} tool.
        if test "x$program_prefix" != xNONE; then
-               gcc_cv_as=${program_prefix}as$build_exeext
+               default_tool_name=${program_prefix}as
        elif test x$build != x$host && test x$build != x$target; then
-               gcc_cv_as=${target_noncanonical}-as$build_exeext
+               default_tool_name=${target_noncanonical}-as
        else
-               gcc_cv_as=`echo as | sed "${program_transform_name}"`$build_exeext
+               default_tool_name=`echo as | sed "${program_transform_name}"`
        fi
+       for ac_prog in $default_tool_name
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_as+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $gcc_cv_as in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_as="$gcc_cv_as" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_as="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-       if test x$host = x$build; then
-           test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
-                      $test_prefix/libexec/gcc/$target_noncanonical \
-                      /usr/lib/gcc/$target_noncanonical/$gcc_version \
-                      /usr/lib/gcc/$target_noncanonical \
-                      $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
-                      $test_prefix/$target_noncanonical/bin"
-       else
-           test_dirs=
-       fi
+  ;;
+esac
+fi
+gcc_cv_as=$ac_cv_path_gcc_cv_as
 
-       if test x$build = x$target; then
-           test_dirs="$test_dirs \
-                  /usr/libexec \
-                  /usr/ccs/gcc \
-                  /usr/ccs/bin \
-                  /udk/usr/ccs/bin \
-                  /bsd43/usr/lib/cmplrs/cc \
-                  /usr/cross64/usr/bin \
-                  /usr/lib/cmplrs/cc \
-                  /sysv/usr/lib/cmplrs/cc \
-                  /svr4/usr/lib/cmplrs/cc \
-                  /usr/bin"
-       fi
+if test -n "$gcc_cv_as"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_as" >&5
+echo "${ECHO_T}$gcc_cv_as" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_as" && break
+done
+test -n "$gcc_cv_as" || gcc_cv_as="$gcc_cv_tool_prefix/$default_tool_name$build_exeext"
 
-       for dir in $test_dirs; do
-               if test -x $dir/as$build_exeext; then
-                       gcc_cv_as=$dir/as$build_exeext
-                       break;
-               fi
-       done
 fi
+test "$silent" != yes && exec 6>&1
+
+ORIGINAL_AS_FOR_TARGET="$gcc_cv_as"
+
+echo "$as_me:$LINENO: checking what assembler to use" >&5
+echo $ECHO_N "checking what assembler to use... $ECHO_C" >&6
 case $in_tree_gas in
   yes)
     echo "$as_me:$LINENO: result: \"newly built gas\"" >&5
@@ -12930,8 +13020,6 @@ esac
 # If build != host, and we aren't building gas in-tree, we identify a
 # build->target linker and hope that it will have the same features
 # as the host->target linker we'll be using.
-echo "$as_me:$LINENO: checking what linker to use" >&5
-echo $ECHO_N "checking what linker to use... $ECHO_C" >&6
 in_tree_ld=no
 gcc_cv_ld=
 gcc_cv_gld_major_version=
@@ -12940,9 +13028,6 @@ gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
 gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
 if test -x "$DEFAULT_LINKER"; then
        gcc_cv_ld="$DEFAULT_LINKER"
-elif test -x collect-ld$build_exeext; then
-       # Build using linker in the current directory.
-       gcc_cv_ld=./collect-ld$build_exeext
 elif test -f $gcc_cv_ld_gld_srcdir/configure.in \
      && test -f ../ld/Makefile \
      && test x$build = x$host; then
@@ -12965,79 +13050,128 @@ elif test -f $gcc_cv_ld_gld_srcdir/configure.in \
        done
        gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
        gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
-       rm -f collect-ld$build_exeext
-       $LN_S ../ld/ld-new$build_exeext collect-ld$build_exeext 2>/dev/null
+       gcc_cv_ld=../ld/ld-new$build_exeext
+elif test -x collect-ld$build_exeext; then
+       # Build using linker in the current directory.
+       gcc_cv_ld=./collect-ld$build_exeext
 elif test -x "$LD_FOR_TARGET"; then
         gcc_cv_ld="$LD_FOR_TARGET"
 elif test -x "$LD" && test x$host = x$target; then
        gcc_cv_ld="$LD"
 fi
 
-if test "x$gcc_cv_ld" = x; then
-       # Search the same directories that the installed compiler will
-       # search.  Else we may find the wrong linker and lose.  If we
-       # do not find a suitable linker binary, then try the user's
-       # path.
-       #
-       # Also note we have to check MD_EXEC_PREFIX before checking the
-       # user's path.  Unfortunately, there is no good way to get at the
-       # value of MD_EXEC_PREFIX here.  So we do a brute force search
-       # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
-       # to be fixed as part of the make/configure rewrite too.
-
-       if test "x$exec_prefix" = xNONE; then
-               if test "x$prefix" = xNONE; then
-                       test_prefix=/usr/local
-               else
-                       test_prefix=$prefix
-               fi
-       else
-               test_prefix=$exec_prefix
-       fi
 
-       # If the loop below does not find a linker, then use whatever
+
+
+
+exec 6>/dev/null
+for ac_prog in ld
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $gcc_cv_ld in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_ld="$gcc_cv_ld" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $gcc_cv_tool_dirs
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_ld="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  ;;
+esac
+fi
+gcc_cv_ld=$ac_cv_path_gcc_cv_ld
+
+if test -n "$gcc_cv_ld"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_ld" >&5
+echo "${ECHO_T}$gcc_cv_ld" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_ld" && break
+done
+
+if test "x$gcc_cv_ld" = x; then
+       # If the loop above did not find a tool, then use whatever
        # one we can find in the users's path.  We are looking for a
-       # ${build} -> ${target} linker.
+       # ${build} -> ${target} tool.
        if test "x$program_prefix" != xNONE; then
-               gcc_cv_ld=${program_prefix}ld$build_exeext
+               default_tool_name=${program_prefix}ld
        elif test x$build != x$host && test x$build != x$target; then
-               gcc_cv_ld=${target_noncanonical}-ld$build_exeext
+               default_tool_name=${target_noncanonical}-ld
        else
-               gcc_cv_ld=`echo ld | sed "${program_transform_name}"`$build_exeext
+               default_tool_name=`echo ld | sed "${program_transform_name}"`
        fi
+       for ac_prog in $default_tool_name
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $gcc_cv_ld in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_ld="$gcc_cv_ld" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_ld="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-       if test x$host = x$build; then
-           test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
-                      $test_prefix/libexec/gcc/$target_noncanonical \
-                      /usr/lib/gcc/$target_noncanonical/$gcc_version \
-                      /usr/lib/gcc/$target_noncanonical \
-                      $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
-                      $test_prefix/$target_noncanonical/bin"
-       else
-           test_dirs=
-       fi
+  ;;
+esac
+fi
+gcc_cv_ld=$ac_cv_path_gcc_cv_ld
 
-       if test x$build = x$target; then
-           test_dirs="$test_dirs \
-                  /usr/libexec \
-                  /usr/ccs/gcc \
-                  /usr/ccs/bin \
-                  /udk/usr/ccs/bin \
-                  /bsd43/usr/lib/cmplrs/cc \
-                  /usr/cross64/usr/bin \
-                  /usr/lib/cmplrs/cc \
-                  /sysv/usr/lib/cmplrs/cc \
-                  /svr4/usr/lib/cmplrs/cc \
-                  /usr/bin"
-       fi
+if test -n "$gcc_cv_ld"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_ld" >&5
+echo "${ECHO_T}$gcc_cv_ld" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_ld" && break
+done
+test -n "$gcc_cv_ld" || gcc_cv_ld="$gcc_cv_tool_prefix/$default_tool_name$build_exeext"
 
-       for dir in $test_dirs; do
-               if test -x $dir/ld$build_exeext; then
-                       gcc_cv_ld=$dir/ld$build_exeext
-                       break;
-               fi
-       done
 fi
+test "$silent" != yes && exec 6>&1
+
+ORIGINAL_LD_FOR_TARGET="$gcc_cv_ld"
+
+echo "$as_me:$LINENO: checking what linker to use" >&5
+echo $ECHO_N "checking what linker to use... $ECHO_C" >&6
 case $in_tree_ld in
   yes)
     echo "$as_me:$LINENO: result: \"newly built ld\"" >&5
@@ -13051,25 +13185,129 @@ esac
 
 # Figure out what nm we will be using.
 gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
-echo "$as_me:$LINENO: checking what nm to use" >&5
-echo $ECHO_N "checking what nm to use... $ECHO_C" >&6
 in_tree_nm=no
-if test -x nm$build_exeext; then
-       gcc_cv_nm=./nm$build_exeext
-elif test -f $gcc_cv_binutils_srcdir/configure.in \
+gcc_cv_nm=
+if test -f $gcc_cv_binutils_srcdir/configure.in \
      && test -f ../binutils/Makefile; then
        # Single tree build which includes binutils.
        in_tree_nm=yes
+       gcc_cv_nm=../binutils/nm-new$build_exeext
+elif test -x nm$build_exeext; then
        gcc_cv_nm=./nm$build_exeext
-       rm -f nm$build_exeext
-       $LN_S ../binutils/nm-new$build_exeext nm$build_exeext 2>/dev/null
-elif test "x$program_prefix" != xNONE; then
-       gcc_cv_nm=${program_prefix}nm$build_exeext
-elif test x$build != x$host && test x$build != x$target; then
-       gcc_cv_nm=${target_noncanonical}-nm$build_exeext
+fi
+
+
+
+
+
+exec 6>/dev/null
+for ac_prog in nm
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_nm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       gcc_cv_nm=`echo nm | sed "${program_transform_name}"`$build_exeext
+  case $gcc_cv_nm in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_nm="$gcc_cv_nm" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $gcc_cv_tool_dirs
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_nm="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  ;;
+esac
 fi
+gcc_cv_nm=$ac_cv_path_gcc_cv_nm
+
+if test -n "$gcc_cv_nm"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_nm" >&5
+echo "${ECHO_T}$gcc_cv_nm" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_nm" && break
+done
+
+if test "x$gcc_cv_nm" = x; then
+       # If the loop above did not find a tool, then use whatever
+       # one we can find in the users's path.  We are looking for a
+       # ${build} -> ${target} tool.
+       if test "x$program_prefix" != xNONE; then
+               default_tool_name=${program_prefix}nm
+       elif test x$build != x$host && test x$build != x$target; then
+               default_tool_name=${target_noncanonical}-nm
+       else
+               default_tool_name=`echo nm | sed "${program_transform_name}"`
+       fi
+       for ac_prog in $default_tool_name
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_gcc_cv_nm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $gcc_cv_nm in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_nm="$gcc_cv_nm" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_nm="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  ;;
+esac
+fi
+gcc_cv_nm=$ac_cv_path_gcc_cv_nm
+
+if test -n "$gcc_cv_nm"; then
+  echo "$as_me:$LINENO: result: $gcc_cv_nm" >&5
+echo "${ECHO_T}$gcc_cv_nm" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$gcc_cv_nm" && break
+done
+test -n "$gcc_cv_nm" || gcc_cv_nm="$gcc_cv_tool_prefix/$default_tool_name$build_exeext"
+
+fi
+test "$silent" != yes && exec 6>&1
+
+ORIGINAL_NM_FOR_TARGET="$gcc_cv_nm"
+
+echo "$as_me:$LINENO: checking what nm to use" >&5
+echo $ECHO_N "checking what nm to use... $ECHO_C" >&6
 case $in_tree_nm in
   yes) echo "$as_me:$LINENO: result: \"newly built nm\"" >&5
 echo "${ECHO_T}\"newly built nm\"" >&6 ;;
@@ -13087,9 +13325,7 @@ elif test -f $gcc_cv_binutils_srcdir/configure.in \
      && test -f ../binutils/Makefile; then
        # Single tree build which includes binutils.
        in_tree_objdump=yes
-       gcc_cv_objdump=./objdump$build_exeext
-       rm -f objdump$build_exeext
-       $LN_S ../binutils/objdump$build_exeext objdump$build_exeext 2>/dev/null
+       gcc_cv_objdump=../binutils/objdump$build_exeext
 elif test "x$program_prefix" != xNONE; then
        gcc_cv_objdump=${program_prefix}objdump$build_exeext
 elif test x$build != x$host && test x$build != x$target; then
@@ -16349,6 +16585,12 @@ s,@BUILD_CFLAGS@,$BUILD_CFLAGS,;t t
 s,@STMP_FIXINC@,$STMP_FIXINC,;t t
 s,@STMP_FIXPROTO@,$STMP_FIXPROTO,;t t
 s,@collect2@,$collect2,;t t
+s,@gcc_cv_as@,$gcc_cv_as,;t t
+s,@ORIGINAL_AS_FOR_TARGET@,$ORIGINAL_AS_FOR_TARGET,;t t
+s,@gcc_cv_ld@,$gcc_cv_ld,;t t
+s,@ORIGINAL_LD_FOR_TARGET@,$ORIGINAL_LD_FOR_TARGET,;t t
+s,@gcc_cv_nm@,$gcc_cv_nm,;t t
+s,@ORIGINAL_NM_FOR_TARGET@,$ORIGINAL_NM_FOR_TARGET,;t t
 s,@libgcc_visibility@,$libgcc_visibility,;t t
 s,@GGC@,$GGC,;t t
 s,@zlibdir@,$zlibdir,;t t
index f5ac726..84a1902 100644 (file)
@@ -30,6 +30,8 @@ AC_INIT
 AC_CONFIG_SRCDIR(tree.c)
 AC_CONFIG_HEADER(auto-host.h:config.in)
 
+gcc_version=`cat $srcdir/BASE-VER`
+
 # Determine the host, build, and target systems
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
@@ -1739,7 +1741,6 @@ esac
 # If build != host, and we aren't building gas in-tree, we identify a
 # build->target assembler and hope that it will have the same features
 # as the host->target assembler we'll be using.
-AC_MSG_CHECKING(what assembler to use)
 in_tree_gas=no
 gcc_cv_as=
 gcc_cv_gas_major_version=
@@ -1747,9 +1748,6 @@ gcc_cv_gas_minor_version=
 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
 if test -x "$DEFAULT_ASSEMBLER"; then
        gcc_cv_as="$DEFAULT_ASSEMBLER"
-elif test -x as$build_exeext; then
-       # Build using assembler in the current directory.
-       gcc_cv_as=./as$build_exeext
 elif test -f $gcc_cv_as_gas_srcdir/configure.in \
      && test -f ../gas/Makefile \
      && test x$build = x$host; then
@@ -1758,8 +1756,7 @@ elif test -f $gcc_cv_as_gas_srcdir/configure.in \
   # we'll use what we're building after installation anyway.
   in_tree_gas=yes
   _gcc_COMPUTE_GAS_VERSION
-  rm -f as$build_exeext
-  $LN_S ../gas/as-new$build_exeext as$build_exeext 2>/dev/null
+  gcc_cv_as=../gas/as-new$build_exeext
   in_tree_gas_is_elf=no
   if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
      || (grep 'obj_format = multi' ../gas/Makefile \
@@ -1768,79 +1765,17 @@ elif test -f $gcc_cv_as_gas_srcdir/configure.in \
     in_tree_gas_is_elf=yes
   fi
 m4_pattern_allow([AS_FOR_TARGET])dnl
+elif test -x as$build_exeext; then
+       # Build using assembler in the current directory.
+       gcc_cv_as=./as$build_exeext
 elif test -x "$AS_FOR_TARGET"; then
         gcc_cv_as="$AS_FOR_TARGET"
 elif test -x "$AS" && test x$host = x$target; then
        gcc_cv_as="$AS"
 fi
 
-gcc_version=`cat $srcdir/BASE-VER`
-
-if test "x$gcc_cv_as" = x; then
-       # Search the same directories that the installed compiler will
-       # search.  Else we may find the wrong assembler and lose.  If we
-       # do not find a suitable assembler binary, then try the user's
-       # path.
-       #
-       # Also note we have to check MD_EXEC_PREFIX before checking the
-       # user's path.  Unfortunately, there is no good way to get at the
-       # value of MD_EXEC_PREFIX here.  So we do a brute force search
-       # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
-       # to be fixed as part of the make/configure rewrite too.
-
-       if test "x$exec_prefix" = xNONE; then
-               if test "x$prefix" = xNONE; then
-                       test_prefix=/usr/local
-               else
-                       test_prefix=$prefix
-               fi
-       else
-               test_prefix=$exec_prefix
-       fi
-
-       # If the loop below does not find an assembler, then use whatever
-       # one we can find in the users's path.  We are looking for a
-       # ${build} -> ${target} assembler.
-       if test "x$program_prefix" != xNONE; then
-               gcc_cv_as=${program_prefix}as$build_exeext
-       elif test x$build != x$host && test x$build != x$target; then
-               gcc_cv_as=${target_noncanonical}-as$build_exeext
-       else
-               gcc_cv_as=`echo as | sed "${program_transform_name}"`$build_exeext
-       fi
-
-       if test x$host = x$build; then
-           test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
-                      $test_prefix/libexec/gcc/$target_noncanonical \
-                      /usr/lib/gcc/$target_noncanonical/$gcc_version \
-                      /usr/lib/gcc/$target_noncanonical \
-                      $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
-                      $test_prefix/$target_noncanonical/bin"
-       else
-           test_dirs=
-       fi
-
-       if test x$build = x$target; then
-           test_dirs="$test_dirs \
-                  /usr/libexec \
-                  /usr/ccs/gcc \
-                  /usr/ccs/bin \
-                  /udk/usr/ccs/bin \
-                  /bsd43/usr/lib/cmplrs/cc \
-                  /usr/cross64/usr/bin \
-                  /usr/lib/cmplrs/cc \
-                  /sysv/usr/lib/cmplrs/cc \
-                  /svr4/usr/lib/cmplrs/cc \
-                  /usr/bin"
-       fi
-
-       for dir in $test_dirs; do
-               if test -x $dir/as$build_exeext; then
-                       gcc_cv_as=$dir/as$build_exeext
-                       break;
-               fi
-       done
-fi
+gcc_AC_CHECK_TOOL(gcc_cv_as, as, ORIGINAL_AS_FOR_TARGET)
+AC_MSG_CHECKING(what assembler to use)
 case $in_tree_gas in
   yes)
     AC_MSG_RESULT("newly built gas")
@@ -1857,7 +1792,6 @@ esac
 # If build != host, and we aren't building gas in-tree, we identify a
 # build->target linker and hope that it will have the same features
 # as the host->target linker we'll be using.
-AC_MSG_CHECKING(what linker to use)
 in_tree_ld=no
 gcc_cv_ld=
 gcc_cv_gld_major_version=
@@ -1866,9 +1800,6 @@ gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
 gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
 if test -x "$DEFAULT_LINKER"; then
        gcc_cv_ld="$DEFAULT_LINKER"
-elif test -x collect-ld$build_exeext; then
-       # Build using linker in the current directory.
-       gcc_cv_ld=./collect-ld$build_exeext
 elif test -f $gcc_cv_ld_gld_srcdir/configure.in \
      && test -f ../ld/Makefile \
      && test x$build = x$host; then
@@ -1895,79 +1826,18 @@ changequote(,)dnl
        gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
        gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
 changequote([,])dnl
-       rm -f collect-ld$build_exeext
-       $LN_S ../ld/ld-new$build_exeext collect-ld$build_exeext 2>/dev/null
+       gcc_cv_ld=../ld/ld-new$build_exeext
+elif test -x collect-ld$build_exeext; then
+       # Build using linker in the current directory.
+       gcc_cv_ld=./collect-ld$build_exeext
 elif test -x "$LD_FOR_TARGET"; then
         gcc_cv_ld="$LD_FOR_TARGET"
 elif test -x "$LD" && test x$host = x$target; then
        gcc_cv_ld="$LD"
 fi
 
-if test "x$gcc_cv_ld" = x; then
-       # Search the same directories that the installed compiler will
-       # search.  Else we may find the wrong linker and lose.  If we
-       # do not find a suitable linker binary, then try the user's
-       # path.
-       #
-       # Also note we have to check MD_EXEC_PREFIX before checking the
-       # user's path.  Unfortunately, there is no good way to get at the
-       # value of MD_EXEC_PREFIX here.  So we do a brute force search
-       # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
-       # to be fixed as part of the make/configure rewrite too.
-
-       if test "x$exec_prefix" = xNONE; then
-               if test "x$prefix" = xNONE; then
-                       test_prefix=/usr/local
-               else
-                       test_prefix=$prefix
-               fi
-       else
-               test_prefix=$exec_prefix
-       fi
-
-       # If the loop below does not find a linker, then use whatever
-       # one we can find in the users's path.  We are looking for a
-       # ${build} -> ${target} linker.
-       if test "x$program_prefix" != xNONE; then
-               gcc_cv_ld=${program_prefix}ld$build_exeext
-       elif test x$build != x$host && test x$build != x$target; then
-               gcc_cv_ld=${target_noncanonical}-ld$build_exeext
-       else
-               gcc_cv_ld=`echo ld | sed "${program_transform_name}"`$build_exeext
-       fi
-
-       if test x$host = x$build; then
-           test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
-                      $test_prefix/libexec/gcc/$target_noncanonical \
-                      /usr/lib/gcc/$target_noncanonical/$gcc_version \
-                      /usr/lib/gcc/$target_noncanonical \
-                      $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
-                      $test_prefix/$target_noncanonical/bin"
-       else
-           test_dirs=
-       fi
-
-       if test x$build = x$target; then
-           test_dirs="$test_dirs \
-                  /usr/libexec \
-                  /usr/ccs/gcc \
-                  /usr/ccs/bin \
-                  /udk/usr/ccs/bin \
-                  /bsd43/usr/lib/cmplrs/cc \
-                  /usr/cross64/usr/bin \
-                  /usr/lib/cmplrs/cc \
-                  /sysv/usr/lib/cmplrs/cc \
-                  /svr4/usr/lib/cmplrs/cc \
-                  /usr/bin"
-       fi
-
-       for dir in $test_dirs; do
-               if test -x $dir/ld$build_exeext; then
-                       gcc_cv_ld=$dir/ld$build_exeext
-                       break;
-               fi
-       done
-fi
+gcc_AC_CHECK_TOOL(gcc_cv_ld, ld, ORIGINAL_LD_FOR_TARGET)
+AC_MSG_CHECKING(what linker to use)
 case $in_tree_ld in
   yes)
     AC_MSG_RESULT("newly built ld")
@@ -1979,24 +1849,19 @@ esac
 
 # Figure out what nm we will be using.
 gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
-AC_MSG_CHECKING(what nm to use)
 in_tree_nm=no
-if test -x nm$build_exeext; then
-       gcc_cv_nm=./nm$build_exeext
-elif test -f $gcc_cv_binutils_srcdir/configure.in \
+gcc_cv_nm=
+if test -f $gcc_cv_binutils_srcdir/configure.in \
      && test -f ../binutils/Makefile; then
        # Single tree build which includes binutils.
        in_tree_nm=yes
+       gcc_cv_nm=../binutils/nm-new$build_exeext
+elif test -x nm$build_exeext; then
        gcc_cv_nm=./nm$build_exeext
-       rm -f nm$build_exeext
-       $LN_S ../binutils/nm-new$build_exeext nm$build_exeext 2>/dev/null
-elif test "x$program_prefix" != xNONE; then
-       gcc_cv_nm=${program_prefix}nm$build_exeext
-elif test x$build != x$host && test x$build != x$target; then
-       gcc_cv_nm=${target_noncanonical}-nm$build_exeext
-else
-       gcc_cv_nm=`echo nm | sed "${program_transform_name}"`$build_exeext
 fi
+
+gcc_AC_CHECK_TOOL(gcc_cv_nm, nm, ORIGINAL_NM_FOR_TARGET)
+AC_MSG_CHECKING(what nm to use)
 case $in_tree_nm in
   yes) AC_MSG_RESULT("newly built nm") ;;
   no)  AC_MSG_RESULT($gcc_cv_nm) ;;
@@ -2011,9 +1876,7 @@ elif test -f $gcc_cv_binutils_srcdir/configure.in \
      && test -f ../binutils/Makefile; then
        # Single tree build which includes binutils.
        in_tree_objdump=yes
-       gcc_cv_objdump=./objdump$build_exeext
-       rm -f objdump$build_exeext
-       $LN_S ../binutils/objdump$build_exeext objdump$build_exeext 2>/dev/null
+       gcc_cv_objdump=../binutils/objdump$build_exeext
 elif test "x$program_prefix" != xNONE; then
        gcc_cv_objdump=${program_prefix}objdump$build_exeext
 elif test x$build != x$host && test x$build != x$target; then