This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cross newlib builds on svn head


Joel Sherrill <joel@OARcorp.com> wrote:

Hi,


I have been trying to build sparc-rtems4.7 on the head using newlib's head for a few days now. I have finally narrowed the behavior down.

If I configure for sparc I am configuring for sparc-rtems4.7 with c and c++, it builds fine. The build process uses xgcc for newlib as one would expect. If I add ada to the --enable-languages then newlib fails to build because it picks a non-existent compile (sparc-rtems4.7-cc) to build with.

Can you try the attached patch?


Paolo
Index: configure.in
===================================================================
--- configure.in	(revision 106381)
+++ configure.in	(working copy)
@@ -1611,17 +1611,6 @@
 tooldir='${exec_prefix}'/${target_alias}
 build_tooldir=${tooldir}
 
-# Generate default definitions for YACC, M4, LEX and other programs that run
-# on the build machine.  These are used if the Makefile can't locate these
-# programs in objdir.
-MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
-AC_CHECK_PROGS([CONFIGURED_BISON], [bison], [$MISSING bison])
-AC_CHECK_PROGS([CONFIGURED_YACC], ['bison -y' byacc yacc], [$MISSING bison -y])
-AC_CHECK_PROGS([CONFIGURED_M4], [gm4 gnum4 m4], [$MISSING m4])
-AC_CHECK_PROGS([CONFIGURED_FLEX], [flex], [$MISSING flex])
-AC_CHECK_PROGS([CONFIGURED_LEX], [flex lex], [$MISSING flex])
-AC_CHECK_PROGS([CONFIGURED_MAKEINFO], makeinfo, [$MISSING makeinfo])
-
 # Create a .gdbinit file which runs the one in srcdir
 # and tells GDB to look there for source files.
 
@@ -2095,13 +2084,81 @@
 AC_SUBST(CC_FOR_BUILD)
 AC_SUBST(config_shell)
 
+# Generate default definitions for YACC, M4, LEX and other programs that run
+# on the build machine.  These are used if the Makefile can't locate these
+# programs in objdir.
+MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
+
+AC_CHECK_PROGS([YACC], ['bison -y' byacc yacc], [$MISSING bison -y])
+case " $build_configdirs " in
+  *" bison "*) YACC='$$r/$(BUILD_SUBDIR)/bison/tests/bison -y' ;;
+  *" byacc "*) YACC='$$r/$(BUILD_SUBDIR)/byacc/byacc' ;;
+esac
+
+AC_CHECK_PROGS([BISON], [bison], [$MISSING bison])
+case " $build_configdirs " in
+  *" bison "*) BISON='$$r/$(BUILD_SUBDIR)/bison/tests/bison' ;;
+esac
+
+AC_CHECK_PROGS([M4], [gm4 gnum4 m4], [$MISSING m4])
+case " $build_configdirs " in
+  *" m4 "*) M4='$$r/$(BUILD_SUBDIR)/m4/m4' ;;
+esac
+
+AC_CHECK_PROGS([LEX], [flex lex], [$MISSING flex])
+case " $build_configdirs " in
+  *" flex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+  *" lex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+esac
+
+AC_CHECK_PROGS([FLEX], [flex], [$MISSING flex])
+case " $build_configdirs " in
+  *" flex "*) FLEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+esac
+
+AC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
+case " $build_configdirs " in
+  *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+  *)
+changequote(,)
+    # For an installed makeinfo, we require it to be from texinfo 4.2 or
+    # higher, else we use the "missing" dummy.
+    if ${MAKEINFO} --version \
+       | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])' >/dev/null 2>&1; then
+      :
+    else
+      MAKEINFO="$MISSING makeinfo"
+    fi
+    ;;
+changequote([,])
+esac
+
+# FIXME: expect and dejagnu may become build tools?
+
+AC_CHECK_PROGS(EXPECT, expect, expect)
+case " $build_configdirs " in
+  *" expect "*)
+    test $host = $build && EXPECT='$$r/$(HOST_SUBDIR)/expect/expect'
+    ;;
+esac
+
+AC_CHECK_PROGS(RUNTEST, runtest, runtest)
+case " $build_configdirs " in
+  *" dejagnu "*)
+    test $host = $build && RUNTEST='$$r/$(HOST_SUBDIR)/dejagnu/runtest'
+    ;;
+esac
+
+
 # Host tools.
 NCN_STRICT_CHECK_TOOLS(AR, ar)
 NCN_STRICT_CHECK_TOOLS(AS, as)
 NCN_STRICT_CHECK_TOOLS(DLLTOOL, dlltool)
 NCN_STRICT_CHECK_TOOLS(LD, ld)
+NCN_STRICT_CHECK_TOOLS(LIPO, lipo)
 NCN_STRICT_CHECK_TOOLS(NM, nm)
 NCN_STRICT_CHECK_TOOLS(RANLIB, ranlib, :)
+NCN_STRICT_CHECK_TOOLS(STRIP, strip, :)
 NCN_STRICT_CHECK_TOOLS(WINDRES, windres)
 NCN_STRICT_CHECK_TOOLS(OBJCOPY, objcopy)
 NCN_STRICT_CHECK_TOOLS(OBJDUMP, objdump)
@@ -2111,8 +2168,7 @@
 AC_SUBST(CFLAGS_FOR_BUILD)
 AC_SUBST(CXXFLAGS)
 
-# Target tools.  Do the tests using the names they may have passed in
-# the environment, then move it to CONFIGURED_*_FOR_TARGET.
+# Target tools.
 NCN_STRICT_CHECK_TARGET_TOOLS(AR_FOR_TARGET, ar)
 NCN_STRICT_CHECK_TARGET_TOOLS(AS_FOR_TARGET, as)
 NCN_STRICT_CHECK_TARGET_TOOLS(CC_FOR_TARGET, cc gcc)
@@ -2129,83 +2185,56 @@
 NCN_STRICT_CHECK_TARGET_TOOLS(STRIP_FOR_TARGET, strip)
 NCN_STRICT_CHECK_TARGET_TOOLS(WINDRES_FOR_TARGET, windres)
 
-CONFIGURED_AR_FOR_TARGET="$AR_FOR_TARGET"
-CONFIGURED_AS_FOR_TARGET="$AS_FOR_TARGET"
-CONFIGURED_CC_FOR_TARGET="$CC_FOR_TARGET"
-CONFIGURED_CXX_FOR_TARGET="$CXX_FOR_TARGET"
-CONFIGURED_DLLTOOL_FOR_TARGET="$DLLTOOL_FOR_TARGET"
-CONFIGURED_GCC_FOR_TARGET="$GCC_FOR_TARGET"
-CONFIGURED_GCJ_FOR_TARGET="$GCJ_FOR_TARGET"
-CONFIGURED_GFORTRAN_FOR_TARGET="$GFORTRAN_FOR_TARGET"
-CONFIGURED_LD_FOR_TARGET="$LD_FOR_TARGET"
-CONFIGURED_LIPO_FOR_TARGET="$LIPO_FOR_TARGET"
-CONFIGURED_NM_FOR_TARGET="$NM_FOR_TARGET"
-CONFIGURED_OBJDUMP_FOR_TARGET="$OBJDUMP_FOR_TARGET"
-CONFIGURED_RANLIB_FOR_TARGET="$RANLIB_FOR_TARGET"
-CONFIGURED_STRIP_FOR_TARGET="$STRIP_FOR_TARGET"
-CONFIGURED_WINDRES_FOR_TARGET="$WINDRES_FOR_TARGET"
+RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
 
-AC_SUBST(CONFIGURED_AR_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_AS_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_CC_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_CXX_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_DLLTOOL_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_GCC_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_GCJ_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_GFORTRAN_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_LD_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_LIPO_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_NM_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_OBJDUMP_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_RANLIB_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_STRIP_FOR_TARGET)dnl
-AC_SUBST(CONFIGURED_WINDRES_FOR_TARGET)dnl
+GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR,
+		[binutils/ar],
+		binutils)
+GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS,
+		[gas/as-new],
+		gas)
+GCC_TARGET_TOOL(cc, CC_FOR_TARGET, CC,
+		[gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/],
+		gcc)
+GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX,
+		[gcc/g++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs],
+		gcc, c++)
+GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX,
+		[gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs],
+		gcc, c++)
+GCC_TARGET_TOOL(dlltool, DLLTOOL_FOR_TARGET, DLLTOOL,
+		[binutils/dlltool],
+		binutils)
+GCC_TARGET_TOOL(gcc, GCC_FOR_TARGET, ,
+		[gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/],
+		gcc)
+GCC_TARGET_TOOL(gcj, GCJ_FOR_TARGET, GCJ,
+		[gcc/gcj -B$$r/$(HOST_SUBDIR)/gcc/],
+		gcc, java)
+GCC_TARGET_TOOL(gfortran, GFORTRAN_FOR_TARGET, GFORTRAN,
+		[gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/],
+		gcc, fortran)
+GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD,
+		[ld/ld-new],
+		ld)
+GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
+GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM,
+		[binutils/nm-new],
+		binutils)
+GCC_TARGET_TOOL(objdump, OBJDUMP_FOR_TARGET, OBJDUMP,
+		[binutils/objdump],
+		binutils)
+GCC_TARGET_TOOL(ranlib, RANLIB_FOR_TARGET, RANLIB,
+		[binutils/ranlib],
+		binutils)
+GCC_TARGET_TOOL(strip, STRIP_FOR_TARGET, STRIP,
+		[binutils/strip],
+		binutils)
+GCC_TARGET_TOOL(windres, WINDRES_FOR_TARGET, WINDRES,
+		[binutils/windres],
+		binutils)
+
 AC_SUBST(FLAGS_FOR_TARGET)
-
-# Fix up target tools.
-if test "x${build}" = "x${host}" ; then
-  # In this case, the newly built tools can and should be used,
-  # so we override the results of the autoconf tests.
-  # This should really only happen when the tools are actually being built,
-  # but that's a further refinement.  The new build scheme, where
-  # tools are built into a structure paralleling where they're installed,
-  # should also eliminate all of this cleanly.
-  AR_FOR_TARGET="\$(USUAL_AR_FOR_TARGET)"
-  AS_FOR_TARGET="\$(USUAL_AS_FOR_TARGET)"
-  CC_FOR_TARGET="\$(USUAL_CC_FOR_TARGET)"
-  CXX_FOR_TARGET="\$(USUAL_CXX_FOR_TARGET)"
-  RAW_CXX_FOR_TARGET="\$(USUAL_RAW_CXX_FOR_TARGET)"
-  DLLTOOL_FOR_TARGET="\$(USUAL_DLLTOOL_FOR_TARGET)"
-  GCC_FOR_TARGET="\$(USUAL_GCC_FOR_TARGET)"
-  GCJ_FOR_TARGET="\$(USUAL_GCJ_FOR_TARGET)"
-  GFORTRAN_FOR_TARGET="\$(USUAL_GFORTRAN_FOR_TARGET)"
-  LD_FOR_TARGET="\$(USUAL_LD_FOR_TARGET)"
-  LIPO_FOR_TARGET="\$(USUAL_LIPO_FOR_TARGET)"
-  NM_FOR_TARGET="\$(USUAL_NM_FOR_TARGET)"
-  OBJDUMP_FOR_TARGET="\$(USUAL_OBJDUMP_FOR_TARGET)"
-  RANLIB_FOR_TARGET="\$(USUAL_RANLIB_FOR_TARGET)"
-  STRIP_FOR_TARGET="\$(USUAL_STRIP_FOR_TARGET)"
-  WINDRES_FOR_TARGET="\$(USUAL_WINDRES_FOR_TARGET)"
-else
-  # Just use the ones we found.
-  AR_FOR_TARGET="\$(CONFIGURED_AR_FOR_TARGET)"
-  AS_FOR_TARGET="\$(CONFIGURED_AS_FOR_TARGET)"
-  CC_FOR_TARGET="\$(CONFIGURED_CC_FOR_TARGET)"
-  CXX_FOR_TARGET="\$(CONFIGURED_CXX_FOR_TARGET)"
-  RAW_CXX_FOR_TARGET="\$(CONFIGURED_CXX_FOR_TARGET)"
-  DLLTOOL_FOR_TARGET="\$(CONFIGURED_DLLTOOL_FOR_TARGET)"
-  GCC_FOR_TARGET="\$(CONFIGURED_GCC_FOR_TARGET)"
-  GCJ_FOR_TARGET="\$(CONFIGURED_GCJ_FOR_TARGET)"
-  GFORTRAN_FOR_TARGET="\$(CONFIGURED_GFORTRAN_FOR_TARGET)"
-  LD_FOR_TARGET="\$(CONFIGURED_LD_FOR_TARGET)"
-  LIPO_FOR_TARGET="\$(CONFIGURED_LIPO_FOR_TARGET)"
-  NM_FOR_TARGET="\$(CONFIGURED_NM_FOR_TARGET)"
-  OBJDUMP_FOR_TARGET="\$(CONFIGURED_OBJDUMP_FOR_TARGET)"
-  RANLIB_FOR_TARGET="\$(CONFIGURED_RANLIB_FOR_TARGET)"
-  STRIP_FOR_TARGET="\$(CONFIGURED_STRIP_FOR_TARGET)"
-  WINDRES_FOR_TARGET="\$(CONFIGURED_WINDRES_FOR_TARGET)"  
-fi
-
 AC_SUBST(RAW_CXX_FOR_TARGET)
 
 # Certain tools may need extra flags.
@@ -2213,6 +2242,21 @@
 RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET}${extra_ranlibflags_for_target}
 NM_FOR_TARGET=${NM_FOR_TARGET}${extra_nmflags_for_target}
 
+# When building target libraries, we use the same toolchain as the compiler
+# we just built.
+case " $configdirs " in
+  *" gcc "*)
+    COMPILER_AS_FOR_TARGET='$$r/gcc/as'
+    COMPILER_LD_FOR_TARGET='$$r/gcc/collect-ld'
+    COMPILER_NM_FOR_TARGET='$$r/gcc/nm'${extra_nmflags_for_target}
+    ;;
+  *)
+    COMPILER_AS_FOR_TARGET='$(COMPILER_AS_FOR_TARGET)'
+    COMPILER_LD_FOR_TARGET='$(COMPILER_LD_FOR_TARGET)'
+    COMPILER_NM_FOR_TARGET='$(COMPILER_NM_FOR_TARGET)'
+    ;;
+esac
+
 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 AC_ARG_ENABLE(maintainer-mode,
 [  --enable-maintainer-mode enable make rules and dependencies not useful
Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(revision 106381)
+++ Makefile.tpl	(working copy)
@@ -136,7 +136,8 @@
 # with srcdir=..
 HOST_SUBDIR = @host_subdir@
 # This is the list of variables to export in the environment when
-# configuring subdirectories for the host system.
+# configuring subdirectories for the host system.  We need to pass
+# some to the GCC configure because of its hybrid host/target nature.
 HOST_EXPORTS = \
 	$(BASE_EXPORTS) \
 	CC="$(CC)"; export CC; \
@@ -155,6 +156,13 @@
 	WINDRES="$(WINDRES)"; export WINDRES; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
+	AR_FOR_TARGET="$(AR_FOR_TARGET)"; export AR_FOR_TARGET; \
+	AS_FOR_TARGET="$(AS_FOR_TARGET)"; export AS_FOR_TARGET; \
+	GCC_FOR_TARGET="$(GCC_FOR_TARGET)"; export GCC_FOR_TARGET; \
+	LD_FOR_TARGET="$(LD_FOR_TARGET)"; export LD_FOR_TARGET; \
+	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
+	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
+	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
@@ -186,7 +194,7 @@
 BASE_TARGET_EXPORTS = \
 	$(BASE_EXPORTS) \
 	AR="$(AR_FOR_TARGET)"; export AR; \
-	AS="$(AS_FOR_TARGET)"; export AS; \
+	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
 	CC="$(CC_FOR_TARGET)"; export CC; \
 	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -195,10 +203,10 @@
 	GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
 	GFORTRAN="$(GFORTRAN_FOR_TARGET)"; export GFORTRAN; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
-	LD="$(LD_FOR_TARGET)"; export LD; \
+	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
 	LIPO="$(LIPO_FOR_TARGET)"; export LIPO; \
-	NM="$(NM_FOR_TARGET)"; export NM; \
+	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
@@ -248,91 +256,43 @@
 # here so that they can be overridden by Makefile fragments.
 BOOT_CFLAGS= -g -O2
 
-CONFIGURED_BISON = @CONFIGURED_BISON@
-BISON = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/bison/tests/bison ; \
-	 else \
-	    echo ${CONFIGURED_BISON} ; \
-	 fi`
+BISON = @BISON@
+YACC = @YACC@
+FLEX = @FLEX@
+LEX = @LEX@
+M4 = @M4@
+MAKEINFO = @MAKEINFO@
+EXPECT = @EXPECT@
+RUNTEST = @RUNTEST@
 
-CONFIGURED_YACC = @CONFIGURED_YACC@
-YACC = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/bison/tests/bison -y ; \
-	elif [ -f $$r/$(BUILD_SUBDIR)/byacc/byacc ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/byacc/byacc ; \
-	else \
-	    echo ${CONFIGURED_YACC} ; \
-	fi`
-
-CONFIGURED_FLEX = @CONFIGURED_FLEX@
-FLEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
-	else echo ${CONFIGURED_FLEX} ; fi`
-
-CONFIGURED_LEX = @CONFIGURED_LEX@
-LEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
-	else echo ${CONFIGURED_LEX} ; fi`
-
-CONFIGURED_M4 = @CONFIGURED_M4@
-M4 = `if [ -f $$r/$(BUILD_SUBDIR)/m4/m4 ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/m4/m4 ; \
-	else echo ${CONFIGURED_M4} ; fi`
-
-# For an installed makeinfo, we require it to be from texinfo 4.2 or
-# higher, else we use the "missing" dummy.  We also pass the subdirectory
-# makeinfo even if only the Makefile is there, because Texinfo builds its
-# manual when made, and it requires its own version.
-CONFIGURED_MAKEINFO = @CONFIGURED_MAKEINFO@
-MAKEINFO = `if [ -f $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/Makefile ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo ; \
-	else if (${CONFIGURED_MAKEINFO} --version \
-	  | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])') >/dev/null 2>&1; \
-        then echo ${CONFIGURED_MAKEINFO}; else echo $$s/missing makeinfo; fi; fi`
-
 # This just becomes part of the MAKEINFO definition passed down to
 # sub-makes.  It lets flags be given on the command line while still
 # using the makeinfo from the object tree.
 # (Default to avoid splitting info files by setting the threshold high.)
 MAKEINFOFLAGS = --split-size=5000000
 
-# FIXME: expect may become a build tool?
-EXPECT = `if [ -f $$r/$(HOST_SUBDIR)/expect/expect ] ; \
-	then echo $$r/$(HOST_SUBDIR)/expect/expect ; \
-	else echo expect ; fi`
-
-RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \
-	then echo $$s/dejagnu/runtest ; \
-	else echo runtest ; fi`
-
 # ---------------------------------------------
 # Programs producing files for the HOST machine
 # ---------------------------------------------
 
 AS = @AS@
-
 AR = @AR@
 AR_FLAGS = rc
-
 CC = @CC@
-CFLAGS = @CFLAGS@
-LIBCFLAGS = $(CFLAGS)
-
 CXX = @CXX@
-CXXFLAGS = @CXXFLAGS@
-LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
-
 DLLTOOL = @DLLTOOL@
-
-NM = @NM@
-
 LD = @LD@
-LDFLAGS = 
-
+LIPO = @LIPO@
+NM = @NM@
 RANLIB = @RANLIB@
-
+STRIP = @STRIP@
 WINDRES = @WINDRES@
 
+CFLAGS = @CFLAGS@
+LDFLAGS = 
+LIBCFLAGS = $(CFLAGS)
+CXXFLAGS = @CXXFLAGS@
+LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 PICFLAG = 
 
 # -----------------------------------------------
@@ -342,242 +302,42 @@
 FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
 
 AR_FOR_TARGET=@AR_FOR_TARGET@
-CONFIGURED_AR_FOR_TARGET=@CONFIGURED_AR_FOR_TARGET@
-USUAL_AR_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/ar ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/ar ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(AR); \
-    else \
-      echo $(CONFIGURED_AR_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 AS_FOR_TARGET=@AS_FOR_TARGET@
-CONFIGURED_AS_FOR_TARGET=@CONFIGURED_AS_FOR_TARGET@
-USUAL_AS_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gas/as-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gas/as-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/as ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/as ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(AS); \
-    else \
-      echo $(CONFIGURED_AS_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_CC_FOR_TARGET=@CONFIGURED_CC_FOR_TARGET@
-USUAL_CC_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CC); \
-    else \
-      echo $(CONFIGURED_CC_FOR_TARGET) ; \
-    fi; \
-  fi`
 
-# During gcc bootstrap, if we use some random cc for stage1 then
-# CFLAGS will be just -g.  We want to ensure that TARGET libraries
-# (which we know are built with gcc) are built with optimizations so
-# prepend -O2 when setting CFLAGS_FOR_TARGET.
-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
-SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
-
 # If GCC_FOR_TARGET is not overriden on the command line, then this
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=@GCC_FOR_TARGET@
-CONFIGURED_GCC_FOR_TARGET=@CONFIGURED_GCC_FOR_TARGET@
-USUAL_GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) \
-  $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ $(FLAGS_FOR_TARGET)
-LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
-
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
 CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_CXX_FOR_TARGET=@CONFIGURED_CXX_FOR_TARGET@
-USUAL_CXX_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/g++ ] ; then \
-    (echo $$r/$(HOST_SUBDIR)/gcc/g++ -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++; \
-    test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; \
-    echo -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs) | tr '\015\012' '  '; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CXX); \
-    else \
-      echo $(CONFIGURED_CXX_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-USUAL_RAW_CXX_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CXX); \
-    else \
-      echo $(CONFIGURED_CXX_FOR_TARGET) ; \
-    fi; \
-  fi`
-
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
-LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
-
 GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_GCJ_FOR_TARGET=@CONFIGURED_GCJ_FOR_TARGET@
-USUAL_GCJ_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/gcj ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/gcj -B$$r/$(HOST_SUBDIR)/gcc ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(GCJ); \
-    else \
-      echo $(CONFIGURED_GCJ_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_GFORTRAN_FOR_TARGET=@CONFIGURED_GFORTRAN_FOR_TARGET@
-USUAL_GFORTRAN_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/gfortran ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(GFORTRAN); \
-    else \
-      echo $(CONFIGURED_GFORTRAN_FOR_TARGET) ; \
-    fi; \
-  fi`
-
-
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
-CONFIGURED_DLLTOOL_FOR_TARGET=@CONFIGURED_DLLTOOL_FOR_TARGET@
-USUAL_DLLTOOL_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/dlltool ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/dlltool ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(DLLTOOL); \
-    else \
-      echo $(CONFIGURED_DLLTOOL_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 LD_FOR_TARGET=@LD_FOR_TARGET@
-CONFIGURED_LD_FOR_TARGET=@CONFIGURED_LD_FOR_TARGET@
-USUAL_LD_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/ld/ld-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/ld/ld-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/collect-ld ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/collect-ld ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(LD); \
-    else \
-      echo $(CONFIGURED_LD_FOR_TARGET) ; \
-    fi; \
-  fi`
 
-LDFLAGS_FOR_TARGET = 
-
 LIPO_FOR_TARGET=@LIPO_FOR_TARGET@
-CONFIGURED_LIPO_FOR_TARGET=@CONFIGURED_LIPO_FOR_TARGET@
-USUAL_LIPO_FOR_TARGET = ` \
-  if [ '$(host)' = '$(target)' ] ; then \
-    if [ x'$(LIPO)' != x ]; then \
-       echo $(LIPO); \
-    else \
-       echo lipo; \
-    fi; \
-  else \
-    echo $(CONFIGURED_LIPO_FOR_TARGET) ; \
-  fi`
-
 NM_FOR_TARGET=@NM_FOR_TARGET@
-CONFIGURED_NM_FOR_TARGET=@CONFIGURED_NM_FOR_TARGET@
-USUAL_NM_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/nm-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/nm-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/nm ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/nm ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(NM); \
-    else \
-      echo $(CONFIGURED_NM_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
-CONFIGURED_OBJDUMP_FOR_TARGET=@CONFIGURED_OBJDUMP_FOR_TARGET@
-USUAL_OBJDUMP_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/objdump ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/objdump ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(OBJDUMP)' != x ]; then \
-         echo $(OBJDUMP); \
-      else \
-         echo objdump; \
-      fi; \
-    else \
-      echo $(CONFIGURED_OBJDUMP_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
-CONFIGURED_RANLIB_FOR_TARGET=@CONFIGURED_RANLIB_FOR_TARGET@
-USUAL_RANLIB_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/ranlib ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/ranlib ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(RANLIB)' != x ]; then \
-         echo $(RANLIB); \
-      else \
-         echo ranlib; \
-      fi; \
-    else \
-      echo $(CONFIGURED_RANLIB_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
-CONFIGURED_STRIP_FOR_TARGET=@CONFIGURED_STRIP_FOR_TARGET@
-USUAL_STRIP_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/strip ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/strip ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(STRIP)' != x ]; then \
-         echo $(STRIP); \
-      else \
-         echo strip; \
-      fi; \
-    else \
-      echo $(CONFIGURED_STRIP_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 WINDRES_FOR_TARGET=@WINDRES_FOR_TARGET@
-CONFIGURED_WINDRES_FOR_TARGET=@CONFIGURED_WINDRES_FOR_TARGET@
-USUAL_WINDRES_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/windres ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/windres ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(WINDRES); \
-    else \
-      echo $(CONFIGURED_WINDRES_FOR_TARGET) ; \
-    fi; \
-  fi`
 
+COMPILER_AS_FOR_TARGET=@COMPILER_AS_FOR_TARGET@
+COMPILER_LD_FOR_TARGET=@COMPILER_LD_FOR_TARGET@
+COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_TARGET@
+
+# During gcc bootstrap, if we use some random cc for stage1 then
+# CFLAGS will be just -g.  We want to ensure that TARGET libraries
+# (which we know are built with gcc) are built with optimizations so
+# prepend -O2 when setting CFLAGS_FOR_TARGET.
+CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
+LDFLAGS_FOR_TARGET = 
 PICFLAG_FOR_TARGET = 
 
 # ------------------------------------
@@ -644,8 +404,10 @@
 	'CXX=$(CXX)' \
 	'DLLTOOL=$(DLLTOOL)' \
 	'LD=$(LD)' \
+	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
 	'RANLIB=$(RANLIB)' \
+	'STRIP=$(STRIP)' \
 	'WINDRES=$(WINDRES)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
@@ -721,28 +483,19 @@
 .PHONY: all
 all:
 @if gcc-bootstrap
+	[ -f stage_final ] || echo stage3 > stage_final
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	if [ ! -f stage_last ]; then \
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) bootstrap; \
-	fi
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble; \
 @endif gcc-bootstrap
 	@$(unstage)
-@if gcc-no-bootstrap
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all-prebootstrap
-@endif gcc-no-bootstrap
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	if [ -f stage_last ]; then \
-	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host; \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host; \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target; \
 	fi
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all-target
 	@$(stage)
 
 .PHONY: all-build
@@ -1440,7 +1193,7 @@
 
 @if gcc-bootstrap
 unstage = [ -f stage_current ] || $(MAKE) `cat stage_last`-start
-stage = $(MAKE) `cat stage_current`-end
+stage = [ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
 @endif gcc-bootstrap
 
 .PHONY: unstage stage
@@ -1495,7 +1248,7 @@
 .PHONY: stage[+id+]-start stage[+id+]-end
 
 stage[+id+]-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stage[+id+] > stage_current ; \
 	echo stage[+id+] > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)[+
@@ -1548,7 +1301,8 @@
 	else \
 	  $(MAKE) stage[+id+]-start; \
 	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage[+id+]; \
-	fi
+	fi[+ IF compare-target +]
+	$(MAKE) [+compare-target+][+ ENDIF compare-target +]
 
 .PHONY: all-stage[+id+] clean-stage[+id+]
 do-clean: clean-stage[+id+]
@@ -1564,7 +1318,7 @@
 	  echo Cannot compare object files as stage [+prev+] was deleted. ; \
 	  exit 0 ; \
 	fi; \
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	$(stage); \
 	rm -f .bad_compare ; \
 	cd stage[+id+]-gcc; \
 	files=`find . -name "*$(objext)" -print` ; \
@@ -1594,16 +1348,23 @@
 
 [+ IF bootstrap-target +]
 .PHONY: [+bootstrap-target+]
-[+bootstrap-target+]: stage[+id+]-bubble
-	[+ IF compare-target +]$(MAKE) [+compare-target+]
-	[+ ENDIF compare-target +]$(MAKE) $(RECURSE_FLAGS_TO_PASS) all
+[+bootstrap-target+]:
+	echo stage[+id+] > stage_final
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) stage[+id+]-bubble
+	@$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
+	@$(stage)
 [+ ENDIF bootstrap-target +]
 
 # Rules to wipe a stage and all the following ones, also used for cleanstrap
 [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
 .PHONY: distclean-stage[+id+]
 distclean-stage[+id+]::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stage[+id+]-* [+
 	  IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
 
Index: config/acx.m4
===================================================================
--- config/acx.m4	(revision 106381)
+++ config/acx.m4	(working copy)
@@ -296,3 +296,35 @@
 AC_SUBST(LN)dnl
 ])
 
+dnl GCC_TARGET_TOOL(PROGRAM, TARGET-VAR, HOST-VAR, IN-TREE-TOOL, DIR, LANGUAGE)
+AC_DEFUN([GCC_TARGET_TOOL],
+[AC_MSG_CHECKING(where to find the target $1)
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  AC_MSG_RESULT(pre-installed)
+else
+  ifelse([$5],, ok=no,
+  [ok=yes
+  case " ${configdirs} " in
+    *" $5 "*) ;;
+    *) ok=no ;;
+  esac])
+  ifelse([$6],,, 
+  [case ,${enable_languages}, in
+    *,$6,*) ;;
+    *) ok=no ;;
+  esac])
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    $2='$$r/$(HOST_SUBDIR)/$4'
+    AC_MSG_RESULT(just compiled)
+ifelse([$3],,,
+  [elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    $2='$($3)'
+    AC_MSG_RESULT(host tool)])
+  else
+    # We need a cross tool
+    AC_MSG_RESULT(pre-installed)
+  fi
+fi])
Index: configure
===================================================================
--- configure	(revision 106381)
+++ configure	(working copy)
@@ -2816,221 +2816,6 @@
 tooldir='${exec_prefix}'/${target_alias}
 build_tooldir=${tooldir}
 
-# Generate default definitions for YACC, M4, LEX and other programs that run
-# on the build machine.  These are used if the Makefile can't locate these
-# programs in objdir.
-MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
-for ac_prog in bison
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2829: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_BISON'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_BISON"; then
-  ac_cv_prog_CONFIGURED_BISON="$CONFIGURED_BISON" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_BISON="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_BISON="$ac_cv_prog_CONFIGURED_BISON"
-if test -n "$CONFIGURED_BISON"; then
-  echo "$ac_t""$CONFIGURED_BISON" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_BISON" && break
-done
-test -n "$CONFIGURED_BISON" || CONFIGURED_BISON="$MISSING bison"
-
-for ac_prog in 'bison -y' byacc yacc
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2864: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_YACC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_YACC"; then
-  ac_cv_prog_CONFIGURED_YACC="$CONFIGURED_YACC" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_YACC="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_YACC="$ac_cv_prog_CONFIGURED_YACC"
-if test -n "$CONFIGURED_YACC"; then
-  echo "$ac_t""$CONFIGURED_YACC" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_YACC" && break
-done
-test -n "$CONFIGURED_YACC" || CONFIGURED_YACC="$MISSING bison -y"
-
-for ac_prog in gm4 gnum4 m4
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2899: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_M4'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_M4"; then
-  ac_cv_prog_CONFIGURED_M4="$CONFIGURED_M4" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_M4="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_M4="$ac_cv_prog_CONFIGURED_M4"
-if test -n "$CONFIGURED_M4"; then
-  echo "$ac_t""$CONFIGURED_M4" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_M4" && break
-done
-test -n "$CONFIGURED_M4" || CONFIGURED_M4="$MISSING m4"
-
-for ac_prog in flex
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2934: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_FLEX'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_FLEX"; then
-  ac_cv_prog_CONFIGURED_FLEX="$CONFIGURED_FLEX" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_FLEX="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_FLEX="$ac_cv_prog_CONFIGURED_FLEX"
-if test -n "$CONFIGURED_FLEX"; then
-  echo "$ac_t""$CONFIGURED_FLEX" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_FLEX" && break
-done
-test -n "$CONFIGURED_FLEX" || CONFIGURED_FLEX="$MISSING flex"
-
-for ac_prog in flex lex
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2969: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_LEX'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_LEX"; then
-  ac_cv_prog_CONFIGURED_LEX="$CONFIGURED_LEX" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_LEX="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_LEX="$ac_cv_prog_CONFIGURED_LEX"
-if test -n "$CONFIGURED_LEX"; then
-  echo "$ac_t""$CONFIGURED_LEX" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_LEX" && break
-done
-test -n "$CONFIGURED_LEX" || CONFIGURED_LEX="$MISSING flex"
-
-for ac_prog in makeinfo
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3004: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CONFIGURED_MAKEINFO'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CONFIGURED_MAKEINFO"; then
-  ac_cv_prog_CONFIGURED_MAKEINFO="$CONFIGURED_MAKEINFO" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CONFIGURED_MAKEINFO="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CONFIGURED_MAKEINFO="$ac_cv_prog_CONFIGURED_MAKEINFO"
-if test -n "$CONFIGURED_MAKEINFO"; then
-  echo "$ac_t""$CONFIGURED_MAKEINFO" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CONFIGURED_MAKEINFO" && break
-done
-test -n "$CONFIGURED_MAKEINFO" || CONFIGURED_MAKEINFO="$MISSING makeinfo"
-
-
 # Create a .gdbinit file which runs the one in srcdir
 # and tells GDB to look there for source files.
 
@@ -3510,6 +3295,344 @@
 
 
 
+# Generate default definitions for YACC, M4, LEX and other programs that run
+# on the build machine.  These are used if the Makefile can't locate these
+# programs in objdir.
+MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
+
+for ac_prog in 'bison -y' byacc yacc
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3309: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$YACC"; then
+  ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_YACC="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+YACC="$ac_cv_prog_YACC"
+if test -n "$YACC"; then
+  echo "$ac_t""$YACC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="$MISSING bison -y"
+
+case " $build_configdirs " in
+  *" bison "*) YACC='$$r/$(BUILD_SUBDIR)/bison/tests/bison -y' ;;
+  *" byacc "*) YACC='$$r/$(BUILD_SUBDIR)/byacc/byacc' ;;
+esac
+
+for ac_prog in bison
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3349: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_BISON'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$BISON"; then
+  ac_cv_prog_BISON="$BISON" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_BISON="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+BISON="$ac_cv_prog_BISON"
+if test -n "$BISON"; then
+  echo "$ac_t""$BISON" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$BISON" && break
+done
+test -n "$BISON" || BISON="$MISSING bison"
+
+case " $build_configdirs " in
+  *" bison "*) BISON='$$r/$(BUILD_SUBDIR)/bison/tests/bison' ;;
+esac
+
+for ac_prog in gm4 gnum4 m4
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3388: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_M4'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$M4"; then
+  ac_cv_prog_M4="$M4" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_M4="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+M4="$ac_cv_prog_M4"
+if test -n "$M4"; then
+  echo "$ac_t""$M4" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$M4" && break
+done
+test -n "$M4" || M4="$MISSING m4"
+
+case " $build_configdirs " in
+  *" m4 "*) M4='$$r/$(BUILD_SUBDIR)/m4/m4' ;;
+esac
+
+for ac_prog in flex lex
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3427: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$LEX"; then
+  ac_cv_prog_LEX="$LEX" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_LEX="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+LEX="$ac_cv_prog_LEX"
+if test -n "$LEX"; then
+  echo "$ac_t""$LEX" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$LEX" && break
+done
+test -n "$LEX" || LEX="$MISSING flex"
+
+case " $build_configdirs " in
+  *" flex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+  *" lex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+esac
+
+for ac_prog in flex
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3467: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_FLEX'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$FLEX"; then
+  ac_cv_prog_FLEX="$FLEX" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_FLEX="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+FLEX="$ac_cv_prog_FLEX"
+if test -n "$FLEX"; then
+  echo "$ac_t""$FLEX" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$FLEX" && break
+done
+test -n "$FLEX" || FLEX="$MISSING flex"
+
+case " $build_configdirs " in
+  *" flex "*) FLEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
+esac
+
+for ac_prog in makeinfo
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3506: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$MAKEINFO"; then
+  ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_MAKEINFO="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+MAKEINFO="$ac_cv_prog_MAKEINFO"
+if test -n "$MAKEINFO"; then
+  echo "$ac_t""$MAKEINFO" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$MAKEINFO" && break
+done
+test -n "$MAKEINFO" || MAKEINFO="$MISSING makeinfo"
+
+case " $build_configdirs " in
+  *" makeinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+  *)
+
+    # For an installed makeinfo, we require it to be from texinfo 4.2 or
+    # higher, else we use the "missing" dummy.
+    if ${MAKEINFO} --version \
+       | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])' >/dev/null 2>&1; then
+      :
+    else
+      MAKEINFO="$MISSING makeinfo"
+    fi
+    ;;
+
+esac
+
+# FIXME: expect and dejagnu may become build tools?
+
+for ac_prog in expect
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3559: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_EXPECT'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$EXPECT"; then
+  ac_cv_prog_EXPECT="$EXPECT" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_EXPECT="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+EXPECT="$ac_cv_prog_EXPECT"
+if test -n "$EXPECT"; then
+  echo "$ac_t""$EXPECT" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$EXPECT" && break
+done
+test -n "$EXPECT" || EXPECT="expect"
+
+case " $build_configdirs " in
+  *" expect "*)
+    test $host = $build && EXPECT='$$r/$(HOST_SUBDIR)/expect/expect'
+    ;;
+esac
+
+for ac_prog in runtest
+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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3600: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RUNTEST'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$RUNTEST"; then
+  ac_cv_prog_RUNTEST="$RUNTEST" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_RUNTEST="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+RUNTEST="$ac_cv_prog_RUNTEST"
+if test -n "$RUNTEST"; then
+  echo "$ac_t""$RUNTEST" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$RUNTEST" && break
+done
+test -n "$RUNTEST" || RUNTEST="runtest"
+
+case " $build_configdirs " in
+  *" dejagnu "*)
+    test $host = $build && RUNTEST='$$r/$(HOST_SUBDIR)/dejagnu/runtest'
+    ;;
+esac
+
+
 # Host tools.
 ncn_tool_prefix=
 test -n "$host_alias" && ncn_tool_prefix=$host_alias-
@@ -3521,7 +3644,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3525: checking for $ac_word" >&5
+echo "configure:3648: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3552,7 +3675,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3556: checking for $ac_word" >&5
+echo "configure:3679: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3596,7 +3719,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3600: checking for $ac_word" >&5
+echo "configure:3723: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3627,7 +3750,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3631: checking for $ac_word" >&5
+echo "configure:3754: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3671,7 +3794,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3675: checking for $ac_word" >&5
+echo "configure:3798: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3702,7 +3825,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3706: checking for $ac_word" >&5
+echo "configure:3829: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3746,7 +3869,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3750: checking for $ac_word" >&5
+echo "configure:3873: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3777,7 +3900,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3781: checking for $ac_word" >&5
+echo "configure:3904: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3816,12 +3939,87 @@
   fi
 fi
 
+ for ncn_progname in lipo; do
+  if test -n "$ncn_tool_prefix"; then
+    # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3948: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LIPO'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_LIPO="${ncn_tool_prefix}${ncn_progname}"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+LIPO="$ac_cv_prog_LIPO"
+if test -n "$LIPO"; then
+  echo "$ac_t""$LIPO" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  fi
+  if test -z "$ac_cv_prog_LIPO" && test $build = $host ; then
+    # Extract the first word of "${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_progname}; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3979: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LIPO'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_LIPO="${ncn_progname}"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+LIPO="$ac_cv_prog_LIPO"
+if test -n "$LIPO"; then
+  echo "$ac_t""$LIPO" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ 
+  fi
+  test -n "$ac_cv_prog_LIPO" && break
+done
+
+if test -z "$ac_cv_prog_LIPO" ; then
+  set dummy lipo
+  if test $build = $host ; then
+    LIPO="$2"
+  else
+    LIPO="${ncn_tool_prefix}$2"
+  fi
+fi
+
  for ncn_progname in nm; do
   if test -n "$ncn_tool_prefix"; then
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3825: checking for $ac_word" >&5
+echo "configure:4023: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3852,7 +4050,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3856: checking for $ac_word" >&5
+echo "configure:4054: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3896,7 +4094,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3900: checking for $ac_word" >&5
+echo "configure:4098: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3927,7 +4125,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3931: checking for $ac_word" >&5
+echo "configure:4129: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3961,12 +4159,82 @@
   RANLIB=":"
 fi
 
+ for ncn_progname in strip; do
+  if test -n "$ncn_tool_prefix"; then
+    # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:4168: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_STRIP="${ncn_tool_prefix}${ncn_progname}"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+STRIP="$ac_cv_prog_STRIP"
+if test -n "$STRIP"; then
+  echo "$ac_t""$STRIP" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  fi
+  if test -z "$ac_cv_prog_STRIP" && test $build = $host ; then
+    # Extract the first word of "${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_progname}; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:4199: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_STRIP="${ncn_progname}"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+STRIP="$ac_cv_prog_STRIP"
+if test -n "$STRIP"; then
+  echo "$ac_t""$STRIP" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ 
+  fi
+  test -n "$ac_cv_prog_STRIP" && break
+done
+
+if test -z "$ac_cv_prog_STRIP" ; then
+  STRIP=":"
+fi
+
  for ncn_progname in windres; do
   if test -n "$ncn_tool_prefix"; then
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3970: checking for $ac_word" >&5
+echo "configure:4238: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3997,7 +4265,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4001: checking for $ac_word" >&5
+echo "configure:4269: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4041,7 +4309,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4045: checking for $ac_word" >&5
+echo "configure:4313: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4072,7 +4340,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4076: checking for $ac_word" >&5
+echo "configure:4344: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4116,7 +4384,7 @@
     # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4120: checking for $ac_word" >&5
+echo "configure:4388: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4147,7 +4415,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4151: checking for $ac_word" >&5
+echo "configure:4419: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4192,14 +4460,13 @@
 
 
 
-# Target tools.  Do the tests using the names they may have passed in
-# the environment, then move it to CONFIGURED_*_FOR_TARGET.
+# Target tools.
  for ncn_progname in ar; do
   if test -n "$ncn_target_tool_prefix"; then
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4203: checking for $ac_word" >&5
+echo "configure:4470: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4230,7 +4497,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4234: checking for $ac_word" >&5
+echo "configure:4501: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4274,7 +4541,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4278: checking for $ac_word" >&5
+echo "configure:4545: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4305,7 +4572,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4309: checking for $ac_word" >&5
+echo "configure:4576: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4349,7 +4616,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4353: checking for $ac_word" >&5
+echo "configure:4620: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4380,7 +4647,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4384: checking for $ac_word" >&5
+echo "configure:4651: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4424,7 +4691,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4428: checking for $ac_word" >&5
+echo "configure:4695: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4455,7 +4722,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4459: checking for $ac_word" >&5
+echo "configure:4726: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4499,7 +4766,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4503: checking for $ac_word" >&5
+echo "configure:4770: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4530,7 +4797,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4534: checking for $ac_word" >&5
+echo "configure:4801: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4574,7 +4841,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4578: checking for $ac_word" >&5
+echo "configure:4845: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCC_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4605,7 +4872,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4609: checking for $ac_word" >&5
+echo "configure:4876: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCC_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4644,7 +4911,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4648: checking for $ac_word" >&5
+echo "configure:4915: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCJ_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4675,7 +4942,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4679: checking for $ac_word" >&5
+echo "configure:4946: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCJ_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4719,7 +4986,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4723: checking for $ac_word" >&5
+echo "configure:4990: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GFORTRAN_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4750,7 +5017,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4754: checking for $ac_word" >&5
+echo "configure:5021: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GFORTRAN_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4794,7 +5061,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4798: checking for $ac_word" >&5
+echo "configure:5065: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4825,7 +5092,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4829: checking for $ac_word" >&5
+echo "configure:5096: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4869,7 +5136,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4873: checking for $ac_word" >&5
+echo "configure:5140: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LIPO_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4900,7 +5167,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4904: checking for $ac_word" >&5
+echo "configure:5171: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LIPO_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4944,7 +5211,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4948: checking for $ac_word" >&5
+echo "configure:5215: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NM_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4975,7 +5242,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4979: checking for $ac_word" >&5
+echo "configure:5246: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NM_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5019,7 +5286,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5023: checking for $ac_word" >&5
+echo "configure:5290: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5050,7 +5317,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5054: checking for $ac_word" >&5
+echo "configure:5321: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5094,7 +5361,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5098: checking for $ac_word" >&5
+echo "configure:5365: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5125,7 +5392,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5129: checking for $ac_word" >&5
+echo "configure:5396: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5164,7 +5431,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5168: checking for $ac_word" >&5
+echo "configure:5435: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5195,7 +5462,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5199: checking for $ac_word" >&5
+echo "configure:5466: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5239,7 +5506,7 @@
     # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5243: checking for $ac_word" >&5
+echo "configure:5510: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5270,7 +5537,7 @@
     # Extract the first word of "${ncn_progname}", so it can be a program name with args.
 set dummy ${ncn_progname}; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5274: checking for $ac_word" >&5
+echo "configure:5541: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES_FOR_TARGET'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5310,77 +5577,439 @@
 fi
 
 
-CONFIGURED_AR_FOR_TARGET="$AR_FOR_TARGET"
-CONFIGURED_AS_FOR_TARGET="$AS_FOR_TARGET"
-CONFIGURED_CC_FOR_TARGET="$CC_FOR_TARGET"
-CONFIGURED_CXX_FOR_TARGET="$CXX_FOR_TARGET"
-CONFIGURED_DLLTOOL_FOR_TARGET="$DLLTOOL_FOR_TARGET"
-CONFIGURED_GCC_FOR_TARGET="$GCC_FOR_TARGET"
-CONFIGURED_GCJ_FOR_TARGET="$GCJ_FOR_TARGET"
-CONFIGURED_GFORTRAN_FOR_TARGET="$GFORTRAN_FOR_TARGET"
-CONFIGURED_LD_FOR_TARGET="$LD_FOR_TARGET"
-CONFIGURED_LIPO_FOR_TARGET="$LIPO_FOR_TARGET"
-CONFIGURED_NM_FOR_TARGET="$NM_FOR_TARGET"
-CONFIGURED_OBJDUMP_FOR_TARGET="$OBJDUMP_FOR_TARGET"
-CONFIGURED_RANLIB_FOR_TARGET="$RANLIB_FOR_TARGET"
-CONFIGURED_STRIP_FOR_TARGET="$STRIP_FOR_TARGET"
-CONFIGURED_WINDRES_FOR_TARGET="$WINDRES_FOR_TARGET"
+RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
 
+echo $ac_n "checking where to find the target ar""... $ac_c" 1>&6
+echo "configure:5584: checking where to find the target ar" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    AR_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/ar'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    AR_FOR_TARGET='$(AR)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target as""... $ac_c" 1>&6
+echo "configure:5609: checking where to find the target as" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gas "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    AS_FOR_TARGET='$$r/$(HOST_SUBDIR)/gas/as-new'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    AS_FOR_TARGET='$(AS)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target cc""... $ac_c" 1>&6
+echo "configure:5634: checking where to find the target cc" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    CC_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    CC_FOR_TARGET='$(CC)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target c++""... $ac_c" 1>&6
+echo "configure:5659: checking where to find the target c++" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  case ,${enable_languages}, in
+    *,c++,*) ;;
+    *) ok=no ;;
+  esac
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/g++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    CXX_FOR_TARGET='$(CXX)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target c++ for libstdc++""... $ac_c" 1>&6
+echo "configure:5687: checking where to find the target c++ for libstdc++" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  case ,${enable_languages}, in
+    *,c++,*) ;;
+    *) ok=no ;;
+  esac
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    RAW_CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    RAW_CXX_FOR_TARGET='$(CXX)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target dlltool""... $ac_c" 1>&6
+echo "configure:5715: checking where to find the target dlltool" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    DLLTOOL_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/dlltool'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    DLLTOOL_FOR_TARGET='$(DLLTOOL)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target gcc""... $ac_c" 1>&6
+echo "configure:5740: checking where to find the target gcc" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    GCC_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/'
+    echo "$ac_t""just compiled" 1>&6
 
-
-# Fix up target tools.
-if test "x${build}" = "x${host}" ; then
-  # In this case, the newly built tools can and should be used,
-  # so we override the results of the autoconf tests.
-  # This should really only happen when the tools are actually being built,
-  # but that's a further refinement.  The new build scheme, where
-  # tools are built into a structure paralleling where they're installed,
-  # should also eliminate all of this cleanly.
-  AR_FOR_TARGET="\$(USUAL_AR_FOR_TARGET)"
-  AS_FOR_TARGET="\$(USUAL_AS_FOR_TARGET)"
-  CC_FOR_TARGET="\$(USUAL_CC_FOR_TARGET)"
-  CXX_FOR_TARGET="\$(USUAL_CXX_FOR_TARGET)"
-  RAW_CXX_FOR_TARGET="\$(USUAL_RAW_CXX_FOR_TARGET)"
-  DLLTOOL_FOR_TARGET="\$(USUAL_DLLTOOL_FOR_TARGET)"
-  GCC_FOR_TARGET="\$(USUAL_GCC_FOR_TARGET)"
-  GCJ_FOR_TARGET="\$(USUAL_GCJ_FOR_TARGET)"
-  GFORTRAN_FOR_TARGET="\$(USUAL_GFORTRAN_FOR_TARGET)"
-  LD_FOR_TARGET="\$(USUAL_LD_FOR_TARGET)"
-  LIPO_FOR_TARGET="\$(USUAL_LIPO_FOR_TARGET)"
-  NM_FOR_TARGET="\$(USUAL_NM_FOR_TARGET)"
-  OBJDUMP_FOR_TARGET="\$(USUAL_OBJDUMP_FOR_TARGET)"
-  RANLIB_FOR_TARGET="\$(USUAL_RANLIB_FOR_TARGET)"
-  STRIP_FOR_TARGET="\$(USUAL_STRIP_FOR_TARGET)"
-  WINDRES_FOR_TARGET="\$(USUAL_WINDRES_FOR_TARGET)"
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target gcj""... $ac_c" 1>&6
+echo "configure:5762: checking where to find the target gcj" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
 else
-  # Just use the ones we found.
-  AR_FOR_TARGET="\$(CONFIGURED_AR_FOR_TARGET)"
-  AS_FOR_TARGET="\$(CONFIGURED_AS_FOR_TARGET)"
-  CC_FOR_TARGET="\$(CONFIGURED_CC_FOR_TARGET)"
-  CXX_FOR_TARGET="\$(CONFIGURED_CXX_FOR_TARGET)"
-  RAW_CXX_FOR_TARGET="\$(CONFIGURED_CXX_FOR_TARGET)"
-  DLLTOOL_FOR_TARGET="\$(CONFIGURED_DLLTOOL_FOR_TARGET)"
-  GCC_FOR_TARGET="\$(CONFIGURED_GCC_FOR_TARGET)"
-  GCJ_FOR_TARGET="\$(CONFIGURED_GCJ_FOR_TARGET)"
-  GFORTRAN_FOR_TARGET="\$(CONFIGURED_GFORTRAN_FOR_TARGET)"
-  LD_FOR_TARGET="\$(CONFIGURED_LD_FOR_TARGET)"
-  LIPO_FOR_TARGET="\$(CONFIGURED_LIPO_FOR_TARGET)"
-  NM_FOR_TARGET="\$(CONFIGURED_NM_FOR_TARGET)"
-  OBJDUMP_FOR_TARGET="\$(CONFIGURED_OBJDUMP_FOR_TARGET)"
-  RANLIB_FOR_TARGET="\$(CONFIGURED_RANLIB_FOR_TARGET)"
-  STRIP_FOR_TARGET="\$(CONFIGURED_STRIP_FOR_TARGET)"
-  WINDRES_FOR_TARGET="\$(CONFIGURED_WINDRES_FOR_TARGET)"  
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  case ,${enable_languages}, in
+    *,java,*) ;;
+    *) ok=no ;;
+  esac
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    GCJ_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/gcj -B$$r/$(HOST_SUBDIR)/gcc/'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    GCJ_FOR_TARGET='$(GCJ)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
 fi
+echo $ac_n "checking where to find the target gfortran""... $ac_c" 1>&6
+echo "configure:5790: checking where to find the target gfortran" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" gcc "*) ;;
+    *) ok=no ;;
+  esac
+  case ,${enable_languages}, in
+    *,fortran,*) ;;
+    *) ok=no ;;
+  esac
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    GFORTRAN_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    GFORTRAN_FOR_TARGET='$(GFORTRAN)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target ld""... $ac_c" 1>&6
+echo "configure:5818: checking where to find the target ld" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" ld "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    LD_FOR_TARGET='$$r/$(HOST_SUBDIR)/ld/ld-new'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    LD_FOR_TARGET='$(LD)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target lipo""... $ac_c" 1>&6
+echo "configure:5843: checking where to find the target lipo" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=no
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    LIPO_FOR_TARGET='$$r/$(HOST_SUBDIR)/'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    LIPO_FOR_TARGET='$(LIPO)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target nm""... $ac_c" 1>&6
+echo "configure:5864: checking where to find the target nm" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    NM_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/nm-new'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    NM_FOR_TARGET='$(NM)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target objdump""... $ac_c" 1>&6
+echo "configure:5889: checking where to find the target objdump" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    OBJDUMP_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/objdump'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    OBJDUMP_FOR_TARGET='$(OBJDUMP)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target ranlib""... $ac_c" 1>&6
+echo "configure:5914: checking where to find the target ranlib" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    RANLIB_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/ranlib'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    RANLIB_FOR_TARGET='$(RANLIB)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target strip""... $ac_c" 1>&6
+echo "configure:5939: checking where to find the target strip" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    STRIP_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/strip'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    STRIP_FOR_TARGET='$(STRIP)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
+echo $ac_n "checking where to find the target windres""... $ac_c" 1>&6
+echo "configure:5964: checking where to find the target windres" >&5
+if test "x${build}" != "x${host}" ; then
+  # Canadian cross, just use what we found
+  echo "$ac_t""pre-installed" 1>&6
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+  
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    WINDRES_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/windres'
+    echo "$ac_t""just compiled" 1>&6
+elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    WINDRES_FOR_TARGET='$(WINDRES)'
+    echo "$ac_t""host tool" 1>&6
+  else
+    # We need a cross tool
+    echo "$ac_t""pre-installed" 1>&6
+  fi
+fi
 
 
 
+
 # Certain tools may need extra flags.
 AR_FOR_TARGET=${AR_FOR_TARGET}${extra_arflags_for_target}
 RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET}${extra_ranlibflags_for_target}
 NM_FOR_TARGET=${NM_FOR_TARGET}${extra_nmflags_for_target}
 
+# When building target libraries, we use the same toolchain as the compiler
+# we just built.
+case " $configdirs " in
+  *" gcc "*)
+    COMPILER_AS_FOR_TARGET='$$r/gcc/as'
+    COMPILER_LD_FOR_TARGET='$$r/gcc/collect-ld'
+    COMPILER_NM_FOR_TARGET='$$r/gcc/nm'${extra_nmflags_for_target}
+    ;;
+  *)
+    COMPILER_AS_FOR_TARGET='$(AS_FOR_TARGET)'
+    COMPILER_LD_FOR_TARGET='$(LD_FOR_TARGET)'
+    COMPILER_NM_FOR_TARGET='$(NM_FOR_TARGET)'
+    ;;
+esac
+
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:5384: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:6013: checking whether to enable maintainer-specific portions of Makefiles" >&5
 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
@@ -5427,7 +6056,7 @@
 # gcc for stageN-gcc and stagePREV-gcc for stage(N-1).  In case this is not
 # possible, however, we can resort to mv.
 echo $ac_n "checking if symbolic links between directories work""... $ac_c" 1>&6
-echo "configure:5431: checking if symbolic links between directories work" >&5
+echo "configure:6060: checking if symbolic links between directories work" >&5
 if eval "test \"`echo '$''{'gcc_cv_prog_ln_s_dir'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5651,12 +6280,6 @@
 s%@gmpinc@%$gmpinc%g
 s%@stage1_languages@%$stage1_languages%g
 s%@SYSROOT_CFLAGS_FOR_TARGET@%$SYSROOT_CFLAGS_FOR_TARGET%g
-s%@CONFIGURED_BISON@%$CONFIGURED_BISON%g
-s%@CONFIGURED_YACC@%$CONFIGURED_YACC%g
-s%@CONFIGURED_M4@%$CONFIGURED_M4%g
-s%@CONFIGURED_FLEX@%$CONFIGURED_FLEX%g
-s%@CONFIGURED_LEX@%$CONFIGURED_LEX%g
-s%@CONFIGURED_MAKEINFO@%$CONFIGURED_MAKEINFO%g
 s%@bootstrap_lean@%$bootstrap_lean%g
 /@serialization_dependencies@/r $serialization_dependencies
 s%@serialization_dependencies@%%g
@@ -5682,12 +6305,22 @@
 s%@target_configdirs@%$target_configdirs%g
 s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g
 s%@config_shell@%$config_shell%g
+s%@YACC@%$YACC%g
+s%@BISON@%$BISON%g
+s%@M4@%$M4%g
+s%@LEX@%$LEX%g
+s%@FLEX@%$FLEX%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@EXPECT@%$EXPECT%g
+s%@RUNTEST@%$RUNTEST%g
 s%@AR@%$AR%g
 s%@AS@%$AS%g
 s%@DLLTOOL@%$DLLTOOL%g
 s%@LD@%$LD%g
+s%@LIPO@%$LIPO%g
 s%@NM@%$NM%g
 s%@RANLIB@%$RANLIB%g
+s%@STRIP@%$STRIP%g
 s%@WINDRES@%$WINDRES%g
 s%@OBJCOPY@%$OBJCOPY%g
 s%@OBJDUMP@%$OBJDUMP%g
@@ -5708,21 +6341,6 @@
 s%@RANLIB_FOR_TARGET@%$RANLIB_FOR_TARGET%g
 s%@STRIP_FOR_TARGET@%$STRIP_FOR_TARGET%g
 s%@WINDRES_FOR_TARGET@%$WINDRES_FOR_TARGET%g
-s%@CONFIGURED_AR_FOR_TARGET@%$CONFIGURED_AR_FOR_TARGET%g
-s%@CONFIGURED_AS_FOR_TARGET@%$CONFIGURED_AS_FOR_TARGET%g
-s%@CONFIGURED_CC_FOR_TARGET@%$CONFIGURED_CC_FOR_TARGET%g
-s%@CONFIGURED_CXX_FOR_TARGET@%$CONFIGURED_CXX_FOR_TARGET%g
-s%@CONFIGURED_DLLTOOL_FOR_TARGET@%$CONFIGURED_DLLTOOL_FOR_TARGET%g
-s%@CONFIGURED_GCC_FOR_TARGET@%$CONFIGURED_GCC_FOR_TARGET%g
-s%@CONFIGURED_GCJ_FOR_TARGET@%$CONFIGURED_GCJ_FOR_TARGET%g
-s%@CONFIGURED_GFORTRAN_FOR_TARGET@%$CONFIGURED_GFORTRAN_FOR_TARGET%g
-s%@CONFIGURED_LD_FOR_TARGET@%$CONFIGURED_LD_FOR_TARGET%g
-s%@CONFIGURED_LIPO_FOR_TARGET@%$CONFIGURED_LIPO_FOR_TARGET%g
-s%@CONFIGURED_NM_FOR_TARGET@%$CONFIGURED_NM_FOR_TARGET%g
-s%@CONFIGURED_OBJDUMP_FOR_TARGET@%$CONFIGURED_OBJDUMP_FOR_TARGET%g
-s%@CONFIGURED_RANLIB_FOR_TARGET@%$CONFIGURED_RANLIB_FOR_TARGET%g
-s%@CONFIGURED_STRIP_FOR_TARGET@%$CONFIGURED_STRIP_FOR_TARGET%g
-s%@CONFIGURED_WINDRES_FOR_TARGET@%$CONFIGURED_WINDRES_FOR_TARGET%g
 s%@FLAGS_FOR_TARGET@%$FLAGS_FOR_TARGET%g
 s%@RAW_CXX_FOR_TARGET@%$RAW_CXX_FOR_TARGET%g
 s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 106381)
+++ Makefile.in	(working copy)
@@ -133,7 +133,8 @@
 # with srcdir=..
 HOST_SUBDIR = @host_subdir@
 # This is the list of variables to export in the environment when
-# configuring subdirectories for the host system.
+# configuring subdirectories for the host system.  We need to pass
+# some to the GCC configure because of its hybrid host/target nature.
 HOST_EXPORTS = \
 	$(BASE_EXPORTS) \
 	CC="$(CC)"; export CC; \
@@ -152,6 +153,13 @@
 	WINDRES="$(WINDRES)"; export WINDRES; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
+	AR_FOR_TARGET="$(AR_FOR_TARGET)"; export AR_FOR_TARGET; \
+	AS_FOR_TARGET="$(AS_FOR_TARGET)"; export AS_FOR_TARGET; \
+	GCC_FOR_TARGET="$(GCC_FOR_TARGET)"; export GCC_FOR_TARGET; \
+	LD_FOR_TARGET="$(LD_FOR_TARGET)"; export LD_FOR_TARGET; \
+	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
+	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
+	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
@@ -183,7 +191,7 @@
 BASE_TARGET_EXPORTS = \
 	$(BASE_EXPORTS) \
 	AR="$(AR_FOR_TARGET)"; export AR; \
-	AS="$(AS_FOR_TARGET)"; export AS; \
+	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
 	CC="$(CC_FOR_TARGET)"; export CC; \
 	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -192,10 +200,10 @@
 	GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
 	GFORTRAN="$(GFORTRAN_FOR_TARGET)"; export GFORTRAN; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
-	LD="$(LD_FOR_TARGET)"; export LD; \
+	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
 	LIPO="$(LIPO_FOR_TARGET)"; export LIPO; \
-	NM="$(NM_FOR_TARGET)"; export NM; \
+	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
@@ -245,91 +253,43 @@
 # here so that they can be overridden by Makefile fragments.
 BOOT_CFLAGS= -g -O2
 
-CONFIGURED_BISON = @CONFIGURED_BISON@
-BISON = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/bison/tests/bison ; \
-	 else \
-	    echo ${CONFIGURED_BISON} ; \
-	 fi`
+BISON = @BISON@
+YACC = @YACC@
+FLEX = @FLEX@
+LEX = @LEX@
+M4 = @M4@
+MAKEINFO = @MAKEINFO@
+EXPECT = @EXPECT@
+RUNTEST = @RUNTEST@
 
-CONFIGURED_YACC = @CONFIGURED_YACC@
-YACC = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/bison/tests/bison -y ; \
-	elif [ -f $$r/$(BUILD_SUBDIR)/byacc/byacc ] ; then \
-	    echo $$r/$(BUILD_SUBDIR)/byacc/byacc ; \
-	else \
-	    echo ${CONFIGURED_YACC} ; \
-	fi`
-
-CONFIGURED_FLEX = @CONFIGURED_FLEX@
-FLEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
-	else echo ${CONFIGURED_FLEX} ; fi`
-
-CONFIGURED_LEX = @CONFIGURED_LEX@
-LEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
-	else echo ${CONFIGURED_LEX} ; fi`
-
-CONFIGURED_M4 = @CONFIGURED_M4@
-M4 = `if [ -f $$r/$(BUILD_SUBDIR)/m4/m4 ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/m4/m4 ; \
-	else echo ${CONFIGURED_M4} ; fi`
-
-# For an installed makeinfo, we require it to be from texinfo 4.2 or
-# higher, else we use the "missing" dummy.  We also pass the subdirectory
-# makeinfo even if only the Makefile is there, because Texinfo builds its
-# manual when made, and it requires its own version.
-CONFIGURED_MAKEINFO = @CONFIGURED_MAKEINFO@
-MAKEINFO = `if [ -f $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/Makefile ] ; \
-	then echo $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo ; \
-	else if (${CONFIGURED_MAKEINFO} --version \
-	  | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])') >/dev/null 2>&1; \
-        then echo ${CONFIGURED_MAKEINFO}; else echo $$s/missing makeinfo; fi; fi`
-
 # This just becomes part of the MAKEINFO definition passed down to
 # sub-makes.  It lets flags be given on the command line while still
 # using the makeinfo from the object tree.
 # (Default to avoid splitting info files by setting the threshold high.)
 MAKEINFOFLAGS = --split-size=5000000
 
-# FIXME: expect may become a build tool?
-EXPECT = `if [ -f $$r/$(HOST_SUBDIR)/expect/expect ] ; \
-	then echo $$r/$(HOST_SUBDIR)/expect/expect ; \
-	else echo expect ; fi`
-
-RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \
-	then echo $$s/dejagnu/runtest ; \
-	else echo runtest ; fi`
-
 # ---------------------------------------------
 # Programs producing files for the HOST machine
 # ---------------------------------------------
 
 AS = @AS@
-
 AR = @AR@
 AR_FLAGS = rc
-
 CC = @CC@
-CFLAGS = @CFLAGS@
-LIBCFLAGS = $(CFLAGS)
-
 CXX = @CXX@
-CXXFLAGS = @CXXFLAGS@
-LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
-
 DLLTOOL = @DLLTOOL@
-
-NM = @NM@
-
 LD = @LD@
-LDFLAGS = 
-
+LIPO = @LIPO@
+NM = @NM@
 RANLIB = @RANLIB@
-
+STRIP = @STRIP@
 WINDRES = @WINDRES@
 
+CFLAGS = @CFLAGS@
+LDFLAGS = 
+LIBCFLAGS = $(CFLAGS)
+CXXFLAGS = @CXXFLAGS@
+LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 PICFLAG = 
 
 # -----------------------------------------------
@@ -339,242 +299,42 @@
 FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
 
 AR_FOR_TARGET=@AR_FOR_TARGET@
-CONFIGURED_AR_FOR_TARGET=@CONFIGURED_AR_FOR_TARGET@
-USUAL_AR_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/ar ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/ar ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(AR); \
-    else \
-      echo $(CONFIGURED_AR_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 AS_FOR_TARGET=@AS_FOR_TARGET@
-CONFIGURED_AS_FOR_TARGET=@CONFIGURED_AS_FOR_TARGET@
-USUAL_AS_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gas/as-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gas/as-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/as ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/as ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(AS); \
-    else \
-      echo $(CONFIGURED_AS_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_CC_FOR_TARGET=@CONFIGURED_CC_FOR_TARGET@
-USUAL_CC_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CC); \
-    else \
-      echo $(CONFIGURED_CC_FOR_TARGET) ; \
-    fi; \
-  fi`
 
-# During gcc bootstrap, if we use some random cc for stage1 then
-# CFLAGS will be just -g.  We want to ensure that TARGET libraries
-# (which we know are built with gcc) are built with optimizations so
-# prepend -O2 when setting CFLAGS_FOR_TARGET.
-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
-SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
-
 # If GCC_FOR_TARGET is not overriden on the command line, then this
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=@GCC_FOR_TARGET@
-CONFIGURED_GCC_FOR_TARGET=@CONFIGURED_GCC_FOR_TARGET@
-USUAL_GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) \
-  $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ $(FLAGS_FOR_TARGET)
-LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
-
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
 CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_CXX_FOR_TARGET=@CONFIGURED_CXX_FOR_TARGET@
-USUAL_CXX_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/g++ ] ; then \
-    (echo $$r/$(HOST_SUBDIR)/gcc/g++ -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++; \
-    test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; \
-    echo -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs) | tr '\015\012' '  '; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CXX); \
-    else \
-      echo $(CONFIGURED_CXX_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-USUAL_RAW_CXX_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(CXX); \
-    else \
-      echo $(CONFIGURED_CXX_FOR_TARGET) ; \
-    fi; \
-  fi`
-
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
-LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
-
 GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_GCJ_FOR_TARGET=@CONFIGURED_GCJ_FOR_TARGET@
-USUAL_GCJ_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/gcj ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/gcj -B$$r/$(HOST_SUBDIR)/gcc ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(GCJ); \
-    else \
-      echo $(CONFIGURED_GCJ_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CONFIGURED_GFORTRAN_FOR_TARGET=@CONFIGURED_GFORTRAN_FOR_TARGET@
-USUAL_GFORTRAN_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/gcc/gfortran ] ; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(GFORTRAN); \
-    else \
-      echo $(CONFIGURED_GFORTRAN_FOR_TARGET) ; \
-    fi; \
-  fi`
-
-
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
-CONFIGURED_DLLTOOL_FOR_TARGET=@CONFIGURED_DLLTOOL_FOR_TARGET@
-USUAL_DLLTOOL_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/dlltool ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/dlltool ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(DLLTOOL); \
-    else \
-      echo $(CONFIGURED_DLLTOOL_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 LD_FOR_TARGET=@LD_FOR_TARGET@
-CONFIGURED_LD_FOR_TARGET=@CONFIGURED_LD_FOR_TARGET@
-USUAL_LD_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/ld/ld-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/ld/ld-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/collect-ld ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/collect-ld ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(LD); \
-    else \
-      echo $(CONFIGURED_LD_FOR_TARGET) ; \
-    fi; \
-  fi`
 
-LDFLAGS_FOR_TARGET = 
-
 LIPO_FOR_TARGET=@LIPO_FOR_TARGET@
-CONFIGURED_LIPO_FOR_TARGET=@CONFIGURED_LIPO_FOR_TARGET@
-USUAL_LIPO_FOR_TARGET = ` \
-  if [ '$(host)' = '$(target)' ] ; then \
-    if [ x'$(LIPO)' != x ]; then \
-       echo $(LIPO); \
-    else \
-       echo lipo; \
-    fi; \
-  else \
-    echo $(CONFIGURED_LIPO_FOR_TARGET) ; \
-  fi`
-
 NM_FOR_TARGET=@NM_FOR_TARGET@
-CONFIGURED_NM_FOR_TARGET=@CONFIGURED_NM_FOR_TARGET@
-USUAL_NM_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/nm-new ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/nm-new ; \
-  elif [ -f $$r/$(HOST_SUBDIR)/gcc/nm ]; then \
-    echo $$r/$(HOST_SUBDIR)/gcc/nm ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(NM); \
-    else \
-      echo $(CONFIGURED_NM_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
-CONFIGURED_OBJDUMP_FOR_TARGET=@CONFIGURED_OBJDUMP_FOR_TARGET@
-USUAL_OBJDUMP_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/objdump ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/objdump ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(OBJDUMP)' != x ]; then \
-         echo $(OBJDUMP); \
-      else \
-         echo objdump; \
-      fi; \
-    else \
-      echo $(CONFIGURED_OBJDUMP_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
-CONFIGURED_RANLIB_FOR_TARGET=@CONFIGURED_RANLIB_FOR_TARGET@
-USUAL_RANLIB_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/ranlib ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/ranlib ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(RANLIB)' != x ]; then \
-         echo $(RANLIB); \
-      else \
-         echo ranlib; \
-      fi; \
-    else \
-      echo $(CONFIGURED_RANLIB_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
-CONFIGURED_STRIP_FOR_TARGET=@CONFIGURED_STRIP_FOR_TARGET@
-USUAL_STRIP_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/strip ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/strip ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      if [ x'$(STRIP)' != x ]; then \
-         echo $(STRIP); \
-      else \
-         echo strip; \
-      fi; \
-    else \
-      echo $(CONFIGURED_STRIP_FOR_TARGET) ; \
-    fi; \
-  fi`
-
 WINDRES_FOR_TARGET=@WINDRES_FOR_TARGET@
-CONFIGURED_WINDRES_FOR_TARGET=@CONFIGURED_WINDRES_FOR_TARGET@
-USUAL_WINDRES_FOR_TARGET = ` \
-  if [ -f $$r/$(HOST_SUBDIR)/binutils/windres ] ; then \
-    echo $$r/$(HOST_SUBDIR)/binutils/windres ; \
-  else \
-    if [ '$(host)' = '$(target)' ] ; then \
-      echo $(WINDRES); \
-    else \
-      echo $(CONFIGURED_WINDRES_FOR_TARGET) ; \
-    fi; \
-  fi`
 
+COMPILER_AS_FOR_TARGET=@COMPILER_AS_FOR_TARGET@
+COMPILER_LD_FOR_TARGET=@COMPILER_LD_FOR_TARGET@
+COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_TARGET@
+
+# During gcc bootstrap, if we use some random cc for stage1 then
+# CFLAGS will be just -g.  We want to ensure that TARGET libraries
+# (which we know are built with gcc) are built with optimizations so
+# prepend -O2 when setting CFLAGS_FOR_TARGET.
+CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
+LDFLAGS_FOR_TARGET = 
 PICFLAG_FOR_TARGET = 
 
 # ------------------------------------
@@ -712,8 +472,10 @@
 	'CXX=$(CXX)' \
 	'DLLTOOL=$(DLLTOOL)' \
 	'LD=$(LD)' \
+	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
 	'RANLIB=$(RANLIB)' \
+	'STRIP=$(STRIP)' \
 	'WINDRES=$(WINDRES)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
@@ -869,28 +631,19 @@
 .PHONY: all
 all:
 @if gcc-bootstrap
+	[ -f stage_final ] || echo stage3 > stage_final
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	if [ ! -f stage_last ]; then \
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) bootstrap; \
-	fi
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble; \
 @endif gcc-bootstrap
 	@$(unstage)
-@if gcc-no-bootstrap
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all-prebootstrap
-@endif gcc-no-bootstrap
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	if [ -f stage_last ]; then \
-	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host; \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host; \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target; \
 	fi
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all-target
 	@$(stage)
 
 .PHONY: all-build
@@ -35115,7 +34868,7 @@
 
 @if gcc-bootstrap
 unstage = [ -f stage_current ] || $(MAKE) `cat stage_last`-start
-stage = $(MAKE) `cat stage_current`-end
+stage = [ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
 @endif gcc-bootstrap
 
 .PHONY: unstage stage
@@ -35170,7 +34923,7 @@
 .PHONY: stage1-start stage1-end
 
 stage1-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stage1 > stage_current ; \
 	echo stage1 > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -35306,7 +35059,7 @@
 
 .PHONY: distclean-stage1
 distclean-stage1::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stage1-* 
 
 
@@ -35316,7 +35069,7 @@
 .PHONY: stage2-start stage2-end
 
 stage2-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stage2 > stage_current ; \
 	echo stage2 > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -35488,15 +35241,23 @@
 
 
 .PHONY: bootstrap2
-bootstrap2: stage2-bubble
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all
+bootstrap2:
+	echo stage2 > stage_final
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) stage2-bubble
+	@$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
+	@$(stage)
 
 
 # Rules to wipe a stage and all the following ones, also used for cleanstrap
 distclean-stage1:: distclean-stage2 
 .PHONY: distclean-stage2
 distclean-stage2::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stage2-* 
 
 
@@ -35506,7 +35267,7 @@
 .PHONY: stage3-start stage3-end
 
 stage3-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stage3 > stage_current ; \
 	echo stage3 > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -35668,6 +35429,7 @@
 	  $(MAKE) stage3-start; \
 	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage3; \
 	fi
+	$(MAKE) compare
 
 .PHONY: all-stage3 clean-stage3
 do-clean: clean-stage3
@@ -35683,7 +35445,11 @@
 	  echo Cannot compare object files as stage 2 was deleted. ; \
 	  exit 0 ; \
 	fi; \
+<<<<<<< Makefile.in
+	$(stage); \
+=======
 	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+>>>>>>> 1.283
 	rm -f .bad_compare ; \
 	cd stage3-gcc; \
 	files=`find . -name "*$(objext)" -print` ; \
@@ -35713,16 +35479,23 @@
 
 
 .PHONY: bootstrap
-bootstrap: stage3-bubble
-	$(MAKE) compare
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all
+bootstrap:
+	echo stage3 > stage_final
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) stage3-bubble
+	@$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
+	@$(stage)
 
 
 # Rules to wipe a stage and all the following ones, also used for cleanstrap
 distclean-stage2:: distclean-stage3 
 .PHONY: distclean-stage3
 distclean-stage3::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stage3-* compare 
 
 
@@ -35735,7 +35508,7 @@
 .PHONY: stage4-start stage4-end
 
 stage4-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stage4 > stage_current ; \
 	echo stage4 > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -35897,6 +35670,7 @@
 	  $(MAKE) stage4-start; \
 	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage4; \
 	fi
+	$(MAKE) compare3
 
 .PHONY: all-stage4 clean-stage4
 do-clean: clean-stage4
@@ -35912,7 +35686,11 @@
 	  echo Cannot compare object files as stage 3 was deleted. ; \
 	  exit 0 ; \
 	fi; \
+<<<<<<< Makefile.in
+	$(stage); \
+=======
 	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+>>>>>>> 1.283
 	rm -f .bad_compare ; \
 	cd stage4-gcc; \
 	files=`find . -name "*$(objext)" -print` ; \
@@ -35942,16 +35720,23 @@
 
 
 .PHONY: bootstrap4
-bootstrap4: stage4-bubble
-	$(MAKE) compare3
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all
+bootstrap4:
+	echo stage4 > stage_final
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) stage4-bubble
+	@$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
+	@$(stage)
 
 
 # Rules to wipe a stage and all the following ones, also used for cleanstrap
 distclean-stage3:: distclean-stage4 
 .PHONY: distclean-stage4
 distclean-stage4::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stage4-* compare3 
 
 
@@ -35961,7 +35746,7 @@
 .PHONY: stageprofile-start stageprofile-end
 
 stageprofile-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stageprofile > stage_current ; \
 	echo stageprofile > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -36137,7 +35922,7 @@
 distclean-stage1:: distclean-stageprofile 
 .PHONY: distclean-stageprofile
 distclean-stageprofile::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stageprofile-* 
 
 
@@ -36147,7 +35932,7 @@
 .PHONY: stagefeedback-start stagefeedback-end
 
 stagefeedback-start::
-	@[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
+	@$(stage); \
 	echo stagefeedback > stage_current ; \
 	echo stagefeedback > stage_last; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)
@@ -36319,15 +36104,23 @@
 
 
 .PHONY: profiledbootstrap
-profiledbootstrap: stagefeedback-bubble
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all
+profiledbootstrap:
+	echo stagefeedback > stage_final
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(RECURSE_FLAGS_TO_PASS) stagefeedback-bubble
+	@$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
+	@$(stage)
 
 
 # Rules to wipe a stage and all the following ones, also used for cleanstrap
 distclean-stageprofile:: distclean-stagefeedback 
 .PHONY: distclean-stagefeedback
 distclean-stagefeedback::
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+	@$(stage)
 	rm -rf stagefeedback-* 
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]