<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>compiler/LICENSE</filename>
    </added>
    <added>
      <filename>compiler/ghc.mk</filename>
    </added>
    <added>
      <filename>docs/users_guide/ghc.mk</filename>
    </added>
    <added>
      <filename>driver/ghc.mk</filename>
    </added>
    <added>
      <filename>driver/ghc/ghc.mk</filename>
    </added>
    <added>
      <filename>driver/ghci/ghc.mk</filename>
    </added>
    <added>
      <filename>driver/mangler/ghc.mk</filename>
    </added>
    <added>
      <filename>driver/split/ghc.mk</filename>
    </added>
    <added>
      <filename>ghc.mk</filename>
    </added>
    <added>
      <filename>ghc/ghc.mk</filename>
    </added>
    <added>
      <filename>gmp/ghc.mk</filename>
    </added>
    <added>
      <filename>gmp/tarball/gmp-4.2.4-nodoc.tar.bz2</filename>
    </added>
    <added>
      <filename>includes/ghc.mk</filename>
    </added>
    <added>
      <filename>libffi/ghc.mk</filename>
    </added>
    <added>
      <filename>libffi/libffi.autotools-update.patch</filename>
    </added>
    <added>
      <filename>libffi/libffi.dllize-3.0.6.patch</filename>
    </added>
    <added>
      <filename>libffi/tarball/libffi-3.0.6.tar.gz</filename>
    </added>
    <added>
      <filename>mk/old-config.mk.in</filename>
    </added>
    <added>
      <filename>mk/project.mk.in</filename>
    </added>
    <added>
      <filename>mk/sub-makefile.mk</filename>
    </added>
    <added>
      <filename>rts/ghc.mk</filename>
    </added>
    <added>
      <filename>rules/all-target.mk</filename>
    </added>
    <added>
      <filename>rules/bindist.mk</filename>
    </added>
    <added>
      <filename>rules/build-dependencies.mk</filename>
    </added>
    <added>
      <filename>rules/build-package-data.mk</filename>
    </added>
    <added>
      <filename>rules/build-package-way.mk</filename>
    </added>
    <added>
      <filename>rules/build-package.mk</filename>
    </added>
    <added>
      <filename>rules/build-perl.mk</filename>
    </added>
    <added>
      <filename>rules/build-prog.mk</filename>
    </added>
    <added>
      <filename>rules/c-objs.mk</filename>
    </added>
    <added>
      <filename>rules/c-sources.mk</filename>
    </added>
    <added>
      <filename>rules/c-suffix-rules.mk</filename>
    </added>
    <added>
      <filename>rules/clean-target.mk</filename>
    </added>
    <added>
      <filename>rules/distdir-opts.mk</filename>
    </added>
    <added>
      <filename>rules/distdir-way-opts.mk</filename>
    </added>
    <added>
      <filename>rules/docbook.mk</filename>
    </added>
    <added>
      <filename>rules/haddock.mk</filename>
    </added>
    <added>
      <filename>rules/hi-rule.mk</filename>
    </added>
    <added>
      <filename>rules/hs-objs.mk</filename>
    </added>
    <added>
      <filename>rules/hs-sources.mk</filename>
    </added>
    <added>
      <filename>rules/hs-suffix-rules-srcdir.mk</filename>
    </added>
    <added>
      <filename>rules/hs-suffix-rules.mk</filename>
    </added>
    <added>
      <filename>rules/includes-sources.mk</filename>
    </added>
    <added>
      <filename>rules/manual-package-config.mk</filename>
    </added>
    <added>
      <filename>rules/package-config.mk</filename>
    </added>
    <added>
      <filename>rules/shell-wrapper.mk</filename>
    </added>
    <added>
      <filename>rules/way-prelims.mk</filename>
    </added>
    <added>
      <filename>utils/genapply/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/genprimopcode/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/ghc-cabal/ghc-cabal.hs</filename>
    </added>
    <added>
      <filename>utils/ghc-cabal/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/ghc-pkg/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/hasktags/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/hp2ps/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/hpc/Main.hs</filename>
    </added>
    <added>
      <filename>utils/hpc/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/mkdependC/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/mkdirhier/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/runghc/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/touchy/ghc.mk</filename>
    </added>
    <added>
      <filename>utils/unlit/ghc.mk</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,663 +1,143 @@
-############################################################################
-#
-#		This is the top-level Makefile for GHC
-#
-# Targets: 
-#
-# 	bootstrap (DEFAULT)
-#		Builds GHC, then builds the libraries,
-#		then uses this GHC (&quot;stage 1&quot;) to build itself
-#		(&quot;stage 2&quot;).
-#
-#	bootstrap2
-#		Same as bootstrap
-#
-#	bootstrap3
-#		bootstrap2 + we build GHC one more time (&quot;stage 3&quot;)
-#
-#	stage1
-#		Just build up to stage 1
-#
-#	stage2
-#		Just build stage 2 (stage 1 must be built)
-#
-#	stage3
-#		Just build stage 3 (stage 2 must be built)
-#
-#	all
-#		Same as bootstrap
-#
-#       install
-#		Install everything, including stage 2 compiler by default
-#		(override with stage=3, for example).
-#
-#	dist
-#		Make a source dist (WARNING: runs 'make distclean' first)
-#
-#	binary-dist
-#		Builds a binary distribution
-#
-#	framework-pkg  [MacOS only]
-#		Builds /Library/Frameworks/GHC.framework wrapped into a Mac
-#		installer package
-#
-#	framework-binary-dist  [MacOS only]
-#		Builds GHC.framework encapsulating a binary distribution
-#		(to give a relocatable framework)
-#
-#	hc-file-bundle
-#		Builds an HC-file bundle, for bootstrapping
-#
-#	clean, distclean, maintainer-clean
-#		Increasing levels of cleanliness
-#
-############################################################################
 
-TOP=.
-include $(TOP)/mk/boilerplate.mk
+ifeq &quot;$(wildcard distrib/)&quot; &quot;&quot;
 
-#
-# Order is important! It's e.g. necessary to descend into include/
-# before the rest to have a config.h, etc.
-#
-# If we're booting from .hc files, swap the order
-# we descend into subdirs - to boot utils must be before driver.
-#
-.PHONY: stage1 stage2 stage3 bootstrap bootstrap2 bootstrap3
+# We're in a bindist
 
-# We can't 'make boot' in libraries until stage1 is built
-ifeq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-SUBDIRS_BUILD = includes compiler docs utils driver
-else
-SUBDIRS_BUILD = includes utils driver docs compiler libraries/Cabal/doc
-endif
+.PHONY: default
+default:
+	@echo 'Run &quot;make install&quot; to install'
+	@false
 
-SUBDIRS = gmp libffi includes utils docs rts compiler ghc driver libraries libraries/Cabal/doc
+.PHONY: install
+install:
+	$(MAKE) -r --no-print-directory -f ghc.mk install BINDIST=YES NO_INCLUDE_DEPS=YES
 
-check-all: check-packages check-tools
-
-# Sanity check that all the boot libraries are in the tree, to catch
-# failure to run darcs-all.
-check-packages :
-	@ds=`grep &quot;^[^# ][^ ]*  *[^ ][^ ]*  *[^ ][^ ]*$$&quot; packages | sed &quot;s/ .*//&quot;`;\
-	for d in $$ds; do \
-	  if test ! -d $$d; then \
-	     echo &quot;Looks like you're missing $$d,&quot;; \
-	     echo &quot;maybe you haven't done './darcs-all get'?&quot;; \
-	     exit 1; \
-	  fi \
-	done
-	@if test ! -f libraries/base/configure; then \
-	    echo &quot;Looks like you're missing base's configure script.&quot;; \
-	    echo &quot;Did you run 'sh boot' at the top level?&quot;; \
-	    exit 1; \
-	fi
-
-HAVE_EVAL := NO
-$(eval HAVE_EVAL := YES)
-
-check-tools:
-ifeq &quot;$(HSCOLOUR_SRCS) $(HSCOLOUR)&quot; &quot;YES &quot;
-	@echo &quot;HsColour needed but wasn't found.&quot;
-	@echo &quot;Set HSCOLOUR_SRCS=NO if you don't want to use it&quot;
-	exit 1
-endif
-ifeq &quot;$(HAVE_EVAL)&quot; &quot;NO&quot;
-	@echo &quot;Your make doesn't support eval. You need GNU make &gt;= 3.80&quot;
-	exit 1
-endif
-	@:
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ifneq &quot;$(WhatGccIsCalled)&quot; &quot;&quot;
-GCC_LIB_DEP = stamp.inplace-gcc-lib
-endif
-endif
-
-stage1 : $(GCC_LIB_DEP) check-all
-	$(MAKE) -C libraries boot
-	$(MAKE) -C gmp       all
-	$(MAKE) -C utils/mkdependC boot
-	$(MAKE) -C utils with-bootstrapping-compiler
-	@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
-	for i in $(SUBDIRS_BUILD); do \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  echo &quot;== $(MAKE) boot $(MFLAGS);&quot;; \
-	  echo &quot; in $(shell pwd)/$$i&quot;; \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  $(MAKE) --no-print-directory -C $$i $(MFLAGS) boot; \
-	  if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
-	done; \
-	for i in $(SUBDIRS_BUILD); do \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  echo &quot;== $(MAKE) all $(MFLAGS);&quot;; \
-	  echo &quot; in $(shell pwd)/$$i&quot;; \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  $(MAKE) --no-print-directory -C $$i $(MFLAGS) all; \
-	  if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
-	done
-	$(MAKE) -C libffi    all
-	$(MAKE) -C rts boot
-	$(MAKE) -C rts
-	$(MAKE) -C libraries all
-
-# When making distributions (i.e., whether with binary-dist or using the 
-# vanilla install target to create an installer package), we can have problems
-# if some things (e.g. ghc-pkg) are compiled with the bootstrapping compiler 
-# and some (e.g. the stage 2 compiler) with the stage1 compiler. See #1860 for
-# an example.  Thus, we explicitly build a second version with the stage 1 
-# compiler of all utils that get installed and of all extra support binaries
-# includes in binary dists.
-stage2 : check-all
-	$(MAKE) -C compiler stage=2 boot
-	$(MAKE) -C compiler stage=2
-	$(MAKE) -C utils with-stage-2
-	$(MAKE) -C libraries stage=2 all
-ifeq &quot;$(HADDOCK_DOCS)&quot; &quot;YES&quot;
-	$(MAKE) -C libraries doc
-	$(MAKE) -C compiler  doc stage=2
-endif
+.PHONY: show
+show:
+	$(MAKE) -r --no-print-directory -f ghc.mk $@
 
-stage3 : check-all
-	$(MAKE) -C compiler stage=3 boot
-	$(MAKE) -C compiler stage=3
-
-bootstrap  : bootstrap2
-
-bootstrap2 : stage1
-	$(MAKE) stage2
-
-bootstrap3 : bootstrap2
-	$(MAKE) stage3
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ifneq &quot;$(WhatGccIsCalled)&quot; &quot;&quot;
-all :: stamp.inplace-gcc-lib
-
-.PHONY: stamp.inplace-gcc-lib
-
-# This is a hack to make Cabal able to find ld when we run tests with
-# the inplace ghc. We should probably install all the gcc stuff in our
-# tree somewhere, and then have install copy it from there rather than
-# from the filesystem.
-stamp.inplace-gcc-lib:
-	$(RM) -r ghc/gcc-lib
-	mkdir ghc/gcc-lib
-	cp $(LD) ghc/gcc-lib
-	touch $@
-
-clean ::
-	$(RM) -r ghc/gcc-lib
-	$(RM) -f inplace-gcc-lib
-endif
-endif
-
-all :: bootstrap
-
-# -----------------------------------------------------------------------------
-# Installing
-
-# We want to install the stage 2 bootstrapped compiler by default, but we let
-# the user override this by saying 'make install stage=1', for example.
-ifeq &quot;$(stage)&quot; &quot;&quot;
-INSTALL_STAGE = stage=2
 else
-INSTALL_STAGE =
-endif
-
-install-strip:
-	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
-
-# Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
-install :: check-packages
-	$(MKDIRHIER) $(DESTDIR)$(datadir)
-	echo &quot;[]&quot; &gt; $(DESTDIR)$(datadir)/package.conf
-	@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
-	for i in $(SUBDIRS); do \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  echo &quot;== $(MAKE) $@ $(MFLAGS);&quot;; \
-	  echo &quot; in $(shell pwd)/$$i&quot;; \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
-	  if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
-	done
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-# These files need to be in the InstallShield
-# INSTALL_DATAS rather than INSTALL_DOCS is used so these files go
-# in the top-level directory of the distribution
-INSTALL_DATAS += ANNOUNCE LICENSE README
-endif
 
-# If installing on Windows with MinGW32, copy the gcc compiler, headers and libs
-# and the perl interpreter and dll into the GHC prefix directory.
-# Gcc and Perl source locations derived from configuration data.
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ifneq &quot;$(WhatGccIsCalled)&quot; &quot;&quot;
-install ::
-	-mkdir $(prefix)/gcc-lib
-	-mkdir $(prefix)/include
-	-mkdir $(prefix)/include/mingw
-	-cp -rp $(GccDir)../include/* $(prefix)/include/mingw
-	-cp -rp $(GccDir)../lib/gcc-lib/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
-	-cp -rp $(GccDir)../lib/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
-	-cp -rp $(GccDir)../libexec/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
-	-cp $(GccDir)../lib/*.* $(prefix)/gcc-lib
-	-cp $(GccDir)gcc.exe $(prefix)
-	-cp $(GccDir)as.exe $(prefix)/gcc-lib
-	-cp $(GccDir)ld.exe $(prefix)/gcc-lib
-	-cp $(GccDir)dllwrap.exe $(prefix)/gcc-lib
-	-cp $(GccDir)dlltool.exe $(prefix)/gcc-lib
-	-cp $(GhcDir)../perl.exe $(prefix)
-	-cp $(GhcDir)../perl56.dll $(prefix)
-endif
-endif
-
-# Install gcc-extra-opts
-install ::
-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) $(INSTALL_OPTS) extra-gcc-opts $(DESTDIR)$(libdir)
+# The problem we need to solve is as follows.  
+#
+# GNU make supports included Makefiles, and it is clever enough to try
+# to update those Makefiles when they are out-of-date or missing.  It
+# first reads all the Makefiles, and then tries to build each one if
+# it is out-of-date, using the rules in the Makefiles themselves.
+# When it has brought all the Makefiles up-to-date, it restarts itself
+# to read the newly-generated Makefiles.
+#
+# This works fine, unless there are dependencies *between* the
+# Makefiles.  For example in the GHC build, for each package we have a
+# package-data.mk file which is generated by the ghc-cabal program,
+# and we have a .depend file.  The .depend file cannot be generated
+# until package-data.mk has been generated and make has been restarted
+# to read in its contents, because it is the package-data.mk file that
+# tells us which modules are in the package.  But make always makes
+# all the Makefiles before restarting - it doesn't take into account a
+# dependency between Makefiles and restart itself earlier.
 
-install-docs ::
-	@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
-	for i in $(SUBDIRS); do \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  echo &quot;== $(MAKE) $@ $(MFLAGS);&quot;; \
-	  echo &quot; in $(shell pwd)/$$i&quot;; \
-	  echo &quot;------------------------------------------------------------------------&quot;; \
-	  $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
-	  if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
-	done
+# Consider the following makefile:
 
-# -----------------------------------------------------------------------------
-# Making a binary distribution
-#
-# `dist' `binary-dist'
-#      Create a distribution tar file for this program. The tar file
-#      should be set up so that the file names in the tar file start with
-#      a subdirectory name which is the name of the package it is a
-#      distribution for. This name can include the version number.
+# --------------------
+# all :
 #
-#      For example, the distribution tar file of GCC version 1.40 unpacks
-#      into a subdirectory named `gcc-1.40'.
+# include inc1.mk
 # 
-#      The easiest way to do this is to create a subdirectory
-#      appropriately named, use ln or cp to install the proper files in
-#      it, and then tar that subdirectory.
+# inc1.mk : Makefile
+# 	echo &quot;X = C&quot; &gt;$@
 # 
-#      The dist target should explicitly depend on all non-source files
-#      that are in the distribution, to make sure they are up to date in
-#      the distribution. See Making Releases.
-#
-#	binary-dist is a GHC addition for binary distributions
+# include inc2.mk
 # 
+# inc2.mk : inc1.mk
+# 	echo &quot;Y = $(X)&quot; &gt;$@
+# --------------------
 
-binary-dist::
-	-rm -rf $(BIN_DIST_DIR)
-	-$(RM) $(BIN_DIST_TAR_BZ2)
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-
-binary-dist::
-	$(MAKE) prefix=$(BIN_DIST_DIR) install
-	$(MAKE) prefix=$(BIN_DIST_DIR) install-docs
-
-binary-dist::
-	cd $(BIN_DIST_DIR) &amp;&amp; $(SHELL) ../distrib/prep-bin-dist-mingw
-
-binary-dist::
-	$(MKDIRHIER) $(BIN_DIST_DIR)/icons
-	cp distrib/hsicon.ico $(BIN_DIST_DIR)/icons
-
-# Tar up the distribution and build a manifest
-binary-dist :: tar-binary-dist
-
-.PHONY: tar-binary-dist
-tar-binary-dist:
-	( cd $(BIN_DIST_TOPDIR_ABS); $(TAR) cf - $(BIN_DIST_NAME) | bzip2 &gt; $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2) )
-	( cd $(BIN_DIST_TOPDIR_ABS); bunzip2 -c $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2) | $(TAR) tf - | sed &quot;s/^ghc-$(ProjectVersion)/fptools/&quot; | sort &gt;$(FPTOOLS_TOP_ABS)/bin-manifest-$(ProjectVersion) )
-
-else
-
-.PHONY: binary-dist
-
-BIN_DIST_VARFILE=$(BIN_DIST_PREP)/Makefile-vars.in
-
-WHERE_AM_I = $(BIN_DIST_NAME)
-
-binary-dist::
-# For the most part we will be putting filenames in $(BIN_DIST_LIST),
-# and telling tar to tar all of those files up. So to start with we
-# remove $(BIN_DIST_LIST) so that we can start with an empty slate
-	$(RM) -f $(BIN_DIST_LIST)
-# Now we add a few files from mk/ to $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/package.mk     &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/install.mk     &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/recurse.mk     &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/cabal.mk       &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/cabal-flags.mk &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/mk/fptools.css    &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/ANNOUNCE          &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/LICENSE           &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/install-sh        &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/extra-gcc-opts.in &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/config.guess      &gt;&gt; $(BIN_DIST_LIST)
-	echo $(WHERE_AM_I)/config.sub        &gt;&gt; $(BIN_DIST_LIST)
-# Now we recurse into various subdirectories and tell them to add and
-# files that they want into $(BIN_DIST_LIST)
-# XXX Ug, this duplication of &quot;-C foo WHERE_AM_I=.../foo&quot; isn't nice.
-	$(MAKE) -C gmp                 binary-dist WHERE_AM_I=$(WHERE_AM_I)/gmp
-	$(MAKE) -C includes            binary-dist WHERE_AM_I=$(WHERE_AM_I)/includes
-	$(MAKE) -C compiler            binary-dist WHERE_AM_I=$(WHERE_AM_I)/compiler $(INSTALL_STAGE)
-	$(MAKE) -C ghc                 binary-dist WHERE_AM_I=$(WHERE_AM_I)/ghc      $(INSTALL_STAGE)
-	$(MAKE) -C rts                 binary-dist WHERE_AM_I=$(WHERE_AM_I)/rts
-	$(MAKE) -C driver              binary-dist WHERE_AM_I=$(WHERE_AM_I)/driver
-	$(MAKE) -C utils               binary-dist WHERE_AM_I=$(WHERE_AM_I)/utils
-	$(MAKE) -C docs                binary-dist WHERE_AM_I=$(WHERE_AM_I)/docs
-	$(MAKE) -C libffi              binary-dist WHERE_AM_I=$(WHERE_AM_I)/libffi
-	$(MAKE) -C libraries           binary-dist WHERE_AM_I=$(WHERE_AM_I)/libraries
-	$(MAKE) -C libraries/Cabal/doc binary-dist WHERE_AM_I=$(WHERE_AM_I)/libraries/Cabal/doc
-# Now thinks get messier. Some files we need to move around, rename or
-# generate. We do this under $(BIN_DIST_PREP).
-	$(RM) -rf    $(BIN_DIST_PREP_DIR)
-	$(MKDIRHIER) $(BIN_DIST_PREP)/mk
-	echo 'include $$(TOP)/Makefile-vars' &gt;  $(BIN_DIST_PREP)/mk/boilerplate.mk
-	echo 'include $$(TOP)/mk/package.mk' &gt;  $(BIN_DIST_PREP)/mk/target.mk
-	echo 'include $$(TOP)/mk/install.mk' &gt;&gt; $(BIN_DIST_PREP)/mk/target.mk
-	echo 'include $$(TOP)/mk/recurse.mk' &gt;&gt; $(BIN_DIST_PREP)/mk/target.mk
-	touch                                   $(BIN_DIST_PREP)/mk/bindist.mk
-ifeq &quot;$(darwin_TARGET_OS)&quot; &quot;1&quot;
-	cp mk/fix_install_names.sh $(BIN_DIST_PREP)/mk
-endif
-
-	cp distrib/Makefile         $(BIN_DIST_PREP)
-	cp distrib/INSTALL          $(BIN_DIST_PREP)
-	cp distrib/README           $(BIN_DIST_PREP)
-	cp distrib/configure-bin.ac $(BIN_DIST_PREP)/configure.ac
-# We can't just list aclocal.m4 in $(BIN_DIST_LIST), as it needs to be
-# next to configure.ac when we run autoreconf
-	cp aclocal.m4               $(BIN_DIST_PREP)
-	cd $(BIN_DIST_PREP) &amp;&amp; autoreconf
-# We need to copy the pwd program that was built with stage1 to where
-# the build system expects to find it, i.e. the location the pwd built
-# with the bootstrapping compiler normally occupies
-	$(MKDIRHIER) $(BIN_DIST_PREP)/utils/pwd
-	cp utils/pwd/dist-install/build/pwd/pwd $(BIN_DIST_PREP)/utils/pwd
-# And likewise the installPackage program
-	$(MKDIRHIER) $(BIN_DIST_PREP)/utils/installPackage/install-inplace/bin
-	cp utils/installPackage/dist-install/build/installPackage/installPackage \
-	   $(BIN_DIST_PREP)/utils/installPackage/install-inplace/bin
-
-	echo &quot;package = ghc&quot;                              &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;version = $(ProjectVersion)&quot;                &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;ProjectVersion = $(ProjectVersion)&quot;         &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;HaveLibGmp = $(HaveLibGmp)&quot;                 &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;GhcLibsWithUnix = $(GhcLibsWithUnix)&quot;       &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;GhcWithInterpreter = $(GhcWithInterpreter)&quot; &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;GhcHasEditline = $(GhcHasEditline)&quot;         &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;BootingFromHc = $(BootingFromHc)&quot;           &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;XMLDocWays = $(XMLDocWays)&quot;                 &gt;&gt; $(BIN_DIST_VARFILE)
-# We won't actually use xsltproc, but we need to know if it's &quot;&quot; or not
-	echo &quot;XSLTPROC = $(XSLTPROC)&quot;                     &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;TARGETPLATFORM = $(TARGETPLATFORM)&quot;         &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;HADDOCK_DOCS = $(HADDOCK_DOCS)&quot;             &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;LATEX_DOCS = $(LATEX_DOCS)&quot;                 &gt;&gt; $(BIN_DIST_VARFILE)
-	echo &quot;INTEGER_LIBRARY = $(INTEGER_LIBRARY)&quot;       &gt;&gt; $(BIN_DIST_VARFILE)
-	cat distrib/Makefile-bin-vars.in                  &gt;&gt; $(BIN_DIST_VARFILE)
-
-# With that done, we can now build the actual tarball
-
-	$(RM) -f $(BIN_DIST_NAME)
-	ln -s . $(BIN_DIST_NAME)
-# h means &quot;follow symlinks&quot;, e.g. if aclocal.m4 is a symlink to a source
-# tree then we want to include the real file, not a symlink to it
-	$(TAR) hcf $(BIN_DIST_TAR) -T $(BIN_DIST_LIST)
-	cd $(BIN_DIST_PREP_DIR) &amp;&amp; $(TAR) rf ../$(BIN_DIST_TAR) $(BIN_DIST_NAME)
-	bzip2 &lt; $(BIN_DIST_TAR) &gt; $(BIN_DIST_TAR_BZ2)
-	$(TAR) tf $(BIN_DIST_TAR) | sort &gt; bin-manifest-$(ProjectVersion)
-endif
-
-PUBLISH_FILES = $(BIN_DIST_TAR_BZ2)
-
-# Upload the distribution and documentation
-ifneq &quot;$(ISCC)&quot; &quot;&quot;
-WINDOWS_INSTALLER_BASE = ghc-$(ProjectVersion)-$(TARGETPLATFORM)
-WINDOWS_INSTALLER = $(WINDOWS_INSTALLER_BASE)$(exeext)
-
-PUBLISH_FILES += $(WINDOWS_INSTALLER)
-
-binary-dist :: generate-windows-installer
-
-.PHONY: generate-windows-installer
-generate-windows-installer ::
-	$(SED) &quot;s/@VERSION@/$(ProjectVersion)/&quot; distrib/ghc.iss | $(ISCC) /O. /F$(WINDOWS_INSTALLER_BASE) -
-endif
-
-# Upload the distribution and documentation
-ifneq &quot;$(PublishLocation)&quot; &quot;&quot;
-publish ::
-	make publish-binary-dist 'prefix=$(BIN_DIST_INST_DIR)'
-endif
-
-nTimes = set -e; for i in `seq 1 $(1)`; do echo Try &quot;$$i: $(2)&quot;; if $(2); then break; fi; done
-
-.PHONY: publish-binary-dist
-publish-binary-dist ::
-	@for f in $(PUBLISH_FILES); \
-	    do $(call nTimes,10,$(PublishCp) $$f $(PublishLocation)/dist); \
-	done
-
-# You need to &quot;make binddisttest&quot; before publishing the docs, as it
-# works by publish setting $(prefix) to inside the binddisttest
-# directory so $(docdir) points to the right place.
-
-# We assume that Windows means Cygwin, as we can't just use docdir
-# unchanged or rsync (really SSH?) thinks that c:/foo means /foo on
-# the machine c.
-
-ifeq &quot;$(Windows)&quot; &quot;YES&quot;
-PUBLISH_DOCDIR = $(shell cygpath --unix $(docdir))
-else
-PUBLISH_DOCDIR = $(docdir)
-endif
-
-publish-binary-dist ::
-	$(call nTimes,10,$(PublishCp) -r &quot;$(PUBLISH_DOCDIR)&quot;/* $(PublishLocation)/docs)
-
-binary-dist::
-	@echo &quot;Mechanical and super-natty! Inspect the result and *if* happy; freeze, sell and get some sleep!&quot;
-
-# -----------------------------------------------------------------------------
-# Building MacOS installer packages
-#
-# 'framework-pkg'
-#	Create an installer package for /Library/Frameworks/GHC.framework
-#
-# 'framework-binary-dist'
-#	Create an installer package for GHC.framework encapsulating a
-#	binary-dist to make it relocatable
-#	FIXME: This is only partially implemented so far
-
-ifeq &quot;$(darwin_TARGET_OS)&quot; &quot;1&quot;
-
-.PHONY: framework-pkg framework-binary-dist
-
-framework-pkg:
-	$(MAKE) -C distrib/MacOS framework-pkg
-
-framework-binary-dist:
-	$(MAKE) -C distrib/MacOS framework-binary-dist
-
-endif
-
-# -----------------------------------------------------------------------------
-# Building source distributions
-#
-# Do it like this: 
-#
-#	$ make
-#	$ make dist
-#
-# WARNING: `make dist' calls `make distclean' before tarring up the tree.
-#
-
-.PHONY: dist
-
-#
-# Directory in which we're going to build the src dist
-#
-SRC_DIST_NAME=ghc-$(ProjectVersion)
-SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
+# Now try it:
+# 
+# $ make -f fail.mk
+# fail.mk:3: inc1.mk: No such file or directory
+# fail.mk:8: inc2.mk: No such file or directory
+# echo &quot;X = C&quot; &gt;inc1.mk
+# echo &quot;Y = &quot; &gt;inc2.mk
+# make: Nothing to be done for `all'.
 
+# make built both inc1.mk and inc2.mk without restarting itself
+# between the two (even though we added a dependency on inc1.mk from
+# inc2.mk).
 #
-# Files to include in source distributions
-#
-SRC_DIST_DIRS += mk docs distrib bindisttest $(filter-out docs distrib libraries/Cabal/doc,$(SUBDIRS))
-SRC_DIST_FILES += \
-	configure.ac config.guess config.sub configure \
-	aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
-	ghc.spec.in ghc.spec extra-gcc-opts.in VERSION boot
+# The solution we adopt in the GHC build system is essentially this:
 
-# -----------------------------------------------------------------------------
-# Source distributions
-
-# A source dist is built from a complete build tree, because we
-# require some extra files not contained in a darcs checkout: the
-# output from Happy and Alex, for example.
+# --------------------
+# PHASE = 0
 # 
-# The steps performed by 'make dist' are as follows:
-#   - create a complete link-tree of the current build tree in /tmp
-#   - run 'make distclean' on that tree
-#   - remove a bunch of other files that we know shouldn't be in the dist
-#   - tar up first the extralibs package, then the main source package
-
-EXTRA_LIBS=$(patsubst %, $(SRC_DIST_NAME)/%, $(shell grep -E &quot;extralibs|dph&quot; packages | grep -v &quot;^\#&quot; | sed &quot;s/ .*//&quot;))
-
-SRC_DIST_TARBALL = ghc-$(ProjectVersion)-src.tar.bz2
-SRC_DIST_EXTRALIBS_TARBALL = ghc-$(ProjectVersion)-src-extralibs.tar.bz2
-
-VERSION :
-	echo $(ProjectVersion) &gt;VERSION
-
-dist :: VERSION
-
-# Use:
-#     $(call copy_generated_compiler_file,cmm,CmmLex,x)
-# to copy the generated file that replaces compiler/cmm/CmmLex.x
-# XXX Should this be unconditional? Do we want to support making a src dist
-# from an unbuilt tree?
-copy_generated_compiler_file = \
-  if test -f $(FPTOOLS_TOP_ABS)/compiler/dist-stage2/build/$2.hs; \
-  then \
-    $(CP) $(FPTOOLS_TOP_ABS)/compiler/dist-stage2/build/$2.hs compiler/$1/ ; \
-    mv compiler/$1/$2.$3 compiler/$1/$2.$3.source ; \
-  fi
-copy_generated_util_file = \
-  if test -f $(FPTOOLS_TOP_ABS)/utils/$1/dist-install/build/$1/$1-tmp/$2.hs; \
-  then \
-    $(CP) $(FPTOOLS_TOP_ABS)/utils/$1/dist-install/build/$1/$1-tmp/$2.hs utils/$1/ ; \
-    mv utils/$1/$2.$3 utils/$1/$2.$3.source ; \
-  fi
-
-dist ::
-	$(RM) -rf $(SRC_DIST_DIR)
-	$(RM) $(SRC_DIST_NAME).tar.gz
-	mkdir $(SRC_DIST_DIR)
-	( cd $(SRC_DIST_DIR) \
-	  &amp;&amp; for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i &amp;&amp; lndir $(FPTOOLS_TOP_ABS)/$$i ); done \
-	  &amp;&amp; for i in $(SRC_DIST_FILES); do $(LN_S) $(FPTOOLS_TOP_ABS)/$$i .; done \
-	  &amp;&amp; $(MAKE) distclean \
-	  &amp;&amp; if test -f $(FPTOOLS_TOP_ABS)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs; then $(CP) $(FPTOOLS_TOP_ABS)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs libraries/haskell-src/Language/Haskell/ ; mv libraries/haskell-src/Language/Haskell/Parser.ly libraries/haskell-src/Language/Haskell/Parser.ly.source ; fi \
-	  &amp;&amp; $(call copy_generated_compiler_file,cmm,CmmLex,x) \
-	  &amp;&amp; $(call copy_generated_compiler_file,cmm,CmmParse,y) \
-	  &amp;&amp; $(call copy_generated_compiler_file,main,ParsePkgConf,y) \
-	  &amp;&amp; $(call copy_generated_compiler_file,parser,HaddockLex,x) \
-	  &amp;&amp; $(call copy_generated_compiler_file,parser,HaddockParse,y) \
-	  &amp;&amp; $(call copy_generated_compiler_file,parser,Lexer,x) \
-	  &amp;&amp; $(call copy_generated_compiler_file,parser,Parser,y.pp) \
-	  &amp;&amp; $(call copy_generated_compiler_file,parser,ParserCore,y) \
-	  &amp;&amp; $(call copy_generated_util_file,hpc,HpcParser,y) \
-	  &amp;&amp; $(RM) -rf compiler/stage[123] mk/build.mk \
-	  &amp;&amp; $(FIND) $(SRC_DIST_DIRS) \( -name _darcs -o -name SRC -o -name &quot;autom4te*&quot; -o -name &quot;*~&quot; -o -name &quot;.cvsignore&quot; -o -name &quot;\#*&quot; -o -name &quot;.\#*&quot; -o -name &quot;log&quot; -o -name &quot;*-SAVE&quot; -o -name &quot;*.orig&quot; -o -name &quot;*.rej&quot; \) -print | xargs $(RM) -rf \
-	)
-	$(TAR) chf - $(EXTRA_LIBS) | bzip2 &gt;$(FPTOOLS_TOP_ABS)/$(SRC_DIST_EXTRALIBS_TARBALL)
-	$(RM) -rf $(EXTRA_LIBS)
-	$(TAR) chf - $(SRC_DIST_NAME) 2&gt;$src_log | bzip2 &gt;$(FPTOOLS_TOP_ABS)/$(SRC_DIST_TARBALL)
-
-# Upload the distribution(s)
-# Retrying is to work around buggy firewalls that corrupt large file transfers
-# over SSH.
-ifneq &quot;$(PublishLocation)&quot; &quot;&quot;
-dist ::
-	@for i in 0 1 2 3 4 5 6 7 8 9; do \
-		echo &quot;Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist&quot;; \
-		if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist; then break; fi; \
-	done
-	@for i in 0 1 2 3 4 5 6 7 8 9; do \
-		echo &quot;Try $$i: $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist&quot;; \
-		if $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist; then break; fi; \
-	done
-endif
-
-# -----------------------------------------------------------------------------
-# HC file bundles
-
-hc-file-bundle :
-	$(RM) -r ghc-$(ProjectVersion)
-	$(LN_S) . ghc-$(ProjectVersion)
-	$(FIND) ghc-$(ProjectVersion)/compiler \
-	     ghc-$(ProjectVersion)/utils \
-	     ghc-$(ProjectVersion)/libraries -follow \
-	  \( -name &quot;*.hc&quot; -o -name &quot;*_hsc.[ch]&quot; -o -name &quot;*_stub.[ch]&quot; \) -print &gt; hc-files-to-go
-	for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/utils ghc-$(ProjectVersion)/libraries -name &quot;*.hsc&quot; -follow -print` &quot;&quot;; do \
-	     if test &quot;x$$f&quot; != &quot;x&quot; &amp;&amp; test -f `echo &quot;$$f&quot; | sed 's/hsc$$/hs/g'`; then \
-	        echo `echo &quot;$$f&quot; | sed 's/hsc$$/hs/g' ` &gt;&gt; hc-files-to-go ; \
-	     fi; \
-	done;
-	for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/rts -name &quot;*.cmm&quot; -follow -print` &quot;&quot;; do \
-	     if test &quot;x$$f&quot; != &quot;x&quot;; then \
-	        echo `echo &quot;$$f&quot; | sed 's/cmm$$/hc/g' ` &gt;&gt; hc-files-to-go ; \
-	     fi; \
-	done;
-	echo ghc-$(ProjectVersion)/libraries/base/GHC/PrimopWrappers.hs &gt;&gt; hc-files-to-go
-	echo ghc-$(ProjectVersion)/compiler/parser/Parser.hs &gt;&gt; hc-files-to-go
-	echo ghc-$(ProjectVersion)/compiler/parser/ParserCore.hs &gt;&gt; hc-files-to-go
-	echo ghc-$(ProjectVersion)/compiler/main/ParsePkgConf.hs &gt;&gt; hc-files-to-go
-	echo ghc-$(ProjectVersion)/libraries/haskell-src/Language/Haskell/Parser.hs &gt;&gt; hc-files-to-go
-	$(TAR) czf ghc-$(ProjectVersion)-$(TARGETPLATFORM)-hc.tar.gz `cat hc-files-to-go`
-
-# -----------------------------------------------------------------------------
-# Cleaning
-
-CLEAN_FILES += hc-files-to-go *-hc.tar.gz
+# ifeq &quot;$(PHASE)&quot; &quot;0&quot;
+# all :
+# 	$(MAKE) PHASE=1
+# else
+# all :
+# endif
+# 
+# -include inc1.mk
+# 
+# inc1.mk : Makefile
+# 	echo &quot;X = C&quot; &gt;$@
+# 
+# ifneq &quot;$(PHASE)&quot; &quot;0&quot;
+# include inc2.mk
+# 
+# inc2.mk : inc1.mk
+# 	echo &quot;Y = $(X)&quot; &gt;$@
+# endif
+# 
+# clean :
+# 	rm -f inc1.mk inc2.mk
+# --------------------
 
-DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h \
-	docs/users_guide/ug-book.xml extra-gcc-opts
+# That is, every time make is invoked, we force it to update inc1.mk
+# and then restart.  In the GHC build system we need to divide the
+# build into 4 phases in fact, with a restart between each phase.  See
+# ghc.mk for the details on what happens in each phase and why.
 
-# don't clean config.mk: it's needed when cleaning stuff later on
-LATE_DIST_CLEAN_FILES += mk/config.mk mk/are-validating.mk
+default : all
+	@:
 
-# VERSION is shipped in a source dist
-MAINTAINER_CLEAN_FILES += VERSION
+# No need to update makefiles for these targets:
+REALGOALS=$(filter-out clean clean_% distclean maintainer-clean show,$(MAKECMDGOALS))
 
-extraclean::
-	$(RM) -rf autom4te.cache
+# NB. not the same as saying '%: ...', which doesn't do the right thing:
+# it does nothing if we specify a target that already exists.
+.PHONY: $(REALGOALS)
+$(REALGOALS) all:
+	@echo &quot;===--- updating makefiles phase 0&quot;
+	$(MAKE) -r --no-print-directory -f ghc.mk phase=0 just-makefiles
+	@echo &quot;===--- updating makefiles phase 1&quot;
+	$(MAKE) -r --no-print-directory -f ghc.mk phase=1 just-makefiles
+	@echo &quot;===--- updating makefiles phase 2&quot;
+	$(MAKE) -r --no-print-directory -f ghc.mk phase=2 just-makefiles
+	@echo &quot;===--- updating makefiles phase 3&quot;
+	$(MAKE) -r --no-print-directory -f ghc.mk phase=3 just-makefiles
+	@echo &quot;===--- finished updating makefiles&quot;
+	$(MAKE) -r --no-print-directory -f ghc.mk $@
 
-clean distclean ::
-	$(RM) -rf inplace-datadir
+binary-dist:
+	rm -f bindist-list
+	$(MAKE) -r --no-print-directory -f ghc.mk bindist BINDIST=YES
+	$(MAKE) -r --no-print-directory -f ghc.mk binary-dist
 
-clean distclean ::
-	$(MAKE) -C bindisttest $@
-	if test -d testsuite; then $(MAKE) -C testsuite $@; fi
+clean distclean maintainer-clean:
+	$(MAKE) -r --no-print-directory -f ghc.mk $@
+	test ! -d testsuite || $(MAKE) -C testsuite $@
 
-# -----------------------------------------------------------------------------
+$(filter clean_%, $(MAKECMDGOALS)) : clean_% :
+	$(MAKE) -r --no-print-directory -f ghc.mk $@
 
-# Turn off target.mk's rules for 'all', 'boot' and 'install'.
-NO_BOOT_TARGET=YES
-NO_ALL_TARGET=YES
-NO_INSTALL_TARGET=YES
+show:
+	$(MAKE) -r --no-print-directory -f ghc.mk $@
 
-include $(TOP)/mk/target.mk
+# If the user says 'make A B', then we don't want to invoke two
+# instances of the rule above in parallel:
+.NOTPARALLEL:
 
-# -----------------------------------------------------------------------------
+endif
 </diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -6,14 +6,14 @@ default_target: all
 # Ideally we'd just include something to give us variables
 # for paths and arguments to tools etc, and those set in mk/build.mk.
 TOP=..
-include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/config.mk
 
 all:
 	$(RM) -rf $(BIN_DIST_INST_SUBDIR)
 	$(RM) -rf ghc*
 	$(RM) HelloWorld HelloWorld.o HelloWorld.hi output
 	# --force-local makes tar not think that c:/foo refers to a remote file
-	$(TAR) --force-local -jxf $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2)
+	$(TAR) --force-local -jxf $(BIN_DIST_TAR_BZ2)
 ifeq &quot;$(Windows)&quot; &quot;YES&quot;
 	mv $(BIN_DIST_NAME) $(BIN_DIST_INST_DIR)
 else</diff>
      <filename>bindisttest/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,9 @@ set -e
 # Check that we have all boot packages.
 for dir in `grep &quot;^[^# ][^ ]*  *[^ ][^ ]*  *[^ ][^ ]*$&quot; packages | sed &quot;s/ .*//&quot;`
 do
-    if test ! -d $dir
+    if test ! -f $dir/LICENSE
     then
-        echo &quot;Looks like you're missing $dir.&quot; &gt;&amp;2
+        echo &quot;Error: $dir/LICENSE doesn't exist.&quot; &gt;&amp;2
         echo &quot;Maybe you haven't done './darcs-all get'?&quot; &gt;&amp;2
         exit 1
     fi
@@ -31,3 +31,19 @@ do
     fi
 done
 
+for f in libraries/*; do
+   dir=`basename $f`
+   cabals=`echo $f/*.cabal`
+   if test -f $cabals; then
+       echo &quot;Creating $f/ghc.mk&quot;
+       rm -f $f/ghc.mk
+       pkg=`basename ${cabals%.cabal}`
+       echo &quot;${f}_PACKAGE = ${pkg}&quot; &gt;&gt; $f/ghc.mk
+       echo &quot;\$(eval \$(call build-package,${f},dist-install,1))&quot; &gt;&gt; $f/ghc.mk
+       rm -f $f/GNUmakefile
+       echo &quot;Creating $f/GNUmakefile&quot;
+       echo &quot;dir = ${f}&quot; &gt;&gt; $f/GNUmakefile
+       echo &quot;TOP = ../..&quot; &gt;&gt; $f/GNUmakefile
+       echo &quot;include \$(TOP)/mk/sub-makefile.mk&quot; &gt;&gt; $f/GNUmakefile
+   fi
+done</diff>
      <filename>boot</filename>
    </modified>
    <modified>
      <diff>@@ -1,503 +1,16 @@
-# -----------------------------------------------------------------------------
-# Main compiler Makefile
-
-# Targets:
-#
-#	all	builds stage1 compiler
-#
-#	boot stage=N   generate build dirs and dependencies for stage N.
-#		       NB. Must be done before 'make stageN'.
-#		       NB. Cannot 'make boot stage=2' until stage1 has
-#		           been built (similarly for stage3).
-#
-#	stage1  (or stage=1) builds stage1 compiler
-#	stage2  (or stage=2) builds stage2 compiler
-#	stage3  (or stage=3) builds stage3 compiler
-#
-
+dir = compiler
 TOP = ..
+SPEC_TARGETS = 1 2 3
+include $(TOP)/mk/sub-makefile.mk
 
-ifeq &quot;$(stage)&quot; &quot;&quot;
-stage=1
-endif
-
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal-flags.mk
-
-ifeq &quot;$(GhcThreaded) $(GhcProfiled)&quot; &quot;YES YES&quot;
-$(error Cannot make GHC both threaded and profiled)
-endif
-
-CONFIG_HS 	= main/Config.hs
-PRIMOP_BITS = primop-data-decl.hs-incl        \
-              primop-tag.hs-incl              \
-              primop-list.hs-incl             \
-              primop-has-side-effects.hs-incl \
-              primop-out-of-line.hs-incl      \
-              primop-commutable.hs-incl       \
-              primop-needs-wrapper.hs-incl    \
-              primop-can-fail.hs-incl         \
-              primop-strictness.hs-incl       \
-              primop-primop-info.hs-incl
-
-boot:: boot.stage.$(stage)
-
-all:: build.stage.$(stage)
-
-doc:: doc.stage.$(stage)
-
-stage1 ::
-	$(MAKE) stage=1
-
-stage2 ::
-	$(MAKE) stage=2
-
-stage3 ::
-	$(MAKE) stage=3
-
-ifeq &quot;$(CLEAN_ALL_STAGES)&quot; &quot;YES&quot;
-clean distclean maintainer-clean::
-	$(RM) -f prelude/primops.txt
-	$(RM) -f $(PRIMOP_BITS)
-	$(RM) -f $(CONFIG_HS)
-	$(RM) -f parser/Parser.y
-	$(RM) -rf stage1 stage2plus
-	$(RM) -f $(STAGE3_PACKAGE_CONF)
-endif
-
-ifeq &quot;$(CLEAN_ALL_STAGES)&quot; &quot;YES&quot;
-clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3
-else
-clean distclean maintainer-clean:: clean.stage.$(stage)
-endif
-
-ifeq &quot;$(CLEAN_ALL_STAGES)&quot; &quot;YES&quot;
-distclean maintainer-clean::
-	$(RM) -f ghc.cabal
-endif
-
-clean.stage.%:
-	$(RM) -f Makefile-stage$*
-# This is a bit naughty. We ought to use:
-#	-$(CABAL) clean --distpref dist-stage$*
-# but that won't work if the Cabal file (a generated file) doesn't
-# exist. So we do this instead:
-	$(RM) -rf dist-stage$*
-
-CONFIGURE_FLAGS_STAGE1 += --flags=stage1
-CONFIGURE_FLAGS_STAGE2 += --flags=-stage1
-
-ifeq &quot;$(GhcWithNativeCodeGen)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE1 += --flags=ncg
-CONFIGURE_FLAGS_STAGE2 += --flags=ncg
-endif
-
-ifeq &quot;$(GhcWithInterpreter)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2 += --flags=ghci
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2 += --enable-shared
-# If we are going to use dynamic libraries instead of .o files for ghci,
-# we will need to always retain CAFs in the compiler.
-# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
-# function which sets the keepCAFs flag for the RTS before any Haskell
-# code is run.
-CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
-endif
-
-ifeq &quot;$(GhcEnableTablesNextToCode) $(GhcUnregisterised)&quot; &quot;YES NO&quot;
-# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
-# or not?
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
-endif
-
-# Should the debugger commands be enabled?
-ifeq &quot;$(GhciWithDebugger)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER
-endif
-
-# Enable editline if:
-#   - we're building stage 2/3, and we have built the editline package
-#
-# But we don't enable editline on Windows, as Windows terminals have
-# editline-like support builtin.
-#
-ifneq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ifeq &quot;$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)&quot; &quot;&quot;
-CONFIGURE_FLAGS_STAGE2 += --flags=editline
-endif
-endif
-endif
-
-ifeq &quot;$(GhcWithNativeCodeGen)&quot; &quot;NO&quot;
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN
-endif
-
-ifeq &quot;$(TargetOS_CPP)&quot; &quot;openbsd&quot;
-COMMON_CONFIGURE_FLAGS += --ld-options=-E
-endif
-
-ifeq &quot;$(GhcUnregisterised)&quot; &quot;NO&quot;
-ifeq &quot;$(HOSTPLATFORM)&quot; &quot;ia64-unknown-linux&quot;
-# needed for generating proper relocation in large binaries: trac #856
-COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax
-endif
-endif
-
-# We need to turn on profiling either if we have been asked to
-# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
-# profiling enabled (GhcProfiled = YES).
-ifneq &quot;$(GhcLibProfiled) $(GhcProfiled)&quot; &quot;NO NO&quot;
-CONFIGURE_FLAGS_STAGE2 += --enable-library-profiling
-# And if we're profiling GHC then we want lots of SCCs.
-# We also don't want to waste time building the non-profiling library,
-# either normally or for ghci. Unfortunately this means that we have to
-# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
-# exist.
-ifeq &quot;$(GhcProfiled)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-auto-all
-CONFIGURE_FLAGS_STAGE2 += --disable-library-vanilla
-CONFIGURE_FLAGS_STAGE2 += --disable-library-for-ghci
-CONFIGURE_FLAGS_STAGE2 += --ghc-pkg-option=--force
-endif
-endif
-
-ifeq &quot;$(HOSTPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-# The #include is vital for the via-C route with older compilers, else the C
-# compiler doesn't realise that the stcall foreign imports are indeed
-# stdcall, and doesn't generate the Foo@8 name for them
-# As it's only important for older compilers we don't need to do anything
-# for stage2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-option='-\#include'    \
-                          --ghc-option='&quot;&lt;windows.h&gt;&quot;' \
-                          --ghc-option='-\#include'    \
-                          --ghc-option='&quot;&lt;process.h&gt;&quot;'
-endif
-
-# ghc_strlen percolates through so many modules that it is easier to get its
-# prototype via a global option instead of a myriad of per-file OPTIONS.
-# Again, this is only important for older compilers, so we don't do it in
-# stage 2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-options='-\#include &quot;cutils.h&quot;'
-
-CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
-CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF)
-
-# In a source dist we don't need to worry about Parser.y(.pp) as we have
-# the .hs file pre-generated
-ifneq &quot;$(wildcard parser/Parser.y.pp)&quot; &quot;&quot;
-PARSER_Y = parser/Parser.y
-endif
-
-boot.stage.%: $(PRIMOP_BITS) $(CONFIG_HS) $(PARSER_Y)
-	test -f $(STAGE3_PACKAGE_CONF) || echo &quot;[]&quot; &gt; $(STAGE3_PACKAGE_CONF)
-	$(CABAL) configure --distpref dist-stage$* \
-	                   $(CONFIGURE_FLAGS_STAGE$*) \
-	                   $(INSTALL_DIRS_CONFIGURE_FLAGS) \
-	                   $(COMMON_CONFIGURE_FLAGS) \
-	                   --ghc-option=-DSTAGE=$*
-	$(RM) -f Makefile-stage$*
-	$(CABAL) makefile  --distpref dist-stage$* -f Makefile-stage$*
-
-build.stage.%:
-	$(MAKE) -f Makefile-stage$* stage=$*
-	$(CABAL) register  --distpref dist-stage$* --inplace
-	$(MAKE) -C ../ghc stage=$*
-
-doc.stage.%:
-	$(CABAL) haddock --distpref dist-stage$* \
-					 --html-location='../$$pkg' \
-	                 --haddock-option=--optghc=-DSTAGE=$* \
-	                 --haddock-option=+RTS --haddock-option=-s --haddock-option=-c --haddock-option=-RTS \
-	                 --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
-
-install:
-	$(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' --distpref dist-stage2
-
-# -----------------------------------------------------------------------------
-# Create compiler configuration
-#
-# The 'echo' commands simply spit the values of various make variables
-# into Config.hs, whence they can be compiled and used by GHC itself
-
-$(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
-	@$(RM) -f $(CONFIG_HS)
-	@echo &quot;Creating $(CONFIG_HS) ... &quot;
-	@echo &quot;module Config where&quot; &gt;&gt;$(CONFIG_HS)
-	@echo &quot;cProjectName          :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectName          = \&quot;$(ProjectName)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectVersion       :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectVersion       = \&quot;$(ProjectVersion)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectVersionInt    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectVersionInt    = \&quot;$(ProjectVersionInt)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectPatchLevel    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cProjectPatchLevel    = \&quot;$(ProjectPatchLevel)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cBooterVersion        :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cBooterVersion        = \&quot;$(GhcVersion)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cStage                :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cStage                = show (STAGE :: Int)&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cHscIfaceFileVersion  :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cHscIfaceFileVersion  = \&quot;$(HscIfaceFileVersion)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cSplitObjs            :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cSplitObjs            = \&quot;$(SupportsSplitObjs)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithInterpreter   :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithInterpreter   = \&quot;$(GhcWithInterpreter)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithNativeCodeGen :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithNativeCodeGen = \&quot;$(GhcWithNativeCodeGen)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithSMP           :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcWithSMP           = \&quot;$(GhcWithSMP)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcRTSWays           :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcRTSWays           = \&quot;$(GhcRTSWays)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcUnregisterised    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcUnregisterised    = \&quot;$(GhcUnregisterised)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcEnableTablesNextToCode :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGhcEnableTablesNextToCode = \&quot;$(GhcEnableTablesNextToCode)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLeadingUnderscore    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLeadingUnderscore    = \&quot;$(LeadingUnderscore)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cRAWCPP_FLAGS         :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cRAWCPP_FLAGS         = \&quot;$(RAWCPP_FLAGS)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGCC                  :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGCC                  = \&quot;$(WhatGccIsCalled)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cMKDLL                :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cMKDLL                = \&quot;$(BLD_DLL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLdIsGNULd            :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLdIsGNULd            = \&quot;$(LdIsGNULd)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLD_X		     :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cLD_X		     = \&quot;$(LD_X)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_DRIVER_DIR_REL   :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_DRIVER_DIR_REL   = \&quot;$(GHC_DRIVER_DIR_REL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_TOUCHY_PGM       :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_TOUCHY_PGM       = \&quot;$(GHC_TOUCHY_PGM)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_TOUCHY_DIR_REL   :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_TOUCHY_DIR_REL   = \&quot;$(GHC_TOUCHY_DIR_REL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_UNLIT_PGM        :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_UNLIT_PGM        = \&quot;$(GHC_UNLIT_PGM)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_UNLIT_DIR_REL    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_UNLIT_DIR_REL    = \&quot;$(GHC_UNLIT_DIR_REL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_MANGLER_PGM      :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_MANGLER_PGM      = \&quot;$(GHC_MANGLER_PGM)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_MANGLER_DIR_REL  :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_MANGLER_DIR_REL  = \&quot;$(GHC_MANGLER_DIR_REL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SPLIT_PGM        :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SPLIT_PGM        = \&quot;$(GHC_SPLIT_PGM)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SPLIT_DIR_REL    :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SPLIT_DIR_REL    = \&quot;$(GHC_SPLIT_DIR_REL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SYSMAN_PGM       :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SYSMAN_PGM       = \&quot;$(GHC_SYSMAN)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SYSMAN_DIR_REL   :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_SYSMAN_DIR_REL   = \&quot;$(GHC_SYSMAN_DIR)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_CP               :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_CP               = \&quot;$(GHC_CP)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_PERL             :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cGHC_PERL             = \&quot;$(GHC_PERL)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cEnableWin32DLLs      :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cEnableWin32DLLs      = \&quot;$(EnableWin32DLLs)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cCONTEXT_DIFF         :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cCONTEXT_DIFF         = \&quot;$(CONTEXT_DIFF)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cUSER_WAY_NAMES       :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cUSER_WAY_NAMES       = \&quot;$(USER_WAY_NAMES)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cUSER_WAY_OPTS        :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cUSER_WAY_OPTS        = \&quot;$(USER_WAY_OPTS)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cDEFAULT_TMPDIR       :: String&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cDEFAULT_TMPDIR       = \&quot;$(DEFAULT_TMPDIR)\&quot;&quot; &gt;&gt; $(CONFIG_HS)
-	@echo &quot;cRelocatableBuild     :: Bool&quot;                 &gt;&gt; $(CONFIG_HS)
-ifeq &quot;$(RelocatableBuild)&quot; &quot;YES&quot;
-	@echo &quot;cRelocatableBuild     = True&quot;                  &gt;&gt; $(CONFIG_HS)
-else
-	@echo &quot;cRelocatableBuild     = False&quot;                 &gt;&gt; $(CONFIG_HS)
-endif
-	@echo &quot;cLibFFI               :: Bool&quot;                 &gt;&gt; $(CONFIG_HS)
-ifeq &quot;$(UseLibFFIForAdjustors)&quot; &quot;YES&quot;
-	@echo &quot;cLibFFI               = True&quot;                  &gt;&gt; $(CONFIG_HS)
-else
-	@echo &quot;cLibFFI               = False&quot;                 &gt;&gt; $(CONFIG_HS)
-endif
-	@echo done.
-
-# -----------------------------------------------------------------------------
-# Create platform includes
-
-# Here we generate a little header file containing CPP symbols that GHC
-# uses to determine which platform it is building on/for.  The platforms
-# can differ between stage1 and stage2 if we're cross-compiling, so we
-# need one of these header files per stage.
-
-PLATFORM_H = ghc_boot_platform.h
-
-stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
-	$(MKDIRHIER) stage1
-	@echo &quot;Creating $@...&quot;
-	@$(RM) $@
-	@echo &quot;#ifndef __PLATFORM_H__&quot;  &gt;$@
-	@echo &quot;#define __PLATFORM_H__&quot; &gt;&gt;$@
-	@echo &gt;&gt; $@
-	@echo &quot;#define BuildPlatform_NAME  \&quot;$(BUILDPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HostPlatform_NAME   \&quot;$(HOSTPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TargetPlatform_NAME \&quot;$(TARGETPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(BuildPlatform_CPP)_BUILD  	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(HostPlatform_CPP)_HOST		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetPlatform_CPP)_TARGET	1&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(BuildArch_CPP)_BUILD_ARCH  	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(HostArch_CPP)_HOST_ARCH	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetArch_CPP)_TARGET_ARCH	1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_ARCH \&quot;$(BuildArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_ARCH \&quot;$(HostArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_ARCH \&quot;$(TargetArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(BuildOS_CPP)_BUILD_OS 		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(HostOS_CPP)_HOST_OS		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetOS_CPP)_TARGET_OS	1&quot; &gt;&gt; $@  
-	@echo &quot;#define BUILD_OS \&quot;$(BuildOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_OS \&quot;$(HostOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_OS \&quot;$(TargetOS_CPP)\&quot;&quot; &gt;&gt; $@
-ifeq &quot;$(HostOS_CPP)&quot; &quot;irix&quot;
-	@echo &quot;#ifndef $(IRIX_MAJOR)_TARGET_OS		 &quot; &gt;&gt; $@  
-	@echo &quot;#define $(IRIX_MAJOR)_TARGET_OS		1&quot; &gt;&gt; $@  
-	@echo &quot;#endif					 &quot; &gt;&gt; $@  
-endif
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(BuildVendor_CPP)_BUILD_VENDOR 	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(HostVendor_CPP)_HOST_VENDOR	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetVendor_CPP)_TARGET_VENDOR  1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_VENDOR \&quot;$(BuildVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_VENDOR \&quot;$(HostVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_VENDOR \&quot;$(TargetVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#endif /* __PLATFORM_H__ */&quot;          &gt;&gt; $@
-	@echo &quot;Done.&quot;
-
-# For stage2 and above, the BUILD platform is the HOST of stage1, and
-# the HOST platform is the TARGET of stage1.  The TARGET remains the same
-# (stage1 is the cross-compiler, not stage2).
-stage2plus/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
-	$(MKDIRHIER) stage2plus
-	@echo &quot;Creating $@...&quot;
-	@$(RM) $@
-	@echo &quot;#ifndef __PLATFORM_H__&quot;  &gt;$@
-	@echo &quot;#define __PLATFORM_H__&quot; &gt;&gt;$@
-	@echo &gt;&gt; $@
-	@echo &quot;#define BuildPlatform_NAME  \&quot;$(HOSTPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HostPlatform_NAME   \&quot;$(TARGETPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TargetPlatform_NAME \&quot;$(TARGETPLATFORM)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostPlatform_CPP)_BUILD  	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetPlatform_CPP)_HOST		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetPlatform_CPP)_TARGET	1&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostArch_CPP)_BUILD_ARCH  	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetArch_CPP)_HOST_ARCH	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetArch_CPP)_TARGET_ARCH	1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_ARCH \&quot;$(HostArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_ARCH \&quot;$(TargetArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_ARCH \&quot;$(TargetArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostOS_CPP)_BUILD_OS 		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetOS_CPP)_HOST_OS		1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetOS_CPP)_TARGET_OS	1&quot; &gt;&gt; $@  
-	@echo &quot;#define BUILD_OS \&quot;$(HostOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_OS \&quot;$(TargetOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_OS \&quot;$(TargetOS_CPP)\&quot;&quot; &gt;&gt; $@
-ifeq &quot;$(HostOS_CPP)&quot; &quot;irix&quot;
-	@echo &quot;#ifndef $(IRIX_MAJOR)_TARGET_OS		 &quot; &gt;&gt; $@  
-	@echo &quot;#define $(IRIX_MAJOR)_TARGET_OS		1&quot; &gt;&gt; $@  
-	@echo &quot;#endif					 &quot; &gt;&gt; $@  
-endif
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostVendor_CPP)_BUILD_VENDOR 	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetVendor_CPP)_HOST_VENDOR	1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetVendor_CPP)_TARGET_VENDOR  1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_VENDOR \&quot;$(HostVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_VENDOR \&quot;$(TargetVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_VENDOR \&quot;$(TargetVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#endif /* __PLATFORM_H__ */&quot;          &gt;&gt; $@
-	@echo &quot;Done.&quot;
-
-ifeq &quot;$(stage)&quot; &quot;1&quot;
-STAGE_PLATFORM_H = stage1/$(PLATFORM_H)
-else
-STAGE_PLATFORM_H = stage2plus/$(PLATFORM_H)
-endif
-
-boot :: $(STAGE_PLATFORM_H)
-
-# ----------------------------------------------------------------------------
-#		Generate supporting stuff for prelude/PrimOp.lhs 
-#		from prelude/primops.txt
-
-SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
-SRC_CPP_OPTS += ${GhcCppOpts}
-
-prelude/primops.txt parser/Parser.y: %: %.pp stage1/$(PLATFORM_H)
-	$(CPP) $(RAWCPP_FLAGS) -P $(CPP_OPTS) -x c $&lt; | grep -v '^#pragma GCC' &gt; $@
-
-primop-data-decl.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --data-decl          &lt; $&lt; &gt; $@
-primop-tag.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --primop-tag         &lt; $&lt; &gt; $@
-primop-list.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --primop-list        &lt; $&lt; &gt; $@
-primop-has-side-effects.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --has-side-effects   &lt; $&lt; &gt; $@
-primop-out-of-line.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --out-of-line        &lt; $&lt; &gt; $@
-primop-commutable.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --commutable         &lt; $&lt; &gt; $@
-primop-needs-wrapper.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --needs-wrapper      &lt; $&lt; &gt; $@
-primop-can-fail.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --can-fail           &lt; $&lt; &gt; $@
-primop-strictness.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --strictness         &lt; $&lt; &gt; $@
-primop-primop-info.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --primop-primop-info &lt; $&lt; &gt; $@
-
-# Usages aren't used any more; but the generator 
-# can still generate them if we want them back
-primop-usage.hs-incl: prelude/primops.txt
-	$(GENPRIMOP) --usage              &lt; $&lt; &gt; $@
-
-html:
-	$(MAKE) doc stage=2
-
-install-docs:
-	@:
-
-#-----------------------------------------------------------------------------
-# binary-dist
-#
+.PHONY: 1 2 3
 
-# Ideally we'd get these from the Cabal file's Install-Includes:
-BINDIST_EXTRAS += HsVersions.h
-ifeq &quot;$(stage)&quot; &quot;1&quot;
-BINDIST_EXTRAS += stage1/ghc_boot_platform.h
-else
-BINDIST_EXTRAS += stage2plus/ghc_boot_platform.h
-endif
+1:
+	+$(TOPMAKE) stage=1 all_ghc_stage1 compiler_stage1_NO_BUILD_DEPS=YES
 
-include $(TOP)/mk/bindist.mk
-LIB_DIST_DIR = dist-stage2
+2:
+	+$(TOPMAKE) stage=2 all_ghc_stage2 compiler_stage2_NO_BUILD_DEPS=YES
 
-#-----------------------------------------------------------------------------
-# etags generation
-ifeq &quot;$(HOSTPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-GHCTAGS = $(TOP)/utils/ghctags/ghctags.exe
-else
-GHCTAGS = $(TOP)/utils/ghctags/ghctags-inplace
-endif
-GHCTAGS_ROOT = main/GHC.hs ghci/InteractiveUI.hs main/PprTyThing.hs
+3:
+	+$(TOPMAKE) stage=3 all_ghc_stage3 compiler_stage3_NO_BUILD_DEPS=YES
 
-# etags for stage2 is actually broken since it requires building
-# ghctags against an older ghc api
-etags: etags.stage.2
-etags.stage.%:
-	$(GHCTAGS) --topdir $(FPTOOLS_TOP_ABS) --etags --use-cabal-config=./dist-stage$* -- -DSTAGE=$* -- $(GHCTAGS_ROOT)</diff>
      <filename>compiler/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+-- WARNING: ghc.cabal is automatically generated from ghc.cabal.in by
+-- ./configure.  Make sure you are editing ghc.cabal.in, not ghc.cabal.
+
 Name: ghc
 Version: @ProjectVersion@
 License: BSD3
@@ -45,6 +48,15 @@ Flag ncg
 
 Flag stage1
     Description: Is this stage 1?
+    Default: False
+
+Flag stage2
+    Description: Is this stage 2?
+    Default: False
+
+Flag stage3
+    Description: Is this stage 3?
+    Default: False
 
 Library
     Exposed: False
@@ -103,7 +115,12 @@ Library
             Build-Depends: extensible-exceptions
             Extensions: PatternSignatures
     else
-        Include-Dirs: stage2plus
+        if flag(stage2)
+            Include-Dirs: stage2
+        else
+            if flag(stage3)
+                Include-Dirs: stage2
+
     Install-Includes: HsVersions.h, ghc_boot_platform.h
 
     c-sources:</diff>
      <filename>compiler/ghc.cabal.in</filename>
    </modified>
    <modified>
      <diff>@@ -72,7 +72,8 @@ doMkDependHS srcs = do
     -- Prcess them one by one, dumping results into makefile
     -- and complaining about cycles
     hsc_env &lt;- getSession
-    mapM (liftIO . processDeps dflags hsc_env excl_mods (mkd_tmp_hdl files)) sorted
+    root &lt;- liftIO getCurrentDirectory
+    mapM (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted
 
     -- If -ddump-mod-cycles, show cycles in the module graph
     liftIO $ dumpModCycles dflags mod_summaries
@@ -158,6 +159,7 @@ beginMkDependHS dflags = do
 processDeps :: DynFlags
             -&gt; HscEnv
             -&gt; [ModuleName]
+            -&gt; FilePath
             -&gt; Handle           -- Write dependencies to here
             -&gt; SCC ModSummary
             -&gt; IO ()
@@ -176,11 +178,11 @@ processDeps :: DynFlags
 --
 -- For {-# SOURCE #-} imports the &quot;hi&quot; will be &quot;hi-boot&quot;.
 
-processDeps _ _ _ _ (CyclicSCC nodes)
+processDeps _ _ _ _ _ (CyclicSCC nodes)
   =     -- There shouldn't be any cycles; report them
     ghcError (ProgramError (showSDoc $ GHC.cyclicModuleErr nodes))
 
-processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
+processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC node)
   = do  { let extra_suffixes = depSuffixes dflags
               include_pkg_deps = depIncludePkgDeps dflags
               src_file  = msHsFilePath node
@@ -194,7 +196,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
                            Nothing      -&gt; return () ;
                            Just hi_file -&gt; do
                      { let hi_files = insertSuffixes hi_file extra_suffixes
-                           write_dep (obj,hi) = writeDependency hdl [obj] hi
+                           write_dep (obj,hi) = writeDependency root hdl [obj] hi
 
                         -- Add one dependency for each suffix;
                         -- e.g.         A.o   : B.hi
@@ -204,7 +206,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
 
                 -- Emit std dependency of the object(s) on the source file
                 -- Something like       A.o : A.hs
-        ; writeDependency hdl obj_files src_file
+        ; writeDependency root hdl obj_files src_file
 
                 -- Emit a dependency for each import
 
@@ -248,12 +250,18 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps
         }
 
 -----------------------------
-writeDependency :: Handle -&gt; [FilePath] -&gt; FilePath -&gt; IO ()
--- (writeDependency h [t1,t2] dep) writes to handle h the dependency
+writeDependency :: FilePath -&gt; Handle -&gt; [FilePath] -&gt; FilePath -&gt; IO ()
+-- (writeDependency r h [t1,t2] dep) writes to handle h the dependency
 --      t1 t2 : dep
-writeDependency hdl targets dep
-  = hPutStrLn hdl (unwords (map forOutput targets) ++ &quot; : &quot; ++ forOutput dep)
-    where forOutput = escapeSpaces . reslash Forwards . normalise
+writeDependency root hdl targets dep
+  = do let -- We need to avoid making deps on
+           --     c:/foo/...
+           -- on cygwin as make gets confused by the :
+           -- Making relative deps avoids some instances of this.
+           dep' = makeRelative root dep
+           forOutput = escapeSpaces . reslash Forwards . normalise
+           output = unwords (map forOutput targets) ++ &quot; : &quot; ++ forOutput dep'
+       hPutStrLn hdl output
 
 -----------------------------
 insertSuffixes</diff>
      <filename>compiler/main/DriverMkDepend.hs</filename>
    </modified>
    <modified>
      <diff>@@ -77,27 +77,20 @@ How GHC finds its files
 [Note topdir]
 
 GHC needs various support files (library packages, RTS etc), plus
-various auxiliary programs (cp, gcc, etc).  It starts by finding topdir:
-
-     for &quot;installed&quot; topdir is the root of GHC's support files ($libdir)
-     for &quot;in-place&quot;  topdir is the root of the build tree
+various auxiliary programs (cp, gcc, etc).  It starts by finding topdir,
+the root of GHC's support files
 
 On Unix:
   - ghc always has a shell wrapper that passes a -B&lt;dir&gt; option
-  - in an installation, &lt;dir&gt; is $libdir
-  - in a build tree, &lt;dir&gt; is $TOP/inplace-datadir
-  - so we detect the build-tree case and add &quot;..&quot; to get us back to $TOP
 
 On Windows:
   - ghc never has a shell wrapper.
   - we can find the location of the ghc binary, which is
-        $topdir/bin/ghc.exe                   in an installation, or
-        $topdir/ghc/stage1-inplace/ghc.exe    in a build tree.
-  - we detect which one of these we have, and calculate $topdir.
-
+        $topdir/bin/&lt;something&gt;.exe
+    where &lt;something&gt; may be &quot;ghc&quot;, &quot;ghc-stage2&quot;, or similar
+  - we strip off the &quot;bin/&lt;something&gt;.exe&quot; to leave $topdir.
 
-from topdir we can find package.conf, which contains the locations of
-almost everything else, whether we're in a build tree or installed.
+from topdir we can find package.conf, ghc-asm, etc.
 
 
 SysTools.initSysProgs figures out exactly where all the auxiliary programs
@@ -113,8 +106,8 @@ Config.hs contains two sorts of things
   etc           They do *not* include paths
 
 
-  cUNLIT_DIR_REL   The *path* to the directory containing unlit, split etc
-  cSPLIT_DIR_REL   *relative* to the root of the build tree,
+  cUNLIT_DIR   The *path* to the directory containing unlit, split etc
+  cSPLIT_DIR   *relative* to the root of the build tree,
                    for use when running *in-place* in a build tree (only)
 
 
@@ -159,46 +152,28 @@ initSysTools :: Maybe String    -- Maybe TopDir path (without the '-B' prefix)
 
 
 initSysTools mbMinusB dflags0
-  = do  { (am_installed, top_dir) &lt;- findTopDir mbMinusB
+  = do  { top_dir &lt;- findTopDir mbMinusB
                 -- see [Note topdir]
                 -- NB: top_dir is assumed to be in standard Unix
                 -- format, '/' separated
 
-        ; let installed, installed_bin :: FilePath -&gt; FilePath
-              installed_bin pgm  = top_dir &lt;/&gt; pgm
-              installed     file = top_dir &lt;/&gt; file
-              inplace dir   pgm  = top_dir &lt;/&gt; dir &lt;/&gt; pgm
-
-        ; let pkgconfig_path
-                | am_installed = installed &quot;package.conf&quot;
-                | otherwise    = inplace &quot;inplace-datadir&quot; &quot;package.conf&quot;
-
-              ghc_usage_msg_path
-                | am_installed = installed &quot;ghc-usage.txt&quot;
-                | otherwise    = inplace cGHC_DRIVER_DIR_REL &quot;ghc-usage.txt&quot;
+        ; let installed :: FilePath -&gt; FilePath
+              installed file = top_dir &lt;/&gt; file
+              installed_mingw_bin file = top_dir &lt;/&gt; &quot;..&quot; &lt;/&gt; &quot;mingw&quot; &lt;/&gt; &quot;bin&quot; &lt;/&gt; file
 
-              ghci_usage_msg_path
-                | am_installed = installed &quot;ghci-usage.txt&quot;
-                | otherwise    = inplace cGHC_DRIVER_DIR_REL &quot;ghci-usage.txt&quot;
+        ; let pkgconfig_path      = installed &quot;package.conf&quot;
+              ghc_usage_msg_path  = installed &quot;ghc-usage.txt&quot;
+              ghci_usage_msg_path = installed &quot;ghci-usage.txt&quot;
 
                 -- For all systems, unlit, split, mangle are GHC utilities
                 -- architecture-specific stuff is done when building Config.hs
-              unlit_path
-                | am_installed = installed_bin cGHC_UNLIT_PGM
-                | otherwise    = inplace cGHC_UNLIT_DIR_REL cGHC_UNLIT_PGM
+              unlit_path = installed cGHC_UNLIT_PGM
 
                 -- split and mangle are Perl scripts
-              split_script
-                | am_installed = installed_bin cGHC_SPLIT_PGM
-                | otherwise    = inplace cGHC_SPLIT_DIR_REL cGHC_SPLIT_PGM
+              split_script  = installed cGHC_SPLIT_PGM
+              mangle_script = installed cGHC_MANGLER_PGM
 
-              mangle_script
-                | am_installed = installed_bin cGHC_MANGLER_PGM
-                | otherwise    = inplace cGHC_MANGLER_DIR_REL cGHC_MANGLER_PGM
-
-              windres_path
-                | am_installed = installed_bin &quot;bin/windres&quot;
-                | otherwise    = &quot;windres&quot;
+              windres_path  = installed_mingw_bin &quot;windres&quot;
 
         ; tmpdir &lt;- getTemporaryDirectory
         ; let dflags1 = setTmpDir tmpdir dflags0
@@ -209,43 +184,19 @@ initSysTools mbMinusB dflags0
              ghcError (InstallationError
                          (&quot;Can't find package.conf as &quot; ++ pkgconfig_path))
 
-        -- On Windows, gcc and friends are distributed with GHC,
-        --      so when &quot;installed&quot; we look in TopDir/bin
-        -- When &quot;in-place&quot;, or when not on Windows, we look wherever
-        --      the build-time configure script found them
+        -- On Windows, mingw is distributed with GHC,
+        --      so we look in TopDir/../mingw/bin
         ; let
-              -- The trailing &quot;/&quot; is absolutely essential; gcc seems
-              -- to construct file names simply by concatenating to
-              -- this -B path with no extra slash We use &quot;/&quot; rather
-              -- than &quot;\\&quot; because otherwise &quot;\\\&quot; is mangled
-              -- later on; although gcc_args are in NATIVE format,
-              -- gcc can cope
-              --      (see comments with declarations of global variables)
-              gcc_b_arg = Option (&quot;-B&quot; ++ installed &quot;gcc-lib/&quot;)
-              gcc_mingw_include_arg = Option (&quot;-I&quot; ++ installed &quot;include/mingw&quot;)
-              (gcc_prog,gcc_args)
-                | isWindowsHost &amp;&amp; am_installed
-                    -- We tell gcc where its specs file + exes are (-B)
-                    -- and also some places to pick up include files.  We need
-                    -- to be careful to put all necessary exes in the -B place
-                    -- (as, ld, cc1, etc) since if they don't get found there,
-                    -- gcc then tries to run unadorned &quot;as&quot;, &quot;ld&quot;, etc, and
-                    -- will pick up whatever happens to be lying around in
-                    -- the path, possibly including those from a cygwin
-                    -- install on the target, which is exactly what we're
-                    -- trying to avoid.
-                    = (installed_bin &quot;gcc&quot;, [gcc_b_arg, gcc_mingw_include_arg])
-                | otherwise = (cGCC, [])
+              gcc_prog
+                | isWindowsHost = installed_mingw_bin &quot;gcc&quot;
+                | otherwise     = cGCC
               perl_path
-                | isWindowsHost &amp;&amp; am_installed = installed_bin cGHC_PERL
-                | otherwise = cGHC_PERL
+                | isWindowsHost = installed cGHC_PERL
+                | otherwise     = cGHC_PERL
               -- 'touch' is a GHC util for Windows
               touch_path
-                | isWindowsHost
-                    = if am_installed
-                      then installed_bin cGHC_TOUCHY_PGM
-                      else inplace cGHC_TOUCHY_DIR_REL cGHC_TOUCHY_PGM
-                | otherwise = &quot;touch&quot;
+                | isWindowsHost = installed cGHC_TOUCHY_PGM
+                | otherwise     = &quot;touch&quot;
               -- On Win32 we don't want to rely on #!/bin/perl, so we prepend
               -- a call to Perl to get the invocation of split and mangle.
               -- On Unix, scripts are invoked using the '#!' method.  Binary
@@ -261,23 +212,18 @@ initSysTools mbMinusB dflags0
               (mkdll_prog, mkdll_args)
                 | not isWindowsHost
                     = panic &quot;Can't build DLLs on a non-Win32 system&quot;
-                | am_installed =
-                    (installed &quot;gcc-lib/&quot; &lt;/&gt; cMKDLL,
-                     [ Option &quot;--dlltool-name&quot;,
-                       Option (installed &quot;gcc-lib/&quot; &lt;/&gt; &quot;dlltool&quot;),
-                       Option &quot;--driver-name&quot;,
-                       Option gcc_prog, gcc_b_arg, gcc_mingw_include_arg ])
-                | otherwise    = (cMKDLL, [])
+                | otherwise =
+                    (installed_mingw_bin cMKDLL, [])
 
         -- cpp is derived from gcc on all platforms
         -- HACK, see setPgmP below. We keep 'words' here to remember to fix
         -- Config.hs one day.
-        ; let cpp_path  = (gcc_prog, gcc_args ++
+        ; let cpp_path  = (gcc_prog,
                            (Option &quot;-E&quot;):(map Option (words cRAWCPP_FLAGS)))
 
         -- Other things being equal, as and ld are simply gcc
-        ; let   (as_prog,as_args)  = (gcc_prog,gcc_args)
-                (ld_prog,ld_args)  = (gcc_prog,gcc_args)
+        ; let   as_prog  = gcc_prog
+                ld_prog  = gcc_prog
 
         ; return dflags1{
                         ghcUsagePath = ghc_usage_msg_path,
@@ -287,11 +233,11 @@ initSysTools mbMinusB dflags0
                         pgm_L   = unlit_path,
                         pgm_P   = cpp_path,
                         pgm_F   = &quot;&quot;,
-                        pgm_c   = (gcc_prog,gcc_args),
+                        pgm_c   = (gcc_prog,[]),
                         pgm_m   = (mangle_prog,mangle_args),
                         pgm_s   = (split_prog,split_args),
-                        pgm_a   = (as_prog,as_args),
-                        pgm_l   = (ld_prog,ld_args),
+                        pgm_a   = (as_prog,[]),
+                        pgm_l   = (ld_prog,[]),
                         pgm_dll = (mkdll_prog,mkdll_args),
                         pgm_T   = touch_path,
                         pgm_sysman = top_dir ++ &quot;/ghc/rts/parallel/SysMan&quot;,
@@ -303,33 +249,17 @@ initSysTools mbMinusB dflags0
 \end{code}
 
 \begin{code}
-findTopDir :: Maybe String   -- Maybe TopDir path (without the '-B' prefix).
-           -&gt; IO (Bool,      -- True &lt;=&gt; am installed, False &lt;=&gt; in-place
-                  String)    -- TopDir (in Unix format '/' separated)
-
-findTopDir mbMinusB
-  = do { top_dir &lt;- get_proto
-       ; exists1 &lt;- doesFileExist (top_dir &lt;/&gt; &quot;package.conf&quot;)
-       ; exists2 &lt;- doesFileExist (top_dir &lt;/&gt; &quot;inplace&quot;)
-       ; let amInplace = not exists1 -- On Windows, package.conf doesn't exist
-                                     -- when we are inplace
-                      || exists2 -- On Linux, the presence of inplace signals
-                                 -- that we are inplace
-
-       ; let real_top = if exists2 then top_dir &lt;/&gt; &quot;..&quot; else top_dir
-
-       ; return (not amInplace, real_top)
-       }
-  where
-    -- get_proto returns a Unix-format path (relying on getBaseDir to do so too)
-    get_proto = case mbMinusB of
-                  Just minusb -&gt; return (normalise minusb)
-                  Nothing
-                      -&gt; do maybe_exec_dir &lt;- getBaseDir -- Get directory of executable
-                            case maybe_exec_dir of       -- (only works on Windows;
-                                                         --  returns Nothing on Unix)
-                              Nothing  -&gt; ghcError (InstallationError &quot;missing -B&lt;dir&gt; option&quot;)
-                              Just dir -&gt; return dir
+-- returns a Unix-format path (relying on getBaseDir to do so too)
+findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix).
+           -&gt; IO String    -- TopDir (in Unix format '/' separated)
+findTopDir (Just minusb) = return (normalise minusb)
+findTopDir Nothing
+    = do -- Get directory of executable
+         maybe_exec_dir &lt;- getBaseDir
+         case maybe_exec_dir of
+             -- &quot;Just&quot; on Windows, &quot;Nothing&quot; on unix
+             Nothing  -&gt; ghcError (InstallationError &quot;missing -B&lt;dir&gt; option&quot;)
+             Just dir -&gt; return dir
 \end{code}
 
 
@@ -473,25 +403,10 @@ runMkDLL dflags args = do
 
 runWindres :: DynFlags -&gt; [Option] -&gt; IO ()
 runWindres dflags args = do
-  let (gcc,gcc_args) = pgm_c dflags
+  let (_gcc,gcc_args) = pgm_c dflags
       windres        = pgm_windres dflags
   mb_env &lt;- getGccEnv gcc_args
-  runSomethingFiltered dflags id &quot;Windres&quot; windres
-        -- we must tell windres where to find gcc: it might not be on PATH
-        (Option (&quot;--preprocessor=&quot; ++
-                 unwords (map quote (gcc : map showOpt gcc_args ++
-                                     [&quot;-E&quot;, &quot;-xc&quot;, &quot;-DRC_INVOKED&quot;])))
-        -- -- use-temp-file is required for windres to interpret the
-        -- quoting in the preprocessor arg above correctly.  Without
-        -- this, windres calls the preprocessor with popen, which gets
-        -- the quoting wrong (discovered by experimentation and
-        -- reading the windres sources).  See #1828.
-        : Option &quot;--use-temp-file&quot;
-        : args)
-        -- we must use the PATH workaround here too, since windres invokes gcc
-        mb_env
-  where
-        quote x = '\&quot;' : x ++ &quot;\&quot;&quot;
+  runSomethingFiltered dflags id &quot;Windres&quot; windres args mb_env
 
 touch :: DynFlags -&gt; String -&gt; String -&gt; IO ()
 touch dflags purpose arg =
@@ -833,8 +748,8 @@ traceCmd dflags phase_name cmd_line action
 
 getBaseDir :: IO (Maybe String)
 #if defined(mingw32_HOST_OS)
--- Assuming we are running ghc, accessed by path  $()/bin/ghc.exe,
--- return the path $(stuff).  Note that we drop the &quot;bin/&quot; directory too.
+-- Assuming we are running ghc, accessed by path  $(stuff)/bin/ghc.exe,
+-- return the path $(stuff)/lib.
 getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32.
                 buf &lt;- mallocArray len
                 ret &lt;- getModuleFileName nullPtr buf len
@@ -844,13 +759,14 @@ getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32.
                                     return (Just (rootDir s))
   where
     rootDir s = case splitFileName $ normalise s of
-                (d, ghc_exe) | lower ghc_exe == &quot;ghc.exe&quot; -&gt;
+                (d, ghc_exe)
+                 | lower ghc_exe `elem` [&quot;ghc.exe&quot;,
+                                         &quot;ghc-stage1.exe&quot;,
+                                         &quot;ghc-stage2.exe&quot;,
+                                         &quot;ghc-stage3.exe&quot;] -&gt;
                     case splitFileName $ takeDirectory d of
-                    -- installed ghc.exe is in $topdir/bin/ghc.exe
-                    (d', bin) | lower bin == &quot;bin&quot; -&gt; takeDirectory d'
-                    -- inplace ghc.exe is in $topdir/ghc/stage1-inplace/ghc.exe
-                    (d', x) | &quot;-inplace&quot; `isSuffixOf` lower x -&gt; 
-                        takeDirectory d' &lt;/&gt; &quot;..&quot;
+                    -- ghc is in $topdir/bin/ghc.exe
+                    (d', bin) | lower bin == &quot;bin&quot; -&gt; takeDirectory d' &lt;/&gt; &quot;lib&quot;
                     _ -&gt; fail
                 _ -&gt; fail
         where fail = panic (&quot;can't decompose ghc.exe path: &quot; ++ show s)</diff>
      <filename>compiler/main/SysTools.lhs</filename>
    </modified>
    <modified>
      <diff>@@ -143,8 +143,14 @@ rnImportDecl this_mod (L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot
 
 	-- Issue a user warning for a redundant {- SOURCE -} import
 	-- NB that we arrange to read all the ordinary imports before 
-	-- any of the {- SOURCE -} imports
-    warnIf (want_boot &amp;&amp; not (mi_boot iface))
+	-- any of the {- SOURCE -} imports.
+        --
+        -- in --make and GHCi, the compilation manager checks for this,
+        -- and indeed we shouldn't do it here because the existence of
+        -- the non-boot module depends on the compilation order, which
+        -- is not deterministic.  The hs-boot test can show this up.
+    dflags &lt;- getDOpts
+    warnIf (want_boot &amp;&amp; not (mi_boot iface) &amp;&amp; isOneShot (ghcMode dflags))
 	   (warnRedundantSourceImport imp_mod_name)
 
     let</diff>
      <filename>compiler/rename/RnNames.lhs</filename>
    </modified>
    <modified>
      <diff>@@ -95,10 +95,18 @@ HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
 
 if test x&quot;$TargetPlatform&quot; != x&quot;$HostPlatform&quot; ; then
-    echo &quot;GHC configuration does not support differing host/target (i.e., cross-compiling)&quot;
-    exit 1
+    AC_MSG_ERROR([
+      GHC configuration does not support differing host/target (i.e., cross-compiling)])
 fi
 
+case $HostPlatform in
+*-cygwin*)
+    AC_MSG_WARN([GHC does not support the Cygwin target at the moment])
+    AC_MSG_WARN([I'm assuming you wanted to build for i386-unknown-mingw32])
+    HostPlatform=i386-unknown-mingw32  
+    ;;
+esac
+
 exeext=''
 soext='.so'
 #
@@ -645,12 +653,16 @@ AC_ARG_WITH([ghc],
   fi
   WithGhc=&quot;$GHC&quot;])
 # GHC is passed to Cabal, so we need a native path
-if test &quot;x$HostPlatform&quot;  = &quot;xi386-unknown-mingw32&quot; &amp;&amp; \
-   test &quot;${OSTYPE}&quot;      != &quot;msys&quot;                  &amp;&amp; \
-   test &quot;${WithGhc}&quot;     != &quot;&quot;
+if test &quot;${WithGhc}&quot; != &quot;&quot; &amp;&amp; test &quot;$HostPlatform&quot; = &quot;i386-unknown-mingw32&quot;
 then
-    # Canonicalise to &lt;drive&gt;:/path/to/ghc
-    WithGhc=`cygpath -m ${WithGhc}`
+    if test &quot;${OSTYPE}&quot; = &quot;msys&quot;
+    then
+        WithGhc=`echo &quot;${WithGhc}&quot; | sed &quot;s#^/\([a-zA-Z]\)/#\1:/#&quot;`
+    else
+        # Canonicalise to &lt;drive&gt;:/path/to/ghc
+        WithGhc=`cygpath -m ${WithGhc}`
+    fi
+    echo &quot;Canonicalised to: ${WithGhc}&quot;
 fi
 AC_SUBST([WithGhc])
 
@@ -663,8 +675,27 @@ AC_ARG_WITH(hc,
 )
 AC_SUBST(WithHc)
 
+AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
+[AC_HELP_STRING([--enable-bootstrap-with-devel-snapshot],
+                [Allow bootstrapping using a development snapshot of GHC.  This is not guaranteed to work.])],
+        EnableBootstrapWithDevelSnaphost=YES,
+        EnableBootstrapWithDevelSnaphost=NO
+)
+
 if test &quot;$WithGhc&quot; != &quot;&quot;; then
   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
+
+  if test `expr $GhcMinVersion % 2` = &quot;1&quot;; then
+     echo $EnableBootstrapWithDevelSnaphost
+     if test &quot;$EnableBootstrapWithDevelSnaphost&quot; = &quot;NO&quot;; then
+        AC_MSG_ERROR([
+     $WithGhc is a development snapshot of GHC, version $GhcVersion.
+     Bootstrapping using this version of GHC is not supported, and may not
+     work.  Use --enable-bootstrap-with-devel-snapshot to try it anyway,
+     or --with-ghc to specify a different GHC to use.])
+     fi
+  fi
+
   AC_SUBST(GhcVersion)dnl
   AC_SUBST(GhcMajVersion)dnl
   AC_SUBST(GhcMinVersion)dnl
@@ -971,6 +1002,10 @@ dnl ** check for tar
 dnl   if GNU tar is named gtar, look for it first.
 AC_PATH_PROGS(TarCmd,gtar tar,tar)
 
+dnl ** check for patch
+dnl if GNU patch is named gpatch, look for it first
+AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
+
 AC_PATH_PROG(HSCOLOUR,HsColour)
 # HsColour is passed to Cabal, so we need a native path
 if test &quot;x$HostPlatform&quot;  = &quot;xi386-unknown-mingw32&quot; &amp;&amp; \
@@ -989,15 +1024,6 @@ FP_PROG_FO_PROCESSOR
 dnl ** check for ghc-pkg command
 FP_PROG_GHC_PKG
 
-AC_ARG_WITH(greencard,
-[AC_HELP_STRING([--with-greencard=ARG],
-        [Use ARG as the path to greencard  [default=autodetct]])],
-[
-GreenCardCmd=$withval;
-FPTOOLS_GREENCARD(3.00)
-]
-)
-
 dnl ** check for installed happy binary + version
 dnl    (don't do it if we're booting from .hc files though.)
 if test &quot;$BootingFromHc&quot; = &quot;NO&quot;; then
@@ -1290,7 +1316,7 @@ else
 fi
 AC_SUBST(HavePapi)
 
-AC_CONFIG_FILES([mk/config.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml])
+AC_CONFIG_FILES([mk/config.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml])
 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp &gt; mk/stamp-h])
 AC_OUTPUT
 
@@ -1313,3 +1339,69 @@ checkMake380() {
 checkMake380 make
 checkMake380 gmake
 
+echo [&quot;
+----------------------------------------------------------------------
+Configure completed successfully.
+
+   Building GHC version  : $ProjectVersion
+
+   Build platform        : $BuildPlatform
+   Host platform         : $HostPlatform
+   Target platform       : $TargetPlatform
+&quot;]
+
+if test &quot;$BootingFromHc&quot; = &quot;YES&quot;; then
+echo [&quot;\
+   Bootstrapping from HC files.
+&quot;]
+else
+echo [&quot;\
+   Bootstrapping using   : $WithGhc
+      which is version   : $GhcVersion
+&quot;]
+fi
+
+echo [&quot;\
+   Using GCC             : $WhatGccIsCalled
+      which is version   : $GccVersion
+
+   ld       : $LdCmd
+   Happy    : $HappyCmd
+   Alex     : $AlexCmd
+   Python   : $PythonCmd
+   Perl     : $PerlCmd&quot;]
+
+if test &quot;$HSCOLOUR&quot; = &quot;&quot;; then
+echo [&quot;
+   HsColour was not found; documentation will not contain source links
+&quot;]
+else
+echo [&quot;\
+   HsColour : $HSCOLOUR
+&quot;]
+fi
+
+if test &quot;$DIR_DOCBOOK_XSL&quot; = &quot;&quot;; then
+echo [&quot;\
+   Building DocBook documentation : no&quot;]
+else
+echo [&quot;\
+   Building DocBook documentation : yes&quot;]
+fi
+
+
+echo [&quot;\
+   Building shared libraries      : $BuildSharedLibs&quot;]
+
+echo [&quot;----------------------------------------------------------------------
+&quot;]
+
+echo &quot;\
+For a standard build of GHC (fully optimised with profiling), type (g)make.
+
+To make changes to the default build configuration, copy the file
+mk/build.mk.sample to mk/build.mk, and edit the settings in there.
+
+For more information on how to configure your GHC build, see
+   http://hackage.haskell.org/trac/ghc/wiki/Building
+&quot;</diff>
      <filename>configure.ac</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ dnl
 #
 
 # Is it there?
-AC_INIT(Makefile-vars.in)
+AC_INIT(mk/config.mk.in)
 
 exeext=''
 
@@ -148,7 +148,7 @@ dnl ** Check gcc version and flags we need to pass it **
 FP_GCC_EXTRA_FLAGS
 
 #
-AC_CONFIG_FILES(Makefile-vars extra-gcc-opts)
+AC_CONFIG_FILES(extra-gcc-opts mk/config.mk)
 AC_OUTPUT
 
 echo &quot;****************************************************&quot;</diff>
      <filename>distrib/configure-bin.ac</filename>
    </modified>
    <modified>
      <diff>@@ -50,9 +50,6 @@ distclean: clean
 
 maintainer-clean: distclean
 
-ifeq &quot;$(LATEX_DOCS)&quot; &quot;YES&quot;
-BINDIST_EXTRAS += core.pdf
-endif
 include $(TOP)/mk/bindist.mk
 
 # dummy targets</diff>
      <filename>docs/ext-core/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -45,7 +45,6 @@ install-docs:: $(MAN_PAGE).$(MAN_SECTION)
 
 endif
 
-BINDIST_EXTRAS += $(MAN_PAGE).$(MAN_SECTION)
 include $(TOP)/mk/bindist.mk
 
 include $(TOP)/mk/target.mk</diff>
      <filename>docs/man/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,63 +1,3 @@
-#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.11 2005/05/05 00:58:38 sof Exp $
-#
-
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-# -----------------------------------------------------------------------------
-# ghci script
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-C_PROG = ghci$(exeext)
-C_PROG_VERSIONED = ghci-$(ProjectVersion)$(exeext)
-C_OBJS += ghci.res
-
-all :: $(C_PROG_VERSIONED)
-$(C_PROG_VERSIONED) : $(C_PROG)
-	cp $&lt; $@
-else
-C_SRCS=
-endif
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-INSTALL_PROGS    += $(C_PROG) $(C_PROG_VERSIONED)
-GHCII_SCRIPT=$(DESTDIR)$(bindir)/ghcii.sh
-GHCII_SCRIPT_VERSIONED = $(DESTDIR)$(bindir)/ghcii-$(ProjectVersion).sh
-install::
-	$(RM) -f $(GHCII_SCRIPT)
-	echo &quot;#!$(SHELL)&quot;                                  &gt;&gt; $(GHCII_SCRIPT)
-	echo 'exec &quot;$$0&quot;/../ghc --interactive $${1+&quot;$$@&quot;}' &gt;&gt; $(GHCII_SCRIPT)
-	chmod +x $(GHCII_SCRIPT)
-	cp $(GHCII_SCRIPT) $(GHCII_SCRIPT_VERSIONED)
-	chmod +x $(GHCII_SCRIPT_VERSIONED)
-else
-LINK = ghci
-LINK_TARGET = $(LINK)-$(ProjectVersion)
-INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
-install::
-	$(RM) -f $(INSTALLED_SCRIPT)
-	echo &quot;#!$(SHELL)&quot;                                   &gt;&gt; $(INSTALLED_SCRIPT)
-	echo 'exec $(bindir)/ghc-$(ProjectVersion) --interactive $${1+&quot;$$@&quot;}' &gt;&gt; $(INSTALLED_SCRIPT)
-	$(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
-endif
-
-ifneq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-INPLACE_SCRIPT = ghci
-INPLACE_GHC = $(FPTOOLS_TOP_ABS)/ghc/stage2-inplace/ghc
-CLEAN_FILES += $(INPLACE_SCRIPT)
-all::
-	$(RM) -f $(INPLACE_SCRIPT)
-	echo &quot;#!$(SHELL)&quot;                                    &gt;&gt; $(INPLACE_SCRIPT)
-	echo &quot;exec $(INPLACE_GHC) --interactive $${1+&quot;$$@&quot;}&quot; &gt;&gt; $(INPLACE_SCRIPT)
-	$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
-endif
-
-ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ghci.res : ghci.rc ghci.ico
-	windres --preprocessor=&quot;$(CPP) -xc -DRC_INVOKED&quot; -o ghci.res -i ghci.rc -O coff
-endif
-
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = driver/ghci
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>driver/ghci/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,26 +1,3 @@
-#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.3 2001/03/23 16:36:21 simonmar Exp $
-
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-PROG = ghc-asm
-all:: $(PROG).prl
-	$(RM) -f $(PROG)
-	echo '#!$(PERL)'                                &gt;&gt; $(PROG)
-	echo '$$TARGETPLATFORM  = &quot;$(TARGETPLATFORM)&quot;;' &gt;&gt; $(PROG)
-	cat $&lt;                                          &gt;&gt; $(PROG)
-	$(EXECUTABLE_FILE) $(PROG)
-
-INSTALL_LIBEXEC_SCRIPTS += $(PROG)
-CLEAN_FILES += $(PROG) $(PROG).prl
-
-# needed for bootstrapping with HC files
-ifeq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-boot :: all
-endif
-
-BINDIST_EXTRAS += $(PROG)
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = driver/mangler
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>driver/mangler/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,3 @@
-#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.2 2000/11/03 16:54:52 simonmar Exp $
-
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-PROG = ghc-split
-all:: $(PROG).prl
-	$(RM) -f $(PROG)
-	echo '#!$(PERL)'                                &gt;&gt; $(PROG)
-	echo '$$TARGETPLATFORM  = &quot;$(TARGETPLATFORM)&quot;;' &gt;&gt; $(PROG)
-	cat $&lt;                                          &gt;&gt; $(PROG)
-	$(EXECUTABLE_FILE) $(PROG)
-
-INSTALL_LIBEXEC_SCRIPTS += $(PROG)
-CLEAN_FILES += $(PROG) $(PROG).prl
-
-BINDIST_EXTRAS += $(PROG)
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = driver/split
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>driver/split/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+# WARNING: ghc.spec is automatically generated from ghc.spec.in by
+# ./configure.  Make sure you are editing ghc.spec.in, not ghc.spec.
+#
 # RPM spec file for GHC					         -*-rpm-spec-*-
 #
 # Copyright [1998..2007] The GHC Team</diff>
      <filename>ghc.spec.in</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,6 @@
 
 module Main (main) where
 
-#include &quot;HsVersions.h&quot;
-
 -- The official GHC API
 import qualified GHC
 import GHC		( DynFlags(..), HscTarget(..),</diff>
      <filename>ghc/Main.hs</filename>
    </modified>
    <modified>
      <diff>@@ -1,155 +1,16 @@
+dir = ghc
+TOP = ..
+SPEC_TARGETS = 1 2 3
+include $(TOP)/mk/sub-makefile.mk
 
-TOP=..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal-flags.mk
+.PHONY: 1 2 3
 
-ifeq &quot;$(stage)&quot; &quot;&quot;
-stage=1
-endif
+1:
+	+$(TOPMAKE) stage=1 all_ghc_stage1 compiler_stage1_NO_BUILD_DEPS=YES
 
-ifeq &quot;$(HOSTPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-INSTALL_FLAGS =
-else
-INSTALL_FLAGS = --enable-shell-wrappers
-endif
+2:
+	+$(TOPMAKE) stage=2 all_ghc_stage2 compiler_stage2_NO_BUILD_DEPS=YES
 
-# Don't strip the inplace versions, we might need to debug them
-INPLACE_INSTALL_FLAGS += --disable-executable-stripping
-
-boot:: boot.stage.$(stage)
-
-all:: build.stage.$(stage)
-
-rebuild ::
-	-$(CABAL) clean --distpref dist-stage$(stage)
-	$(RM) -rf stage$(stage)-inplace
-	$(MAKE) boot all
-
-stage1 ::
-	$(MAKE) stage=1
-
-stage2 ::
-	$(MAKE) stage=2
-
-stage3 ::
-	$(MAKE) stage=3
-
-
-ifeq &quot;$(CLEAN_ALL_STAGES)&quot; &quot;YES&quot;
-clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3
-else
-clean distclean maintainer-clean:: clean.stage.$(stage)
-endif
-
-ifeq &quot;$(CLEAN_ALL_STAGES)&quot; &quot;YES&quot;
-distclean maintainer-clean::
-	$(RM) -f ghc-bin.cabal
-endif
-
-clean.stage.%:
-	$(RM) -rf stage$*-inplace
-# This is a bit naughty. We ought to use:
-#	-$(CABAL) clean --distpref dist-stage$*
-# but that won't work if the Cabal file (a generated file) doesn't
-# exist. So we do this instead:
-	$(RM) -rf dist-stage$*
-
-CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
-
-ifeq &quot;$(GhcWithInterpreter)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2PLUS += --flags=ghci
-else
-CONFIGURE_FLAGS_STAGE2PLUS += --flags=-ghci
-endif
-
-ifeq &quot;$(GhcProfiled)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2PLUS += --enable-executable-profiling
-endif
-ifeq &quot;$(GhcDebugged)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-debug
-endif
-ifeq &quot;$(GhcThreaded)&quot; &quot;YES&quot;
-# Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
-CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-threaded
-endif
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-dynamic
-endif
-
-CONFIGURE_FLAGS_STAGE2 = $(CONFIGURE_FLAGS_STAGE2PLUS)
-CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2PLUS)
-
-CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF)
-
-CONFIGURE_FLAGS_STAGE1 += $(foreach flag, $(GhcStage1HcOpts), --ghc-option=$(flag))
-CONFIGURE_FLAGS_STAGE2 += $(foreach flag, $(GhcStage2HcOpts), --ghc-option=$(flag))
-CONFIGURE_FLAGS_STAGE3 += $(foreach flag, $(GhcStage3HcOpts), --ghc-option=$(flag))
-
-BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(SRC_HC_OPTS))
-# Allow EXTRA_HC_OPTS to be used from the command line to add options 
-# when building (e.g. -v)
-BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS))
-
-# XXX In stage2+ we should really use the inplace ghc-pkg
-# It works because installPackage doesn't actually use ghc-pkg, as there's
-# no library to register
-
-ifeq &quot;$(stage)&quot; &quot;1&quot;
-ifeq &quot;$(ghc_ge_609)&quot; &quot;NO&quot;
-# GHC 6.9+ can handle cross-package recompilation checking, but
-# we don't rely on the bootstrapping compiler being able to do this.
-TOUCH_MAIN = $(RM) dist-stage1/build/ghc/ghc-tmp/Main.o
-endif
-endif
-
-dist-stage1 dist-stage2 dist-stage3: dist-stage%: boot.stage.%
-
-boot.stage.%:
-	$(CABAL) configure --distpref dist-stage$*         \
-	                   $(INSTALL_DIRS_CONFIGURE_FLAGS) \
-	                   $(CONFIGURE_FLAGS_STAGE$*)      \
-	                   $(COMMON_CONFIGURE_FLAGS)       \
-	                   --libsubdir=.                   \
-	                   --datadir='$$libdir'            \
-	                   --datasubdir=.
-
-build.stage.%: dist-stage%
-	$(TOUCH_MAIN)
-	$(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
-	$(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' &quot;&quot; \
-	                   $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
-	                   $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
-	                   '$$prefix'                                      \
-	                   '$(INPLACE_DATA_DIR)'                           \
-	                   '$$prefix/libexec'                              \
-	                   '$$prefix/dynlib'                               \
-	                   '$(INPLACE_DATA_DIR)'                           \
-	                   '$$prefix/doc'                                  \
-	                   '$$prefix/html'                                 \
-	                   '$$prefix/haddock'                              \
-	                   --distpref dist-stage$*                         \
-	                   $(INPLACE_INSTALL_FLAGS)                        \
-	                   $(INSTALL_FLAGS)
-
-# XXX For now we always install the stage 2 compiler
-install:
-	$(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
-	                   '$(prefix)' '$(bindir)' '$(libdir)'            \
-                       '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
-                       '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
-	                   --distpref dist-stage2                         \
-	                   $(INSTALL_FLAGS)
-
-html:
-	@:
-
-install-docs:
-	@:
-
-include $(TOP)/mk/bindist.mk
-EXE_DIST_DIR = dist-stage2
+3:
+	+$(TOPMAKE) stage=3 all_ghc_stage3 compiler_stage3_NO_BUILD_DEPS=YES
 </diff>
      <filename>ghc/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+-- WARNING: ghc-bin.cabal is automatically generated from ghc-bin.cabal.in by
+-- ./configure.  Make sure you are editing ghc-bin.cabal.in, not ghc-bin.cabal.
+
 Name: ghc-bin
 Version: @ProjectVersion@
 Copyright: XXX</diff>
      <filename>ghc/ghc-bin.cabal.in</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1 @@
-#!/bin/sh
-
 exec $executablename -B$datadir -dynload wrapped ${1+&quot;$@&quot;}</diff>
      <filename>ghc/ghc.wrapper</filename>
    </modified>
    <modified>
      <diff>@@ -1,202 +1,3 @@
-# -----------------------------------------------------------------------------
-
-TOP = ..
-include $(TOP)/mk/boilerplate.mk
-
-#
-# Header files built from the configure script's findings
-#
-H_CONFIG   = ghcautoconf.h
-H_PLATFORM = ghcplatform.h
-
-#
-# All header files
-#
-H_FILES = $(filter-out $(H_CONFIG) $(H_PLATFORM),$(wildcard *.h))
-
-ifneq &quot;$(DOING_BIN_DIST)&quot; &quot;YES&quot;
-
-#
-# Options
-#
-ifeq &quot;$(GhcUnregisterised)&quot; &quot;YES&quot;
-SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
-endif
-
-ifeq &quot;$(GhcEnableTablesNextToCode) $(GhcUnregisterised)&quot; &quot;YES NO&quot;
-SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
-endif
-
-SRC_CC_OPTS += -I. -I../rts -I../rts/parallel
-ifeq &quot;$(HaveLibGmp)&quot; &quot;YES&quot;
-ifneq &quot;$(GMP_INCLUDE_DIRS)&quot; &quot;&quot;
-SRC_CC_OPTS += -I$(GMP_INCLUDE_DIRS)
-endif
-else
-SRC_CC_OPTS += -I../gmp/gmpbuild
-endif
-
-ifneq &quot;$(GhcWithSMP)&quot; &quot;YES&quot;
-SRC_CC_OPTS += -DNOSMP
-endif
-
-all :: $(H_CONFIG) $(H_PLATFORM)
-
-# The fptools configure script creates the configuration header file and puts it
-# in fptools/mk/config.h. We copy it down to here (without any PACKAGE_FOO
-# definitions to avoid clashes), prepending some make variables specifying cpp
-# platform variables.
-
-ifneq &quot;$(TARGETPLATFORM)&quot;  &quot;$(HOSTPLATFORM)&quot;
-
-$(H_CONFIG) :
-	@echo &quot;*** Cross-compiling: please copy $(H_CONFIG) from the target system&quot;
-	@exit 1
-
-else
-
-$(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk
-
-$(H_CONFIG) : Makefile
-	@echo &quot;Creating $@...&quot;
-	@echo &quot;#ifndef __GHCAUTOCONF_H__&quot;  &gt;$@
-	@echo &quot;#define __GHCAUTOCONF_H__&quot; &gt;&gt;$@
-#	Turn '#define PACKAGE_FOO &quot;blah&quot;' into '/* #undef PACKAGE_FOO */'.
-	@sed 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*&quot;.*&quot;.*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h &gt;&gt; $@
-	@echo &quot;#endif /* __GHCAUTOCONF_H__ */&quot;          &gt;&gt; $@
-	@echo &quot;Done.&quot;
-
-endif
-
-$(H_PLATFORM) : Makefile
-	@echo &quot;Creating $@...&quot;
-	@$(RM) $@
-	@echo &quot;#ifndef __GHCPLATFORM_H__&quot;  &gt;$@
-	@echo &quot;#define __GHCPLATFORM_H__&quot; &gt;&gt;$@
-	@echo &gt;&gt; $@
-	@echo &quot;#define BuildPlatform_TYPE  $(HostPlatform_CPP)&quot; &gt;&gt; $@
-	@echo &quot;#define HostPlatform_TYPE   $(TargetPlatform_CPP)&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostPlatform_CPP)_BUILD  1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetPlatform_CPP)_HOST  1&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostArch_CPP)_BUILD_ARCH  1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetArch_CPP)_HOST_ARCH  1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_ARCH  \&quot;$(HostArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_ARCH  \&quot;$(TargetArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostOS_CPP)_BUILD_OS  1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetOS_CPP)_HOST_OS  1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_OS  \&quot;$(HostOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_OS  \&quot;$(TargetOS_CPP)\&quot;&quot; &gt;&gt; $@
-ifeq &quot;$(HostOS_CPP)&quot; &quot;irix&quot;
-	@echo &quot;#ifndef $(IRIX_MAJOR)_HOST_OS&quot; &gt;&gt; $@  
-	@echo &quot;#define $(IRIX_MAJOR)_HOST_OS  1&quot; &gt;&gt; $@  
-	@echo &quot;#endif&quot; &gt;&gt; $@  
-endif
-	@echo &gt;&gt; $@
-	@echo &quot;#define $(HostVendor_CPP)_BUILD_VENDOR  1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetVendor_CPP)_HOST_VENDOR  1&quot; &gt;&gt; $@
-	@echo &quot;#define BUILD_VENDOR  \&quot;$(HostVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define HOST_VENDOR  \&quot;$(TargetVendor_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;/* These TARGET macros are for backwards compatibily... DO NOT USE! */&quot; &gt;&gt; $@
-	@echo &quot;#define TargetPlatform_TYPE $(TargetPlatform_CPP)&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetPlatform_CPP)_TARGET  1&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetArch_CPP)_TARGET_ARCH  1&quot; &gt;&gt; $@
-	@echo &quot;#define TARGET_ARCH  \&quot;$(TargetArch_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetOS_CPP)_TARGET_OS  1&quot; &gt;&gt; $@  
-	@echo &quot;#define TARGET_OS  \&quot;$(TargetOS_CPP)\&quot;&quot; &gt;&gt; $@
-	@echo &quot;#define $(TargetVendor_CPP)_TARGET_VENDOR  1&quot; &gt;&gt; $@
-	@echo &gt;&gt; $@
-	@echo &quot;#endif /* __GHCPLATFORM_H__ */&quot;          &gt;&gt; $@
-	@echo &quot;Done.&quot;
-
-# ---------------------------------------------------------------------------
-# Make DerivedConstants.h for the compiler
-
-all :: DerivedConstants.h
-
-ifneq &quot;$(TARGETPLATFORM)&quot; &quot;$(HOSTPLATFORM)&quot;
-
-DerivedConstants.h :
-	@echo &quot;*** Cross-compiling: please copy DerivedConstants.h from the target system&quot;
-	@exit 1
-
-else
-
-mkDerivedConstants.c : $(H_CONFIG) $(H_PLATFORM)
-
-mkDerivedConstantsHdr : mkDerivedConstants.o
-	$(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
-
-DerivedConstants.h : mkDerivedConstantsHdr
-	./mkDerivedConstantsHdr &gt;$@
-
-endif
-
-CLEAN_FILES += mkDerivedConstantsHdr$(exeext) DerivedConstants.h
-
-# -----------------------------------------------------------------------------
-#
-
-all :: GHCConstants.h
-
-ifneq &quot;$(TARGETPLATFORM)&quot; &quot;$(HOSTPLATFORM)&quot;
-
-GHCConstants.h :
-	@echo &quot;*** Cross-compiling: please copy DerivedConstants.h from the target system&quot;
-	@exit 1
-
-else
-
-mkGHCConstants : mkGHCConstants.o
-	$(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkGHCConstants.o
-
-mkGHCConstants.o : mkDerivedConstants.c
-	$(CC) -o $@ $(CC_OPTS) -c $&lt;  -DGEN_HASKELL
-
-GHCConstants.h : mkGHCConstants
-	./mkGHCConstants &gt;$@
-
-endif
-
-CLEAN_FILES += mkGHCConstants$(exeext) GHCConstants.h
-
-endif
-
-# ---------------------------------------------------------------------------
-# boot setup:
-#
-#
-# Install all header files
-#
-# Note: we keep per-platform copies of all the include files
-# (ditto for interface files). This is not *really* needed, but
-# it gives (perhaps) a cleaner binary dist structure..might change.
-#
-INSTALL_HEADERS += $(H_FILES) $(H_CONFIG) $(H_PLATFORM)
-
-BINDIST_EXTRAS += $(INSTALL_HEADERS)
-include $(TOP)/mk/bindist.mk
-
-#
-# `make clean' settings:
-#
-CLEAN_FILES += $(H_CONFIG) $(H_PLATFORM)
-
-#
-# Finally, slurp in the standard targets.
-#
-include $(TOP)/mk/target.mk
-
-# We need DerivedConstants.h in order to make dependencies in the RTS
-# sources, so 'make boot' here should behave like 'make all'.
-#
-# However, note that we should do this only *after* 'make boot' has
-# created .depend in here; otherwise an out-of-date .depend file can
-# prevent 'make boot' from working, requiring manual removal of
-# .depend (see #1095).  This is why the following target comes *after*
-# target.mk is included above (target.mk contains &quot;boot :: depend&quot;).
-#
-boot :: all
+dir = includes
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>includes/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -397,7 +397,7 @@ GLOBAL_REG_DECL(bdescr *,HpAlloc,REG_HpAlloc)
    -------------------------------------------------------------------------- */
 
 
-#define FunReg ((StgFunTable *)((void *)BaseReg - FIELD_OFFSET(struct PartCapability_, r)))
+#define FunReg ((StgFunTable *)((void *)BaseReg - STG_FIELD_OFFSET(struct PartCapability_, r)))
 
 #define stg_EAGER_BLACKHOLE_info  (FunReg-&gt;stgEagerBlackholeInfo)
 #define stg_gc_enter_1            (FunReg-&gt;stgGCEnter1)</diff>
      <filename>includes/Regs.h</filename>
    </modified>
    <modified>
      <diff>@@ -76,7 +76,7 @@
 
 /* Compute offsets of struct fields
  */
-#define FIELD_OFFSET(s_type, field) ((StgWord)&amp;(((s_type*)0)-&gt;field))
+#define STG_FIELD_OFFSET(s_type, field) ((StgWord)&amp;(((s_type*)0)-&gt;field))
 
 /*
  * 'Portable' inlining:</diff>
      <filename>includes/Stg.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,199 +1,3 @@
-
-TOP=..
-DONT_WANT_STD_GHCI_LIB_RULE=YES
-DONT_WANT_STD_LIBRARY=YES
-
-include $(TOP)/mk/boilerplate.mk
-# Override haddock generation for this package
-HADDOCK_DOCS=NO
-
-# We package libffi as Haskell package for two reasons: 
-
-# 1) GHC uses different names for shared and static libs, so it can
-#    choose the lib variant to link with on its own. With regular
-#    libtool styled shared lib names, the linker would interfer and
-#    link against the shared lib variant even when GHC runs in -static
-#    mode.
-# 2) The first issue isn't a problem when a shared lib of libffi would
-#    be installed in system locations, but we do not assume that. So,
-#    when running in -dynamic mode, we must either install libffi to
-#    system locations ourselves, or we must add its location to
-#    respective environment variable, (DY)LD_LIBRARY_PATH etc...before
-#    we call dynamically linked binaries. Especially, the latter is
-#    necessary as GHC calls binary it produced before its installation
-#    phase. However, both mechanism, installing to system locations or
-#    modifying (DY)LD_LIBRARY_PATH, are already in place for Haskell
-#    packages so with packaging libffi as Haskell package we reuse
-#    them naturally.
-
-PACKAGE=ffi
-# -----------------------------------------------------------------------------
-#
-# We use libffi's own configuration stuff.
-
-PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
-
-# 2007-09-26
-#     set -o igncr 
-# is not a valid command on non-Cygwin-systems.
-# Let it fail silently instead of aborting the build.
-#
-# 2007-07-05
-# We do
-#     set -o igncr; export SHELLOPTS
-# here as otherwise checking the size of limbs
-# makes the build fall over on Cygwin. See the thread
-# http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
-# for more details.
-
-# 2007-07-05
-# Passing
-#     as_ln_s='cp -p'
-# isn't sufficient to stop cygwin using symlinks the mingw gcc can't
-# follow, as it isn't used consistently. Instead we put an ln.bat in
-# path that always fails.
-
-LIBFFI_TARBALL := $(firstword $(wildcard libffi*.tar.gz))
-LIBFFI_DIR := $(subst .tar.gz,,$(LIBFFI_TARBALL))
-
-BINDIST_STAMPS = stamp.ffi.build stamp.ffi.configure
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-STAMP_BUILD = stamp.ffi.build-shared
-STAMP_CONFIGURE = stamp.ffi.configure-shared
-else
-STAMP_BUILD = stamp.ffi.build
-STAMP_CONFIGURE = stamp.ffi.configure
-endif
-
-INSTALL_HEADERS += ffi.h
-STATIC_LIB = libffi.a
-INSTALL_LIBS += libHSffi.a libHSffi_p.a HSffi.o
-
-# We have to add the GHC version to the name of our dynamic libs, because
-# they will be residing in the system location along with dynamic libs from
-# other GHC installations.
-
-HS_DYN_LIB_NAME=libHSffi-ghc$(ProjectVersion)$(soext)
-
-ifeq &quot;$(Windows)&quot; &quot;YES&quot;
-DYNAMIC_PROG = $(HS_DYN_LIB_NAME).a
-DYNAMIC_LIBS = $(HS_DYN_LIB_NAME)
-else
-DYNAMIC_PROG =
-DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.7
-endif
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-EnableShared=yes
-else
-EnableShared=no
-endif
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-INSTALL_LIBS  += $(HS_DYN_LIB_NAME)
-ifeq &quot;$(Windows)&quot; &quot;YES&quot;
-INSTALL_PROGS += $(HS_DYN_LIB_NAME).a
-endif
-endif
-
-install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
-
-# We have to fake a non-working ln for configure, so that the fallback
-# option (cp -p) gets used instead.  Otherwise the libffi build system
-# will use cygwin symbolic linkks which cannot be read by mingw gcc.
-# The same trick is played by the GMP build in ../gmp.
-
-$(STAMP_CONFIGURE):
-	$(RM) -rf $(LIBFFI_DIR) build
-	$(TAR) -zxf $(LIBFFI_TARBALL)
-	mv $(LIBFFI_DIR) build
-	chmod +x ln
-	patch -p0 &lt; libffi-dllize-3.0.6.patch
-
-	# This patch is just the resulting delta from running automake, autoreconf, libtoolize --force --copy
-	patch -p0 &lt; libffi-autotools-update.patch
-
-	(set -o igncr 2&gt;/dev/null) &amp;&amp; set -o igncr; export SHELLOPTS; \
-	    PATH=`pwd`:$$PATH; \
-	    export PATH; \
-	    cd build &amp;&amp; \
-	    CC=$(WhatGccIsCalled) $(SHELL) configure \
-		  --enable-static=yes \
-	          --enable-shared=$(EnableShared) \
-		  --host=$(PLATFORM) --build=$(PLATFORM)
-
-	# libffi.so needs to be built with the correct soname.
-	# NOTE: this builds libffi_convience.so with the incorrect
-	# soname, but we don't need that anyway!
-	$(CP) build/libtool build/libtool.orig
-	sed -e s/soname_spec=.*/soname_spec=&quot;$(HS_DYN_LIB_NAME)&quot;/ build/libtool.orig &gt; build/libtool
-
-	# We don't want libtool's cygwin hacks
-	$(CP) build/libtool build/libtool.orig
-	sed -e s/dlname=\'\$$tdlname\'/dlname=\'\$$dlname\'/ build/libtool.orig &gt; build/libtool
-
-	touch $@
-
-ffi.h: $(STAMP_CONFIGURE)
-	$(CP) build/include/ffi.h .
-
-$(STAMP_BUILD): $(STAMP_CONFIGURE)
-	$(MAKE) -C build MAKEFLAGS=
-	(cd build; ./libtool --mode=install cp libffi.la $(FPTOOLS_TOP_ABS)/libffi)
-	$(CP) $(STATIC_LIB) libHSffi.a
-	$(CP) $(STATIC_LIB) libHSffi_p.a
-	touch $@
-
-libHSffi.a libHSffi_p.a: $(STAMP_BUILD)
-
-all :: libHSffi.a libHSffi_p.a
-
-# The GHCi import lib isn't needed as compiler/ghci/Linker.lhs + rts/Linker.c
-# link the interpreted references to FFI to the compiled FFI.
-# Instead of adding libffi to the list preloaded packages (see
-# compiler/ghci/Linker.lhs:emptyPLS) we generate an empty HSffi.o
-
-HSffi.o: libHSffi.a
-	touch empty.c
-	$(CC) -c empty.c -o HSffi.o
-
-all :: HSffi.o
-
-ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
-ifeq &quot;$(Windows)&quot; &quot;YES&quot;
-# Windows libtool creates &lt;soname&gt;.dll, and as we already patched that
-# there is no need to copy from libffi.dll to libHSffi...dll.
-# However, the renaming is still required for the import library
-# libffi.dll.a.
-$(HS_DYN_LIB_NAME).a: $(STAMP_BUILD)
-	$(CP) libffi.dll.a $(HS_DYN_LIB_NAME).a
-all :: $(HS_DYN_LIB_NAME).a
-
-else
-# Rename libffi.so to libHSffi...so
-$(HS_DYN_LIB_NAME): $(DYNAMIC_LIBS)
-	$(CP) $(word 1,$(DYNAMIC_LIBS)) $(HS_DYN_LIB_NAME)
-
-all :: $(HS_DYN_LIB_NAME)
-endif
-endif
-
-clean distclean maintainer-clean ::
-	$(RM) -f stamp.ffi.* ffi.h empty.c
-	$(RM) -f libffi.a libffi.la $(DYNAMIC_PROG) $(DYNAMIC_LIBS) $(HS_DYN_LIB_NAME) $(HS_DYN_LIB_NAME).a
-	$(RM) -rf build
-
-#-----------------------------------------------------------------------------
-#
-# binary-dist
-
-include $(TOP)/mk/target.mk
-
-BINDIST_EXTRAS += package.conf.in
-BINDIST_EXTRAS += $(BINDIST_STAMPS)
-BINDIST_EXTRAS += $(INSTALL_PROGS)
-BINDIST_EXTRAS += $(INSTALL_LIBS)
-BINDIST_EXTRAS += $(INSTALL_HEADERS)
-include $(TOP)/mk/bindist.mk
-
+dir = libffi
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>libffi/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-name:		PACKAGE
+name:		ffi
 version:	1.0
 license:	BSD3
 maintainer:	glasgow-haskell-users@haskell.org
@@ -11,7 +11,7 @@ import-dirs:
 #ifdef INSTALLING
 library-dirs:		LIB_DIR
 #else /* !INSTALLING */
-library-dirs:		FPTOOLS_TOP_ABS&quot;/libffi&quot;
+library-dirs:		TOP&quot;/libffi&quot;
 #endif
 
 hs-libraries:   &quot;HSffi&quot;
@@ -19,7 +19,7 @@ hs-libraries:   &quot;HSffi&quot;
 #ifdef INSTALLING
 include-dirs:		INCLUDE_DIR
 #else /* !INSTALLING */
-include-dirs:		FPTOOLS_TOP_ABS&quot;/libffi/build/include&quot;
+include-dirs:		TOP&quot;/libffi/build/include&quot;
 #endif
 
 depends:</diff>
      <filename>libffi/package.conf.in</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,8 @@
 # Which warnings we like to use
 MyWarningOpts   = -W -fno-warn-unused-matches -fwarn-unused-imports
 
+GhcLibWays = v
+
 # -------- 1. A Performance/Distribution build--------------------------------
 
 ifeq &quot;$(BuildFlavour)&quot; &quot;perf&quot;
@@ -36,7 +38,7 @@ GhcStage1HcOpts = -O -fasm
 GhcStage2HcOpts = -O2 -fasm
 GhcHcOpts       = -Rghc-timing
 GhcLibHcOpts    = -O2 -XGenerics
-GhcLibWays      = p
+GhcLibWays     += p
 
 endif
 
@@ -48,7 +50,6 @@ SRC_HC_OPTS     = -H64m -O0 -fasm
 GhcStage1HcOpts = -O -fasm
 GhcStage2HcOpts = -O0 -fasm
 GhcLibHcOpts    = -O0 -fasm
-GhcLibWays      =
 SplitObjs       = NO
 
 endif
@@ -61,7 +62,6 @@ SRC_HC_OPTS     = -H64m -O0 -fasm
 GhcStage1HcOpts = -O -fasm
 GhcStage2HcOpts = -O0 -fasm
 GhcLibHcOpts    = -O -fasm
-GhcLibWays      =
 SplitObjs       = NO
 
 endif
@@ -72,7 +72,6 @@ ifeq &quot;$(BuildFlavour)&quot; &quot;devel1&quot;
 
 SRC_HC_OPTS     = -H64m -O -fasm $(MyWarningOpts)
 GhcLibHcOpts    = -O -dcore-lint $(MyWarningOpts)
-GhcLibWays      =
 GhcStage1HcOpts = -Rghc-timing -O0 -DDEBUG
 GhcStage2HcOpts = -Rghc-timing -O -fasm
 SplitObjs = NO
@@ -85,7 +84,6 @@ ifeq &quot;$(BuildFlavour)&quot; &quot;devel2&quot;
 
 SRC_HC_OPTS     = -H64m -O -fasm $(MyWarningOpts)
 GhcLibHcOpts    = -O -dcore-lint $(MyWarningOpts)
-GhcLibWays      =
 GhcStage1HcOpts = -Rghc-timing -O -fasm
 GhcStage2HcOpts = -Rghc-timing -O0 -DDEBUG
 SplitObjs = NO</diff>
      <filename>mk/build.mk.sample</filename>
    </modified>
    <modified>
      <diff>@@ -32,123 +32,11 @@ $(error GNU make version 3.79.1 or later is required.)
 endif
 endif
 
-################################################################################
-#
-# GHC Version
-#
-
-# ProjectVersion    is treated as a *string*
-# ProjectVersionInt is treated as an *integer* (for cpp defines)
-
-# Versioning scheme: A.B.C
-#         A: major version, decimal, any number of digits
-#         B: minor version, decimal, any number of digits
-#	  C: patchlevel, one digit, omitted if zero.
-#
-# ProjectVersionInt does *not* contain the patchlevel (rationale: this
-# figure is used for conditional compilations, and library interfaces
-# etc. are not supposed to change between patchlevels).
-#
-# The ProjectVersionInt is included in interface files, and GHC
-# checks that it's reading interface generated by the same ProjectVersion
-# as itself. It does this even though interface file syntax may not 
-# change between versions.  Rationale: calling conventions or other 
-# random .o-file stuff might change even if the .hi syntax doesn't
-
-ProjectName       = @ProjectName@
-ProjectTags       =
-ProjectVersion    = @ProjectVersion@$(ProjectTags)
-ProjectVersionInt = @ProjectVersionInt@
-ProjectPatchLevel = @ProjectPatchLevel@
-
-################################################################################
-#
-#		Platform variables
-#
-################################################################################
+# TOP: the top of the fptools hierarchy, absolute path.
+# On Windows this is a c:/foo/bar style path.
+TOP		= @hardtop@
 
-# A &quot;platform&quot; is the GNU cpu-type/manufacturer/operating-system target machine
-# specifier.  E.g. sparc-sun-solaris2
-#
-# Build  platform: the platform on which we are doing this build
-# Host   platform: the platform on which these binaries will run
-# Target platform: the platform for which this compiler will generate code
-#
-# We don't support build &amp; host being different, because the build
-# process creates binaries that are run during the build, and also
-# installed.
-#
-# If host &amp; target are different, then we are building a compiler
-# which will generate intermediate .hc files to port to the target
-# architecture for bootstrapping.  The libraries and stage 2 compiler
-# will be built as HC files for the target system, and likely won't
-# build on this host platform.
-#
-# An important invariant is that for any piece of source code, the
-# platform on which the code is going to run is the HOST platform,
-# and the platform on which we are building is the BUILD platform.
-# Additionally for the compiler, the platform this compiler will
-# generate code for is the TARGET.  TARGET is not meaningful outside
-# the compiler sources.
-#
-# Guidelines for when to use HOST vs. TARGET:
-#
-#  - In the build system (Makefile, foo.mk), normally we should test
-#    $(HOSTPLATFORM).  There are some cases (eg. installation), where
-#    we expect $(HOSTPLATFORM)==$(TARGETPLATFORM), so in those cases it
-#    doesn't matter which is used.
-#
-#  - In the compiler itself, we should test HOST or TARGET depending
-#    on whether the conditional relates to the code being generated, or
-#    the platform on which the compiler is running.  See the section
-#    on &quot;Coding Style&quot; in the commentary for more details.
-#
-#  - In all other code, we should be testing HOST only.
-#
-# NOTE: cross-compiling is not well supported by the build system.
-# You have to do a lot of work by hand to cross compile: see the
-# section on &quot;Porting GHC&quot; in the Building Guide.
-
-HOSTPLATFORM			= @HostPlatform@
-TARGETPLATFORM			= @TargetPlatform@
-BUILDPLATFORM			= @BuildPlatform@
-
-# Hack alert:
-# in one or two places, we need to get at the OS version (major and
-# perhaps even minor), HostOS_Full is the OS name reported by
-# AC_CANONICAL_SYSTEM.
-#
-HostPlatform_CPP		= @HostPlatform_CPP@
-HostArch_CPP			= @HostArch_CPP@
-HostOS_CPP			= @HostOS_CPP@
-HostOS_Full			= @HostOS_Full@
-HostVendor_CPP	                = @HostVendor_CPP@
-
-TargetPlatform_CPP		= @TargetPlatform_CPP@
-TargetArch_CPP			= @TargetArch_CPP@
-TargetOS_CPP			= @TargetOS_CPP@
-TargetVendor_CPP                = @TargetVendor_CPP@
-
-BuildPlatform_CPP		= @BuildPlatform_CPP@
-BuildArch_CPP			= @BuildArch_CPP@
-BuildOS_CPP			= @BuildOS_CPP@
-BuildVendor_CPP                 = @BuildVendor_CPP@
-
-@HostPlatform_CPP@_HOST           = 1
-@TargetPlatform_CPP@_TARGET       = 1
-@BuildPlatform_CPP@_BUILD         = 1
-
-@HostArch_CPP@_HOST_ARCH          = 1
-@TargetArch_CPP@_TARGET_ARCH      = 1
-@BuildArch_CPP@_BUILD_ARCH        = 1
-
-@HostOS_CPP@_HOST_OS              = 1
-@TargetOS_CPP@_TARGET_OS          = 1
-@BuildOS_CPP@_BUILD_OS            = 1
-
-@HostVendor_CPP@_HOST_VENDOR      = 1
-@TargetVendor_CPP@_TARGET_VENDOR  = 1
-@BuildVendor_CPP@_BUILD_VENDOR    = 1
+include $(TOP)/mk/project.mk
 
 ################################################################################
 #
@@ -156,22 +44,6 @@ BuildVendor_CPP                 = @BuildVendor_CPP@
 #
 ################################################################################
 
-# Leading underscores on symbol names in object files
-# Valid options: YES/NO
-#
-LeadingUnderscore=@LeadingUnderscore@
-
-# Pin a suffix on executables? If so, what (Windows only).
-exeext=@exeext@
-soext=@soext@
-
-# Windows=YES if on a Windows platform
-ifneq &quot;$(findstring $(HostOS_CPP), mingw32 cygwin32)&quot; &quot;&quot;
-Windows=YES
-else
-Windows=NO
-endif
-
 # BootingFromHc - build GHC and the libraries from .hc files?
 BootingFromHc = @BootingFromHc@
 
@@ -360,14 +232,13 @@ HscIfaceFileVersion=6
 # Which directory (in libraries/) contains the integer library?
 INTEGER_LIBRARY=integer-gmp
 
-# What extra ways to build the libraries in
+# We build the libraries at least the &quot;vanilla&quot; way (way &quot;v&quot;)
+GhcLibWays = v
+
 # In addition to the normal sequential way, the default is to also build
-# profiled prelude libraries.
-# When booting from .hc files, turn this off.
-ifeq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-GhcLibWays=
-else
-GhcLibWays=p
+# profiled prelude libraries unless we are booting from .hc files
+ifneq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
+GhcLibWays += p
 endif
 
 ifeq &quot;$(BuildSharedLibs)&quot; &quot;YES&quot;
@@ -422,7 +293,7 @@ GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
 #		but we switch it on for the libraries so that we generate
 #		the code in case someone importing wants it
 
-GhcLibHcOpts=-O2 -Rghc-timing -XGenerics
+GhcLibHcOpts=-O2 -XGenerics
 
 # Win32 only: Enable the RTS and libraries to be built as DLLs
 DLLized=@EnableWin32DLLs@
@@ -543,19 +414,15 @@ ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
 DEFAULT_TMPDIR		= /C/TEMP
 endif
 
-# FPTOOLS_TOP_ABS: the top of the fptools hierarchy, absolute path.
-# On Windows this is a c:/foo/bar style path.
-FPTOOLS_TOP_ABS		= @hardtop@
-
-BIN_DIST_TOPDIR_ABS=$(FPTOOLS_TOP_ABS)
+BIN_DIST_TOPDIR_ABS=$(TOP)
 BIN_DIST_DIR=$(BIN_DIST_TOPDIR_ABS)/$(BIN_DIST_NAME)
 
 BIN_DIST_NAME=ghc-$(ProjectVersion)
-BIN_DIST_TAR=$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
+BIN_DIST_TAR=$(TOP)/$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
 BIN_DIST_TAR_BZ2=$(BIN_DIST_TAR).bz2
-BIN_DIST_PREP_DIR=$(FPTOOLS_TOP_ABS)/bindist-prep
+BIN_DIST_PREP_DIR=$(TOP)/bindist-prep
 BIN_DIST_PREP=$(BIN_DIST_PREP_DIR)/$(BIN_DIST_NAME)
-BIN_DIST_LIST=$(FPTOOLS_TOP_ABS)/bindist-list
+BIN_DIST_LIST=$(TOP)/bindist-list
 
 # Definition of installation directories, we don't use half of these, but since
 # the configure script has them on offer while passing through, we might as well
@@ -609,8 +476,8 @@ ifeq &quot;$(RelocatableBuild)&quot; &quot;YES&quot;
 # Hack: our directory layouts tend to be different on Windows, so
 # hack around configure's bogus assumptions here.
 datarootdir := $(prefix)
-datadir     := $(prefix)
-libdir      := $(prefix)
+datadir     := $(prefix)/lib
+libdir      := $(prefix)/lib
 
 docdir    := $(prefix)/doc
 htmldir   := $(docdir)
@@ -660,8 +527,6 @@ ifacedir		= $(libdir)
 #     (NOTE: configure script setting is ignored).
 libexecdir		= $(libdir)
 
-GHC_PKG_PROG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/install-inplace/bin/ghc-pkg
-
 #-----------------------------------------------------------------------------
 # install configuration
 
@@ -718,10 +583,6 @@ SRC_HC_OPTS += -H32m -O
 # These flags make flex 8-bit
 SRC_FLEX_OPTS	+= -8
 
-# lint gets all CPP's flags too
-SRC_LINT_OPTS		+= -axz -DLINT $(SRC_CPP_OPTS)
-WAY$(_way)_LINT_OPTS	+= WAY$(_way)_CPP_OPTS
-
 # Default fptools options for dllwrap.
 SRC_BLD_DLL_OPTS += --target=i386-mingw32
 
@@ -736,120 +597,62 @@ GC_CPP_OPTS += -P -E -x c -traditional -D__GLASGOW_HASKELL__
 ################################################################################
 
 # Here we provide defines for the various directories in the source tree,
-# so we can move things around more easily.  A define $(GHC_FOO_DIR_REL)
-# indicates a directory relative to the top of the source tree, whereas
-# $(GHC_FOO_DIR) is a directory relative to the current directory.
-# $(GHC_FOO_DIR_ABS) is the absolute path to the directory.
-
-GHC_UTILS_DIR_REL	= utils
-GHC_INCLUDE_DIR_REL	= includes
-GHC_COMPILER_DIR_REL = ghc
-GHC_RTS_DIR_REL	   	= rts
-GHC_UTILS_DIR_REL 	= utils
-GHC_DRIVER_DIR_REL	= driver
-GHC_COMPAT_DIR_REL	= compat
-
-GHC_MKDEPENDC_DIR_REL	= $(GHC_UTILS_DIR_REL)/mkdependC
-GHC_LTX_DIR_REL		= $(GHC_UTILS_DIR_REL)/ltx
-GHC_RUNTEST_DIR_REL	= $(GHC_UTILS_DIR_REL)/runstdtest
-GHC_LNDIR_DIR_REL	= $(GHC_UTILS_DIR_REL)/lndir
-GHC_MKDIRHIER_DIR_REL	= $(GHC_UTILS_DIR_REL)/mkdirhier
-GHC_DOCBOOK_DIR_REL	= $(GHC_UTILS_DIR_REL)/docbook
-GHC_UNLIT_DIR_REL    	= $(GHC_UTILS_DIR_REL)/unlit
-GHC_HP2PS_DIR_REL	= $(GHC_UTILS_DIR_REL)/hp2ps
-GHC_HSTAGS_DIR_REL	= $(GHC_UTILS_DIR_REL)/hasktags
-GHC_GHCTAGS_DIR_REL	= $(GHC_UTILS_DIR_REL)/ghctags
-GHC_HSC2HS_DIR_REL	= $(GHC_UTILS_DIR_REL)/hsc2hs
-GHC_TOUCHY_DIR_REL	= $(GHC_UTILS_DIR_REL)/touchy
-GHC_PKG_DIR_REL		= $(GHC_UTILS_DIR_REL)/ghc-pkg
-GHC_GENPRIMOP_DIR_REL	= $(GHC_UTILS_DIR_REL)/genprimopcode
-GHC_GENAPPLY_DIR_REL	= $(GHC_UTILS_DIR_REL)/genapply
-
-GHC_MANGLER_DIR_REL	= $(GHC_DRIVER_DIR_REL)/mangler
-GHC_SPLIT_DIR_REL	= $(GHC_DRIVER_DIR_REL)/split
-GHC_SYSMAN_DIR_REL	= $(GHC_RTS_DIR_REL)/parallel
-
-INPLACE_DATA_DIR	= $(FPTOOLS_TOP_ABS)/inplace-datadir
-
-GHC_UTILS_DIR		= $(FPTOOLS_TOP)/$(GHC_UTILS_DIR_REL)
-GHC_INCLUDE_DIR	  	= $(FPTOOLS_TOP)/$(GHC_INCLUDE_DIR_REL)
-GHC_COMPILER_DIR	= $(FPTOOLS_TOP)/$(GHC_COMPILER_DIR_REL)
-GHC_RTS_DIR	   	= $(FPTOOLS_TOP)/$(GHC_RTS_DIR_REL)
-GHC_UTILS_DIR 		= $(FPTOOLS_TOP)/$(GHC_UTILS_DIR_REL)
-GHC_DRIVER_DIR		= $(FPTOOLS_TOP)/$(GHC_DRIVER_DIR_REL)
-GHC_COMPAT_DIR		= $(FPTOOLS_TOP)/$(GHC_COMPAT_DIR_REL)
-
-GHC_MKDEPENDC_DIR	= $(FPTOOLS_TOP)/$(GHC_MKDEPENDC_DIR_REL)
-GHC_LTX_DIR		= $(FPTOOLS_TOP)/$(GHC_LTX_DIR_REL)
-GHC_RUNTEST_DIR		= $(FPTOOLS_TOP)/$(GHC_RUNTEST_DIR_REL)
-GHC_LNDIR_DIR		= $(FPTOOLS_TOP)/$(GHC_LNDIR_DIR_REL)
-GHC_MKDIRHIER_DIR	= $(FPTOOLS_TOP)/$(GHC_MKDIRHIER_DIR_REL)
-GHC_DOCBOOK_DIR		= $(FPTOOLS_TOP)/$(GHC_DOCBOOK_DIR_REL)
-GHC_UNLIT_DIR    	= $(FPTOOLS_TOP)/$(GHC_UNLIT_DIR_REL)
-GHC_HP2PS_DIR		= $(FPTOOLS_TOP)/$(GHC_HP2PS_DIR_REL)
-GHC_HSTAGS_DIR		= $(FPTOOLS_TOP)/$(GHC_HSTAGS_DIR_REL)
-GHC_GHCTAGS_DIR		= $(FPTOOLS_TOP)/$(GHC_GHCTAGS_DIR_REL)
-GHC_HSC2HS_DIR		= $(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)
-GHC_TOUCHY_DIR		= $(FPTOOLS_TOP)/$(GHC_TOUCHY_DIR_REL)
-GHC_PKG_DIR		= $(FPTOOLS_TOP)/$(GHC_PKG_DIR_REL)
-GHC_GENPRIMOP_DIR	= $(FPTOOLS_TOP)/$(GHC_GENPRIMOP_DIR_REL)
-GHC_GENAPPLY_DIR	= $(FPTOOLS_TOP)/$(GHC_GENAPPLY_DIR_REL)
-
-GHC_MANGLER_DIR		= $(FPTOOLS_TOP)/$(GHC_MANGLER_DIR_REL)
-GHC_SPLIT_DIR		= $(FPTOOLS_TOP)/$(GHC_SPLIT_DIR_REL)
-GHC_SYSMAN_DIR		= $(FPTOOLS_TOP)/$(GHC_SYSMAN_DIR_REL)
-
-GHC_UTILS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_UTILS_DIR_REL)
-GHC_INCLUDE_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_INCLUDE_DIR_REL)
-GHC_COMPILER_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)
-GHC_RTS_DIR_ABS	   	= $(FPTOOLS_TOP_ABS)/$(GHC_RTS_DIR_REL)
-GHC_UTILS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_UTILS_DIR_REL)
-GHC_DRIVER_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_DRIVER_DIR_REL)
-GHC_COMPAT_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_COMPAT_DIR_REL)
-
-GHC_MKDEPENDC_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_MKDEPENDC_DIR_REL)
-GHC_LTX_DIR_ABS		= $(FPTOOLS_TOP_ABS)/$(GHC_LTX_DIR_REL)
-GHC_RUNTEST_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_RUNTEST_DIR_REL)
-GHC_LNDIR_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_LNDIR_DIR_REL)
-GHC_MKDIRHIER_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_MKDIRHIER_DIR_REL)
-GHC_DOCBOOK_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_DOCBOOK_DIR_REL)
-GHC_UNLIT_DIR    	= $(FPTOOLS_TOP_ABS)/$(GHC_UNLIT_DIR_REL)
-GHC_HP2PS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_HP2PS_DIR_REL)
-GHC_HSTAGS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_HSTAGS_DIR_REL)
-GHC_GHCTAGS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_GHCTAGS_DIR_REL)
-GHC_HSC2HS_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)
-GHC_TOUCHY_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_TOUCHY_DIR_REL)
-GHC_PKG_DIR_ABS		= $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)
-GHC_GENPRIMOP_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_GENPRIMOP_DIR_REL)
-GHC_GENAPPLY_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_GENAPPLY_DIR_REL)
-GHC_COMPILER_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)
-
-GHC_MANGLER_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_MANGLER_DIR_REL)
-GHC_SYSMAN_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_SYSMAN_DIR_REL)
-GHC_SPLIT_DIR_ABS	= $(FPTOOLS_TOP_ABS)/$(GHC_SPLIT_DIR_REL)
+# so we can move things around more easily.  A define $(GHC_FOO_DIR)
+# indicates a directory relative to the top of the source tree.
+
+GHC_UTILS_DIR           = utils
+GHC_INCLUDE_DIR         = includes
+GHC_COMPILER_DIR        = compiler
+GHC_PROG_DIR            = ghc
+GHC_RTS_DIR             = rts
+GHC_DRIVER_DIR          = driver
+GHC_COMPAT_DIR          = compat
+
+GHC_MKDEPENDC_DIR       = $(GHC_UTILS_DIR)/mkdependC
+GHC_LTX_DIR             = $(GHC_UTILS_DIR)/ltx
+GHC_RUNTEST_DIR         = $(GHC_UTILS_DIR)/runstdtest
+GHC_LNDIR_DIR           = $(GHC_UTILS_DIR)/lndir
+GHC_MKDIRHIER_DIR       = $(GHC_UTILS_DIR)/mkdirhier
+GHC_DOCBOOK_DIR         = $(GHC_UTILS_DIR)/docbook
+GHC_UNLIT_DIR           = $(GHC_UTILS_DIR)/unlit
+GHC_HP2PS_DIR           = $(GHC_UTILS_DIR)/hp2ps
+GHC_HSTAGS_DIR          = $(GHC_UTILS_DIR)/hasktags
+GHC_GHCTAGS_DIR         = $(GHC_UTILS_DIR)/ghctags
+GHC_HSC2HS_DIR          = $(GHC_UTILS_DIR)/hsc2hs
+GHC_TOUCHY_DIR          = $(GHC_UTILS_DIR)/touchy
+GHC_PKG_DIR             = $(GHC_UTILS_DIR)/ghc-pkg
+GHC_GENPRIMOP_DIR       = $(GHC_UTILS_DIR)/genprimopcode
+GHC_GENAPPLY_DIR        = $(GHC_UTILS_DIR)/genapply
+GHC_CABAL_DIR           = $(GHC_UTILS_DIR)/ghc-cabal
+GHC_MANGLER_DIR         = $(GHC_DRIVER_DIR)/mangler
+GHC_SPLIT_DIR           = $(GHC_DRIVER_DIR)/split
+GHC_SYSMAN_DIR          = $(GHC_RTS_DIR)/parallel
 
 # -----------------------------------------------------------------------------
 # Names of programs in the GHC tree
 #
-#      xxx_PGM	        the name of an executable, without the path
-#      xxx		the executable relative to the current dir
-
-GHC_UNLIT_PGM		= unlit$(exeext)
-GHC_HP2PS_PGM		= hp2ps
-GHC_HSTAGS_PGM		= hasktags
-GHC_GHCTAGS_INPLACE_PGM	= ghctags-inplace
-GHC_HSC2HS_INPLACE_PGM	= hsc2hs
-GHC_TOUCHY_PGM		= touchy$(exeext)
-GHC_MANGLER_PGM		= ghc-asm
-GHC_SPLIT_PGM		= ghc-split
-GHC_SYSMAN_PGM 		= SysMan
-GHC_GENPRIMOP_PGM	= genprimopcode
-GHC_GENAPPLY_PGM	= genapply
-GHC_MKDEPENDC_PGM 	= mkdependC
-GHC_LTX_PGM 		= ltx
-GHC_MKDIRHIER_PGM	= mkdirhier
-GHC_LNDIR_PGM		= lndir
-GHC_RUNTEST_PGM		= runstdtest
+#      xxx_PGM          the name of an executable, without the path
+#      xxx              the executable relative to the current dir
+
+GHC_UNLIT_PGM           = unlit$(exeext)
+GHC_HP2PS_PGM           = hp2ps$(exeext)
+GHC_HSTAGS_PGM          = hasktags$(exeext)
+GHC_GHCTAGS_PGM         = ghctags$(exeext)
+GHC_HSC2HS_PGM          = hsc2hs$(exeext)
+GHC_TOUCHY_PGM          = touchy$(exeext)
+GHC_MANGLER_PGM         = ghc-asm
+GHC_SPLIT_PGM           = ghc-split
+GHC_SYSMAN_PGM          = SysMan
+GHC_GENPRIMOP_PGM       = genprimopcode$(exeext)
+GHC_GENAPPLY_PGM        = genapply$(exeext)
+GHC_CABAL_PGM           = ghc-cabal$(exeext)
+GHC_PKG_PGM             = ghc-pkg$(exeext)
+GHC_MKDEPENDC_PGM       = mkdependC
+GHC_LTX_PGM             = ltx$(exeext)
+GHC_MKDIRHIER_PGM       = mkdirhier
+GHC_LNDIR_PGM           = lndir
+GHC_RUNTEST_PGM         = runstdtest
+GHC_DUMMY_GHC_PGM       = dummy-ghc$(exeext)
 
 ifeq &quot;$(TARGETPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
 GHC_CP			= &quot;xcopy /y&quot;
@@ -859,23 +662,32 @@ GHC_CP			= $(CP)
 GHC_PERL		= $(PERL)
 endif
 
-UNLIT			= $(GHC_UNLIT_DIR)/$(GHC_UNLIT_PGM)
 HP2PS			= $(GHC_HP2PS_DIR)/$(GHC_HP2PS_PGM)
 HSTAGS			= $(GHC_HSTAGS_DIR)/$(GHC_HSTAGS_PGM)
-GHCTAGS_INPLACE		= $(GHC_GHCTAGS_DIR)/$(GHC_GHCTAGS_INPLACE_PGM)
-HSC2HS_INPLACE		= $(GHC_HSC2HS_DIR)/install-inplace/bin/$(GHC_HSC2HS_INPLACE_PGM)
-MANGLER			= $(GHC_MANGLER_DIR)/$(GHC_MANGLER_PGM)
-SPLIT			= $(GHC_SPLIT_DIR)/$(GHC_SPLIT_PGM)
+MANGLER			= $(INPLACE_LIB)/$(GHC_MANGLER_PGM)
+SPLIT			= $(INPLACE_LIB)/$(GHC_SPLIT_PGM)
 SYSMAN 			= $(GHC_SYSMAN_DIR)/$(GHC_SYSMAN_PGM)
-GHC_PKG_INPLACE		= $(GHC_PKG_PROG)
-GENPRIMOP		= $(GHC_GENPRIMOP_DIR)/$(GHC_GENPRIMOP_PGM)
-GENAPPLY		= $(GHC_GENAPPLY_DIR)/$(GHC_GENAPPLY_PGM)
-MKDEPENDC 		= $(GHC_MKDEPENDC_DIR)/$(GHC_MKDEPENDC_PGM)
 LTX 			= $(GHC_LTX_DIR)/$(GHC_LTX_PGM)
-MKDIRHIER		= $(GHC_MKDIRHIER_DIR)/$(GHC_MKDIRHIER_PGM)
 LNDIR			= $(GHC_LNDIR_DIR)/$(GHC_LNDIR_PGM)
 RUNTEST			= $(GHC_RUNTEST_DIR)/$(GHC_RUNTEST_PGM)
 
+INPLACE			= inplace
+INPLACE_BIN		= $(INPLACE)/bin
+INPLACE_LIB		= $(INPLACE)/lib
+INPLACE_MINGW		= $(INPLACE)/mingw
+
+UNLIT			= $(INPLACE_LIB)/$(GHC_UNLIT_PGM)
+TOUCHY                  = $(INPLACE_LIB)/$(GHC_TOUCHY_PGM)
+MKDIRHIER		= $(INPLACE_BIN)/$(GHC_MKDIRHIER_PGM)
+MKDEPENDC 		= $(INPLACE_BIN)/$(GHC_MKDEPENDC_PGM)
+GHC_CABAL_INPLACE	= $(INPLACE_BIN)/$(GHC_CABAL_PGM)
+GENAPPLY_INPLACE	= $(INPLACE_BIN)/$(GHC_GENAPPLY_PGM)
+GHC_PKG_INPLACE		= $(INPLACE_BIN)/$(GHC_PKG_PGM)
+GHCTAGS_INPLACE		= $(INPLACE_BIN)/$(GHC_GHCTAGS_PGM)
+HSC2HS_INPLACE		= $(INPLACE_BIN)/$(GHC_HSC2HS_PGM)
+GENPRIMOP_INPLACE	= $(INPLACE_BIN)/$(GHC_GENPRIMOP_PGM)
+DUMMY_GHC_INPLACE	= $(INPLACE_BIN)/$(GHC_DUMMY_GHC_PGM)
+
 GENERATED_FILE  = chmod a-w
 EXECUTABLE_FILE = chmod +x
 
@@ -891,7 +703,14 @@ EXECUTABLE_FILE = chmod +x
 # NOTE: Don't override $(GHC) in build.mk, use configure --with-ghc instead
 # (because the version numbers have to be calculated).
 
-GHC		= @WithGhc@
+GHC := @WithGhc@
+# If we have a make dependency on c:/ghc/ghc, and the file is actually
+# called c:/ghc/ghc.exe, then make will think that ghc doesn't exist
+# and that it doesn't know how to create it.
+ifneq &quot;$(wildcard $(GHC).exe)&quot; &quot;&quot;
+GHC := $(GHC).exe
+endif
+
 GhcDir          = $(dir $(GHC))
 
 # Set to YES if $(GHC) has the editline package installed
@@ -905,63 +724,31 @@ NHC		= @NHC@
 # tree).  We can refer to &quot;this ghc&quot; as $(GHC_INPLACE):
 
 GHC_INPLACE = $(GHC_STAGE1)
-GHC_STAGE1  = $(GHC_COMPILER_DIR_ABS)/stage1-inplace/ghc
-GHC_STAGE2  = $(GHC_COMPILER_DIR_ABS)/stage2-inplace/ghc
-GHC_STAGE3  = $(GHC_COMPILER_DIR_ABS)/stage3-inplace/ghc
-# XXX All those used to have -no-user-package-conf, but then we can't
-# pass them to Cabal
 
-BOOTSTRAPPING_CONF = $(FPTOOLS_TOP_ABS)/libraries/bootstrapping.conf
+GHC_STAGE0_ABS = $(GHC)
+GHC_STAGE1_ABS = $(TOP)/$(INPLACE_BIN)/ghc-stage1$(exeext)
+GHC_STAGE2_ABS = $(TOP)/$(INPLACE_BIN)/ghc-stage2$(exeext)
+GHC_STAGE3_ABS = $(TOP)/$(INPLACE_BIN)/ghc-stage3$(exeext)
 
-# NOTE: add -no-user-package-conf for stage 1-3 above, so that
-# we avoid picking up any packages the user might happen to have
-# installed for this GHC version.  They are bound to be incompatible
-# with the packages we built in the tree.
+GHC_STAGE0  = $(GHC)
+GHC_STAGE1  = $(INPLACE_BIN)/ghc-stage1$(exeext)
+GHC_STAGE2  = $(INPLACE_BIN)/ghc-stage2$(exeext)
+GHC_STAGE3  = $(INPLACE_BIN)/ghc-stage3$(exeext)
 
-ifeq &quot;$(stage)&quot; &quot;2&quot;
-  UseStage1 = YES
-endif
-ifneq &quot;$(findstring YES, $(UseStage1) $(BootingFromHc))&quot; &quot;&quot;
-
-# We are using the stage1 compiler to compile Haskell code, set up
-# some variables appropriately:
-HC		=$(GHC_STAGE1)
-MKDEPENDHS	=$(GHC_STAGE1)
-USE_NEW_MKDEPEND_FLAGS = YES
-GhcVersion	= @ProjectVersion@
-GhcPatchLevel	= @ProjectPatchLevel@
-# oops, these are wrong:
-GhcMajVersion	= @GhcMajVersion@
-GhcMinVersion	= @GhcMinVersion@
+# Install stage 2 by default, can be changed to 3
+INSTALL_GHC_STAGE=2
 
-ghc_ge_607 = YES
-ghc_ge_609 = YES
+BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
 
-else # not UseStage1 or BootingFromHc
+INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf
 
-# Some useful GHC version predicates:
-ghc_ge_607 = @ghc_ge_607@
-ghc_ge_609 = @ghc_ge_609@
-
-HC	        = @WithHc@
-MKDEPENDHS	= $(GHC)
-USE_NEW_MKDEPEND_FLAGS = $(ghc_ge_609)
 GhcVersion	= @GhcVersion@
 GhcPatchLevel	= @GhcPatchLevel@
 GhcMajVersion	= @GhcMajVersion@
 GhcMinVersion	= @GhcMinVersion@
 
-# We build a few packages using the installed GHC as part of the
-# bootstrapping process.  These are installed into a local
-# package.conf file, $(BOOTSTRAPPING_CONF).  When we invoke the
-# installed GHC we need to pass it -package-conf $(BOOTSTRAPPING_CONF).
-# So the following variables expand to -package-conf $(BOOTSTRAPPING_CONF)
-# when $(HC) does *not* point to one of the GHC binaries built in
-# the local tree.
-#
-BOOTSTRAPPING_PACKAGE_CONF_HC_OPTS =$(if $(findstring inplace, $(HC)),,-package-conf $(BOOTSTRAPPING_CONF))
-BOOTSTRAPPING_PACKAGE_CONF_MKDEPENDHS_OPTS =$(if $(findstring inplace, $(MKDEPENDHS)),,-package-conf $(BOOTSTRAPPING_CONF))
-endif
+ghc_ge_607 = @ghc_ge_607@
+ghc_ge_609 = @ghc_ge_609@
 
 # Canonicalised ghc version number, used for easy (integer) version
 # comparisons.  We must expand $(GhcMinVersion) to two digits by
@@ -988,7 +775,6 @@ ifneq &quot;$(strip $(UseGcc))&quot;  &quot;YES&quot;
   CC	= cc
 else
   CC	= $(WhatGccIsCalled)
-  GccDir = $(dir $(WhatGccIsCalled))
 endif
 endif
 
@@ -1054,7 +840,7 @@ INSTALL			= @INSTALL@
 # install-sh script (if chosen). This not terribly useful to us, so we convert
 # it into an abs. path.
 # 
-INSTALL			:= $(subst .././install-sh,$(FPTOOLS_TOP_ABS)/install-sh,$(INSTALL))
+INSTALL			:= $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
 LATEX			= latex
 HEVEA			= hevea
 HACHA			= hacha
@@ -1108,6 +894,7 @@ LdIsGNULd		= @LdIsGNULd@
 REAL_SHELL=$(SHELL)
 SIZE			= size
 STRIP			= strip
+PATCH			= @PatchCmd@
 TAR			= @TarCmd@
 ZIP			= zip
 
@@ -1156,12 +943,6 @@ XSLTPROC_LABEL_OPTS	= --stringparam toc.section.depth 3 \
 BLD_DLL			= dllwrap
 
 #
-# .NET support software
-#
-ILX2IL                  = ilx2il
-ILASM                   = ilasm
-
-#
 # ghc-pkg
 #
 GHC_PKG		        = @GhcPkgCmd@
@@ -1180,11 +961,11 @@ HAPPY_VERSION		= @HappyVersion@
 #
 # Options to pass to Happy when we're going to compile the output with GHC
 #
-GHC_HAPPY_OPTS		= -agc --strict
+SRC_HAPPY_OPTS		= -agc --strict
 
 # Temp. to work around performance problems in the HEAD around 8/12/2003,
 # A Happy compiled with this compiler needs more stack.
-SRC_HAPPY_OPTS		= +RTS -K2m -RTS
+SRC_HAPPY_OPTS		+= +RTS -K2m -RTS
 
 #
 # Alex
@@ -1194,7 +975,7 @@ ALEX_VERSION		= @AlexVersion@
 #
 # Options to pass to Happy when we're going to compile the output with GHC
 #
-GHC_ALEX_OPTS		= -g
+SRC_ALEX_OPTS		= -g
 
 # Should we build haddock docs?
 HADDOCK_DOCS = YES
@@ -1229,7 +1010,7 @@ endif
 #
 # The ways currently defined.
 #
-ALL_WAYS=p t s mp mg a b c d e f g h i j k l m n o A B
+ALL_WAYS=v p t l s mp mg debug dyn thr thr_l debug_dyn thr_dyn thr_debug_dyn thr_p thr_debug thr_debug_l
 USER_WAYS=a b c d e f g h j k l m n o A B
 
 #
@@ -1240,9 +1021,9 @@ USER_WAYS=a b c d e f g h j k l m n o A B
 # 
 # If you want to add to these default options, fill in the variables below:
 
-# Way 'i':
-WAY_i_NAME=ILX
-WAY_i_HC_OPTS= -filx -fruntime-types
+# Way 'v':
+WAY_v_NAME=vanilla
+WAY_v_HC_OPTS= 
 
 # Way 'p':
 WAY_p_NAME=profiling
@@ -1412,5 +1193,5 @@ else
 BIN_DIST_INST_SUBDIR = installed
 endif
 
-BIN_DIST_INST_DIR = $(FPTOOLS_TOP_ABS)/bindisttest/$(BIN_DIST_INST_SUBDIR)
+BIN_DIST_INST_DIR = $(TOP)/bindisttest/$(BIN_DIST_INST_SUBDIR)
 </diff>
      <filename>mk/config.mk.in</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,9 @@
 
--include $(TOP)/mk/are-validating.mk
+-include mk/are-validating.mk
 
 ifeq &quot;$(Validating)&quot; &quot;YES&quot;
-include $(TOP)/mk/validate-settings.mk
--include $(TOP)/mk/validate.mk
+include mk/validate-settings.mk
+-include mk/validate.mk
 else
--include $(TOP)/mk/build.mk
+-include mk/build.mk
 endif</diff>
      <filename>mk/custom-settings.mk</filename>
    </modified>
    <modified>
      <diff>@@ -14,14 +14,14 @@ GhcStage2HcOpts = -O -fasm
 # running of the tests, and faster building of the utils to be installed
 
 GhcLibHcOpts    = -O -fasm -dcore-lint
-GhcLibWays      =
+GhcLibWays      = v
 SplitObjs       = NO
 NoFibWays       =
 STRIP           = :
 GhcBootLibs     = YES
 
 ifeq &quot;$(ValidateHpc)&quot; &quot;YES&quot;
-GhcStage2HcOpts += -fhpc -hpcdir $(FPTOOLS_TOP_ABS)/testsuite/hpc_output/
+GhcStage2HcOpts += -fhpc -hpcdir $(TOP)/testsuite/hpc_output/
 endif
 ifeq &quot;$(ValidateSlow)&quot; &quot;YES&quot;
 GhcStage2HcOpts += -XGenerics -DDEBUG</diff>
      <filename>mk/validate-settings.mk</filename>
    </modified>
    <modified>
      <diff>@@ -148,7 +148,7 @@ struct Capability_ {
 INLINE_HEADER Capability *
 regTableToCapability (StgRegTable *reg)
 {
-    return (Capability *)((void *)((unsigned char*)reg - FIELD_OFFSET(Capability,r)));
+    return (Capability *)((void *)((unsigned char*)reg - STG_FIELD_OFFSET(Capability,r)));
 }
 
 // Initialise the available capabilities.</diff>
      <filename>rts/Capability.h</filename>
    </modified>
    <modified>
      <diff>@@ -1425,7 +1425,7 @@ run_BCO:
             ffi_call(cif, fn, ret, argptrs);
 
 	    // And restart the thread again, popping the RET_DYN frame.
-	    cap = (Capability *)((void *)((unsigned char*)resumeThread(tok) - FIELD_OFFSET(Capability,r)));
+	    cap = (Capability *)((void *)((unsigned char*)resumeThread(tok) - STG_FIELD_OFFSET(Capability,r)));
 	    LOAD_STACK_POINTERS;
 
             // Re-load the pointer to the BCO from the RET_DYN frame,</diff>
      <filename>rts/Interpreter.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,497 +1,4 @@
-#-----------------------------------------------------------------------------
-#
-#  This is the Makefile for the runtime-system stuff.
-#  This stuff is written in C (and cannot be written in Haskell).
-#
-#  .c  files are vanilla C,
-#  .hc files are &quot;Haskellized-C&quot;, compiled using the C compiler and
-#      (possibly) the assembly-mangler.  The GHC driver script
-#      knows how to compile this stuff.
-
-#-----------------------------------------------------------------------------
-# Preamble
-
-TOP=..
-
-# Set UseGhcForCc: this causes the fptools build system to use a different
-# set of suffix rules for compiling C code, using $(HC) rather than $(CC)
-# and prepending &quot;-optc&quot; to $(CC_OPTS).  NB. must be done before including
-# boilerplate.mk below.
-UseGhcForCc = YES
-
-include $(TOP)/mk/boilerplate.mk
-
-PACKAGE = rts
-
-HC=$(GHC_INPLACE)
-
-
-# Setting _way here is a nasty hack to make sure we get libHSrts*.a etc
-# rather than just libHSrts.a when we are installing bindists.
-ifeq &quot;$(DOING_BIN_DIST)&quot; &quot;YES&quot;
-_way = *
-endif
-
-# -----------------------------------------------------------------------------
-# RTS ways
-
-WAYS=$(strip $(GhcLibWays) $(GhcRTSWays))
-
-ifneq &quot;$(findstring debug, $(way))&quot; &quot;&quot;
-GhcRtsHcOpts=
-GhcRtsCcOpts=-g -O0
-endif
-
-ifeq &quot;$(BeConservative)&quot; &quot;YES&quot;
-GhcRtsCcOpts += -DBE_CONSERVATIVE
-endif
-
-# -----------------------------------------------------------------------------
-
-# There's nothing for Haddock here...
-override HADDOCK_DOCS = NO
-
-# -----------------------------------------------------------------------------
-
-# Tells the build system not to add various Haskellish options to $(SRC_HC_OPTS)
-NON_HS_PACKAGE = YES
-
-# grab sources from these subdirectories
-ALL_DIRS = hooks parallel sm eventlog
-
-ifeq &quot;$(HOSTPLATFORM)&quot; &quot;i386-unknown-mingw32&quot;
-ALL_DIRS += win32
-else
-ALL_DIRS += posix
-endif
-
-ifneq &quot;$(findstring dyn, $(way))&quot; &quot;&quot;
-DYNAMIC_RTS=YES
-else
-DYNAMIC_RTS=NO
-endif
-
-ifeq &quot;$(DYNAMIC_RTS) $(HOSTPLATFORM)&quot; &quot;YES i386-unknown-mingw32&quot;
-EXCLUDED_SRCS += Main.c
-# It's not included in the DLL, but we need to compile it up separately.
-
-all :: Main.$(way_)o
-INSTALL_LIBS += Main.$(way_)o
-else
-EXCLUDED_SRCS += RtsDllMain.c
-endif
-
-# This file ends up being empty unless we're building for a powerpc
-# or darwin system, and it is reported that Solaris ld chokes on it when
-# building HSrts.o.
-ifeq &quot;$(findstring $(TargetArch_CPP), powerpc powerpc64)&quot; &quot;&quot;
-ifeq &quot;$(findstring $(TargetOS_CPP), darwin)&quot; &quot;&quot;
-EXCLUDED_SRCS += AdjustorAsm.S
-endif
-endif
-
-EXCLUDED_SRCS += parallel/SysMan.c
-
-EXCLUDED_SRCS += dyn-wrapper.c
-
-# compile generic patchable dyn-wrapper
-
-DYNWRAPPER_SRC = dyn-wrapper.c
-DYNWRAPPER_PROG = dyn-wrapper$(exeext)
-$(DYNWRAPPER_PROG): $(DYNWRAPPER_SRC)
-	$(HC) -cpp -optc-include -optcdyn-wrapper-patchable-behaviour.h $(INPLACE_EXTRA_FLAGS) $&lt; -o $@
-
-# The build system doesn't give us these
-CMM_SRCS = $(filter-out AutoApply%.cmm, $(wildcard *.cmm)) $(EXTRA_CMM_SRCS)
-CMM_OBJS = $(patsubst %.cmm,%.$(way_)o, $(CMM_SRCS))
-
-CLEAN_FILES += $(CMM_OBJS)
-
-# Override the default $(LIBOBJS) (defaults to $(HS_OBJS))
-LIBOBJS = $(C_OBJS) $(CMM_OBJS)
-
-SplitObjs=NO
-
-H_FILES = $(wildcard ../includes/*.h) $(wildcard *.h)
-
-#-----------------------------------------------------------------------------
-# Flags for compiling RTS .c and .hc files
-
-# gcc provides lots of useful warnings if you ask it.
-# This is a pretty good list to start with - use a # to comment out
-# any you don't like.
-WARNING_OPTS += -Wall
-WARNING_OPTS += -W
-WARNING_OPTS += -Wstrict-prototypes 
-WARNING_OPTS += -Wmissing-prototypes 
-WARNING_OPTS += -Wmissing-declarations
-WARNING_OPTS += -Winline
-WARNING_OPTS += -Waggregate-return
-#WARNING_OPTS += -Wpointer-arith
-#WARNING_OPTS += -Wbad-function-cast
-#WARNING_OPTS += -Wcast-align
-#WARNING_OPTS += -Wnested-externs
-#WARNING_OPTS += -Wshadow
-#WARNING_OPTS += -Wcast-qual
-#WARNING_OPTS += -Wno-unused 
-#WARNING_OPTS += -Wredundant-decls 
-#WARNING_OPTS += -Wconversion
-
-STANDARD_OPTS += -I../includes -I. -Iparallel -Ism -Ieventlog
-
-# COMPILING_RTS is only used when building Win32 DLL support.
-STANDARD_OPTS += -DCOMPILING_RTS
-
-# HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
-# only included in .c compilations.  HC_OPTS included the WAY_* opts, which
-# must be included in both types of compilations.
-
-SRC_CC_OPTS += $(WARNING_OPTS)
-SRC_CC_OPTS += $(STANDARD_OPTS)
-
-SRC_CC_OPTS += $(GhcRtsCcOpts)
-SRC_HC_OPTS += $(GhcRtsHcOpts) $(STANDARD_OPTS) -package-name rts
-
-ifneq &quot;$(GhcWithSMP)&quot; &quot;YES&quot;
-SRC_CC_OPTS += -DNOSMP
-SRC_HC_OPTS += -optc-DNOSMP
-endif
-
-ifeq &quot;$(UseLibFFIForAdjustors)&quot; &quot;YES&quot;
-SRC_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
-endif
-
-ifeq &quot;$(Windows)&quot; &quot;YES&quot;
-# SDM: when compiled with -fasm the RTS currently has bogus references to 
-# __imp_base_ things, so working around for now:
-SRC_HC_OPTS = -fvia-C
-endif
-
-ifneq &quot;$(DYNAMIC_RTS)&quot; &quot;YES&quot;
-SRC_HC_OPTS += -static
-else
-LIB_LD_OPTS += -ignore-package base -ignore-package rts
-ifeq &quot;$(DYNAMIC_RTS) $(HOSTPLATFORM)&quot; &quot;YES i386-unknown-mingw32&quot;
-LIB_DEPS=buildbase
-.PHONY: buildbase
-
-BASE_DIST_LIB=$(TOP)/libraries/base/dist/build
-
-# The following must be a one liner otherwise its evaluation won't be delayed until base/rts packages are properly registered
-LIB_LD_OPTS = $(foreach lib,$(shell $(GHC_PKG_INPLACE) field base hs-libraries | sed -e 's/hs-libraries: //'),&quot;-l$(lib)-ghc$(ProjectVersion)$(soext)&quot;) $(foreach lib,$(shell $(GHC_PKG_INPLACE) field rts extra-libraries | sed -e s/extra-libraries://),&quot;-l$(lib)&quot;) $(foreach libdir,$(shell $(GHC_PKG_INPLACE) field base library-dirs | sed -e 's/library-dirs: //' | sed -e s,\\\\,/,g) $(shell $(GHC_PKG_INPLACE) field rts library-dirs | sed -e s/library-dirs:// | sed -e s/\\\\/\\\\\\\\/g),&quot;-L$(libdir)&quot;)
-endif
-endif
-
-# Mac OS X: make sure we compile for the right OS version
-SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
-SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
-LIB_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
-
-# XXX DQ is now the same on all platforms, so get rid of it
-DQ = \&quot;
-
-# If Main.c is built with optimisation then the SEH exception stuff on
-# Windows gets confused.
-# This has to be in HC rather than CC opts, as otherwise there's a
-# -optc-O2 that comes after it.
-Main_HC_OPTS += -optc-O0
-
-RtsMessages_CC_OPTS += -DProjectVersion=$(DQ)$(ProjectVersion)$(DQ)
-RtsUtils_CC_OPTS += -DProjectVersion=$(DQ)$(ProjectVersion)$(DQ)
-RtsUtils_CC_OPTS += -DRtsWay=$(DQ)rts$(_way)$(DQ)
-#
-RtsUtils_CC_OPTS += -DHostPlatform=$(DQ)$(HOSTPLATFORM)$(DQ)
-RtsUtils_CC_OPTS += -DHostArch=$(DQ)$(HostArch_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DHostOS=$(DQ)$(HostOS_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DHostVendor=$(DQ)$(HostVendor_CPP)$(DQ)
-#
-RtsUtils_CC_OPTS += -DBuildPlatform=$(DQ)$(BUILDPLATFORM)$(DQ)
-RtsUtils_CC_OPTS += -DBuildArch=$(DQ)$(BuildArch_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DBuildOS=$(DQ)$(BuildOS_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DBuildVendor=$(DQ)$(BuildVendor_CPP)$(DQ)
-#
-RtsUtils_CC_OPTS += -DTargetPlatform=$(DQ)$(TARGETPLATFORM)$(DQ)
-RtsUtils_CC_OPTS += -DTargetArch=$(DQ)$(TargetArch_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DTargetOS=$(DQ)$(TargetOS_CPP)$(DQ)
-RtsUtils_CC_OPTS += -DTargetVendor=$(DQ)$(TargetVendor_CPP)$(DQ)
-#
-RtsUtils_CC_OPTS += -DGhcUnregisterised=$(DQ)$(GhcUnregisterised)$(DQ)
-RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=$(DQ)$(GhcEnableTablesNextToCode)$(DQ)
-
-# ffi.h triggers prototype warnings, so disable them here:
-Interpreter_CC_OPTS += -Wno-strict-prototypes
-Adjustor_CC_OPTS += -Wno-strict-prototypes
-sm/Storage_CC_OPTS += -Wno-strict-prototypes
-
-StgCRun_CC_OPTS += -w
-Typeable_CC_OPTS += -w
-RetainerProfile_CC_OPTS += -w
-sm/Compact_CC_OPTS += -w
-# On Windows:
-win32/ConsoleHandler_CC_OPTS += -w
-win32/ThrIOManager_CC_OPTS += -w
-win32/Ticker_CC_OPTS += -w
-# The above warning supression flags are a temporary kludge.
-# While working on this module you are encouraged to remove it and fix
-# any warnings in the module. See
-#     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
-# for details
-
-ifeq &quot;$(way)&quot; &quot;mp&quot;
-SRC_HC_OPTS += -I$$PVM_ROOT/include
-endif
-
-# If -DDEBUG is in effect, adjust package conf accordingly..
-ifneq &quot;$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))&quot; &quot;&quot;
-PACKAGE_CPP_OPTS += -DDEBUG
-endif
-
-ifeq &quot;$(HaveLibMingwEx)&quot; &quot;YES&quot;
-PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
-endif
-
-ifeq &quot;$(GhciWithDebugger)&quot; &quot;YES&quot;
-STANDARD_OPTS += -DDEBUGGER
-endif
-
-ifeq &quot;$(DotnetSupport)&quot; &quot;YES&quot;
-
-# 
-# Would like to just use SUBDIRS here, but need to
-# descend into dotnet/ earlier than that.
-#
-all ::
-	$(MAKE) -C dotnet all
-
-# But use SUBDIRS for other recursive targets.
-SUBDIRS += dotnet
-
-LIBOBJS += dotnet/Invoke.o
-endif
-
-# Suppress uninitialized variable warnings for GC.c
-GC_CC_OPTS 	+= -Wno-uninitialized
-
-#-----------------------------------------------------------------------------
-# Include the Front panel code?
-
-# we need GTK+ for the front panel
-ifneq &quot;$(GTK_CONFIG)&quot; &quot;&quot;
-ifeq &quot;$(GhcRtsWithFrontPanel)&quot; &quot;YES&quot;
-SRC_HC_OPTS 		+= `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
-VisCallbacks_CC_OPTS 	+= -Wno-unused
-SRC_MKDEPENDC_OPTS	+= `$(GTK_CONFIG) --cflags`
-else # GhcRtsWithFrontPanel
-EXCLUDED_SRCS		+= $(wildcard Vis*.c)
-endif
-else # GTK_CONFIG
-EXCLUDED_SRCS		+= $(wildcard Vis*.c)
-endif
-
-#-----------------------------------------------------------------------------
-# Add PAPI library if needed
-
-ifeq &quot;$(GhcRtsWithPapi)&quot; &quot;YES&quot;
-
-SRC_CC_OPTS		+= -DUSE_PAPI
-PACKAGE_CPP_OPTS	+= -DUSE_PAPI
-
-PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=$(PapiIncludeDir)
-PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=$(PapiLibDir)
-
-ifneq &quot;$(PapiIncludeDir)&quot; &quot;&quot;
-SRC_HC_OPTS += -I$(PapiIncludeDir)
-SRC_CC_OPTS += -I$(PapiIncludeDir)
-SRC_HSC2HS_OPTS += -I$(PapiIncludeDir)
-endif
-ifneq &quot;$(PapiLibDirs)&quot; &quot;&quot;
-SRC_LD_OPTS += -L$(PapiLibDirs)
-endif
-
-else # GhcRtsWithPapi==YES
-
-PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=&quot;&quot;
-PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=&quot;&quot;
-
-endif
-
-#-----------------------------------------------------------------------------
-# make depend setup
-
-SRC_MKDEPENDC_OPTS += -I. -I../includes
-
-# Hack: we define every way-related option here, so that we get (hopefully)
-# a superset of the dependencies.  To do this properly, we should generate
-# a different set of dependencies for each way.  Further hack: PROFILING and
-# TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now.
-SRC_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG -DEVENTLOG
-
-# -----------------------------------------------------------------------------
-# The auto-generated apply code
-
-# We want a slightly different version for the unregisterised way, so we make
-# AutoApply on a per-way basis (eg. AutoApply_p.cmm).
-
-ifneq &quot;$(DOING_BIN_DIST)&quot; &quot;YES&quot;
-
-AUTO_APPLY_CMM = AutoApply$(_way).cmm
-
-ifneq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-$(AUTO_APPLY_CMM): $(GHC_GENAPPLY)
-	@$(RM) $@
-	$(GENAPPLY) $(if $(filter $(way), u debug_u), -u) &gt;$@
-endif
-
-EXTRA_CMM_SRCS += $(AUTO_APPLY_CMM)
-
-CLEAN_FILES += $(AUTO_APPLY_CMM)
-
-endif
-
-# -----------------------------------------------------------------------------
-
-# Need to get the GMP vars in through CPP to package.conf.in, and put
-# quotes around each element.
-
-empty =
-space = $(empty) $(empty)
-comma = ,
-PACKAGE_CPP_OPTS += -DGMP_INCLUDE_DIRS='$(subst $(space),$(comma),$(patsubst %,&quot;%&quot;,$(strip $(GMP_INCLUDE_DIRS))))'
-PACKAGE_CPP_OPTS += -DGMP_LIB_DIRS='$(subst $(space),$(comma),$(patsubst %,&quot;%&quot;,$(strip $(GMP_LIB_DIRS))))'
-
-ifneq &quot;$(GMP_INCLUDE_DIRS)&quot; &quot;&quot;
-SRC_HC_OPTS += -I$(GMP_INCLUDE_DIRS)
-SRC_CC_OPTS += -I$(GMP_INCLUDE_DIRS)
-SRC_HSC2HS_OPTS += -I$(GMP_INCLUDE_DIRS)
-endif
-ifneq &quot;$(GMP_LIB_DIRS)&quot; &quot;&quot;
-SRC_LD_OPTS += -L$(GMP_LIB_DIRS)
-endif
-
-SRC_CC_OPTS += -I../gmp/gmpbuild
-SRC_HC_OPTS += -I../gmp/gmpbuild
-SRC_HSC2HS_OPTS += -I../gmp/gmpbuild
-SRC_LD_OPTS += -L../gmp/gmpbuild
-
-#-----------------------------------------------------------------------------
-# libffi stuff
-
-SRC_CC_OPTS     += -I../libffi/build/include
-SRC_HC_OPTS     += -I../libffi/build/include
-SRC_HSC2HS_OPTS += -I../libffi/build/include
-SRC_LD_OPTS     += -L../libffi/build/include
-
-#-----------------------------------------------------------------------------
-#
-# Building the GUM SysMan
-#
-
-ifeq &quot;$(way)&quot; &quot;mp&quot;
-all :: parallel/SysMan
-
-ifdef solaris2_TARGET_OS
-__socket_libs = -lsocket -lnsl
-else
-__socket_libs =
-endif
-
-parallel/SysMan : parallel/SysMan.mp_o parallel/LLComms.mp_o RtsUtils.mp_o RtsFlags.mp_o
-	$(RM) $@
-	gcc -o $@ parallel/SysMan.mp_o parallel/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
-
-CLEAN_FILES  += parallel/SysMan.mp_o parallel/SysMan
-INSTALL_LIBEXECS += parallel/SysMan
-endif
-
-#-----------------------------------------------------------------------------
-# Compiling the cmm files
-
-# ToDo: should we really include Rts.h here?  Required for GNU_ATTRIBUTE().
-SRC_HC_OPTS += -I.
-
-# Otherwise the stack-smash handler gets triggered.
-ifeq &quot;$(TargetOS_CPP)&quot; &quot;openbsd&quot;
-SRC_HC_OPTS += -optc-fno-stack-protector
-endif
-
-# -O3 helps unroll some loops (especially in copy() with a constant argument).
-sm/Evac_HC_OPTS += -optc-funroll-loops
-
-ifneq &quot;$(findstring thr, $(way))&quot; &quot;&quot;
-EXTRA_SRCS += sm/Evac_thr.c sm/Scav_thr.c
-CLEAN_FILES += sm/Evac_thr.c sm/Scav_thr.c
-
-sm/Evac_thr.c : sm/Evac.c
-	cp $&lt; $@
-sm/Scav_thr.c : sm/Scav.c
-	cp $&lt; $@
-
-sm/Evac_thr_HC_OPTS += -optc-DPARALLEL_GC
-sm/Scav_thr_HC_OPTS += -optc-DPARALLEL_GC
-
-sm/Evac_thr_HC_OPTS += -optc-funroll-loops
-else
-EXCLUDED_SRCS += sm/Evac_thr.c sm/Scav_thr.c
-endif
-
-# Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
-sm/Compact_HC_OPTS += -optc-finline-limit=2500
-
-# -fno-strict-aliasing is required for the runtime, because we often
-# use a variety of types to represent closure pointers (StgPtr,
-# StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
-# allowed to assume that these pointers do not alias.  eg. without
-# this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
-# upd_evacee() assigments get moved before the object copy.
-SRC_CC_OPTS += -fno-strict-aliasing
-
-# We *want* type-checking of hand-written cmm.
-SRC_HC_OPTS += -dcmm-lint 
-
-ifneq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-# .cmm files depend on all the .h files, to a first approximation.
-%.$(way_)o : %.cmm $(H_FILES)
-	$(HC_PRE_OPTS)
-	$(HC) $(HC_OPTS) -c $&lt; -o $@
-	$(HC_POST_OPTS)
-
-%.$(way_)hc : %.cmm $(H_FILES)
-	$(HC) $(HC_OPTS) -C $&lt; -o $@
-
-%.$(way_)s : %.cmm $(H_FILES)
-	$(HC) $(HC_OPTS) -S $&lt; -o $@
-endif
-
-#-----------------------------------------------------------------------------
-#
-# Files to install
-#
-# Just libHSrts is installed uniformly across ways
-#
-
-include $(TOP)/mk/target.mk
-
-ifeq &quot;$(DYNAMIC_RTS) $(HOSTPLATFORM)&quot; &quot;YES i386-unknown-mingw32&quot;
-# $(LIBRARY).a is not the static library libHSrts.a but
-# libHSrts.dll.a, the import library for dynamic linking required for
-# linking the dynamic version of base
-buildbase: $(LIBRARY).a
-	$(MAKE) way=&quot;&quot; -C ../libraries/ make.library.ghc-prim
-	$(MAKE) way=&quot;&quot; -C ../libraries/ make.library.integer-gmp
-	$(MAKE) way=&quot;&quot; -C ../libraries/ make.library.base
-endif
-
-#-----------------------------------------------------------------------------
-#
-# binary-dist
-
-BINDIST_EXTRAS += package.conf.in
-BINDIST_EXTRAS += $(INSTALL_LIBS)
-BINDIST_EXTRAS += $(INSTALL_LIBEXECS)
-
-# Setting _way here is a nasty hack to make sure we get libHSrts*.a etc
-# rather than just libHSrts.a when we are making bindists.
-binary-dist: _way=*
-
-include $(TOP)/mk/bindist.mk
+dir = rts
+TOP = ..
+include $(TOP)/mk/sub-makefile.mk
 </diff>
      <filename>rts/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@
 #include &quot;ghcconfig.h&quot;
 #include &quot;RtsConfig.h&quot;
 
-name:		PACKAGE
+name:		rts
 version:	1.0
 license:	BSD3
 maintainer:	glasgow-haskell-users@haskell.org
@@ -21,9 +21,9 @@ library-dirs:		LIB_DIR GMP_LIB_DIRS PAPI_LIB_DIR
 			/* force the dist-provided gcc-lib/ into scope. */
 # endif
 #else /* !INSTALLING */
-library-dirs:		FPTOOLS_TOP_ABS&quot;/rts&quot; GMP_LIB_DIRS PAPI_LIB_DIR
+library-dirs:		TOP&quot;/rts/dist/build&quot; GMP_LIB_DIRS PAPI_LIB_DIR
 # if !defined(HAVE_LIB_GMP) &amp;&amp; !defined(HAVE_FRAMEWORK_GMP)
-			, FPTOOLS_TOP_ABS&quot;/gmp&quot;
+			, TOP&quot;/gmp&quot;
 # endif
 #endif
 
@@ -60,9 +60,9 @@ extra-libraries:		&quot;m&quot;		/* for ldexp() */
 #ifdef INSTALLING
 include-dirs:		INCLUDE_DIR GMP_INCLUDE_DIRS PAPI_INCLUDE_DIR
 #else /* !INSTALLING */
-include-dirs:		FPTOOLS_TOP_ABS&quot;/includes&quot;
+include-dirs:		TOP&quot;/includes&quot;
 # if !defined(HAVE_LIB_GMP) &amp;&amp; !defined(HAVE_FRAMEWORK_GMP)
-             		FPTOOLS_TOP_ABS&quot;/gmp/gmpbuild&quot;
+             		TOP&quot;/gmp/gmpbuild&quot;
 # endif
              		GMP_INCLUDE_DIRS
 #endif</diff>
      <filename>rts/package.conf.in</filename>
    </modified>
    <modified>
      <diff>@@ -1,29 +1,3 @@
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-HS_PROG = $(GHC_GENAPPLY_PGM)
-
-# genapply is needed to boot in rts/...
-ifneq &quot;$(BootingFromHc)&quot; &quot;YES&quot;
-boot :: all
-endif
-
-ifeq &quot;$(GhcUnregisterised)&quot; &quot;YES&quot;
-SRC_HC_OPTS += -DNO_REGS
-endif
-
-ifeq &quot;$(ghc_ge_607)&quot; &quot;YES&quot;
-SRC_HC_OPTS += -package pretty
-endif
-
-# Try to get dependencies right...
-SRC_HC_OPTS += -fforce-recomp
-
-GenApply.o : $(GHC_INCLUDE_DIR)/ghcconfig.h
-GenApply.o : $(GHC_INCLUDE_DIR)/MachRegs.h
-GenApply.o : $(GHC_INCLUDE_DIR)/Constants.h
-
-binary-dist:
-	@:
-
-include $(TOP)/mk/target.mk
+dir = utils/genapply
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/genapply/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,3 @@
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-HS_PROG = genprimopcode
-
-binary-dist:
-	@:
-
-include $(TOP)/mk/target.mk
-
+dir = utils/genprimopcode
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/genprimopcode/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -378,19 +378,14 @@ getPkgDatabases modify my_flags = do
   let err_msg = &quot;missing --global-conf option, location of global package.conf unknown\n&quot;
   global_conf &lt;-
      case [ f | FlagGlobalConfig f &lt;- my_flags ] of
-        [] -&gt; do mb_dir &lt;- getExecDir &quot;/bin/ghc-pkg.exe&quot;
+        [] -&gt; do mb_dir &lt;- getLibDir
                  case mb_dir of
                         Nothing  -&gt; die err_msg
                         Just dir -&gt;
-                            do let path1 = dir &lt;/&gt; &quot;package.conf&quot;
-                                   path2 = dir &lt;/&gt; &quot;..&quot; &lt;/&gt; &quot;..&quot; &lt;/&gt; &quot;..&quot;
-                                               &lt;/&gt; &quot;inplace-datadir&quot;
-                                               &lt;/&gt; &quot;package.conf&quot;
-                               exists1 &lt;- doesFileExist path1
-                               exists2 &lt;- doesFileExist path2
-                               if exists1 then return path1
-                                   else if exists2 then return path2
-                                   else die &quot;Can't find package.conf&quot;
+                            do let path = dir &lt;/&gt; &quot;package.conf&quot;
+                               exists &lt;- doesFileExist path
+                               unless exists $ die &quot;Can't find package.conf&quot;
+                               return path
         fs -&gt; return (last fs)
 
   let global_conf_dir = global_conf ++ &quot;.d&quot;
@@ -1053,7 +1048,7 @@ checkGHCiLib dirs batch_lib_dir batch_lib_file lib auto_build
   | auto_build = autoBuildGHCiLib batch_lib_dir batch_lib_file ghci_lib_file
   | otherwise  = do
       m &lt;- doesFileExistOnPath ghci_lib_file dirs
-      when (isNothing m) $
+      when (isNothing m &amp;&amp; ghci_lib_file /= &quot;HSrts.o&quot;) $
         hPutStrLn stderr (&quot;warning: can't find GHCi lib &quot; ++ ghci_lib_file)
  where
     ghci_lib_file = lib &lt;.&gt; &quot;o&quot;
@@ -1069,7 +1064,7 @@ autoBuildGHCiLib dir batch_file ghci_file = do
 #if defined(darwin_HOST_OS)
   r &lt;- rawSystem &quot;ld&quot; [&quot;-r&quot;,&quot;-x&quot;,&quot;-o&quot;,ghci_lib_file,&quot;-all_load&quot;,batch_lib_file]
 #elif defined(mingw32_HOST_OS)
-  execDir &lt;- getExecDir &quot;/bin/ghc-pkg.exe&quot;
+  execDir &lt;- getLibDir
   r &lt;- rawSystem (maybe &quot;&quot; (++&quot;/gcc-lib/&quot;) execDir++&quot;ld&quot;) [&quot;-r&quot;,&quot;-x&quot;,&quot;-o&quot;,ghci_lib_file,&quot;--whole-archive&quot;,batch_lib_file]
 #else
   r &lt;- rawSystem &quot;ld&quot; [&quot;-r&quot;,&quot;-x&quot;,&quot;-o&quot;,ghci_lib_file,&quot;--whole-archive&quot;,batch_lib_file]
@@ -1184,26 +1179,34 @@ subst a b ls = map (\ x -&gt; if x == a then b else x) ls
 unDosifyPath :: FilePath -&gt; FilePath
 unDosifyPath xs = subst '\\' '/' xs
 
-getExecDir :: String -&gt; IO (Maybe String)
+getLibDir :: IO (Maybe String)
+getLibDir = fmap (fmap (&lt;/&gt; &quot;lib&quot;)) $ getExecDir &quot;/bin/ghc-pkg.exe&quot;
+
 -- (getExecDir cmd) returns the directory in which the current
 --                  executable, which should be called 'cmd', is running
 -- So if the full path is /a/b/c/d/e, and you pass &quot;d/e&quot; as cmd,
 -- you'll get &quot;/a/b/c&quot; back as the result
-getExecDir cmd
-  = allocaArray len $ \buf -&gt; do
-        ret &lt;- getModuleFileName nullPtr buf len
-        if ret == 0 then return Nothing
-                    else do s &lt;- peekCString buf
-                            return (Just (reverse (drop (length cmd)
-                                                        (reverse (unDosifyPath s)))))
-  where
-    len = 2048::Int -- Plenty, PATH_MAX is 512 under Win32.
+getExecDir :: String -&gt; IO (Maybe String)
+getExecDir cmd =
+    getExecPath &gt;&gt;= maybe (return Nothing) removeCmdSuffix
+    where unDosifyPath = subst '\\' '/'
+          initN n = reverse . drop n . reverse
+          removeCmdSuffix = return . Just . initN (length cmd) . unDosifyPath
+
+getExecPath :: IO (Maybe String)
+getExecPath =
+     allocaArray len $ \buf -&gt; do
+         ret &lt;- getModuleFileName nullPtr buf len
+         if ret == 0 then return Nothing
+	             else liftM Just $ peekCString buf
+    where len = 2048 -- Plenty, PATH_MAX is 512 under Win32.
+
+foreign import stdcall unsafe &quot;GetModuleFileNameA&quot;
+    getModuleFileName :: Ptr () -&gt; CString -&gt; Int -&gt; IO Int32
 
-foreign import stdcall unsafe  &quot;GetModuleFileNameA&quot;
-  getModuleFileName :: Ptr () -&gt; CString -&gt; Int -&gt; IO Int32
 #else
-getExecDir :: String -&gt; IO (Maybe String)
-getExecDir _ = return Nothing
+getLibDir :: IO (Maybe String)
+getLibDir = return Nothing
 #endif
 
 -----------------------------------------</diff>
      <filename>utils/ghc-pkg/Main.hs</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,3 @@
-
-TOP=../..
-ENABLE_SHELL_WRAPPERS = YES
-EXTRA_CLEAN = Version.hs
-EXTRA_INPLACE_CONFIGURE_FLAGS = $(INPLACE_GHC_DATADIR_CONFIGURE_FLAGS)
-EXTRA_STAGE2_CONFIGURE_FLAGS = --datasubdir=.
-
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal.mk
-
-with-bootstrapping-compiler: Version.hs
-with-stage-2: Version.hs
-
-Version.hs: Makefile $(TOP)/mk/config.mk
-	$(RM) -f Version.hs
-	echo &quot;module Version where&quot;                    &gt;&gt; Version.hs
-	echo &quot;version, targetOS, targetARCH :: String&quot; &gt;&gt; Version.hs
-	echo &quot;version    = \&quot;$(ProjectVersion)\&quot;&quot;      &gt;&gt; Version.hs
-	echo &quot;targetOS   = \&quot;$(TargetOS_CPP)\&quot;&quot;        &gt;&gt; Version.hs
-	echo &quot;targetARCH = \&quot;$(TargetArch_CPP)\&quot;&quot;      &gt;&gt; Version.hs
-
+dir = utils/ghc-pkg
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/ghc-pkg/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,3 @@
-
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal.mk
-
+dir = utils/hasktags
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/hasktags/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 #ifndef MAIN_H
 #define MAIN_H
 
-#include &quot;../includes/ghcconfig.h&quot;
+#include &quot;ghcconfig.h&quot;
 #include &lt;stdio.h&gt;
 
 #ifdef __STDC__</diff>
      <filename>utils/hp2ps/Main.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,3 @@
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
-SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
-
-C_PROG 	= hp2ps
-
-SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall
-
-INSTALL_PROGS += $(C_PROG)
-
-LIBS	     = $(LIBM)
-
-CLEAN_FILES += $(C_OBJS) $(C_PROG)
-
-BINDIST_EXTRAS += $(C_PROG)
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = utils/hp2ps
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/hp2ps/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,3 @@
-
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal.mk
-
+dir = utils/hpc
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/hpc/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,24 +1,3 @@
-#
-# Boilerplate Makefile for building perl script that
-# needs some configured constants prepended to it.
-#
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-boot :: all
-
-PROG=mkdependC
-CLEAN_FILES += $(PROG)
-all::
-	$(RM) -f $(PROG)
-	echo '#!$(PERL)'                               &gt;&gt; $(PROG)
-	echo '$$DEFAULT_TMPDIR = &quot;$(DEFAULT_TMPDIR)&quot;;' &gt;&gt; $(PROG)
-	echo '$$CPP            = &quot;$(CPP)&quot;;'            &gt;&gt; $(PROG)
-	echo '$$BUILDPLATFORM  = &quot;$(BUILDPLATFORM)&quot;;'  &gt;&gt; $(PROG)
-	cat $(PROG).prl                                &gt;&gt; $(PROG)
-	$(EXECUTABLE_FILE) $(PROG)
-
-binary-dist:
-	@:
-
-include $(TOP)/mk/target.mk
+dir = utils/mkdependC
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/mkdependC/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -122,6 +122,8 @@ sub mangle_command_line_args {
 	    push(@Defines, $2);
 	} elsif ( /^(-optc)?(-I.*)/ ) {
 	    $Include_dirs .= &quot; $2&quot;;
+	} elsif ( /^(-optc)?(-isystem.*)/ ) {
+	    $Include_dirs .= &quot; $2&quot;;
 
 	} elsif ($Dashdashes_seen != 1) { # not between -- ... --
 	    if ( /^-v$/ ) {</diff>
      <filename>utils/mkdependC/mkdependC.prl</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,3 @@
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-boot :: all
-
-PROG=mkdirhier
-CLEAN_FILES += $(PROG)
-all::
-	$(RM) -f $(PROG)
-	echo '#!$(SHELL)'                              &gt;&gt; $(PROG)
-	cat $(PROG).sh                                 &gt;&gt; $(PROG)
-	$(EXECUTABLE_FILE) $(PROG)
-
-BINDIST_EXTRAS += $(PROG)
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = utils/mkdirhier
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/mkdirhier/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -48,8 +48,6 @@ $(BASH_INSTALLERS): install.bash.%:
 	cat $*.bash      &gt;&gt; $(bindir)/$*
 	$(EXECUTABLE_FILE)  $(bindir)/$*
 
-BINDIST_EXTRAS += $(addsuffix .pl,$(PERL_PROGS))
-BINDIST_EXTRAS += $(addsuffix .bash,$(BASH_PROGS))
 include $(TOP)/mk/bindist.mk
 
 include $(TOP)/mk/target.mk</diff>
      <filename>utils/parallel/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,3 @@
-
-TOP=../..
-ENABLE_SHELL_WRAPPERS = YES
-
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal.mk
-
-distclean maintainer-clean:
-	$(RM) -f runghc.cabal
-
-# XXX Need to make runhaskell somehow
-
+dir = utils/runghc
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/runghc/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -22,8 +22,6 @@
 
 module Main (main) where
 
-import Paths_runghc
-
 import Control.Exception
 import Data.Char
 import Data.List
@@ -85,7 +83,7 @@ parseRunGhcFlags = f mempty
 
 printVersion :: IO ()
 printVersion = do
-    putStrLn (&quot;runghc &quot; ++ showVersion version)
+    putStrLn (&quot;runghc &quot; ++ VERSION)
 
 printUsage :: IO ()
 printUsage = do</diff>
      <filename>utils/runghc/runghc.hs</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,7 @@
 #include &lt;sys/types.h&gt;
 #include &lt;fcntl.h&gt;
 #include &lt;errno.h&gt;
+#include &lt;utime.h&gt;
 
 int
 main(int argc, char** argv)</diff>
      <filename>utils/touchy/touchy.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,25 +1,3 @@
-TOP=../..
-include $(TOP)/mk/boilerplate.mk
-
-# Exclude for booting
-ifeq &quot;$(stage)&quot; &quot;2&quot;
-SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
-SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
-endif
-
-C_SRCS=unlit.c
-C_PROG=unlit
-SRC_CC_OPTS += -O
-
-# Get it over with!
-boot :: all
-
-#
-# Install unlit in lib/
-#
-INSTALL_LIBEXECS += $(C_PROG)
-
-BINDIST_EXTRAS += $(C_PROG)
-include $(TOP)/mk/bindist.mk
-
-include $(TOP)/mk/target.mk
+dir = utils/unlit
+TOP = ../..
+include $(TOP)/mk/sub-makefile.mk</diff>
      <filename>utils/unlit/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -90,10 +90,8 @@ static char *ofilename = NULL;
  * if noisy is not set.
  */
 
-complain(file, lin, what)
-char *file;
-char *what;
-int lin; {
+void complain(char *file, int lin, char *what)
+{
     if (noisy) {
         if (file)
             fprintf(stderr, &quot;%s &quot;, file);
@@ -102,7 +100,7 @@ int lin; {
     }
 }
 
-writeerror()
+void writeerror(void)
 {
     if (!strcmp(ofilename,&quot;-&quot;)) {
 	fprintf(stderr, CANNOTWRITESTDOUT);
@@ -112,9 +110,8 @@ writeerror()
     exit(1);
 }
 
-myputc(c, ostream)
-char c;
-FILE *ostream; {
+void myputc(char c, FILE *ostream)
+{
     if (putc(c,ostream) == EOF) {
 	writeerror();
     }	
@@ -247,10 +244,8 @@ FILE *istream, *ostream; {
  *  - there should be at least one DEFN line in a script.
  */
 
-unlit(file, istream, ostream)
-char *file;
-FILE *istream;
-FILE *ostream; {
+void unlit(char *file, FILE *istream, FILE *ostream)
+{
     line last, this=START;
     int  linesread=0;
     int  defnsread=0;
@@ -317,9 +312,8 @@ FILE *ostream; {
  * position to specify the standard input or the standard output respectively.
  */
 
-main(argc,argv)
-int argc;
-char **argv; {
+int main(int argc,char **argv)
+{
     FILE *istream, *ostream;
     char *file;
 </diff>
      <filename>utils/unlit/unlit.c</filename>
    </modified>
    <modified>
      <diff>@@ -58,6 +58,11 @@ if [ $no_clean -eq 0 ]; then
         make distclean
     fi
 
+    INSTDIR=`pwd`/inst
+    if [ &quot;$OSTYPE&quot; = &quot;cygwin&quot; ]
+    then
+        INSTDIR=`cygpath -m &quot;$INSTDIR&quot;`
+    fi
     case $OSTYPE in
         cygwin|msys) config_args=--build=i386-unknown-mingw32
             if [ -f c:/mingw/bin/gcc.exe ]
@@ -72,7 +77,7 @@ if [ $no_clean -eq 0 ]; then
     esac
 
     sh boot
-    ./configure &quot;--prefix=`pwd`/inst&quot; $config_args
+    ./configure --prefix=&quot;$INSTDIR&quot; $config_args
 fi
 
 thisdir=`utils/pwd/pwd forwardslash`</diff>
      <filename>validate</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>driver/ghc-pkg/Makefile</filename>
    </removed>
    <removed>
      <filename>driver/runhaskell/Makefile</filename>
    </removed>
    <removed>
      <filename>gmp/Makefile</filename>
    </removed>
    <removed>
      <filename>gmp/gmp-4.2.1-nodoc.tar.gz</filename>
    </removed>
    <removed>
      <filename>libffi/libffi-3.0.6.tar.gz</filename>
    </removed>
    <removed>
      <filename>libffi/libffi-autotools-update.patch</filename>
    </removed>
    <removed>
      <filename>libffi/libffi-dllize-3.0.6.patch</filename>
    </removed>
    <removed>
      <filename>libraries/Makefile</filename>
    </removed>
    <removed>
      <filename>mk/bindist.mk</filename>
    </removed>
    <removed>
      <filename>mk/boilerplate.mk</filename>
    </removed>
    <removed>
      <filename>mk/cabal-flags.mk</filename>
    </removed>
    <removed>
      <filename>mk/cabal.mk</filename>
    </removed>
    <removed>
      <filename>mk/install.mk</filename>
    </removed>
    <removed>
      <filename>mk/opts.mk</filename>
    </removed>
    <removed>
      <filename>mk/package.mk</filename>
    </removed>
    <removed>
      <filename>mk/paths.mk</filename>
    </removed>
    <removed>
      <filename>mk/recurse.mk</filename>
    </removed>
    <removed>
      <filename>mk/suffix.mk</filename>
    </removed>
    <removed>
      <filename>mk/target.mk</filename>
    </removed>
    <removed>
      <filename>utils/hpc/Hpc.hs</filename>
    </removed>
    <removed>
      <filename>utils/installPackage/Makefile</filename>
    </removed>
    <removed>
      <filename>utils/installPackage/installPackage.cabal</filename>
    </removed>
    <removed>
      <filename>utils/installPackage/installPackage.hs</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ca40a5a4c61f3624425ed4ff87800ee840a697e6</id>
    </parent>
  </parents>
  <author>
    <name>Ian Lynagh</name>
    <email>igloo@earth.li</email>
  </author>
  <url>http://github.com/ghc-hq/ghc/commit/09d89a7b69137353303283b093f43a4c873b1ae7</url>
  <id>09d89a7b69137353303283b093f43a4c873b1ae7</id>
  <committed-date>2009-04-26T04:42:15-07:00</committed-date>
  <authored-date>2009-04-26T04:42:15-07:00</authored-date>
  <message>GHC new build system megapatch</message>
  <tree>17beb47743ac5a3a1da046603718a4206f414ffc</tree>
  <committer>
    <name>Ian Lynagh</name>
    <email>igloo@earth.li</email>
  </committer>
</commit>
