diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..b5fce9ccdffca09799aaa26cb5de4af163ac7258
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:45:54 simonm Exp $
+
+TOP = .
+SUBDIRS = glafp-utils ghc
+include $(TOP)/mk/gen.mk
+include $(TOP)/mk/subdir.mk
+
+line = @echo "------------------------------------------------------------------------------"
+
+boot ::
+	@echo "Bootstrapping $(PROJECTNAME)..."
+	$(line)
+	@echo "Booting glafp-utils"
+	$(line)
+	@$(MAKE) -C glafp-utils boot
+
+	$(line)
+	@echo "Booting ghc"
+	$(line)
+	@$(MAKE) -C ghc boot
+
+	@echo "Done!"
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index 93b4582e5ad7a1bfd260ed5c7bed85d6b3058d21..0000000000000000000000000000000000000000
--- a/Makefile.in
+++ /dev/null
@@ -1,36 +0,0 @@
-# @configure_input@
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-CC = @CC@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-     
-LIBS = @LIBS@
-
-CFLAGS = -O
-LDFLAGS = -O
-     
-prefix = /usr/local
-exec_prefix = $(prefix)
-binprefix =
-manprefix =
-     
-bindir = $(exec_prefix)/bin
-libdir = $(exec_prefix)/lib
-mandir = $(prefix)/man/man1
-manext = 1
-     
-SHELL = /bin/sh
-
-Makefile: Makefile.in config.status
-	$(SHELL) config.status
-config.status: configure
-	$(SHELL) config.status --recheck
-configure: configure.in
-	cd $(srcdir) && autoconf < configure.in > configure.new
-	grep -v '# Generated automatically from' < configure.new > configure
-    
diff --git a/STARTUP.in b/STARTUP.in
deleted file mode 100644
index 0416b7fe5058e331af481a80512257b2aeb5602d..0000000000000000000000000000000000000000
--- a/STARTUP.in
+++ /dev/null
@@ -1,129 +0,0 @@
-#! /bin/sh
-#
-# die quickly if anything goes astray...
-set -e
-
-# figure out the absolute pathname of the "top" directory
-# (the one which has "mkworld", "nofib", "glafp-utils", etc., as subdirs)
-hardtop=`pwd`
-hardtop=`echo $hardtop | sed 's|^/tmp_mnt/|/|' | sed 's|^/export/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|'`
-echo ''
-echo "*** The top of your build tree is: $hardtop"
-
-case "$hardtop" in
-  # NeXTStep brain damage
-  /private/tmp_mnt/auto* )
-    echo '***'
-    echo '*** AAARRRGGGHHHH!!!'
-    echo '***'
-    echo '*** Stupid automounter (and pwd) will not tell me'
-    echo '*** the absolute pathname for the current directory.'
-    echo '*** Be sure to set TopDirPwd in mkworld/site-DEF.jm.'
-    echo '*** (Then it does not matter what this script decides.)'
-    echo '***'
-    ;;
-esac
-
-# make "mkworld", "literate", and "glafp-utils" (no special configuration)
-
-#	make all the Makefiles first
-
-for i in @DoingMkWorld@ @DoingGlaFpUtils@ @DoingLiterate@ ; do
-  if [ -d $i ] ; then
-    ( set -e;								\
-      cd $i ;								\
-      echo '' ;								\
-      echo "*** configuring $i ..." ;					\
-      @MakeCmd@ -f Makefile.BOOT BOOT_DEFINES="-P none -S std -DTopDirPwd=$hardtop";	\
-      echo '' ;								\
-      echo "*** making Makefiles in $i ..." ;				\
-      @MakeCmd@ Makefile ; 						\
-      @MakeCmd@ Makefiles 						\
-    )
-  else
-    echo warning: $i is not a directory -- doing nothing for it
-  fi
-done
-
-#	now make the dependencies and Real Stuff
-
-for i in @DoingMkWorld@ @DoingGlaFpUtils@ @DoingLiterate@ ; do
-  if [ -d $i ] ; then
-    ( set -e;								\
-      cd $i ;								\
-      echo '' ;								\
-      echo "*** making dependencies in $i ..." ;			\
-      @MakeCmd@ depend ;						\
-      echo '' ;								\
-      echo "*** making all in $i ..." ;					\
-      @MakeCmd@ all							\
-    )
-  else
-    echo warning: $i is not a directory -- doing nothing for it
-  fi
-done
-
-# OK, now make the \`real' Makefiles
-
-passed_in_setup="-S @MkWorldSetup@"
-
-for i in @DoingGHC@ @DoingHsLibs@ @DoingHappy@ @DoingHaggis@ @DoingNoFib@ EndOfList ; do
-  if [ $i = nofib ] ; then
-     setup=$passed_in_setup
-  else
-     setup=''
-  fi
-  if [ -d $i ] ; then
-    ( set -e;								\
-      cd $i ;								\
-      echo '' ;								\
-      echo "*** configuring $i ..." ;					\
-      @MakeCmd@ -f Makefile.BOOT BOOT_DEFINES="-P $i $setup -C mkworld -DTopDirPwd=$hardtop"; \
-      echo '' ;								\
-      echo "*** making Makefiles in $i ..." ;				\
-      @MakeCmd@ Makefile ; 						\
-      @MakeCmd@ Makefiles 						\
-    )
-  else
-    if [ $i != EndOfList ] ; then
-	echo warning: $i is not a directory -- doing nothing for it
-    fi
-  fi
-done
-
-# Finally, the dependencies
-
-for i in @DoingGHC@ @DoingHsLibs@ @DoingHappy@ @DoingHaggis@ @DoingNoFib@ EndOfList ; do
-  if [ -d $i ] ; then
-    ( set -e;								\
-      cd $i ;								\
-      echo '' ;								\
-      echo "*** making dependencies in $i ..." ;			\
-      @MakeCmd@ depend 							\
-    )
-  else
-    if [ $i != EndOfList ] ; then
-	echo warning: $i is not a directory -- doing nothing for it
-    fi
-  fi
-done
-
-echo ''
-echo '*******************************************************************'
-echo "* Looking good! All you should need to do now is...               *"
-echo '*                                                                 *'
-for i in @DoingGHC@ @DoingHsLibs@ @DoingHappy@ @DoingHaggis@ @DoingNoFib@ EndOfList ; do
-    if [ $i != EndOfList ] ; then
-	echo "        cd $i"
-	if [ $i = nofib ] ; then
-	    echo '        make all        # or...'
-	    echo '        make runtests'
-	else
-	    echo '        make all'
-	    echo '        make install   # if you are so inclined...'
-	fi
-    fi
-done
-echo '*                                                                 *'
-echo '*******************************************************************'
-exit 0
diff --git a/configure.in b/configure.in
index b8f227996f9c381277e4bd51000e3d8ec93af681..9ff21f66445bd1e07b1f0d5ae3abf7438a9db927 100644
--- a/configure.in
+++ b/configure.in
@@ -12,88 +12,60 @@ dnl * INITIAL SETUP, CHOICE OF PLATFORM(S)
 # Do "./configure --help" to see what flags are available.
 # (Better yet, read the documentation!)
 #
+AC_INIT(mk/platform.mk)
+
 # -------------------------------------------------------------------------
-AC_INIT(STARTUP.in)
-#
 # Prepare to generate the following header files
 #
-AC_CONFIG_HEADER(ghc/includes/config.h)
-# and  literate/config.h ???
-# ToDo !!!!!!!!!!!!!!!!
-#
+AC_CONFIG_HEADER(ghc/includes/config.h literate/lit-deatify/config.h)
+
 # No, we don't do `--srcdir'...
 if test x"$srcdir" != 'x.' ; then
     echo "This configuration does not support the \`--srcdir' option."
     exit 1
 fi
 
+hardtop=`pwd`
+hardtop=`echo $hardtop | sed 's|^/tmp_mnt/|/|' | sed 's|^/export/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|'`
+echo ''
+echo "*** The top of your build tree is: $hardtop"
+AC_SUBST(hardtop)
+
 # -------------------------------------------------------------------------
 dnl ** choose what blobs to build (ghc,hslibs,haggis,happy,nofib,????)
 
 # set to the name for the dir if doing it, otherwise empty
-DoingGHC='ghc'
 DoingHsLibs=''
 DoingNoFib=''
 DoingHappy=''
 DoingHaggis=''
-DoingLiterate=''
-# the following are not normally changed
-DoingMkWorld='mkworld'
-DoingGlaFpUtils='glafp-utils'
-
 MkWorldSetup='std'
 
-AC_ARG_ENABLE(ghc,
+AC_ARG_ENABLE(hslibs,
    [
 **********************************************************************
 * Configuration options for the Glasgow functional-programming tools *
 **********************************************************************
 
-First, select *which* of the tools you want to build,
-with --{enable,disable}-{ghc,hslibs,nofib,happy,haggis}.
-(The default is: only GHC (Glasgow Haskell compiler).)
+First, select *which* of the tools you want to build, with
+--{enable,disable}-{hslibs,nofib,happy,haggis}.  (Currently, you have to
+build ghc.)
 
-Second, you may set one of a few applies-in-all-cases options.
-For example, --with-tmpdir=/usr/tmp.
+Second, you may set one of a few applies-in-all-cases options.  For
+example, --with-tmpdir=/usr/tmp.
 
-Then you may set various options which are specifically for the
-tools you choose in step 1.  For GHC, perhaps --enable-concurrent.
-For NoFib, perhaps --enable-all-tests.  And so on.
+Then you may set various options which are specifically for the tools you
+choose in step 1.  For GHC, perhaps --enable-concurrent.  For NoFib,
+perhaps --enable-all-tests.  And so on.
 
-The rest of this message lists all of the configure options.  If the
-option is enabled by default, the message says how to disable it.  And
-vice versa.
+The rest of this message lists all of the configure options.  If the option
+is enabled by default, the message says how to disable it.  And vice versa.
 
-If you are confused, don't forget the installation documents that came
-with the software!
+If you are confused, don't forget the installation documents that came with
+the software!
 
 *******************************************************************
-** FOR SELECTING WHICH GLASGOW FP TOOLS TO BUILD:
-
---disable-ghc     do *not* build GHC as part of Glasgow FP tools],
-   [case "$enableval" in
-        yes) DoingGHC='ghc'
-             ;;
-        no)  DoingGHC=''
-             ;;
-        *)   echo "I don't understand this option: --enable-ghc=$enableval"
-             exit 1
-             ;;
-    esac])
-if test "xxx$DoingGHC" = 'xxxghc' -a \( ! -d ghc \) ; then
-    DoingGHC=''
-    echo 'Doing --disable-ghc, as there is no ghc directory'
-fi
-ghc_mkworld_site_ghc_jm='ghc/mkworld/site-ghc.jm'
-ghc_includes_platform_h='ghc/includes/platform.h'
-# duznae work: ghc_includes_config_h='ghc/includes/config.h'
-if test "xxx$DoingGHC" = 'xxx' ; then
-    ghc_mkworld_site_ghc_jm=''
-    ghc_includes_platform_h=''
-#   ghc_includes_config_h=''
-fi
-
-AC_ARG_ENABLE(hslibs,
+** FOR SELECTING WHICH GLASGOW FP TOOLS TO BUILD:]
    [--enable-hslibs   build suite of Haskell libraries],
    [case "$enableval" in
         yes) DoingHsLibs='hslibs'
@@ -108,10 +80,6 @@ if test "xxx$DoingHsLibs" = 'xxxhslibs' -a \( ! -d hslibs \) ; then
     DoingHsLibs=''
     echo 'Doing --disable-hslibs, as there is no hslibs directory'
 fi
-hslibs_mkworld_site_hslibs_jm='hslibs/mkworld/site-hslibs.jm'
-if test "xxx$DoingHsLibs" = 'xxx' ; then
-    hslibs_mkworld_site_hslibs_jm=''
-fi
 
 AC_ARG_ENABLE(nofib,
    [--enable-nofib    build NoFib suite as part of Glasgow FP tools],
@@ -128,10 +96,6 @@ if test "xxx$DoingNoFib" = 'xxxnofib' -a \( ! -d nofib \) ; then
     DoingNoFib=''
     echo 'Doing --disable-nofib, as there is no nofib directory'
 fi
-nofib_mkworld_site_nofib_jm='nofib/mkworld/site-nofib.jm'
-if test "xxx$DoingNoFib" = 'xxx' ; then
-    nofib_mkworld_site_nofib_jm=''
-fi
 
 AC_ARG_ENABLE(happy,
    [--enable-happy    build Happy parser-generator as part of Glasgow FP tools],
@@ -165,64 +129,10 @@ if test "xxx$DoingHaggis" = 'xxxhaggis' -a \( ! -d haggis \) ; then
     echo 'Doing --disable-haggis, as there is no haggis directory'
 fi
 
-AC_ARG_ENABLE(literate,
-   [
-The following three are \`for hackers only':
---disable-literate    do *not* build literate-programming stuff],
-   [case "$enableval" in
-        yes) DoingLiterate='literate'
-             ;;
-        no)  DoingLiterate=''
-             ;;
-        *)   echo "I don't understand this option: --enable-literate=$enableval"
-             exit 1
-             ;;
-    esac])
-if test "xxx$DoingLiterate" = 'xxxliterate' -a \( ! -d literate \) ; then
-    DoingLiterate=''
-    echo 'Doing --disable-literate, as there is no literate directory'
-fi
-
-AC_ARG_ENABLE(mkworld,
-   [--disable-mkworld     do *not* build \`mkworld' configuration stuff],
-   [case "$enableval" in
-        yes) DoingMkWorld='mkworld'
-             ;;
-        no)  DoingMkWorld=''
-             ;;
-        *)   echo "I don't understand this option: --enable-mkworld=$enableval"
-             exit 1
-             ;;
-    esac])
-if test "xxx$DoingMkWorld" = 'xxxmkworld' -a \( ! -d mkworld \) ; then
-    DoingMkWorld=''
-    echo 'Doing --disable-mkworld, as there is no mkworld directory'
-fi
-
-AC_ARG_ENABLE(glafp-utils,
-   [--disable-glafp-utils do *not* build \`glafp utilities'],
-   [case "$enableval" in
-        yes) DoingGlaFpUtils='glafp-utils'
-             ;;
-        no)  DoingGlaFpUtils=''
-             ;;
-        *)   echo "I don't understand this option: --enable-glafp-utils=$enableval"
-             exit 1
-             ;;
-    esac])
-if test "xxx$DoingGlaFpUtils" = 'xxxglafp-utils' -a \( ! -d glafp-utils \) ; then
-    DoingGlaFpUtils=''
-    echo 'Doing --disable-glafp-utils, as there is no glafp-utils directory'
-fi
-
-AC_SUBST(DoingGHC)
 AC_SUBST(DoingHsLibs)
 AC_SUBST(DoingNoFib)
 AC_SUBST(DoingHappy)
 AC_SUBST(DoingHaggis)
-AC_SUBST(DoingLiterate)
-AC_SUBST(DoingMkWorld)
-AC_SUBST(DoingGlaFpUtils)
 
 # -------------------------------------------------------------------------
 dnl ** choose host(/target/build) platform
@@ -726,19 +636,22 @@ AC_ARG_WITH(tmpdir,
 AC_SUBST(TmpDir)
 
 dnl ** possibly set a max heap for Haskell compilations
-# let the user specify a maximum heap to be used; the old
-# "I have a 64MB machine, why not use a 32MB heap?" thing.
-HcMaxHeapWasSet='NO'
-HcMaxHeap='0'
+HcMaxHeapFlag=''
 AC_ARG_WITH(max-heap,
    [
 --with-max-heap=<heap size, e.g., 32m> 
-	Do all Haskell compilations with a heap of this size.  (If
-	you've got it, flaunt it.)],
-   [HcMaxHeapWasSet='YES'
-    HcMaxHeap="$withval"])
-AC_SUBST(HcMaxHeapWasSet)
-AC_SUBST(HcMaxHeap)
+	Do all Haskell compilations with a heap of this size.],
+   [HcMaxHeapFlag="-H$withval"])
+AC_SUBST(HcMaxHeapFlag)
+
+dnl ** possibly set a max stack for Haskell compilations
+HcMaxStackFlag=''
+AC_ARG_WITH(max-stack,
+   [
+--with-max-stack=<stack size, e.g., 4m> 
+	Do all Haskell compilations with a stack of this size.],
+   [HcMaxStackFlag="-K$withval"])
+AC_SUBST(HcMaxStackFlag)
 
 dnl ** figure out about mkdependHS
 MkDependHSCmd='mkdependHS'
@@ -1273,14 +1186,8 @@ dnl as some seds (notably OSF) only allow 99 commands (!!!).
 dnl We will do the equivalent by a HACK further down.
 
 # -------------------------------------------------------------------------
-dnl
-dnl * `GHC' CONFIGURATION STUFF
+dnl GHC CONFIGURATION STUFF
 
-if test "xxx$DoingGHC" = 'xxxghc' ; then
-# a very big "if"!
-#
-#---------------------------------------------------------------
-#
 dnl ** which Haskell compiler to bootstrap GHC with?
 # Figure out what Haskell compiler(s) to use for booting
 #
@@ -1517,23 +1424,14 @@ AC_SUBST(GhcWithSockets)
 
 # Here, by HACK means, we dump all the Build_ info
 # into a file.  See comment above.
-rm -f ghc/mkworld/buildinfo.jm
-echo creating ghc/mkworld/buildinfo.jm
-cat > ghc/mkworld/buildinfo.jm <<EOF
-XCOMM ** DO NOT EDIT! **
-XCOMM This file is obliterated every time 'configure' is run!
-
-EOF
+rm -f ghc/mk/buildinfo.mk
+echo creating ghc/mk/buildinfo.mk
+touch ghc/mk/buildinfo.mk
 for xx in normal p t u mc mr mt mp mg 2s 1s du a b c d e f g h i j k l m n o A B ; do
     eval "yy=\$Build_$xx"
-    echo "#ifndef Build_$xx"     >> ghc/mkworld/buildinfo.jm
-    echo "#define Build_$xx $yy" >> ghc/mkworld/buildinfo.jm
-    echo "#endif"		 >> ghc/mkworld/buildinfo.jm
+    echo "Build_$xx = $yy" >> ghc/mk/buildinfo.mk
 done
 
-# here ends a very big if DoingGHC = 'ghc' ...
-fi
-
 # -------------------------------------------------------------------------
 dnl
 dnl * `HsLibs' CONFIGURATION STUFF
@@ -1593,20 +1491,19 @@ AC_SUBST(WithHsLibsHcType)
 
 # Here, by HACK means, we dump all the Build_ info
 # into a file.  See comment above.
-rm -f hslibs/mkworld/buildinfo.jm
-echo creating hslibs/mkworld/buildinfo.jm
-cat > hslibs/mkworld/buildinfo.jm <<EOF
-XCOMM ** DO NOT EDIT! **
-XCOMM This file is obliterated every time 'configure' is run!
+rm -f hslibs/mk/buildinfo.mk
+echo creating hslibs/mk/buildinfo.mk
+cat > hslibs/mk/buildinfo.mk <<EOF
+# ** DO NOT EDIT! **
+# This file is obliterated every time 'configure' is run!
 
 EOF
 for xx in normal p t u mc mr mt mp mg 2s 1s du a b c d e f g h i j k l m n o A B ; do
     eval "yy=\$Build_$xx"
-    echo "#ifndef Build_$xx"     >> hslibs/mkworld/buildinfo.jm
-    echo "#define Build_$xx $yy" >> hslibs/mkworld/buildinfo.jm
-    echo "#endif"		 >> hslibs/mkworld/buildinfo.jm
+    echo "Build_$xx = $yy" >> hslibs/mk/buildinfo.mk
 done
 
+
 # here ends a very big if DoingHsLibs = 'hslibs' ...
 fi
 #
@@ -1757,16 +1654,6 @@ fi
 #
 # -------------------------------------------------------------------------
 dnl
-dnl * `Literate' CONFIGURATION STUFF
-
-dnl if test "xxx$DoingLiterate" = 'xxxliterate' ; then
-dnl # a very big "if"!
-dnl 
-dnl # here ends a very big if DoingLiterate = 'literate' ...
-dnl fi
-#
-# -------------------------------------------------------------------------
-dnl
 dnl * `NoFib' CONFIGURATION STUFF
 
 if test "xxx$DoingNoFib" = 'xxxnofib' ; then
@@ -2009,28 +1896,24 @@ dnl AC_SUBST(IncludeParallelNoFibTests)
 
 # Here, by HACK means, we dump all the Include*NoFibTests info
 # into a file.  See comment above.
-rm -f nofib/mkworld/buildinfo.jm
-echo creating nofib/mkworld/buildinfo.jm
+rm -f nofib/mk/buildinfo.mk
+echo creating nofib/mk/buildinfo.mk
 cat > nofib/mkworld/buildinfo.jm <<EOF
-XCOMM ** DO NOT EDIT! **
-XCOMM This file is obliterated every time 'configure' is run!
+# ** DO NOT EDIT! **
+# This file is obliterated every time 'configure' is run!
 
 EOF
 for xx in Real Spectral Imaginary GHC_ONLY Specialise PRIVATE Parallel ; do
     eval "yy=\$Include${xx}NoFibTests"
-    echo "#ifndef Include${xx}NoFibTests"     >> nofib/mkworld/buildinfo.jm
-    echo "#define Include${xx}NoFibTests $yy" >> nofib/mkworld/buildinfo.jm
-    echo "#endif"			      >> nofib/mkworld/buildinfo.jm
+    echo "Include${xx}NoFibTests = $yy" >> nofib/mk/buildinfo.mk
 done
 
 # Here, by HACK means, we add all the Build_ info
 # into a file.  See comment above.
-
+ 
 for xx in normal p t u mc mr mt mp mg 2s 1s du a b c d e f g h i j k l m n o A B ; do
     eval "yy=\$Build_$xx"
-    echo "#ifndef Build_$xx"     >> nofib/mkworld/buildinfo.jm
-    echo "#define Build_$xx $yy" >> nofib/mkworld/buildinfo.jm
-    echo "#endif"		 >> nofib/mkworld/buildinfo.jm
+    echo "Build_$xx = $yy"     >> nofib/mk/buildinfo.mk
 done
 
 # here ends a very big if DoingNoFib = 'nofib' ...
@@ -2042,9 +1925,9 @@ dnl * extract non-header files with substitution (end)
 #
 AC_SUBST(MkWorldSetup)
 
-AC_OUTPUT(Makefile STARTUP mkworld/site.jm mkworld/platform.h mkworld/config.h $ghc_mkworld_site_ghc_jm $ghc_includes_platform_h $hslibs_mkworld_site_hslibs_jm $nofib_mkworld_site_nofib_jm)
+AC_OUTPUT(mk/platform.mk mk/utils.mk mk/install.mk ghc/mk/ghcconfig.mk ghc/includes/platform.h)
 
 echo '************************************************'
-echo '*** NOW DO: sh < STARTUP'
+echo '*** NOW DO: make boot; make all'
 echo '************************************************'
 exit 0
diff --git a/ghc/Jmakefile b/ghc/Jmakefile
deleted file mode 100644
index f6bae9dd7349b76c4f85ee3c8e97b3c62c227f58..0000000000000000000000000000000000000000
--- a/ghc/Jmakefile
+++ /dev/null
@@ -1,38 +0,0 @@
-#define IHaveSubdirs
-
-/* order in SUBDIRS is not supposed to be important but ...
-	"compiler" must be before "lib", because we use
-	the compiler just built to compile pieces of "lib".
-
-	"includes" also needs to be v early, to ensure that
-	GhcConstants.h is made before needed.
-
-	if we're building from .hc files, we do the libraries
-	first, then the compiler; otherwise the other way around
-
-*/
-#if HaskellCompilerType == HC_USE_HC_FILES
-#define __compiler_and_lib lib compiler
-#else
-#define __compiler_and_lib compiler lib
-#endif
-
-SUBDIRS = includes \
-	  utils \
-	  driver \
-	  runtime \
-	  docs \
-	  __compiler_and_lib
-
-/*OUT:	  parsers */
-
-#undef __compiler_and_lib
-
-/* "CONTRIB" is also a SUBDIR, but there is nothing to build there.
- */
-
-/* the standard "whoami" target will give the basic info. */
-/* this target adds to it. */
-whoami::
-	@echo using a \`$(BUILDPLATFORM)\' host to build a Haskell compiler to run on a
-	@echo \`$(HOSTPLATFORM)\' host that will generate \`C\' target code
diff --git a/ghc/Makefile b/ghc/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..effd0a9e7a4fc848cce39883eb32abb4763cb0f2
--- /dev/null
+++ b/ghc/Makefile
@@ -0,0 +1,79 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:46:26 simonm Exp $
+
+TOP=..
+include $(TOP)/ghc/mk/ghc.mk
+
+line = @echo "------------------------------------------------------------------------------"
+
+define BuildLibs
+$(line)
+@echo "Building Libraries"
+$(line)
+@$(MAKE) -C lib depend all
+endef
+
+define BuildCompiler
+$(line)
+@echo "Building Compiler"
+$(line)
+@$(MAKE) -C compiler depend all
+endef
+
+# dependencies:
+#	everything needs utils
+#	includes needs driver (for mkNativeGen.c)
+#	make depend except in {utils,driver} needs includes	
+#	RTS and compiler need includes
+
+boot ::
+	$(line)
+	@echo "Building Utils"
+	$(line)
+	@$(MAKE) -C utils depend all
+
+	$(line)
+	@echo "Building Driver"
+	$(line)
+	@$(MAKE) -C driver all
+
+	$(line)
+	@echo "Building Includes"
+	$(line)
+	@$(MAKE) -C includes all
+
+	$(line)
+	@echo "Building Runtime System"
+	$(line)
+	@$(MAKE) -C runtime depend all
+
+	$(line)
+	@echo "Building Docs"
+	$(line)
+	@$(MAKE) -C docs depend all
+
+ifeq ($(HaskellCompilerType), HC_USE_HC_FILES)
+	$(BuildLibs)
+	$(BuildCompiler)
+else
+	$(BuildCompiler)
+	$(BuildLibs)
+endif
+
+# "CONTRIB" is also a SUBDIR, but there is nothing to build there.
+SUBDIRS = utils driver includes runtime docs compiler lib
+
+# Make the required directories for install.
+
+install_dirs ::
+	$(MKDIRHIER) $(INSTBINDIR_GHC)
+	$(MKDIRHIER) $(INSTSCRIPTDIR_GHC)
+	$(MKDIRHIER) $(INSTLIBDIR_GHC)
+	$(MKDIRHIER) $(INSTLIBDIR_GHC)/includes
+	$(MKDIRHIER) $(INSTDATADIR_GHC)
+	$(MKDIRHIER) $(INSTDATADIR_GHC)/includes
+	$(MKDIRHIER) $(INSTDATADIR_GHC)/imports
+
+install :: install_dirs
+
+include $(TOP)/mk/subdir.mk
diff --git a/ghc/Makefile.BOOT b/ghc/Makefile.BOOT
deleted file mode 100644
index 72b7dbf17969a64fb1bbb71e6b69cfeeee655b15..0000000000000000000000000000000000000000
--- a/ghc/Makefile.BOOT
+++ /dev/null
@@ -1,59 +0,0 @@
-# hand-hacked Makefile to boot the "make world" process
-#---------------------------------------------------------------------
-
-# Platform-specific configuration stuff was read from: sun.cf
-
-SHELL = /bin/sh
-PATHSEP = /
-
-#******** NB: TOP setting
-TOP = ..
-CURRENT_DIR = ./ghc
-
-RM=rm -f
-MV=mv -f
-BOOTSTRAPCFLAGS =
-
-# Project identification -- name, version, and stuff
-
-PROJECTNAME      = Booting the Make World System
-PROJECTVERSION   = none
-PROJECTLABEL     = generic
-SETUPLABEL       = std
-
-PROJECTCONFIGDIR =
-
-###########################################################################
-# Configuration stuff (jmake, its friends and templates)
-
-JMKMF         = jmkmf_used_only_with_installed_utils
-JRESTOREDEPS  = $(JMAKESRC)/jrestoredeps
-JMAKE         = $(JMAKESRC)/jmake
-JMAKE_DEFINES =
-
-JMAKESRC = $(TOP)/mkworld
-
-JMAKE_CMD = $(NEWTOP)$(JMAKE) -I$(NEWTOP)$(JMAKESRC) $(BOOTSTRAPCFLAGS) -DTopDir=$(TOP) -DCurDir=$(CURRENT_DIR) $(BOOT_DEFINES)
-
-###########################################################################
-
-Makefile:: $(JMAKE)
-
-$(JMAKE):
-	@(cd $(JMAKESRC) && if [ -f Makefile ]; then \
-	echo "checking $@ in $(JMAKESRC) first..."; $(MAKE) all; else \
-	echo "bootstrapping $@ from Makefile.BOOT in $(JMAKESRC) first..."; \
-	$(MAKE) -f Makefile.BOOT BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \
-	echo "okay, continuing in $(CURRENT_DIR)")
-
-Makefile::
-	-@if [ -f Makefile ]; then \
-	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
-	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
-	else exit 0; fi
-	$(JMAKE_CMD)
-	$(JRESTOREDEPS)
-	@if cmp -s Makefile Makefile.bak; then $(RM) Makefile.bak ; else exit 0 ; fi
-	@chmod 444 Makefile
-	@echo ==== The new Makefile is for\: ====
-	@$(MAKE) whoami
diff --git a/ghc/compiler/Jmakefile b/ghc/compiler/Jmakefile
deleted file mode 100644
index 925f261c8a94934e243c50b2349ff1d88fdc1765..0000000000000000000000000000000000000000
--- a/ghc/compiler/Jmakefile
+++ /dev/null
@@ -1,920 +0,0 @@
-/* preliminaries */
-
-/* (only subdir is the test suite) */
-
-#if IncludeTestDirsInBuild == YES
-# define IHaveSubdirs
-
-# define __ghc_compiler_tests_dir tests
-#else
-# define __ghc_compiler_tests_dir /* nothing */
-#endif
-SUBDIRS = __ghc_compiler_tests_dir
-#undef __ghc_compiler_tests_dir
-
-#define NoAllTargetForSubdirs
-#define NoDocsTargetForSubdirs
-#define NoInstallDocsTargetForSubdirs
-#define NoDependTargetForSubdirs
-#define NoInstallTargetForSubdirs
-#define NoTagTargetForSubdirs
-
-/* Suffix rules: we do not use them much at all in GHC.
-   We need some magic stuff (from suffixes-GEN.ljm) for
-   the parser files.
-*/
-SuffixRules_flexish()
-SuffixRule_c_o()
-
-.SUFFIXES: .lhi
-.lhi.hi:
-	$(RM) $@
-	$(GHC_UNLIT) $< $@
-	@chmod 444 $@
-
-/* assume ALL source is in subdirectories one level below
-   they don't have Jmakefiles; this Jmakefile controls everything
-*/
-
-SUBDIR_LIST = \ /* here they are, colon separated (for mkdependHS) */
-utils:basicTypes:types:hsSyn:prelude:rename:typecheck:deSugar:coreSyn:specialise:simplCore:stranal:stgSyn:simplStg:codeGen:nativeGen:absCSyn:main:reader:profiling:deforest:parser
-
-#ifdef MainIncludeDir
-MAIN_INCLUDE_DIR=MainIncludeDir
-#else
-MAIN_INCLUDE_DIR=$(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
-#endif
-
-/* helps to find GhcConstants.h in codeGen/CgCompInfo.lhs */
-#ifdef CompInfoDir
-COMPINFO_DIR=CompInfoDir
-#else
-COMPINFO_DIR=$(TOP_PWD)/$(CURRENT_DIR)/codeGen
-#endif
-/* nativeGen, elsewhere */
-#ifdef NativeGenDir
-NATIVEGEN_DIR=NativeGenDir
-#else
-NATIVEGEN_DIR=$(TOP_PWD)/$(CURRENT_DIR)/nativeGen
-#endif
-
-/* in order-of-passes order, utility modules at the end */
-
-#define READERSRCS_HS	\
-parser/U_constr.hs	\
-parser/U_binding.hs	\
-parser/U_pbinding.hs	\
-parser/U_entidt.hs	\
-parser/U_list.hs	\
-parser/U_literal.hs	\
-parser/U_maybe.hs	\
-parser/U_either.hs	\
-parser/U_qid.hs		\
-parser/U_tree.hs 	\
-parser/U_ttype.hs
-
-#define hsp_library libhsp.a
-
-#define READERSRCS_LHS	\
-parser/UgenUtil.lhs	\
-parser/UgenAll.lhs	\
-reader/ReadPrefix.lhs	\
-\
-reader/PrefixSyn.lhs	\
-reader/PrefixToHs.lhs	\
-reader/RdrHsSyn.lhs	\
-\
-hsSyn/HsBinds.lhs  /* abstract Haskell syntax */ \
-hsSyn/HsCore.lhs \
-hsSyn/HsDecls.lhs \
-hsSyn/HsExpr.lhs \
-hsSyn/HsImpExp.lhs \
-hsSyn/HsLit.lhs \
-hsSyn/HsMatches.lhs \
-hsSyn/HsPat.lhs \
-hsSyn/HsPragmas.lhs \
-hsSyn/HsTypes.lhs \
-hsSyn/HsSyn.lhs
-
-#define NOT_SO_BASICSRCS_LHS 	\
-basicTypes/FieldLabel.lhs	\
-basicTypes/Id.lhs		\
-basicTypes/IdInfo.lhs		\
-basicTypes/IdUtils.lhs		\
-basicTypes/Literal.lhs		\
-basicTypes/Name.lhs 		\
-basicTypes/PprEnv.lhs		\
-basicTypes/PragmaInfo.lhs	\
-basicTypes/SrcLoc.lhs		\
-basicTypes/UniqSupply.lhs 	\
-basicTypes/Unique.lhs		\
-\
-types/Class.lhs			\
-types/Kind.lhs			\
-types/PprType.lhs		\
-types/TyCon.lhs			\
-types/TyVar.lhs			\
-types/Usage.lhs			\
-types/Type.lhs			\
-\
-specialise/SpecEnv.lhs
-
-#define RENAMERSRCS_HS \
-rename/ParseIface.hs
-
-#define RENAMERSRCS_LHS \
-rename/ParseUtils.lhs \
-rename/RnHsSyn.lhs \
-rename/RnMonad.lhs \
-rename/Rename.lhs \
-rename/RnNames.lhs \
-rename/RnSource.lhs \
-rename/RnBinds.lhs \
-rename/RnExpr.lhs \
-rename/RnIfaces.lhs \
-rename/RnUtils.lhs
-
-#define TCSRCS_LHS \
-typecheck/TcHsSyn.lhs \
-typecheck/GenSpecEtc.lhs \
-typecheck/Inst.lhs	\
-typecheck/TcBinds.lhs \
-typecheck/TcClassDcl.lhs \
-typecheck/TcDefaults.lhs \
-typecheck/TcDeriv.lhs \
-typecheck/TcExpr.lhs \
-typecheck/TcGenDeriv.lhs \
-typecheck/TcGRHSs.lhs \
-typecheck/TcIfaceSig.lhs \
-typecheck/TcInstDcls.lhs \
-typecheck/TcInstUtil.lhs \
-typecheck/TcMatches.lhs \
-typecheck/TcModule.lhs \
-typecheck/TcMonad.lhs \
-typecheck/TcEnv.lhs \
-typecheck/TcKind.lhs \
-typecheck/TcType.lhs \
-typecheck/TcMonoType.lhs \
-typecheck/TcPat.lhs \
-typecheck/TcSimplify.lhs \
-typecheck/TcTyClsDecls.lhs \
-typecheck/TcTyDecls.lhs \
-typecheck/Unify.lhs
-
-/*
-typecheck/TcPragmas.lhs \
-*/
-
-#define DSSRCS_LHS \
-deSugar/Desugar.lhs \
-deSugar/Match.lhs \
-deSugar/MatchCon.lhs \
-deSugar/MatchLit.lhs \
-deSugar/DsBinds.lhs \
-deSugar/DsCCall.lhs \
-deSugar/DsExpr.lhs \
-deSugar/DsGRHSs.lhs \
-deSugar/DsHsSyn.lhs \
-deSugar/DsListComp.lhs \
-deSugar/DsMonad.lhs \
-deSugar/DsUtils.lhs \
-\
-coreSyn/CoreLift.lhs \
-coreSyn/CoreLint.lhs
-
-#if GhcWithDeforester != YES
-#define __omit_deforester_flag -DOMIT_DEFORESTER=1
-#define DEFORESTER_SRCS_LHS /*none*/
-#else
-#define __omit_deforester_flag /*nope*/
-#define DEFORESTER_SRCS_LHS \
-deforest/DefSyn.lhs \
-deforest/Core2Def.lhs \
-deforest/Def2Core.lhs \
-deforest/Deforest.lhs \
-deforest/DefUtils.lhs \
-deforest/DefExpr.lhs \
-deforest/Cyclic.lhs \
-deforest/TreelessForm.lhs
-#endif /* GhcWithDeforester */
-
-#define SIMPL_SRCS_LHS \
-coreSyn/AnnCoreSyn.lhs \
-coreSyn/FreeVars.lhs \
-\
-specialise/Specialise.lhs \
-specialise/SpecUtils.lhs \
-\
-simplCore/SimplCase.lhs \
-simplCore/SimplEnv.lhs \
-simplCore/SimplMonad.lhs \
-simplCore/SimplPgm.lhs \
-simplCore/SimplUtils.lhs \
-simplCore/SimplVar.lhs \
-simplCore/Simplify.lhs \
-\
-simplCore/LiberateCase.lhs \
-\
-simplCore/ConFold.lhs \
-simplCore/FloatIn.lhs \
-simplCore/FloatOut.lhs \
-simplCore/SAT.lhs \
-simplCore/SATMonad.lhs \
-simplCore/SetLevels.lhs \
-simplCore/SimplCore.lhs \
-simplCore/OccurAnal.lhs \
-simplCore/FoldrBuildWW.lhs \
-simplCore/AnalFBWW.lhs \
-\
-stranal/StrictAnal.lhs \
-stranal/SaLib.lhs \
-stranal/SaAbsInt.lhs \
-stranal/WwLib.lhs \
-stranal/WorkWrap.lhs DEFORESTER_SRCS_LHS
-
-#define STG_SRCS_LHS \
-stgSyn/CoreToStg.lhs \
-stgSyn/StgSyn.lhs \
-stgSyn/StgUtils.lhs \
-stgSyn/StgLint.lhs \
-profiling/SCCfinal.lhs \
-\
-simplStg/SatStgRhs.lhs \
-simplStg/LambdaLift.lhs \
-simplStg/StgVarInfo.lhs \
-simplStg/UpdAnal.lhs \
-simplStg/StgStats.lhs \
-simplStg/StgSATMonad.lhs \
-simplStg/StgSAT.lhs \
-simplStg/SimplStg.lhs
-
-#define BACKSRCS_LHS \
-absCSyn/AbsCUtils.lhs \
-absCSyn/AbsCSyn.lhs \
-absCSyn/CLabel.lhs \
-absCSyn/Costs.lhs \
-absCSyn/HeapOffs.lhs \
-absCSyn/PprAbsC.lhs \
-\
-codeGen/CodeGen.lhs \
-codeGen/ClosureInfo.lhs \
-codeGen/SMRep.lhs \
-codeGen/CgConTbls.lhs \
-codeGen/CgMonad.lhs \
-codeGen/CgUsages.lhs \
-codeGen/CgHeapery.lhs \
-codeGen/CgStackery.lhs \
-codeGen/CgExpr.lhs \
-codeGen/CgCase.lhs \
-codeGen/CgLetNoEscape.lhs \
-codeGen/CgTailCall.lhs \
-codeGen/CgClosure.lhs \
-codeGen/CgCon.lhs \
-codeGen/CgRetConv.lhs \
-codeGen/CgBindery.lhs \
-codeGen/CgUpdate.lhs
-
-#if GhcWithNativeCodeGen == NO || GhcWithHscBuiltViaC == YES
-    /* if building via C, we *assume* that it is the
-       distributed C files, which do not have a native-code
-       generator in them
-    */
-# define __omit_ncg_maybe -DOMIT_NATIVE_CODEGEN=1
-# define NATIVEGEN_SRCS_LHS /*none*/
-#else
-# define __omit_ncg_maybe /*none*/
-
-# define NATIVEGEN_SRCS_LHS \
-nativeGen/AbsCStixGen.lhs \
-nativeGen/AsmCodeGen.lhs \
-nativeGen/AsmRegAlloc.lhs \
-nativeGen/MachCode.lhs \
-nativeGen/MachMisc.lhs \
-nativeGen/MachRegs.lhs \
-nativeGen/PprMach.lhs \
-nativeGen/RegAllocInfo.lhs \
-nativeGen/Stix.lhs \
-nativeGen/StixInfo.lhs \
-nativeGen/StixInteger.lhs \
-nativeGen/StixPrim.lhs \
-nativeGen/StixMacro.lhs
-#endif
-
-#define UTILSRCS_LHS \
-utils/Argv.lhs \
-utils/Bag.lhs \
-utils/BitSet.lhs \
-utils/CharSeq.lhs \
-utils/Digraph.lhs \
-utils/FiniteMap.lhs \
-utils/ListSetOps.lhs \
-utils/MatchEnv.lhs \
-utils/Maybes.lhs \
-utils/OrdList.lhs \
-utils/Outputable.lhs \
-utils/PprStyle.lhs \
-utils/Pretty.lhs \
-utils/SST.lhs \
-utils/UniqFM.lhs \
-utils/UniqSet.lhs \
-utils/Unpretty.lhs \
-utils/Util.lhs
-
-#define MAIN_SRCS_LHS \
-main/CmdLineOpts.lhs \
-main/ErrUtils.lhs \
-main/MkIface.lhs \
-main/Main.lhs
-
-#define VBASICSRCS_LHS \
-prelude/PrelMods.lhs \
-prelude/PrimRep.lhs \
-prelude/PrimOp.lhs \
-prelude/TysPrim.lhs \
-prelude/TysWiredIn.lhs \
-prelude/PrelVals.lhs \
-prelude/PrelInfo.lhs \
-\
-absCSyn/CStrings.lhs \
-codeGen/CgCompInfo.lhs \
-coreSyn/CoreSyn.lhs \
-coreSyn/CoreUnfold.lhs \
-coreSyn/CoreUtils.lhs \
-coreSyn/PprCore.lhs \
-profiling/CostCentre.lhs \
-simplCore/BinderInfo.lhs \
-simplCore/MagicUFs.lhs
-
-ALLSRCS_HS = READERSRCS_HS RENAMERSRCS_HS
-ALLSRCS_LHS = /* all pieces of the compiler */ \
-VBASICSRCS_LHS		\
-NOT_SO_BASICSRCS_LHS	\
-UTILSRCS_LHS 		\
-MAIN_SRCS_LHS 		\
-READERSRCS_LHS 		\
-RENAMERSRCS_LHS		\
-TCSRCS_LHS		\
-DSSRCS_LHS 		\
-SIMPL_SRCS_LHS 		\
-STG_SRCS_LHS 		\
-BACKSRCS_LHS NATIVEGEN_SRCS_LHS
-
-#if GhcBuilderVersion >= 200
-#  define loop_hi(f) CAT3(f,_1_3,.hi)
-#else
-#  define loop_hi(f) CAT2(f,.hi)
-#endif
-
-DELOOP_HIs =			\
-loop_hi(utils/Ubiq)		\
-loop_hi(absCSyn/AbsCLoop)	\
-loop_hi(basicTypes/IdLoop)	\
-loop_hi(codeGen/CgLoop1)	\
-loop_hi(codeGen/CgLoop2)	\
-loop_hi(deSugar/DsLoop)		\
-loop_hi(hsSyn/HsLoop)		\
-loop_hi(nativeGen/NcgLoop)	\
-loop_hi(prelude/PrelLoop)	\
-loop_hi(rename/RnLoop)		\
-loop_hi(simplCore/SmplLoop)	\
-loop_hi(typecheck/TcMLoop)	\
-loop_hi(typecheck/TcLoop)	\
-loop_hi(types/TyLoop)
-
-/*
-\
-*/
-/* NB: all the ones that may be empty (e.g., NATIVEGEN_SRCS_LHS)
-	need to be on the last line.
-*/
-
-/* should't use these fancy `make' things, really */
-ALLHCS =$(ALLSRCS_LHS:.lhs=.hc) $(ALLSRCS_HS:.hs=.hc)
-ALLOBJS=$(ALLSRCS_LHS:.lhs=.o)  $(ALLSRCS_HS:.hs=.o)
-ALLINTS=$(ALLSRCS_LHS:.lhs=.hi) $(ALLSRCS_HS:.hs=.hi)
-
-.PRECIOUS: $(ALLINTS)
-
-#if GhcWithHscDebug == YES
-# define use_DDEBUG -DDEBUG
-#else
-# define use_DDEBUG /*nothing*/
-#endif
-
-#if GhcWithHscOptimised == YES
-# if GhcBuilderVersion >= 200
-#  define __version_sensitive_flags -O -fshow-import-specs
-# else
-#  define __version_sensitive_flags -O -fshow-import-specs -fomit-derived-read -fomit-reexported-instances
-# endif
-#else
-# if GhcBuilderVersion >= 200
-#  define __version_sensitive_flags /*none*/
-# else
-#  define __version_sensitive_flags -fomit-derived-read -fomit-reexported-instances
-# endif
-#endif
-
-/* avoid use of AllProjectsHcOpts; then put in HcMaxHeapFlag "by hand" */
-#undef  AllProjectsHcOpts
-#define AllProjectsHcOpts /**/
-
-HC_OPTS = -cpp HcMaxHeapFlag -fhaskell-1.3 -fglasgow-exts -DCOMPILING_GHC \
-	-Rghc-timing -I. -i$(SUBDIR_LIST) \
-	use_DDEBUG __version_sensitive_flags __omit_ncg_maybe __omit_deforester_flag
-
-#undef __version_sensitive_flags
-#undef __omit_ncg_maybe
-#undef __omit_deforester_flag
-
-#if GhcWithHscBuiltViaC == YES /* not using a Haskell compiler */
-
-hcs:: $(ALLHCS)
-
-# if HaskellCompilerType == HC_USE_HC_FILES
-HC = $(GHC) /* uses the driver herein */
-# endif
-
-#endif /* using .hc files */
-
-/*
-    -DCOMPILING_GHC
-	Used when compiling GHC.  Some GHC utility modules are
-	*also* part of the GHC library.  There are a few bits
-	of those modules that only apply to GHC itself and
-	should not be in the library stuff.  We use this
-	CPP thing to isolate those bits.
-*/
-
-BuildPgmFromHaskellModules(hsc,$(ALLOBJS) parser/hsclink.o parser/hschooks.o,,libhsp.a)
-
-parser/hschooks.o : parser/hschooks.c
-	$(RM) $@
-	$(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC))
-InstallBinaryTarget(hsc,$(INSTLIBDIR_GHC))
-#endif
-
-/* set up for going either to .hc or to .o files */
-#if GhcWithHscBuiltViaC == YES
-
-/*OLD:SuffixRule_hc_o() */
-
-# if HaskellCompilerType == HC_USE_HC_FILES
-    /* if we do not, we never try to compile .lhs files;
-	we *blast* the macro we would normally use (HACK) (WDP 94/12)
-     */
-
-#  undef HaskellCompileWithSpecifiedFlags
-#  define HaskellCompileWithSpecifiedFlags(module,isuf,osuf,flags)	@@\
-module.osuf : module.isuf						\
-_body_HaskellCompileWithSpecifiedFlags(module.isuf,module.osuf,module,isuf,flags)
-
-#  define compile(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags(module,hc,o,-c,extra_flags)
-
-#  define compile_rec(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags_Recursive(module,hc,o,-c,extra_flags)
-
-# else /* we do! */
-
-#  define compile(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags(module,isuf,hc,-C,extra_flags)
-
-#  define compile_rec(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags_Recursive(module,isuf,hc,-C,extra_flags)
-
-# endif /* ... == HC_USE_HC_FILES */
-
-#else /* ! booting from C */
-
-# define compile(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags(module,isuf,o,-c,extra_flags)
-
-# define compile_rec(module,isuf,extra_flags) \
-HaskellCompileWithExtraFlags_Recursive(module,isuf,o,-c,extra_flags)
-
-#endif /* ! booting from C */
-
-#define if_ghc(x) x
-#if GhcBuilderVersion >= 26
-#  define if_ghc26(x) x
-#else
-#  define if_ghc26(x) /*nothing*/
-#endif
-
-/* OK, here we go: */
-
-rename/ParseIface.hs : rename/ParseIface.y
-	$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
-	happy -g rename/ParseIface.y
-	@chmod 444 rename/ParseIface.hs
-
-compile(absCSyn/AbsCUtils,lhs,)
-compile(absCSyn/CStrings,lhs,)
-compile(absCSyn/CLabel,lhs,)
-compile(absCSyn/Costs,lhs,)
-compile(absCSyn/HeapOffs,lhs,)
-compile(absCSyn/PprAbsC,lhs,)
-compile(absCSyn/AbsCSyn,lhs,if_ghc(-fno-omit-reexported-instances))
-
-compile(hsSyn/HsBinds,lhs,)
-compile(hsSyn/HsCore,lhs,)
-compile(hsSyn/HsDecls,lhs,)
-compile(hsSyn/HsExpr,lhs,if_ghc(-K2m))
-compile(hsSyn/HsImpExp,lhs,)
-compile(hsSyn/HsLit,lhs,)
-compile(hsSyn/HsMatches,lhs,)
-compile(hsSyn/HsPat,lhs,)
-compile(hsSyn/HsPragmas,lhs,)
-compile(hsSyn/HsTypes,lhs,)
-compile(hsSyn/HsSyn,lhs,if_ghc(-fno-omit-reexported-instances))
-
-compile(basicTypes/FieldLabel,lhs,)
-compile(basicTypes/Id,lhs,)
-compile(basicTypes/IdInfo,lhs,-K2m)
-compile(basicTypes/IdUtils,lhs,)
-compile(basicTypes/Literal,lhs,)
-compile(basicTypes/Name,lhs,)
-compile(basicTypes/PprEnv,lhs,)
-compile(basicTypes/PragmaInfo,lhs,)
-compile(basicTypes/SrcLoc,lhs,)
-compile(basicTypes/UniqSupply,lhs,)
-compile(basicTypes/Unique,lhs,)
-
-compile(codeGen/CgBindery,lhs,)
-compile(codeGen/CgCase,lhs,)
-compile(codeGen/CgClosure,lhs,)
-compile(codeGen/CgCompInfo,lhs,-I$(COMPINFO_DIR))
-compile(codeGen/CgCon,lhs,)
-compile(codeGen/CgConTbls,lhs,)
-compile(codeGen/CgExpr,lhs,)
-compile(codeGen/CgHeapery,lhs,)
-compile(codeGen/CgLetNoEscape,lhs,)
-compile(codeGen/CgMonad,lhs,)
-compile(codeGen/CgRetConv,lhs,)
-compile(codeGen/CgStackery,lhs,)
-compile(codeGen/CgTailCall,lhs,)
-compile(codeGen/CgUpdate,lhs,)
-compile(codeGen/CgUsages,lhs,)
-compile(codeGen/ClosureInfo,lhs,)
-compile(codeGen/CodeGen,lhs,)
-compile(codeGen/SMRep,lhs,)
-
-compile(coreSyn/AnnCoreSyn,lhs,if_ghc(-fno-omit-reexported-instances))
-compile(coreSyn/CoreUtils,lhs,)
-compile(coreSyn/CoreLift,lhs,)
-compile(coreSyn/CoreLint,lhs,)
-compile(coreSyn/CoreSyn,lhs,)
-compile(coreSyn/PprCore,lhs,)
-compile(coreSyn/CoreUnfold,lhs,)
-compile(coreSyn/FreeVars,lhs,)
-
-compile(deSugar/Desugar,lhs,)
-compile(deSugar/DsBinds,lhs,)
-compile(deSugar/DsCCall,lhs,)
-compile(deSugar/DsExpr,lhs,)
-compile(deSugar/DsGRHSs,lhs,)
-compile(deSugar/DsHsSyn,lhs,)
-compile(deSugar/DsListComp,lhs,)
-compile(deSugar/DsMonad,lhs,)
-compile(deSugar/DsUtils,lhs,)
-compile(deSugar/Match,lhs,)
-compile(deSugar/MatchCon,lhs,)
-compile(deSugar/MatchLit,lhs,)
-
-compile(main/CmdLineOpts,lhs,if_ghc(-fvia-C))
-compile(main/ErrUtils,lhs,)
-compile(main/Main,lhs,if_ghc(-fvia-C))
-compile(main/MkIface,lhs,)
-
-#if GhcWithNativeCodeGen == YES
-compile(nativeGen/AbsCStixGen,lhs,)
-compile(nativeGen/AsmCodeGen,lhs,-I$(COMPINFO_DIR))
-compile(nativeGen/AsmRegAlloc,lhs,-I$(COMPINFO_DIR))
-compile(nativeGen/MachCode,lhs,-I$(NATIVEGEN_DIR))
-compile(nativeGen/MachMisc,lhs,-I$(NATIVEGEN_DIR))
-compile(nativeGen/MachRegs,lhs,-I$(NATIVEGEN_DIR))
-compile(nativeGen/PprMach,lhs,-I$(NATIVEGEN_DIR) if_ghc(-K2m))
-compile(nativeGen/RegAllocInfo,lhs,-I$(NATIVEGEN_DIR))
-compile(nativeGen/Stix,lhs,)
-compile(nativeGen/StixInfo,lhs,)
-compile(nativeGen/StixInteger,lhs,)
-compile(nativeGen/StixMacro,lhs,)
-compile(nativeGen/StixPrim,lhs,)
-#endif
-
-compile(prelude/PrelInfo,lhs,)
-compile(prelude/PrelMods,lhs,)
-compile(prelude/PrelVals,lhs,)
-compile(prelude/PrimRep,lhs,-I$(COMPINFO_DIR))
-compile(prelude/PrimOp,lhs,-K3m -H10m)
-compile(prelude/TysPrim,lhs,)
-compile(prelude/TysWiredIn,lhs,)
-
-compile(profiling/SCCfinal,lhs,)
-compile(profiling/CostCentre,lhs,)
-
-compile(reader/PrefixSyn,lhs,)
-compile(reader/PrefixToHs,lhs,)
-compile(reader/ReadPrefix,lhs,if_ghc(-fvia-C -I$(COMPINFO_DIR) -Iparser '-#include"hspincl.h"'))
-compile(reader/RdrHsSyn,lhs,)
-
-compile(rename/ParseIface,hs,-Onot) /* sigh */
-compile(rename/ParseUtils,lhs,)
-compile(rename/RnHsSyn,lhs,)
-compile(rename/RnMonad,lhs,if_ghc(-fvia-C))
-compile(rename/Rename,lhs,)
-compile(rename/RnNames,lhs,)
-compile(rename/RnSource,lhs,-H12m)
-compile(rename/RnBinds,lhs,)
-compile(rename/RnExpr,lhs,)
-compile(rename/RnIfaces,lhs,)
-compile(rename/RnUtils,lhs,)
-
-compile(simplCore/BinderInfo,lhs,)
-compile(simplCore/ConFold,lhs,)
-compile(simplCore/FloatIn,lhs,)
-compile(simplCore/FloatOut,lhs,)
-compile(simplCore/LiberateCase,lhs,)
-compile(simplCore/MagicUFs,lhs,)
-compile(simplCore/OccurAnal,lhs,)
-
-compile(simplCore/AnalFBWW,lhs,)
-compile(simplCore/FoldrBuildWW,lhs,)
-
-compile(simplCore/SAT,lhs,)
-compile(simplCore/SATMonad,lhs,)
-compile(simplCore/SetLevels,lhs,)
-compile(simplCore/SimplCase,lhs,)
-compile(simplCore/SimplCore,lhs,)
-compile(simplCore/SimplEnv,lhs,)
-compile(simplCore/SimplMonad,lhs,)
-compile(simplCore/SimplPgm,lhs,)
-compile(simplCore/SimplUtils,lhs,)
-compile(simplCore/SimplVar,lhs,)
-compile(simplCore/Simplify,lhs,)
-
-compile(simplStg/SatStgRhs,lhs,)
-compile(simplStg/LambdaLift,lhs,)
-compile(simplStg/StgVarInfo,lhs,)
-compile(simplStg/UpdAnal,lhs,)
-compile(simplStg/StgStats,lhs,)
-compile(simplStg/StgSATMonad,lhs,)
-compile(simplStg/StgSAT,lhs,)
-compile(simplStg/SimplStg,lhs,)
-
-#if GhcWithDeforester == YES
-compile(deforest/Core2Def,lhs,)
-compile(deforest/Cyclic,lhs,)
-compile(deforest/Def2Core,lhs,)
-compile(deforest/DefExpr,lhs,)
-compile(deforest/DefSyn,lhs,)
-compile(deforest/DefUtils,lhs,)
-compile(deforest/Deforest,lhs,)
-compile(deforest/TreelessForm,lhs,)
-#endif
-
-compile(specialise/Specialise,lhs,-H12m if_ghc(-Onot)) /* -Onot for compile-space reasons */
-compile(specialise/SpecEnv,lhs,)
-compile(specialise/SpecUtils,lhs,)
-
-compile(stgSyn/CoreToStg,lhs,)
-compile(stgSyn/StgUtils,lhs,)
-compile(stgSyn/StgLint,lhs,)
-compile(stgSyn/StgSyn,lhs,if_ghc(-fno-omit-reexported-instances))
-
-compile(stranal/SaAbsInt,lhs,)
-compile(stranal/SaLib,lhs,)
-compile(stranal/StrictAnal,lhs,)
-compile(stranal/WorkWrap,lhs,)
-compile(stranal/WwLib,lhs,)
-
-compile(typecheck/GenSpecEtc,lhs,)
-compile(typecheck/Inst,lhs,)
-compile(typecheck/TcHsSyn,lhs,)
-compile(typecheck/TcBinds,lhs,)
-compile(typecheck/TcClassDcl,lhs,)
-compile(typecheck/TcDefaults,lhs,)
-compile(typecheck/TcDeriv,lhs,)
-compile(typecheck/TcExpr,lhs,)
-compile(typecheck/TcGRHSs,lhs,)
-compile(typecheck/TcGenDeriv,lhs,)
-compile(typecheck/TcIfaceSig,lhs,)
-compile(typecheck/TcInstDcls,lhs,)
-compile(typecheck/TcInstUtil,lhs,)
-compile(typecheck/TcMatches,lhs,)
-compile(typecheck/TcModule,lhs,)
-compile(typecheck/TcMonad,lhs,if_ghc(-fvia-C))
-compile(typecheck/TcKind,lhs,)
-compile(typecheck/TcType,lhs,)
-compile(typecheck/TcEnv,lhs,)
-compile(typecheck/TcMonoType,lhs,)
-compile(typecheck/TcPat,lhs,)
-/*compile(typecheck/TcPragmas,lhs,)*/
-compile(typecheck/TcSimplify,lhs,)
-compile(typecheck/TcTyClsDecls,lhs,)
-compile(typecheck/TcTyDecls,lhs,)
-compile(typecheck/Unify,lhs,)
-
-compile(types/Class,lhs,)
-compile(types/Kind,lhs,)
-compile(types/PprType,lhs,if_ghc26(-Onot)) /* avoid a 0.26 bug */
-compile(types/TyCon,lhs,)
-compile(types/TyVar,lhs,)
-compile(types/Usage,lhs,)
-compile(types/Type,lhs,)
-
-compile(utils/Argv,lhs,if_ghc(-fvia-C))
-compile(utils/Bag,lhs,)
-compile(utils/BitSet,lhs,if_ghc26(-monly-4-regs))
-compile(utils/CharSeq,lhs,if_ghc(-fvia-C)) /* uses stg_putc */
-compile(utils/Digraph,lhs,)
-compile(utils/FiniteMap,lhs,)
-compile(utils/ListSetOps,lhs,)
-compile(utils/Maybes,lhs,)
-compile(utils/OrdList,lhs,)
-compile(utils/Outputable,lhs,)
-compile(utils/PprStyle,lhs,)
-compile(utils/Pretty,lhs,)
-compile(utils/SST,lhs,if_ghc(-fvia-C))
-compile(utils/UniqFM,lhs,)
-compile(utils/UniqSet,lhs,)
-compile(utils/Unpretty,lhs,)
-compile(utils/MatchEnv,lhs,)
-compile(utils/Util,lhs,)
-
-/* for convenience in cross-compiling */
-objs:: $(ALLOBJS)
-
-/* *** parser ************************************************* */
-
-YACC_OPTS = -d
-CC_OPTS = -Iparser -I. -I$(COMPINFO_DIR) /*-DUGEN_DEBUG=1*/ /*-DHSP_DEBUG=1*/
-
-/* add to these on the command line with, e.g., EXTRA_YACC_OPTS=-v */
-
-CPP_DEFINES = $(D_DEBUG)
-
-HSP_SRCS_C =    parser/constr.c		\
-		parser/binding.c	\
-		parser/pbinding.c	\
-		parser/entidt.c		\
-		parser/hslexer.c	\
-		parser/hsparser.tab.c	\
-		parser/id.c		\
-		parser/infix.c		\
-		parser/list.c		\
-		parser/literal.c	\
-		parser/maybe.c		\
-		parser/either.c		\
-		parser/qid.c		\
-		parser/syntax.c		\
-		parser/tree.c		\
-		parser/ttype.c		\
-		parser/type2context.c	\
-		parser/util.c
-
-HSP_OBJS_O =    parser/constr.o		\
-		parser/binding.o	\
-		parser/pbinding.o	\
-		parser/entidt.o		\
-		parser/hslexer.o	\
-		parser/hsparser.tab.o	\
-		parser/id.o		\
-		parser/infix.o		\
-		parser/list.o		\
-		parser/literal.o	\
-		parser/maybe.o		\
-		parser/either.o		\
-		parser/qid.o		\
-		parser/syntax.o		\
-		parser/tree.o		\
-		parser/ttype.o		\
-		parser/type2context.o	\
-		parser/util.o
-
-/* this is for etags */
-REAL_HSP_SRCS_C = parser/main.c 	\
-		parser/hschooks.c	\
-		parser/hsclink.c	\
-		parser/id.c 		\
-		parser/util.c 		\
-		parser/syntax.c 	\
-		parser/type2context.c 	\
-		parser/infix.c 		\
-		parser/printtree.c
-
-UgenNeededHere(all depend)
-
-/* Most hsp files are in libhsp.a, so we can either make
-   a standalone parser, or incorporate the files into
-   the hsc compiler directly (WDP 94/10)
-*/
-NormalLibraryTarget(hsp,$(HSP_OBJS_O))
-
-/* We need the hsp program for hstags to work! */
-/* BuildPgmFromCFiles(hsp,parser/printtree.o parser/main.o,,libhsp.a) */
-
-#if DoInstallGHCSystem == YES
-/* MakeDirectories(install, $(INSTLIBDIR_GHC)) */
-/* InstallBinaryTarget(hsp,$(INSTLIBDIR_GHC)) */
-#endif /* DoInstall... */
-
-YaccRunWithExpectMsg(parser/hsparser,12,0)
-
-parser/hslexer.o : parser/hslexer.c parser/hsparser.tab.h
-	$(RM) $@
-	$(CC) $(CFLAGS) -c $<
-	@if [ \( $(@D) != '.' \) -a \( $(@D) != './' \) ] ; then echo mv $(@F) $@ ; mv $(@F) $@ ; else exit 0 ;	fi
-
-UgenTarget(parser,constr)
-UgenTarget(parser,binding)
-UgenTarget(parser,pbinding)
-UgenTarget(parser,entidt)
-UgenTarget(parser,list)
-UgenTarget(parser,literal)
-UgenTarget(parser,maybe)
-UgenTarget(parser,either)
-UgenTarget(parser,qid)
-UgenTarget(parser,tree)
-UgenTarget(parser,ttype)
-
-UGENS_C = parser/constr.c	\
-	parser/binding.c	\
-	parser/pbinding.c	\
-	parser/entidt.c		\
-	parser/literal.c	\
-	parser/list.c		\
-	parser/maybe.c		\
-	parser/either.c		\
-	parser/qid.c		\
-	parser/tree.c		\
-	parser/ttype.c
-
-/* Putting the -#include"hspincl.h" option into the
-   PARSER_HS_OPTS line really does not work (it depends
-   on the 'make' that you use).
-*/
-PARSER_HS_OPTS = if_ghc(-fvia-C -I$(COMPINFO_DIR) -Iparser)
-
-compile(parser/UgenAll,lhs,if_ghc(-fvia-C))
-compile(parser/UgenUtil,lhs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_constr,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_binding,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_pbinding,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_entidt,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_list,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_literal,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_maybe,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_either,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_qid,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_tree,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-compile(parser/U_ttype,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
-
-/* finished with local macros */
-#undef compile
-#undef compile_rec
-#undef if_ghc
-
-/* *** misc *************************************************** */
-
-DEPSRCS = $(ALLSRCS_LHS) $(ALLSRCS_HS)
-
-#if GhcBuilderVersion < 200
-/* this will go away soon enough... (once 1.3 is settled in) */
-MKDEPENDHS = mkdependHS-1.2
-#endif
-
-#if GhcWithHscBuiltViaC == NO
-MKDEPENDHS_OPTS= -I$(MAIN_INCLUDE_DIR) -I$(COMPINFO_DIR) -x HsVersions.h
-#else /* booting from .hc */
-MKDEPENDHS_OPTS= -o .hc -I$(MAIN_INCLUDE_DIR) -I$(COMPINFO_DIR)  -x HsVersions.h
-#endif /* booting from .hc files */
-
-#if HaskellCompilerType != HC_USE_HC_FILES
-    /* otherwise, the dependencies jeopardize our .hc files --
-	which are all we have! */
-depend :: $(DELOOP_HIs)
-HaskellDependTarget( $(DEPSRCS) )
-#endif
-
-ExtraStuffToClean( $(ALLOBJS) $(HSP_OBJS_O) )
-#if GhcWithHscBuiltViaC == YES
-ExtraStuffToClean( $(ALLHCS) )
-#endif
-ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) )
-
-ClearTagsFile()
-HsTagsTarget( $(ALLSRCS_LHS) )
-HSTAGS_OPTS = $(HC_OPTS) -I$(MAIN_INCLUDE_DIR)
-
-/* count the number of lines in the source files */
-count_lines ::
-	./count_lines $(ALLSRCS_LHS) $(ALLSRCS_HS)
-
-/* accumulate similar info about the sizes of object files */
-count_bytes ::
-	./count_bytes $(ALLSRCS_LHS) $(ALLSRCS_HS)
diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..bb458bade49a1c741e6bbd8a5b17deee6b36e895
--- /dev/null
+++ b/ghc/compiler/Makefile
@@ -0,0 +1,223 @@
+# -----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:46:32 simonm Exp $
+
+TOP = ../..
+FlexSuffixRules = YES
+YaccSuffixRules = YES
+SuffixRule_WantStdOnes = NO
+include $(TOP)/ghc/mk/ghc.mk
+
+# Problem: don't know whether GhcWithHscBuiltViaC until now, so we have
+# to re-include rules.mk to get the correct suffix rules.
+
+FlexSuffixRules =
+YaccSuffixRules =
+ifeq ($(GhcWithHscBuiltViaC),YES)
+  HC = $(GHC)
+  SuffixRule_hc_o = YES
+else
+  HaskellSuffixRules = YES
+endif
+include $(TOP)/mk/rules.mk
+
+#-----------------------------------------------------------------------------
+# make libhsp.a
+
+YFLAGS = -d
+CFLAGS = -Iparser -I. -IcodeGen
+ARCHIVE = libhsp.a
+DESTDIR =  $(INSTLIBDIR_GHC)
+UGN = $(wildcard parser/*.ugn)
+UGNC = $(patsubst %.ugn, %.c, $(UGN))
+UGNH = $(patsubst %.ugn, %.h, $(UGN))
+UGNHS = $(patsubst parser/%.ugn, parser/U_%.hs, $(UGN))
+LIBOBJS = \
+  $(patsubst %.c, %.o, $(UGNC)) parser/hslexer.o parser/hsparser.tab.o \
+  parser/id.o parser/infix.o parser/syntax.o parser/type2context.o \
+  parser/util.o
+
+parser/%.h parser/%.c parser/U_%.hs : parser/%.ugn
+	@$(RM) $@ parser/$*.hs parser/U_$*.hs parser/$*.h
+	$(UGEN) $< || $(RM) parser/$*.h parser/$*.hs
+	@$(MV) -f parser/$*.hs parser/U_$*.hs
+	@chmod 444 parser/$*.h parser/U_$*.hs
+
+parser/%.o : parser/%.c $(UGNH)
+	@$(RM) $@
+	$(CC) $(CFLAGS) -c $< -o $@
+
+clean ::
+	$(RM) parser/hslexer.c parser/hsparser.tab.h parser/hsparser.tab.c
+
+parser/hslexer.o : parser/hslexer.c parser/hsparser.tab.h
+
+include $(TOP)/mk/lib.mk
+
+#-----------------------------------------------------------------------------
+
+ifeq ($(IncludeTestDirsInBuild),YES)
+  SUBDIRS = tests
+endif
+
+ifeq ($(Ghc2_0),YES)
+  %.hi : %_1_3.lhi
+	$(RM) $@
+	$(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
+	@chmod 444 $@
+else
+  %.hi : %.lhi
+	$(RM) $@
+	$(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
+	@chmod 444 $@
+endif
+
+DIRS = \
+  utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
+  specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
+  reader profiling parser
+
+# -----------------------------------------------------------------------------
+# optional directories
+
+ifeq ($(GhcWithDeforester),YES)
+  DIRS += deforest
+endif
+
+ifeq ($(GhcWithNativeCodeGen),YES)
+  DIRS += nativeGen
+else
+  ifeq ($(GhcWithHscBuiltViaC),YES)
+    # If building via C, we *assume* that it is the distributed C files,
+    # which do not have a native-code generator in them
+  else
+    DIRS += nativeGen
+  endif
+endif
+
+# -----------------------------------------------------------------------------
+# wildcard to get the lists of sources/objects
+
+INCLUDEDIRS = $(foreach dir,$(DIRS),-i$(dir))
+SRCS = \
+  $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs)) \
+  $(UGNHS) rename/ParseIface.hs
+LOOPS = $(patsubst %.lhi, %.hi, $(wildcard */*.lhi))
+HCS = $(patsubst %.hs, %.hc, $(patsubst %.lhs, %.hc, $(SRCS)))
+OBJS = \
+  $(patsubst %.hc, %.o, $(HCS)) rename/ParseIface.o \
+  parser/hsclink.o parser/hschooks.o libhsp.a
+
+# -----------------------------------------------------------------------------
+# options for the Haskell compiler
+
+MAKEFLAGS += --no-builtin-rules
+
+HC_OPTS += \
+  -cpp $(HcMaxHeapFlag) $(HcMaxStackFlag) -fhaskell-1.3 \
+  -fglasgow-exts -DCOMPILING_GHC -Rghc-timing -I. -IcodeGen \
+  -InativeGen -Iparser $(INCLUDEDIRS)
+
+# expect 12 shift/reduce conflicts and 0 reduce/reduce conflicts
+
+ifeq ($(GhcWithHscDebug),YES)
+  HC_OPTS += -DDEBUG
+  CFLAGS += -DDEBUG
+endif
+
+ifneq ($(Ghc2_0),YES)
+  HC_OPTS += -fomit-derived-read -fomit-reexported-instances
+endif
+
+ifeq ($(GhcWithHscOptimised),YES)
+  HC_OPTS += -O -fshow-import-specs
+endif
+
+ifeq ($(GhcWithDeforester),NO)
+  HC_OPTS += -DOMIT_DEFORESTER
+endif
+
+# ----------------------------------------------------------------------------
+
+all :: hsc libhsp.a
+
+hsc : $(OBJS)
+	$(HC) $(HC_OPTS) -o $@ $^
+
+parser/hschooks.o : parser/hschooks.c
+	@$(RM) $@
+	$(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
+
+rename/ParseIface.hs : rename/ParseIface.y
+	@$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
+	happy -g rename/ParseIface.y
+	@chmod 444 rename/ParseIface.hs
+
+# ----------------------------------------------------------------------------
+# Special flags for particular modules
+
+absCSyn/AbsCSyn_flags 		= -fno-omit-reexported-instances
+hsSyn/HsExpr_flags 		= -K2m
+hsSyn/HsSyn_flags 		= -fno-omit-reexported-instances
+main/Main_flags 		= -fvia-C
+basicTypes/IdInfo_flags 	= -K2m
+main/CmdLineOpts_flags 		= -fvia-C
+coreSyn/AnnCoreSyn_flags 	= -fno-omit-reexported-instances
+nativeGen/PprMach_flags 	= -K2m
+parser/UgenAll_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/UgenUtil_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_constr_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_binding_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_pbinding_flags 	= -fvia-C '-\#include"hspincl.h"'
+parser/U_entidt_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_list_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_literal_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_maybe_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_either_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_qid_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_tree_flags 		= -fvia-C '-\#include"hspincl.h"'
+parser/U_ttype_flags 		= -fvia-C '-\#include"hspincl.h"'
+prelude/PrimOp_flags 		= -K3m
+reader/ReadPrefix_flags 	= -fvia-C '-\#include"hspincl.h"'
+rename/ParseIface_flags 	= -Onot -H16m
+rename/RnMonad_flags 		= -fvia-C
+rename/RnSource_flags		= -H12m
+rename/RnIfaces_flags		= -H8m
+rename/RnNames_flags		= -H12m
+specialise/Specialise_flags 	= -Onot -H12m
+stgSyn/StgSyn_flags 		= -fno-omit-reexported-instances
+typecheck/TcMonad_flags 	= -fvia-C
+typecheck/TcGenDeriv_flags	= -H10m
+typecheck/TcExpr_flags		= -H10m
+utils/Argv_flags 		= -fvia-C
+utils/CharSeq_flags 		= -fvia-C
+utils/SST_flags 		= -fvia-C
+
+#-----------------------------------------------------------------------------
+# make depend, clean, tags and install
+
+MKDEPENDHSFLAGS = -f .depend -I../includes -x HsVersions.h
+ifeq ($(GhcWithDeforester),NO)
+  MKDEPENDHSFLAGS += -DOMIT_DEFORESTER
+endif
+
+ifeq ($(GhcWithHscBuiltViaC),YES)
+  MKDEPENDHSFLAGS += -o .hc
+else
+  HS_DEP_SRCS = $(SRCS) # should add $(LOOPS) ?
+  include $(TOP)/mk/hsdepend.mk
+endif
+
+clean ::
+	$(RM) */*.o */*.hi $(UGNC) $(UGNH) $(UGNHS)
+	$(RM) rename/ParseIface.hs
+
+veryclean ::
+	$(RM) */*.hc
+
+tags ::
+	@$(RM) TAGS
+	@touch TAGS
+	$(HSTAGS) -I../includes $(HSTAGSFLAGS) $(SRCS)
+
+install ::
+	$(INSTALL) $(INSTBINFLAGS) hsc $(INSTLIBDIR_GHC)
diff --git a/ghc/compiler/simplCore/SimplCore.lhs b/ghc/compiler/simplCore/SimplCore.lhs
index 0d3c544c4106a00d36759f1d9847970a0d285cf1..1de8ab9daafd44ef0a3f052312903257fb8e5339 100644
--- a/ghc/compiler/simplCore/SimplCore.lhs
+++ b/ghc/compiler/simplCore/SimplCore.lhs
@@ -66,7 +66,7 @@ import Unique		( Unique{-instance Eq-} )
 import UniqSupply	( splitUniqSupply )
 import Util		( panic{-ToDo:rm-} )
 
-#if ! OMIT_DEFORESTER
+#ifndef OMIT_DEFORESTER
 import Deforest		( deforestProgram )
 import DefUtils		( deforestable )
 #endif
diff --git a/ghc/docs/Jmakefile b/ghc/docs/Jmakefile
deleted file mode 100644
index ca56ede272926f4335877c13b7fe749546449f32..0000000000000000000000000000000000000000
--- a/ghc/docs/Jmakefile
+++ /dev/null
@@ -1,13 +0,0 @@
-#define IHaveSubdirs
-
-/* just documents here */
-#define NoAllTargetForSubdirs
-#define NoDependTargetForSubdirs
-#define NoRunTestsTargetForSubdirs
-#define NoInstallTargetForSubdirs
-#define NoTagTargetForSubdirs
-
-SUBDIRS = users_guide 		\
-	  install_guide 	\
-	  release_notes		\
-	  state_interface
diff --git a/ghc/docs/Makefile b/ghc/docs/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..f9d5e0c81e91163e52e4de6a01bf859f1c20706e
--- /dev/null
+++ b/ghc/docs/Makefile
@@ -0,0 +1,6 @@
+TOP = ../..
+include $(TOP)/ghc/mk/ghc.mk
+
+SUBDIRS = users_guide install_guide release_notes state_interface
+
+include $(TOP)/mk/subdir.mk
diff --git a/ghc/docs/install_guide/Jmakefile b/ghc/docs/install_guide/Jmakefile
deleted file mode 100644
index bf16d96738a395dcacedf4b7d50a6d70c40eea89..0000000000000000000000000000000000000000
--- a/ghc/docs/install_guide/Jmakefile
+++ /dev/null
@@ -1,3 +0,0 @@
-DocProcessingSuffixRules()
-
-LitDocRootTarget(installing,lit)
diff --git a/ghc/docs/install_guide/Makefile b/ghc/docs/install_guide/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..d897cc6f9cf4d4002eca17062b7baa487856f7d9
--- /dev/null
+++ b/ghc/docs/install_guide/Makefile
@@ -0,0 +1,5 @@
+TOP = ../../..
+LiterateSuffixRules = YES
+DocProcessingSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+#TARGETS = installing.texi installing.dvi
diff --git a/ghc/docs/release_notes/Jmakefile b/ghc/docs/release_notes/Jmakefile
deleted file mode 100644
index 6b696249f2ed435612275330b4e20867d56ac154..0000000000000000000000000000000000000000
--- a/ghc/docs/release_notes/Jmakefile
+++ /dev/null
@@ -1,10 +0,0 @@
-/* there are rules to make this piece of "the book"
- * as a standalone document,
- * but nothing to "install" it
- */
-
-LiterateSuffixRules()
-DocProcessingSuffixRules()
-
-/* no space between the two args! */
-LitDocRootTarget(release,lit)
diff --git a/ghc/docs/release_notes/Makefile b/ghc/docs/release_notes/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..49d154e4a2bbad9a1b970179ba73a188f712a356
--- /dev/null
+++ b/ghc/docs/release_notes/Makefile
@@ -0,0 +1,6 @@
+TOP = ../../..
+LiterateSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+#DocProcessingSuffixRules()
+#LitDocRootTarget(release,lit)
diff --git a/ghc/docs/state_interface/Jmakefile b/ghc/docs/state_interface/Makefile
similarity index 58%
rename from ghc/docs/state_interface/Jmakefile
rename to ghc/docs/state_interface/Makefile
index 08be0d0a7022734d3b52e1b41a639b92955d001c..c1ab89541e43ac8c698f2e422ed9a59e00fe6867 100644
--- a/ghc/docs/state_interface/Jmakefile
+++ b/ghc/docs/state_interface/Makefile
@@ -1,7 +1,9 @@
+TOP = ../../..
+include $(TOP)/ghc/mk/ghc.mk
+
 state-interface.dvi : state-interface.tex
-	$(RM) state-interface.dvi
-	latex state-interface.tex
+	$(LATEX) state-interface.tex
 
 state-interface.tex : state-interface.verb
-	$(RM) state-interface.tex
+	@$(RM) state-interface.tex
 	expand state-interface.verb | verbatim > state-interface.tex
diff --git a/ghc/docs/users_guide/Jmakefile b/ghc/docs/users_guide/Jmakefile
deleted file mode 100644
index e2fa72bd5d41d010ba3a5529eac061e5ca9eedfe..0000000000000000000000000000000000000000
--- a/ghc/docs/users_guide/Jmakefile
+++ /dev/null
@@ -1,6 +0,0 @@
-LiterateSuffixRules()
-DocProcessingSuffixRules()
-
-/* no space between the args! */
-/*LitDocRootTarget(profiling,lit)*/
-LitDocRootTarget(user,lit)
diff --git a/ghc/docs/users_guide/Makefile b/ghc/docs/users_guide/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..005ab541b8ae8886424b43fc84b9a3b1f03a0b00
--- /dev/null
+++ b/ghc/docs/users_guide/Makefile
@@ -0,0 +1,7 @@
+TOP = ../../..
+LiterateSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+#DocProcessingSuffixRules()
+#LitDocRootTarget(profiling,lit)
+#LitDocRootTarget(user,lit)
diff --git a/ghc/driver/Jmakefile b/ghc/driver/Jmakefile
deleted file mode 100644
index 5c7c1097f29e615c5e66f7e310999c6889d9e12b..0000000000000000000000000000000000000000
--- a/ghc/driver/Jmakefile
+++ /dev/null
@@ -1,44 +0,0 @@
-/* stuff to have before we get going */
-MsubNeededHere(ghc)
-UnlitNeededHere(depend)
-
-DYN_LOADABLE_BITS = \
-	ghc-asm.prl \
-	ghc-recomp.prl \
-	ghc-iface.prl \
-	ghc-consist.prl \
-	ghc-split.prl
-
-/* Literate-pgmming suffix rules used herein */
-UnlitSuffixRule(.lprl,.prl)
-
-MsubMakefileDependentProgramScriptTarget(PerlCmd,ghc,ghc.prl,/*no flags*/,/*Makefile*/)
-AllTarget( $(DYN_LOADABLE_BITS) )
-
-/* installation is hackish: because we may want to install w/ a diff name */
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTBINDIR_GHC) $(INSTLIBDIR_GHC))
-
-InstallMsubbedScriptTarget(PerlCmd,ghc-v-temp-name,ghc.prl,$(INSTBINDIR_GHC))
-/* and continuing ... */
-install::
-	$(MV) $(INSTBINDIR_GHC)/ghc-v-temp-name $(INSTBINDIR_GHC)/$(GHC_DRIVER_INST_NAME)
-	$(RM) $(INSTBINDIR_GHC)/ghc-v-temp-name
-
-dyn_loadable_bits : $(DYN_LOADABLE_BITS)
-
-InstallMultNonExecTargets(dyn_loadable_bits, $(DYN_LOADABLE_BITS), $(INSTLIBDIR_GHC))
-
-install :: install_dyn_loadable_bits
-
-#endif /* DoInstallGHCSystem */
-
-depend::
-	@echo make depend done in $(CURRENT_DIR)
-
-ExtraStuffToClean( ghc.prl $(DYN_LOADABLE_BITS) )
-
-ClearTagsFile()
-
-DYN_LOADABLE_LPRLS = $(DYN_LOADABLE_BITS:.prl=.lprl)
-PerlTagsTarget( ghc.lprl $(DYN_LOADABLE_LPRLS) )
diff --git a/ghc/driver/Makefile b/ghc/driver/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..330608071f3718d9135d4275d8414ba798eb7c40
--- /dev/null
+++ b/ghc/driver/Makefile
@@ -0,0 +1,34 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:47:27 simonm Exp $
+
+TOP=../..
+CURRENT_DIR=ghc/driver
+UnlitSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+DYN_LOADABLE_BITS = \
+	ghc-asm.prl \
+	ghc-recomp.prl \
+	ghc-iface.prl \
+	ghc-consist.prl \
+	ghc-split.prl
+
+PROG	= ghc
+SRC	= ghc.prl
+INTERP	= $(PERL)
+DESTDIR	= $(INSTBINDIR_GHC)
+INSTALLED_NAME = $(GHC_DRIVER_INST_NAME)
+
+all :: $(DYN_LOADABLE_BITS)
+
+install :: $(DYN_LOADABLE_BITS)
+	$(INSTALL) $(INSTDATAFLAGS) $(DYN_LOADABLE_BITS) $(INSTLIBDIR_GHC)
+
+clean::
+	$(RM) ghc.prl
+	$(RM) $(DYN_LOADABLE_BITS)
+
+# DYN_LOADABLE_LPRLS = $(DYN_LOADABLE_BITS:.prl=.lprl)
+# PerlTagsTarget( ghc.lprl $(DYN_LOADABLE_LPRLS) )
+
+include $(TOP)/mk/script.mk
diff --git a/ghc/driver/ghc-iface.lprl b/ghc/driver/ghc-iface.lprl
index 6d3bde17779828266315da76363348c62bdf9e0e..f97cbd93a81313e8999957b9abb21be13331b060 100644
--- a/ghc/driver/ghc-iface.lprl
+++ b/ghc/driver/ghc-iface.lprl
@@ -271,7 +271,7 @@ sub calcNewModuleVersion {
 sub mv_change {
     local($mv, $str) = @_;
 
-    print STDERR "$Pgm: module version changed to $mv; reason: $str\n";
+#print STDERR "$Pgm: module version changed to $mv; reason: $str\n";
     return($mv);
 }
 
@@ -287,13 +287,13 @@ sub printNewItemVersion {
     local($idecl) = $Decl{"new:$item"};
 
     if (! defined($Decl{"old:$item"})) {
-	print STDERR "new: $item\n";
+#print STDERR "new: $item\n";
 	print NEWHI  "$item $mod_version\n";
     } elsif ($idecl ne $Decl{"old:$item"})  {
-	print STDERR "changed: $item\n";
+#print STDERR "changed: $item\n";
 	print NEWHI  "$item $mod_version\n";
     } elsif (! defined($Version{"old:$item"}) ) {
-	print STDERR "$item: no old version?!\n" 
+#print STDERR "$item: no old version?!\n" 
     } else {
 	print NEWHI  "$item ", $Version{"old:$item"}, "\n";
     }
diff --git a/ghc/driver/ghc.lprl b/ghc/driver/ghc.lprl
index a669b22da8dee2e0652d5bd864c08d9ed302db28..653e54620e8dd753553da0207244e91b92ac28ad 100644
--- a/ghc/driver/ghc.lprl
+++ b/ghc/driver/ghc.lprl
@@ -222,7 +222,7 @@ $Oopt_FoldrBuildInline		= ''; # was '-fdo-inline-foldr-build';
 
 Things to do with C compilers/etc:
 \begin{code}
-$CcRegd	 	= 'gcc';
+$CcRegd	 	= '$(GHC_OPT_HILEV_ASM)';
 @CcBoth_flags	= ('-S');   # flags for *any* C compilation
 @CcInjects	= ();
 
@@ -248,35 +248,35 @@ Prelude ({\em including} its interface file(s)).
 \begin{code}
 $BuildTag	= ''; # default is sequential build w/ Appel-style GC
 
-%BuildAvail	= ('',	    '$(GHC_BUILD_FLAG_normal)',
-		   '_p',    '$(GHC_BUILD_FLAG_p)',
-		   '_t',    '$(GHC_BUILD_FLAG_t)',
-		   '_u',    '$(GHC_BUILD_FLAG_u)',
-		   '_mc',   '$(GHC_BUILD_FLAG_mc)',
-		   '_mr',   '$(GHC_BUILD_FLAG_mr)',
-		   '_mt',   '$(GHC_BUILD_FLAG_mt)',
-		   '_mp',   '$(GHC_BUILD_FLAG_mp)',
-		   '_mg',   '$(GHC_BUILD_FLAG_mg)',
-		   '_2s',   '$(GHC_BUILD_FLAG_2s)',
-		   '_1s',   '$(GHC_BUILD_FLAG_1s)',
-		   '_du',   '$(GHC_BUILD_FLAG_du)',
-		   '_a',    '$(GHC_BUILD_FLAG_a)',
-		   '_b',    '$(GHC_BUILD_FLAG_b)',
-		   '_c',    '$(GHC_BUILD_FLAG_c)',
-		   '_d',    '$(GHC_BUILD_FLAG_d)',
-		   '_e',    '$(GHC_BUILD_FLAG_e)',
-		   '_f',    '$(GHC_BUILD_FLAG_f)',
-		   '_g',    '$(GHC_BUILD_FLAG_g)',
-		   '_h',    '$(GHC_BUILD_FLAG_h)',
-		   '_i',    '$(GHC_BUILD_FLAG_i)',
-		   '_j',    '$(GHC_BUILD_FLAG_j)',
-		   '_k',    '$(GHC_BUILD_FLAG_k)',
-		   '_l',    '$(GHC_BUILD_FLAG_l)',
-		   '_m',    '$(GHC_BUILD_FLAG_m)',
-		   '_n',    '$(GHC_BUILD_FLAG_n)',
-		   '_o',    '$(GHC_BUILD_FLAG_o)',
-		   '_A',    '$(GHC_BUILD_FLAG_A)',
-		   '_B',    '$(GHC_BUILD_FLAG_B)' );
+%BuildAvail	= ('',	    '$(Build_normal)',
+		   '_p',    '$(Build_p)',
+		   '_t',    '$(Build_t)',
+		   '_u',    '$(Build_u)',
+		   '_mc',   '$(Build_mc)',
+		   '_mr',   '$(Build_mr)',
+		   '_mt',   '$(Build_mt)',
+		   '_mp',   '$(Build_mp)',
+		   '_mg',   '$(Build_mg)',
+		   '_2s',   '$(Build_2s)',
+		   '_1s',   '$(Build_1s)',
+		   '_du',   '$(Build_du)',
+		   '_a',    '$(Build_a)',
+		   '_b',    '$(Build_b)',
+		   '_c',    '$(Build_c)',
+		   '_d',    '$(Build_d)',
+		   '_e',    '$(Build_e)',
+		   '_f',    '$(Build_f)',
+		   '_g',    '$(Build_g)',
+		   '_h',    '$(Build_h)',
+		   '_i',    '$(Build_i)',
+		   '_j',    '$(Build_j)',
+		   '_k',    '$(Build_k)',
+		   '_l',    '$(Build_l)',
+		   '_m',    '$(Build_m)',
+		   '_n',    '$(Build_n)',
+		   '_o',    '$(Build_o)',
+		   '_A',    '$(Build_A)',
+		   '_B',    '$(Build_B)' );
 
 %BuildDescr	= ('',	    'normal sequential',
 		   '_p',    'profiling',
@@ -450,7 +450,7 @@ $Only_preprocess_C = 0;	# pretty hackish
 $PostprocessCcOutput = 0;
 
 # native code-gen or via C?
-$HaveNativeCodeGen = $(GHC_WITH_NATIVE_CODEGEN);
+$HaveNativeCodeGen = $(GhcWithNativeCodeGen);
 $HscOut = '-C='; # '-C=' ==> .hc output; '-S=' ==> .s output; '-N=' ==> neither
 $HscOut = '-S='
     if $HaveNativeCodeGen && $TargetPlatform =~ /^(alpha|sparc)-/; #ToDo: add |i386 !
@@ -1780,7 +1780,7 @@ Before continuing we check that the appropriate build is available.
 \begin{code}
 die "$Pgm: no BuildAvail?? $BuildTag\n" if ! $BuildAvail{$BuildTag}; # sanity
 
-if ( $BuildAvail{$BuildTag} =~ /^-build-.*-not-defined$/ ) {
+if ( $BuildAvail{$BuildTag} =~ /^NO$/ ) {
     print STDERR "$Pgm: a `", $BuildDescr{$BuildTag},
 	"' \"build\" is not available with your GHC setup.\n";
     print STDERR "(It was not configured for it at your site.)\n";
diff --git a/ghc/includes/Jmakefile b/ghc/includes/Jmakefile
deleted file mode 100644
index 90a28193e4195685649e7388dd66bc3856f7135d..0000000000000000000000000000000000000000
--- a/ghc/includes/Jmakefile
+++ /dev/null
@@ -1,105 +0,0 @@
-LH_FILES = \
-RtsTypes.lh	/* runtime system */ \
-RtsFlags.lh \
-\
-SMinterface.lh	/* storage-management related */ \
-SMClosures.lh \
-SMInfoTables.lh \
-SMupdate.lh \
-SMcopying.lh \
-SMcompact.lh \
-SMmark.lh \
-\
-StgMacros.lh \
-StgTypes.lh \
-MachRegs.lh \
-StgRegs.lh \
-COptJumps.lh \
-COptRegs.lh \
-COptWraps.lh \
-\
-GhcConstants.lh \
-\
-Ticky.lh 	/* "ticky-ticky" profiling */ \
-\
-Info.lh		/* Info pointer definitions */ \
-\
-CostCentre.lh   /* for cost centre profiling */ \
-\
-GranSim.lh  \
-Parallel.lh 	/* for PAR build */ \
-Threads.lh   	/* for threads, parallel or not */
-
-H_FILES_FROM_LH_FILES = $(LH_FILES:.lh=.h)
-
-MOST_H_FILES = $(H_FILES_FROM_LH_FILES) \
-stgdefs.h /* top-level including file */ \
-rtsdefs.h	\
-\
-StgDirections.h /* other basic STG things */ \
-StgMachDeps.h 	\
-\
-error.h 	\
-ieee-flpt.h	\
-\
-gmp.h		\
-\
-LLC.h	    /* for PAR build */ \
-HLC.h	    /* ditto */
-
-#if GhcWithNativeCodeGen == YES
-#define __native_h $(TARGETPLATFORM).h
-#else
-#define __native_h /*no*/
-#endif
-
-H_FILES = $(MOST_H_FILES) \
-__native_h /* Must be constructed last */
-
-/* $(TARGETPLATFORM).h should probably be installed in LIB, not DATA (WDP 94/07) */
-
-PLAT_H_FILES = config.h platform.h
-
-#undef __native_h
-
-/* Literate-pgmming suffix rules used herein */
-UnlitSuffixRule(.lh,.h)
-UnlitSuffixRule(.lc,.c)
-
-all :: /* so it is first */
-	@:
-
-UnlitNeededHere(depend)
-
-#if GhcWithNativeCodeGen == YES
-
-GhcDriverNeededHere(depend all mkNativeHdr.o) /* we use its C-compiling know-how */
-
-$(TARGETPLATFORM).h : mkNativeHdr
-	$(RM) $@
-	./mkNativeHdr > $@ || ( rm $@ && exit 1 )
-
-mkNativeHdr.c : mkNativeHdr.lc
-
-mkNativeHdr :: mkNativeHdr.c $(MOST_H_FILES)
-	$(RM) mkNativeHdr mkNativeHdr.o
-	$(GHC) -c mkNativeHdr.c
-	$(CC) -o mkNativeHdr mkNativeHdr.o
-
-#endif /* NativeCodeGen */
-
-all depend :: $(H_FILES)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTDATADIR_GHC)/includes $(INSTLIBDIR_GHC)/includes)
-includestuff:: /* nothing */
-InstallTarget(includestuff)
-InstallMultNonExecTargets(includestuff, $(H_FILES), $(INSTDATADIR_GHC)/includes)
-InstallMultNonExecTargets(includestuff, $(PLAT_H_FILES), $(INSTLIBDIR_GHC)/includes)
-#endif
-
-ExtraStuffToClean( $(H_FILES_FROM_LH_FILES) )
-
-EtagsNeededHere(tags) /* need this to do "make tags" */
-ClearTagsFile()
-CTagsTarget( $(H_FILES) )
diff --git a/ghc/includes/Makefile b/ghc/includes/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..147d73573178b6be7e209503c22c5158cde6131f
--- /dev/null
+++ b/ghc/includes/Makefile
@@ -0,0 +1,41 @@
+TOP = ../..
+UnlitSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+# Literate header files
+HLIT = $(patsubst %.lh, %.h, $(wildcard *.lh))
+
+# Header files built by configure
+HCONFIG = config.h platform.h
+
+# Everything else
+HFILES = stgdefs.h rtsdefs.h StgDirections.h StgMachDeps.h error.h \
+  ieee-flpt.h gmp.h LLC.h HLC.h
+
+ifeq ($(GhcWithNativeCodeGen),YES)
+  ALLFILES = $(HLIT) $(HFILES) $(TARGETPLATFORM).h
+else
+  ALLFILES = $(HLIT) $(HFILES)
+endif
+
+$(TARGETPLATFORM).h : mkNativeHdr
+	$(RM) $@
+	./mkNativeHdr > $@ || ( rm $@ && exit 1 )
+
+mkNativeHdr : mkNativeHdr.c $(HLIT) $(HFILES)
+	$(GHC) -c mkNativeHdr.c
+	$(CC) $(CFLAGS) -o mkNativeHdr mkNativeHdr.c
+
+all :: $(ALLFILES)
+
+install :: $(ALLFILES) $(HCONFIG)
+	$(INSTALL) $(INSTDATAFLAGS) $(ALLFILES) $(INSTDATADIR_GHC)/includes
+	$(INSTALL) $(INSTDATAFLAGS) $(HCONFIG) $(INSTLIBDIR_GHC)/includes
+
+ifeq ($(GhcWithNativeCodeGen),YES)
+  clean ::
+	$(RM) $(HLIT) mkNativeHdr mkNativeHdr.c $(TARGETPLATFORM).h
+else
+  clean ::
+	$(RM) $(HLIT) mkNativeHdr mkNativeHdr.c
+endif
diff --git a/ghc/lib/.depend b/ghc/lib/.depend
new file mode 100644
index 0000000000000000000000000000000000000000..832f3bb7cadec4fd3397a0c141bb3b1d374e7641
--- /dev/null
+++ b/ghc/lib/.depend
@@ -0,0 +1,77 @@
+# DO NOT DELETE: Beginning of Haskell dependencies
+prelude/GHCbase.o : prelude/GHCbase.hs
+prelude/GHCbase.o : required/Array.hi
+prelude/GHCbase.o : required/Char.hi
+prelude/GHCbase.o : required/Ix.hi
+prelude/GHCbase.o : required/Ratio.hi
+prelude/GHCbase.o : prelude/GHCerr.hi
+prelude/GHCerr.o : prelude/GHCerr.hs
+prelude/GHCerr.o : prelude/GHCbase.hi
+prelude/GHCio.o : prelude/GHCio.hs
+prelude/GHCio.o : ../../ghc/includes/error.h
+prelude/GHCio.o : prelude/GHCbase.hi
+prelude/GHCio.o : required/Ix.hi
+prelude/GHCmain.o : prelude/GHCmain.hs
+prelude/GHCmain.o : prelude/GHCbase.hi
+prelude/GHCps.o : prelude/GHCps.hs
+prelude/GHCps.o : required/Ix.hi
+prelude/GHCps.o : required/Char.hi
+prelude/GHCps.o : prelude/GHCbase.hi
+prelude/Prelude.o : prelude/Prelude.hs
+prelude/Prelude.o : ./../includes/ieee-flpt.h
+prelude/Prelude.o : prelude/GHCbase.hi
+prelude/Prelude.o : prelude/GHCio.hi
+prelude/Prelude.o : required/Ratio.hi
+prelude/Prelude.o : required/Char.hi
+prelude/Prelude.o : required/IO.hi
+prelude/PreludeGlaST.o : prelude/PreludeGlaST.hs
+prelude/PreludeGlaST.o : prelude/GHCbase.hi
+required/Array.o : required/Array.hs
+required/Array.o : required/Ix.hi
+required/Array.o : required/List.hi
+required/Array.o : prelude/GHCbase.hi
+required/Char.o : required/Char.hs
+required/Complex.o : required/Complex.hs
+required/Directory.o : required/Directory.hs
+required/Directory.o : prelude/GHCio.hi
+required/Directory.o : prelude/PreludeGlaST.hi
+required/Directory.o : prelude/GHCps.hi
+required/IO.o : required/IO.hs
+required/IO.o : required/Ix.hi
+required/IO.o : prelude/GHCio.hi
+required/IO.o : prelude/GHCbase.hi
+required/IO.o : prelude/GHCps.hi
+required/Ix.o : required/Ix.hs
+required/List.o : required/List.hs
+required/Maybe.o : required/Maybe.hs
+required/Monad.o : required/Monad.hs
+required/Ratio.o : required/Ratio.hs
+required/System.o : required/System.hs
+required/System.o : prelude/GHCio.hi
+required/System.o : prelude/GHCps.hi
+required/System.o : prelude/GHCbase.hi
+concurrent/Channel.o : concurrent/Channel.hs
+concurrent/Channel.o : prelude/GHCbase.hi
+concurrent/ChannelVar.o : concurrent/ChannelVar.hs
+concurrent/ChannelVar.o : prelude/GHCbase.hi
+concurrent/Concurrent.o : concurrent/Concurrent.hs
+concurrent/Concurrent.o : concurrent/Parallel.hi
+concurrent/Concurrent.o : concurrent/ChannelVar.hi
+concurrent/Concurrent.o : concurrent/Channel.hi
+concurrent/Concurrent.o : concurrent/Semaphore.hi
+concurrent/Concurrent.o : concurrent/Merge.hi
+concurrent/Concurrent.o : concurrent/SampleVar.hi
+concurrent/Concurrent.o : prelude/GHCbase.hi
+concurrent/Merge.o : concurrent/Merge.hs
+concurrent/Merge.o : concurrent/Semaphore.hi
+concurrent/Merge.o : prelude/GHCbase.hi
+concurrent/Merge.o : prelude/GHCio.hi
+concurrent/Merge.o : concurrent/Concurrent.hi
+concurrent/Parallel.o : concurrent/Parallel.hs
+concurrent/Parallel.o : prelude/GHCbase.hi
+concurrent/Parallel.o : prelude/GHCerr.hi
+concurrent/SampleVar.o : concurrent/SampleVar.hs
+concurrent/SampleVar.o : prelude/GHCbase.hi
+concurrent/Semaphore.o : concurrent/Semaphore.hs
+concurrent/Semaphore.o : prelude/GHCbase.hi
+# DO NOT DELETE: End of Haskell dependencies
diff --git a/ghc/lib/Jmakefile b/ghc/lib/Jmakefile
deleted file mode 100644
index 350b068ffa7de70612038f0af00be1087c9ed776..0000000000000000000000000000000000000000
--- a/ghc/lib/Jmakefile
+++ /dev/null
@@ -1,236 +0,0 @@
-/* This is the Jmakefile for the library stuff.
-   This stuff is all written in (Glasgow-extended) Haskell.
-
-Everything here *must* be compiled w/ the Glasgow Haskell compiler.
-(Hence the use of $(GHC), rather than $(HC) [the latter is your "standard"
-Haskell compiler -- whatever you've configured]).
-
-If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
-strictly speaking), it will probably work -- it is pinned onto
-GHC_OPTS, just for fun.
-*/
-
-/****************************************************************
-*								*
-* Jmakefile preamble-y things					*
-*								*
-****************************************************************/
-
-#define IHaveSubdirs
-
-#if IncludeTestDirsInBuild == YES
-#define __ghc_lib_tests_dir tests
-#else
-#define __ghc_lib_tests_dir /* nothing */
-#endif
-
-SUBDIRS = cbits __ghc_lib_tests_dir
-
-#define NoDocsTargetForSubdirs
-#define NoInstallDocsTargetForSubdirs
-#define NoDependTargetForSubdirs
-
-GhcDriverNeededHere(depend all)
-EtagsNeededHere(tags)
-
-/****************************************************************
-*								*
-* options used for compiling/etc. things			*
-*								*
-****************************************************************/
-
-/* The driver will give warnings if -split-objs, but that's cool... */
-GHC_OPTS=-recomp -cpp 		\
-	 -dcore-lint 		\
-	 -irequired		\
-	 -fusing-ghc-internals	\
-	 HcMaxHeapFlag $(EXTRA_HC_OPTS)
-
-EXTRA_MKDEPENDHS_OPTS = -irequired:prelude:ghc:hbc:glaExts:concurrent
-
-
-PREL_OPTS=/*???-fcompiling-ghc-internals -fno-implicit-prelude*/
-
-/* per-build options: shared with RTS */
-#define rts_or_lib(r,l) l
-#include "../mkworld/GHC_OPTS"
-
-/* this is just friendliness to "hstags" */
-HSTAGS_OPTS=-fglasgow-exts
-
-/***************************************************************/
-
-/****************************************************************
-*								*
-* what it is we are compiling;					*
-*   these are long and tedious lists, but c'est la guerre	*
-*								*
-****************************************************************/
-
-BASIC_HS =			\
-prelude/Prelude.hs		\
-prelude/GHCbase.hs		\
-prelude/GHCerr.hs		\
-prelude/GHCps.hs		\
-prelude/GHCio.hs		\
-prelude/GHCmain.hs		\
-prelude/PreludeGlaST.hs		\
-				\
-required/Array.hs		\
-required/Char.hs		\
-required/Complex.hs		\
-required/Directory.hs		\
-required/IO.hs			\
-required/Ix.hs			\
-required/List.hs		\
-required/Maybe.hs		\
-required/Monad.hs		\
-required/Ratio.hs		\
-required/System.hs		\
-\
-concurrent/Channel.hs		\
-concurrent/ChannelVar.hs	\
-concurrent/Merge.hs		\
-concurrent/Parallel.hs		\
-concurrent/SampleVar.hs		\
-concurrent/Semaphore.hs		\
-concurrent/Concurrent.hs
-
-BASIC_HIs = $(BASIC_HS:.hs=.hi)
-
-BASIC_OBJS_DIRS	= $(BASIC_HS:.hs=)
-
-/* easy way to make many many Make variables: */
-WayThingVars(BASIC)
-
-/************************************************************************
-*									*
-* Macros for creating and installing libHS<x>.a (in its many flavors).	*
-*									*
-*************************************************************************/
-
-/****************************************************************
-*								*
-* Creating and installing...					*
-*	libHS_<tag>.a		standard Prelude library	*
-*								*
-****************************************************************/
-
-/* make sure install's target dir is there */
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC) $(INSTDATADIR_GHC)/imports)
-
-InstallDataTarget(MODULES,$(INSTDATADIR_GHC)/imports)
-#endif /* installing */
-
-BasicEverything(libHS, $(INSTLIBDIR_GHC), $(INSTDATADIR_GHC))
-
-/****************************************************************
-*								*
-* Creating the individual .hc files: 				*
-*								*
-*   For the just-vary-the-GC-thanks flavors, we only need to	*
-*   compile .hs->.hc once; then re-use the .hc file each time.	*
-*								*
-*   For the profiling one (_p) and all the user-specified	*
-*   ones, we recompile the Haskell each time.			*
-*								*
-*  NB: old (WDP 95/06)						*
-****************************************************************/
-
-/* some "helpful" internal macros first... */
-
-#if GhcWithHscBuiltViaC == YES && HaskellCompilerType == HC_USE_HC_FILES
-#define CompileWayishly__(hc,file,isuf,way,flags)	@@\
-clean  ::						@@\
-	$(RM) CAT3(file,way,.hc)
-#endif
-
-/* now use the macro: */
-
-/* NB: the -Onots are only because -O would not go through on
-   a reasonably-sized machine (i.e., one I have)
-*/
-CompileWayishly(GHC,prelude/Prelude,hs,/*-split-objs Prelude*/ -iprelude -fglasgow-exts -fcompiling-ghc-internals Prelude -fno-implicit-prelude '-#include"cbits/stgio.h"' -H18m -Onot)
-CompileWayishly(GHC,prelude/GHCbase,hs,/*-split-objs GHCbase*/ -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCbase '-#include"cbits/stgio.h"' -H12m -monly-2-regs -Onot)
-CompileWayishly(GHC,prelude/GHCerr,hs, /*-split-objs GHCerr*/ -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCerr -H12m -Onot)
-CompileWayishly(GHC,prelude/GHCps,hs,  /*-split-objs GHCps*/ -iprelude -fglasgow-exts '-#include"cbits/stgio.h"' -monly-3-regs -Onot)
-CompileWayishly(GHC,prelude/GHCio,hs,  /*-split-objs GHCio*/ -iprelude -fglasgow-exts '-#include"cbits/stgio.h"' -Onot)
-CompileWayishly(GHC,prelude/GHCmain,hs,-iprelude -fglasgow-exts)
-CompileWayishly(GHC,prelude/PreludeGlaST,hs,-iprelude -fglasgow-exts)
-
-CompileWayishly(GHC,required/Array,hs, /*-split-objs Array*/ -fglasgow-exts -iprelude -Onot)
-CompileWayishly(GHC,required/Char,hs,  /*-split-objs Char*/)
-CompileWayishly(GHC,required/Complex,hs,/*-split-objs Complex*/)
-CompileWayishly(GHC,required/Directory,hs,/*-split-objs Directory*/ -fglasgow-exts '-#include"cbits/stgio.h"' -monly-3-regs)
-CompileWayishly(GHC,required/IO,hs,/*-split-objs IO*/ -fglasgow-exts '-#include"cbits/stgio.h"')
-CompileWayishly(GHC,required/Ix,hs,    /*-split-objs Ix*/ -fglasgow-exts)
-CompileWayishly(GHC,required/List,hs,  /*-split-objs List*/)
-CompileWayishly(GHC,required/Maybe,hs, /*-split-objs Maybe*/)
-CompileWayishly(GHC,required/Monad,hs, /*-split-objs Monad*/)
-CompileWayishly(GHC,required/Ratio,hs, /*-split-objs Ratio*/)
-CompileWayishly(GHC,required/System,hs,/*-split-objs System*/ -fglasgow-exts '-#include"cbits/stgio.h"')
-
-CompileWayishly(GHC,concurrent/Channel,hs,)
-CompileWayishly(GHC,concurrent/ChannelVar,hs,)
-CompileWayishly(GHC,concurrent/Merge,hs,-iconcurrent)
-CompileWayishly(GHC,concurrent/Parallel,hs,-fglasgow-exts)
-CompileWayishly(GHC,concurrent/SampleVar,hs,)
-CompileWayishly(GHC,concurrent/Semaphore,hs,)
-CompileWayishly(GHC,concurrent/Concurrent,hs,-iconcurrent)
-
-/****************************************************************
-*								*
-* misc "make" targets -- depend, clean, tags			*
-*								*
-****************************************************************/
-
-/* this is a BAD idea!
-ExtraStuffToClean( $(SRCS_C) )
-   without the .hc files, the distrib cannot boot itself
-*/
-ExtraStuffToBeVeryClean( $(SRCS_C) )
-ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) )
-
-ClearTagsFile()
-/* Ugly but OK? [WDP 94/09] */
-HsTagsTarget( */[A-Z]*.*hs )
-HSTAGS_OPTS=-cpp -fglasgow-exts
-
-/* should be *LAST* */
-#if HaskellCompilerType != HC_USE_HC_FILES
-    /* otherwise, the dependencies jeopardize our .hc files --
-	which are all we have! */
-MAIN_INCLUDE_DIR = $(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
-MKDEPENDHS_OPTS= \
-IfBuild_mc(-s mc) \
-IfBuild_mr(-s mr) \
-IfBuild_mt(-s mt) \
-IfBuild_mp(-s mp) \
-IfBuild_mg(-s mg) \
-IfBuild_2s(-s 2s) \
-IfBuild_1s(-s 1s) \
-IfBuild_du(-s du) \
-IfBuild_p(-s p) \
-IfBuild_t(-s t) \
-IfBuild_a(-s a) \
-IfBuild_b(-s b) \
-IfBuild_c(-s c) \
-IfBuild_d(-s d) \
-IfBuild_e(-s e) \
-IfBuild_f(-s f) \
-IfBuild_g(-s g) \
-IfBuild_h(-s h) \
-IfBuild_i(-s i) \
-IfBuild_j(-s j) \
-IfBuild_k(-s k) \
-IfBuild_l(-s l) \
-IfBuild_m(-s m) \
-IfBuild_n(-s n) \
-IfBuild_o(-s o) \
-IfBuild_A(-s A) \
-IfBuild_B(-s B) \
--o hc -I$(MAIN_INCLUDE_DIR) 
-
-HaskellDependTarget( $(BASIC_HS) )
-#endif
diff --git a/ghc/lib/Makefile b/ghc/lib/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..2f90b3af60da92a972da952820e706588edbd5ea
--- /dev/null
+++ b/ghc/lib/Makefile
@@ -0,0 +1,47 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:47:41 simonm Exp $
+
+TOP = ../..
+include $(TOP)/ghc/mk/ghc.mk
+
+SUBDIRS = cbits
+ifeq ($(IncludeTestDirsInBuild),YES)
+  SUBDIRS += tests
+endif
+
+include $(TOP)/mk/subdir.mk
+
+# per-build options: shared with runtime system
+include ../mk/buildflags.mk
+
+#-----------------------------------------------------------------------------
+# libHS.a, in several different 'ways'
+
+all ::
+	@for i in $(WAY_SUFFIXES); do \
+		echo; \
+		echo =========== Making libraries for way $$i; \
+		echo; \
+		$(MAKE) -f Makefile.libHS suffix=$$i; \
+	done
+
+install ::
+	@for i in $(WAY_SUFFIXES); do \
+		$(MAKE) -f Makefile.libHS suffix=$$i install; \
+	done
+
+clean ::
+	@for i in $(WAY_SUFFIXES); do \
+		$(MAKE) -f Makefile.libHS suffix=$$i clean; \
+	done
+
+# Dependencies are done by Makefile.libHS
+
+depend ::
+	@$(MAKE) -f Makefile.libHS depend
+
+
+# install MODULES file
+
+install ::
+	$(INSTALL) $(INSTDATAFLAGS) MODULES $(INSTDATADIR_GHC)/imports
diff --git a/ghc/lib/Makefile.libHS b/ghc/lib/Makefile.libHS
new file mode 100644
index 0000000000000000000000000000000000000000..6e03d3fc13bec50c759226ebe2cdadd3ce8745e5
--- /dev/null
+++ b/ghc/lib/Makefile.libHS
@@ -0,0 +1,125 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile.libHS,v 1.2 1996/11/21 16:47:42 simonm Exp $
+
+TOP = ../..
+include $(TOP)/ghc/mk/ghc.mk
+
+# per-build options: shared with runtime system
+include ../mk/buildflags.mk
+
+# Everything here *must* be compiled with the Glasgow Haskell compiler.
+# (Hence the use of $(GHC), rather than $(HC).)
+# The driver will give warnings if -split-objs, but that's cool...
+
+GHC_OPTS = \
+  -recomp -cpp -dcore-lint -irequired -fusing-ghc-internals -fvia-C \
+  $(HcMaxHeapFlag) $(EXTRA_HC_OPTS)
+
+SRCS = $(wildcard prelude/*.hs required/*.hs concurrent/*.hs)
+OBJS = $(SRCS:.hs=.$(suffix)_o)
+
+#-----------------------------------------------------------------------------
+# Rules for building various types of objects from HS files
+
+# Note: the $(*_flags) module-specific flags come after the $(GHC_OPTS_..) 
+# so that things like -O can be overriden on a per-module basis.
+
+ifeq ($(SplitObjs),YES)
+LIB_GHC = $(GHC) $(GHCFLAGS) -split-objs $(notdir $*) -o $@ -c
+else
+LIB_GHC = $(GHC) $(GHCFLAGS) -o $@ -c
+endif
+
+ifneq ($(GhcWithHscBuiltViaC),YES)
+%.o : %.hs
+	$(LIB_GHC) $($*_flags) $*.hs
+
+%.$(suffix)_o : %.hs
+	$(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
+
+else # $(GhcWithHscBuiltViaC) == YES
+
+%.$(suffix)_o : %.hc
+	$(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
+endif
+
+#-----------------------------------------------------------------------------
+# build the library itself...
+
+ifeq ($(suffix), norm)
+LIB = libHS.a	 		# this one is special
+else
+LIB = libHS_$(suffix).a
+endif
+
+$(LIB) : $(OBJS)
+	@$(RM) $@
+	$(AR) $@ $^
+
+all :: $(LIB)
+
+clean ::
+	$(RM) $(LIB)
+	$(RM) $(OBJS)
+
+install :: $(LIB)
+	$(INSTALL) $(INSTLIBFLAGS) $(LIB) $(INSTLIBDIR_GHC)
+	$(RANLIB) $(INSTLIBDIR_GHC)/$(LIB)
+
+veryclean ::
+	$(RM) */*.hc */*.hi
+
+#-----------------------------------------------------------------------------
+# per-module flags
+
+# The -Onots are only because -O would not go through on
+# a reasonably-sized machine (i.e., one I have)
+
+prelude/Prelude_flags = \
+   -iprelude -fglasgow-exts -fcompiling-ghc-internals Prelude \
+   -fno-implicit-prelude '-\#include"cbits/stgio.h"' -H18m -Onot
+prelude/GHCbase_flags = \
+  -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCbase \
+  '-\#include"cbits/stgio.h"' -H20m -monly-2-regs -Onot
+prelude/GHCerr_flags = \
+  -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCerr -H12m -Onot
+prelude/GHCps_flags = \
+  -iprelude -fglasgow-exts '-\#include"cbits/stgio.h"' -monly-3-regs -Onot
+prelude/GHCio_flags = \
+  -iprelude -fglasgow-exts '-\#include"cbits/stgio.h"' -Onot
+prelude/GHCmain_flags = -iprelude -fglasgow-exts
+prelude/PreludeGlaST_flags = -iprelude -fglasgow-exts
+
+required/Array_flags = -fglasgow-exts -iprelude -Onot
+required/Directory_flags = \
+  -fglasgow-exts '-\#include"cbits/stgio.h"' -monly-3-regs
+required/IO_flags = -fglasgow-exts '-\#include"cbits/stgio.h"'
+required/Ix_flags = -fglasgow-exts
+required/System_flags = -fglasgow-exts '-\#include"cbits/stgio.h"'
+
+concurrent/Merge_flags = -iconcurrent
+concurrent/Parallel_flags = -fglasgow-exts
+concurrent/Concurrent_flags = -iconcurrent
+
+#-----------------------------------------------------------------------------
+# Depend and install stuff
+
+MKDEPENDHS_OPTS += -I$(GHC_INCLUDES)
+MKDEPENDHS_OPTS += -irequired:prelude:ghc:hbc:glaExts:concurrent
+MKDEPENDHS_OPTS += $(foreach way,$(WAY_SUFFIXES),-s .$(way))
+
+# Todo: make this a generic include of hsdepend.mk or something.
+depend :: $(SRCS)
+	$(MKDEPENDHS) $(MKDEPENDHSFLAGS) -- $(GHCFLAGS) -- -f .depend $(SRCS)
+
+#-----------------------------------------------------------------------------
+# install hi files
+
+ifeq ($(suffix),norm)
+HI_FILES = $(SRCS:.hs=.hi)
+else
+HI_FILES = $(SRCS:.hs=.$(suffix)_hi)
+endif
+
+install :: $(HI_FILES)
+	$(INSTALL) $(INSTDATAFLAGS) $(HI_FILES) $(INSTIMPORTSDIR_GHC)
diff --git a/ghc/lib/cbits/Jmakefile b/ghc/lib/cbits/Jmakefile
deleted file mode 100644
index 2fc374cc14f0c3683c580f160605840bc0e21b9a..0000000000000000000000000000000000000000
--- a/ghc/lib/cbits/Jmakefile
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Literate-pgmming suffix rules used herein */
-UnlitSuffixRule(.lc,.c)
-
-CBITS_LC =			\
-	closeFile.lc		\
-	createDirectory.lc	\
-	errno.lc		\
-	fileEOF.lc		\
-	fileGetc.lc		\
-	fileLookAhead.lc	\
-	filePosn.lc		\
-	filePutc.lc		\
-	fileSize.lc		\
-	flushFile.lc		\
-	getBufferMode.lc	\
-	getCurrentDirectory.lc	\
-	getDirectoryContents.lc	\
-	getLock.lc		\
-	inputReady.lc		\
-	openFile.lc		\
-	readFile.lc		\
-	removeDirectory.lc	\
-	removeFile.lc		\
-	renameDirectory.lc	\
-	renameFile.lc		\
-	seekFile.lc		\
-	setBuffering.lc		\
-	setCurrentDirectory.lc	\
-	system.lc		\
-	writeFile.lc
-
-CBITS_OBJS = $(CBITS_LC:.lc=.o)
-C_FILES    = $(CBITS_LC:.lc=.c)
-
-ExtraStuffToClean ( $(C_FILES) )
-
-NormalLibraryTarget(HS_cbits,$(CBITS_OBJS))
-ExtraStuffToClean($(CBITS_OBJS))
-#if DoInstallGHCSystem == YES
-InstallLibraryTarget(HS_cbits,$(INSTLIBDIR_GHC))
-#endif
-
-CompileCBitsly(GHC,closeFile,)
-CompileCBitsly(GHC,createDirectory,)
-CompileCBitsly(GHC,errno,)
-CompileCBitsly(GHC,fileEOF,)
-CompileCBitsly(GHC,fileGetc,)
-CompileCBitsly(GHC,fileLookAhead,)
-CompileCBitsly(GHC,filePosn,)
-CompileCBitsly(GHC,filePutc,)
-CompileCBitsly(GHC,fileSize,)
-CompileCBitsly(GHC,flushFile,)
-CompileCBitsly(GHC,getBufferMode,)
-CompileCBitsly(GHC,getCurrentDirectory,)
-CompileCBitsly(GHC,getDirectoryContents,)
-CompileCBitsly(GHC,getLock,)
-CompileCBitsly(GHC,inputReady,)
-CompileCBitsly(GHC,openFile,)
-CompileCBitsly(GHC,readFile,)
-CompileCBitsly(GHC,removeDirectory,)
-CompileCBitsly(GHC,removeFile,)
-CompileCBitsly(GHC,renameDirectory,)
-CompileCBitsly(GHC,renameFile,)
-CompileCBitsly(GHC,seekFile,)
-CompileCBitsly(GHC,setBuffering,)
-CompileCBitsly(GHC,setCurrentDirectory,)
-CompileCBitsly(GHC,system,)
-CompileCBitsly(GHC,writeFile,)
diff --git a/ghc/lib/cbits/Makefile b/ghc/lib/cbits/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..9266c58ba6d4036d686ea598affb55706be2db69
--- /dev/null
+++ b/ghc/lib/cbits/Makefile
@@ -0,0 +1,37 @@
+# $Id: Makefile,v 1.2 1996/11/21 16:47:46 simonm Exp $
+
+TOP = ../../..
+UnlitSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+ARCHIVE=libHS_cbits.a
+DESTDIR=$(INSTLIBDIR_GHC)
+
+SRCS=\
+closeFile.lc		createDirectory.lc		\
+errno.lc		fileEOF.lc			\
+fileGetc.lc		fileLookAhead.lc		\
+filePosn.lc		filePutc.lc			\
+fileSize.lc		flushFile.lc			\
+getBufferMode.lc	getCurrentDirectory.lc		\
+getDirectoryContents.lc getLock.lc			\
+inputReady.lc		openFile.lc			\
+readFile.lc		removeDirectory.lc		\
+removeFile.lc		renameDirectory.lc		\
+renameFile.lc		seekFile.lc			\
+setBuffering.lc		setCurrentDirectory.lc		\
+system.lc		writeFile.lc
+
+LIBOBJS = $(patsubst %.lc, %.o, $(SRCS))
+
+%.o : %.c
+	@$(RM) $@
+	$(GHC) $(GHCFLAGS) -c $< -o $@
+
+clean ::
+	$(RM) $(SRCS:.lc=.c)
+
+C_DEP_SRCS = $(SRCS) 
+MKDEPENDC_OPTS = -I$(GHC_INCLUDES)
+
+include $(TOP)/mk/lib.mk
diff --git a/ghc/lib/tests/Jmakefile b/ghc/lib/tests/Jmakefile
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/ghc/mk/buildflags.mk b/ghc/mk/buildflags.mk
new file mode 100644
index 0000000000000000000000000000000000000000..10deb4551759b441e43c1ab7e4ae99b8424c2924
--- /dev/null
+++ b/ghc/mk/buildflags.mk
@@ -0,0 +1,198 @@
+#-----------------------------------------------------------------------------
+# $Id: buildflags.mk,v 1.2 1996/11/21 16:47:58 simonm Exp $
+
+# This stuff is used by the Makefiles in lib/ and runtime/.
+
+ifdef DoingRTS
+GCap = -optc-DGCap
+GC2s = -optc-DGC2s
+GC1s = -optc-DG1s
+endif
+
+GHC_OPTS_norm=-O $(GCap)
+GHC_OPTS_p =-O -prof -GPrelude $(GCap) -hisuf p_hi -hisuf-prelude p_hi
+GHC_OPTS_t =-O -ticky -optc-DDEBUG $(GCap) -hisuf t_hi -hisuf-prelude t_hi
+GHC_OPTS_u =-O -unregisterised ???? -ticky $(GCap) -hisuf u_hi -hisuf-prelude u_hi
+GHC_OPTS_mc=-O -concurrent $(GCap) -hisuf mc_hi -hisuf-prelude mc_hi
+GHC_OPTS_mr=-O -concurrent -prof -GPrelude $(GCap) -hisuf mr_hi -hisuf-prelude mr_hi
+GHC_OPTS_mt=-O -concurrent -ticky -optc-DDEBUG $(GCap) -hisuf mt_hi -hisuf-prelude mt_hi
+GHC_OPTS_mp=-O -parallel $(GCap) -hisuf mp_hi -hisuf-prelude mp_hi
+GHC_OPTS_mg=-O -gransim $(GCap) -hisuf mg_hi -hisuf-prelude mg_hi
+
+GHC_OPTS_2s=-O -gc-2s $(GC2s) -hisuf 2s_hi -hisuf-prelude 2s_hi
+GHC_OPTS_1s=-O -gc-1s $(GC1s) -hisuf 1s_hi -hisuf-prelude 1s_hi
+GHC_OPTS_du=-O -gc-du $(GCdu) -hisuf du_hi -hisuf-prelude du_hi
+
+GHC_OPTS_a =-user-setup-a $(GCap) -hisuf a_hi -hisuf-prelude a_hi
+GHC_OPTS_b =-user-setup-b $(GCap) -hisuf b_hi -hisuf-prelude b_hi
+GHC_OPTS_c =-user-setup-c $(GCap) -hisuf c_hi -hisuf-prelude c_hi
+GHC_OPTS_d =-user-setup-d $(GCap) -hisuf d_hi -hisuf-prelude d_hi
+GHC_OPTS_e =-user-setup-e $(GCap) -hisuf e_hi -hisuf-prelude e_hi
+GHC_OPTS_f =-user-setup-f $(GCap) -hisuf f_hi -hisuf-prelude f_hi
+GHC_OPTS_g =-user-setup-g $(GCap) -hisuf g_hi -hisuf-prelude g_hi
+GHC_OPTS_h =-user-setup-h $(GCap) -hisuf h_hi -hisuf-prelude h_hi
+GHC_OPTS_i =-user-setup-i $(GCap) -hisuf i_hi -hisuf-prelude i_hi
+GHC_OPTS_j =-user-setup-j $(GCap) -hisuf j_hi -hisuf-prelude j_hi
+GHC_OPTS_k =-user-setup-k $(GCap) -hisuf k_hi -hisuf-prelude k_hi
+GHC_OPTS_l =-user-setup-l $(GCap) -hisuf l_hi -hisuf-prelude l_hi
+GHC_OPTS_m =-user-setup-m $(GCap) -hisuf m_hi -hisuf-prelude m_hi
+GHC_OPTS_n =-user-setup-n $(GCap) -hisuf n_hi -hisuf-prelude n_hi
+GHC_OPTS_o =-user-setup-o $(GCap) -hisuf o_hi -hisuf-prelude o_hi
+GHC_OPTS_A =-user-setup-A $(GCap) -hisuf A_hi -hisuf-prelude A_hi
+GHC_OPTS_B =-user-setup-B $(GCap) -hisuf B_hi -hisuf-prelude B_hi
+
+# used in hslibs:
+
+HC_OPTS_norm= $(GHC_OPTS_norm)
+HC_OPTS_p = $(GHC_OPTS_p)
+HC_OPTS_t = $(GHC_OPTS_t)
+HC_OPTS_u = $(GHC_OPTS_u)
+HC_OPTS_mc= $(GHC_OPTS_mc)
+HC_OPTS_mr= $(GHC_OPTS_mr)
+HC_OPTS_mt= $(GHC_OPTS_mt)
+HC_OPTS_mp= $(GHC_OPTS_mp)
+HC_OPTS_mg= $(GHC_OPTS_mg)
+HC_OPTS_2s= $(GHC_OPTS_2s)
+HC_OPTS_1s= $(GHC_OPTS_1s)
+HC_OPTS_du= $(GHC_OPTS_du)
+HC_OPTS_a = $(GHC_OPTS_a)
+HC_OPTS_b = $(GHC_OPTS_b)
+HC_OPTS_c = $(GHC_OPTS_c)
+HC_OPTS_d = $(GHC_OPTS_d)
+HC_OPTS_e = $(GHC_OPTS_e)
+HC_OPTS_f = $(GHC_OPTS_f)
+HC_OPTS_g = $(GHC_OPTS_g)
+HC_OPTS_h = $(GHC_OPTS_h)
+HC_OPTS_i = $(GHC_OPTS_i)
+HC_OPTS_j = $(GHC_OPTS_j)
+HC_OPTS_k = $(GHC_OPTS_k)
+HC_OPTS_l = $(GHC_OPTS_l)
+HC_OPTS_m = $(GHC_OPTS_m)
+HC_OPTS_n = $(GHC_OPTS_n)
+HC_OPTS_o = $(GHC_OPTS_o)
+HC_OPTS_A = $(GHC_OPTS_A)
+HC_OPTS_B = $(GHC_OPTS_B)
+
+#-----------------------------------------------------------------------------
+# Build up a list of the suffixes for which we're building
+
+# this stuff is used by the rts and lib Makefiles.
+
+WAY_SUFFIXES =
+
+ifeq ($(Build_normal), YES)
+WAY_SUFFIXES += norm
+endif 
+
+ifeq ($(Build_p), YES)
+WAY_SUFFIXES += p
+endif 
+
+ifeq ($(Build_t), YES)
+WAY_SUFFIXES += t
+endif 
+
+ifeq ($(Build_u), YES)
+WAY_SUFFIXES += u
+endif 
+
+ifeq ($(Build_mc), YES)
+WAY_SUFFIXES += mc
+endif 
+
+ifeq ($(Build_mr), YES)
+WAY_SUFFIXES += mr
+endif 
+
+ifeq ($(Build_mt), YES)
+WAY_SUFFIXES += mt
+endif 
+
+ifeq ($(Build_mp), YES)
+WAY_SUFFIXES += mp
+endif 
+
+ifeq ($(Build_mg), YES)
+WAY_SUFFIXES += mg
+endif 
+
+ifeq ($(Build_2s), YES)
+WAY_SUFFIXES += 2s
+endif 
+
+ifeq ($(Build_1s), YES)
+WAY_SUFFIXES += 1s
+endif 
+
+ifeq ($(Build_du), YES)
+WAY_SUFFIXES += du
+endif 
+
+ifeq ($(Build_a), YES)
+WAY_SUFFIXES += a
+endif 
+
+ifeq ($(Build_b), YES)
+WAY_SUFFIXES += b
+endif 
+
+ifeq ($(Build_c), YES)
+WAY_SUFFIXES += c
+endif 
+
+ifeq ($(Build_d), YES)
+WAY_SUFFIXES += d
+endif 
+
+ifeq ($(Build_e), YES)
+WAY_SUFFIXES += e
+endif 
+
+ifeq ($(Build_f), YES)
+WAY_SUFFIXES += f
+endif 
+
+ifeq ($(Build_g), YES)
+WAY_SUFFIXES += g
+endif 
+
+ifeq ($(Build_h), YES)
+WAY_SUFFIXES += h
+endif 
+
+ifeq ($(Build_i), YES)
+WAY_SUFFIXES += i
+endif 
+
+ifeq ($(Build_j), YES)
+WAY_SUFFIXES += j
+endif 
+
+ifeq ($(Build_k), YES)
+WAY_SUFFIXES += k
+endif 
+
+ifeq ($(Build_l), YES)
+WAY_SUFFIXES += l
+endif 
+
+ifeq ($(Build_m), YES)
+WAY_SUFFIXES += m
+endif 
+
+ifeq ($(Build_n), YES)
+WAY_SUFFIXES += n
+endif 
+
+ifeq ($(Build_o), YES)
+WAY_SUFFIXES += o
+endif 
+
+ifeq ($(Build_A), YES)
+WAY_SUFFIXES += A 
+endif 
+
+ifeq ($(Build_B), YES)
+WAY_SUFFIXES += B
+endif 
+
diff --git a/ghc/mk/ghc-opts.mk b/ghc/mk/ghc-opts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..889d2c43d642d17bccc19acf885c000c3702265d
--- /dev/null
+++ b/ghc/mk/ghc-opts.mk
@@ -0,0 +1,192 @@
+#-----------------------------------------------------------------------------
+# $Id: ghc-opts.mk,v 1.2 1996/11/21 16:47:59 simonm Exp $
+
+ifdef DoingRTS
+GCap = -optc-DGCap
+GC2s = -optc-DGC2s
+GC1s = -optc-DG1s
+endif
+
+GHC_OPTS_norm=-O $(GCap)
+GHC_OPTS_p =-O -prof -GPrelude $(GCap) -hisuf p_hi -hisuf-prelude p_hi
+GHC_OPTS_t =-O -ticky -optc-DDEBUG $(GCap) -hisuf t_hi -hisuf-prelude t_hi
+GHC_OPTS_u =-O -unregisterised ???? -ticky $(GCap) -hisuf u_hi -hisuf-prelude u_hi
+GHC_OPTS_mc=-O -concurrent $(GCap) -hisuf mc_hi -hisuf-prelude mc_hi
+GHC_OPTS_mr=-O -concurrent -prof -GPrelude $(GCap) -hisuf mr_hi -hisuf-prelude mr_hi
+GHC_OPTS_mt=-O -concurrent -ticky -optc-DDEBUG $(GCap) -hisuf mt_hi -hisuf-prelude mt_hi
+GHC_OPTS_mp=-O -parallel $(GCap) -hisuf mp_hi -hisuf-prelude mp_hi
+GHC_OPTS_mg=-O -gransim $(GCap) -hisuf mg_hi -hisuf-prelude mg_hi
+
+GHC_OPTS_2s=-O -gc-2s $(GC2s) -hisuf 2s_hi -hisuf-prelude 2s_hi
+GHC_OPTS_1s=-O -gc-1s $(GC1s) -hisuf 1s_hi -hisuf-prelude 1s_hi
+GHC_OPTS_du=-O -gc-du $(GCdu) -hisuf du_hi -hisuf-prelude du_hi
+
+GHC_OPTS_a =-user-setup-a $(GCap) -hisuf a_hi -hisuf-prelude a_hi
+GHC_OPTS_b =-user-setup-b $(GCap) -hisuf b_hi -hisuf-prelude b_hi
+GHC_OPTS_c =-user-setup-c $(GCap) -hisuf c_hi -hisuf-prelude c_hi
+GHC_OPTS_d =-user-setup-d $(GCap) -hisuf d_hi -hisuf-prelude d_hi
+GHC_OPTS_e =-user-setup-e $(GCap) -hisuf e_hi -hisuf-prelude e_hi
+GHC_OPTS_f =-user-setup-f $(GCap) -hisuf f_hi -hisuf-prelude f_hi
+GHC_OPTS_g =-user-setup-g $(GCap) -hisuf g_hi -hisuf-prelude g_hi
+GHC_OPTS_h =-user-setup-h $(GCap) -hisuf h_hi -hisuf-prelude h_hi
+GHC_OPTS_i =-user-setup-i $(GCap) -hisuf i_hi -hisuf-prelude i_hi
+GHC_OPTS_j =-user-setup-j $(GCap) -hisuf j_hi -hisuf-prelude j_hi
+GHC_OPTS_k =-user-setup-k $(GCap) -hisuf k_hi -hisuf-prelude k_hi
+GHC_OPTS_l =-user-setup-l $(GCap) -hisuf l_hi -hisuf-prelude l_hi
+GHC_OPTS_m =-user-setup-m $(GCap) -hisuf m_hi -hisuf-prelude m_hi
+GHC_OPTS_n =-user-setup-n $(GCap) -hisuf n_hi -hisuf-prelude n_hi
+GHC_OPTS_o =-user-setup-o $(GCap) -hisuf o_hi -hisuf-prelude o_hi
+GHC_OPTS_A =-user-setup-A $(GCap) -hisuf A_hi -hisuf-prelude A_hi
+GHC_OPTS_B =-user-setup-B $(GCap) -hisuf B_hi -hisuf-prelude B_hi
+
+# used in hslibs:
+
+HC_OPTS_norm= $(GHC_OPTS_norm)
+HC_OPTS_p = $(GHC_OPTS_p)
+HC_OPTS_t = $(GHC_OPTS_t)
+HC_OPTS_u = $(GHC_OPTS_u)
+HC_OPTS_mc= $(GHC_OPTS_mc)
+HC_OPTS_mr= $(GHC_OPTS_mr)
+HC_OPTS_mt= $(GHC_OPTS_mt)
+HC_OPTS_mp= $(GHC_OPTS_mp)
+HC_OPTS_mg= $(GHC_OPTS_mg)
+HC_OPTS_2s= $(GHC_OPTS_2s)
+HC_OPTS_1s= $(GHC_OPTS_1s)
+HC_OPTS_du= $(GHC_OPTS_du)
+HC_OPTS_a = $(GHC_OPTS_a)
+HC_OPTS_b = $(GHC_OPTS_b)
+HC_OPTS_c = $(GHC_OPTS_c)
+HC_OPTS_d = $(GHC_OPTS_d)
+HC_OPTS_e = $(GHC_OPTS_e)
+HC_OPTS_f = $(GHC_OPTS_f)
+HC_OPTS_g = $(GHC_OPTS_g)
+HC_OPTS_h = $(GHC_OPTS_h)
+HC_OPTS_i = $(GHC_OPTS_i)
+HC_OPTS_j = $(GHC_OPTS_j)
+HC_OPTS_k = $(GHC_OPTS_k)
+HC_OPTS_l = $(GHC_OPTS_l)
+HC_OPTS_m = $(GHC_OPTS_m)
+HC_OPTS_n = $(GHC_OPTS_n)
+HC_OPTS_o = $(GHC_OPTS_o)
+HC_OPTS_A = $(GHC_OPTS_A)
+HC_OPTS_B = $(GHC_OPTS_B)
+
+#-----------------------------------------------------------------------------
+# Build up a list of the suffixes for which we're building
+
+# this stuff is used by the rts and lib Makefiles.
+
+WAY_SUFFIXES =
+
+ifeq ($(Build_p), YES)
+WAY_SUFFIXES += p
+endif 
+
+ifeq ($(Build_t), YES)
+WAY_SUFFIXES += t
+endif 
+
+ifeq ($(Build_u), YES)
+WAY_SUFFIXES += u
+endif 
+
+ifeq ($(Build_mc), YES)
+WAY_SUFFIXES += mc
+endif 
+
+ifeq ($(Build_mr), YES)
+WAY_SUFFIXES += mr
+endif 
+
+ifeq ($(Build_mt), YES)
+WAY_SUFFIXES += mt
+endif 
+
+ifeq ($(Build_mp), YES)
+WAY_SUFFIXES += mp
+endif 
+
+ifeq ($(Build_mg), YES)
+WAY_SUFFIXES += mg
+endif 
+
+ifeq ($(Build_2s), YES)
+WAY_SUFFIXES += 2s
+endif 
+
+ifeq ($(Build_1s), YES)
+WAY_SUFFIXES += 1s
+endif 
+
+ifeq ($(Build_du), YES)
+WAY_SUFFIXES += du
+endif 
+
+ifeq ($(Build_a), YES)
+WAY_SUFFIXES += a
+endif 
+
+ifeq ($(Build_b), YES)
+WAY_SUFFIXES += b
+endif 
+
+ifeq ($(Build_c), YES)
+WAY_SUFFIXES += c
+endif 
+
+ifeq ($(Build_d), YES)
+WAY_SUFFIXES += d
+endif 
+
+ifeq ($(Build_e), YES)
+WAY_SUFFIXES += e
+endif 
+
+ifeq ($(Build_f), YES)
+WAY_SUFFIXES += f
+endif 
+
+ifeq ($(Build_g), YES)
+WAY_SUFFIXES += g
+endif 
+
+ifeq ($(Build_h), YES)
+WAY_SUFFIXES += h
+endif 
+
+ifeq ($(Build_i), YES)
+WAY_SUFFIXES += i
+endif 
+
+ifeq ($(Build_j), YES)
+WAY_SUFFIXES += j
+endif 
+
+ifeq ($(Build_k), YES)
+WAY_SUFFIXES += k
+endif 
+
+ifeq ($(Build_l), YES)
+WAY_SUFFIXES += l
+endif 
+
+ifeq ($(Build_m), YES)
+WAY_SUFFIXES += m
+endif 
+
+ifeq ($(Build_n), YES)
+WAY_SUFFIXES += n
+endif 
+
+ifeq ($(Build_o), YES)
+WAY_SUFFIXES += o
+endif 
+
+ifeq ($(Build_A), YES)
+WAY_SUFFIXES += A 
+endif 
+
+ifeq ($(Build_B), YES)
+WAY_SUFFIXES += B
+endif 
+
diff --git a/ghc/mk/ghc.mk b/ghc/mk/ghc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3e2bc9148776875e4e0b4ff3f73151662c640f29
--- /dev/null
+++ b/ghc/mk/ghc.mk
@@ -0,0 +1,14 @@
+# -----------------------------------------------------------------------------
+# $Id: ghc.mk,v 1.2 1996/11/21 16:48:00 simonm Exp $
+
+# include the generic build stuff first...
+
+include $(TOP)/mk/gen.mk
+
+# then the specific GHC stuff, so we can override defaults if
+# necessary.
+
+include $(TOP)/ghc/mk/buildinfo.mk
+include $(TOP)/ghc/mk/site-ghc.mk
+include $(TOP)/ghc/mk/ghcconfig.mk
+include $(TOP)/ghc/mk/suffixes-ghc.mk
diff --git a/ghc/mk/ghcconfig.mk.in b/ghc/mk/ghcconfig.mk.in
new file mode 100644
index 0000000000000000000000000000000000000000..41d82f4ee0d51fd8f0d59c78c66ffcfee45f1ca5
--- /dev/null
+++ b/ghc/mk/ghcconfig.mk.in
@@ -0,0 +1,239 @@
+# -----------------------------------------------------------------------------
+# $Id: ghcconfig.mk.in,v 1.2 1996/11/21 16:48:02 simonm Exp $
+
+# This stuff should be split into separate files: that which can be 
+# messed with, and that which can't.
+
+# =============================================================================
+# Autoconf'ed stuff
+
+WithGhcHc		= @WithGhcHc@
+WithGhcHcType		= @WithGhcHcType@
+
+# Override default haskell compiler if required
+ifneq ($(WithGhcHcType),HC_UNSPECIFIED)
+HC			= $(WithGhcHc)
+HaskellCompilerType	= $(WithGhcHcType)
+endif
+
+GhcWithHscBuiltViaC	= @GhcWithHscBuiltViaC@
+GhcWithHscOptimised 	= @GhcWithHscOptimised@
+GhcWithHscDebug 	= @GhcWithHscDebug@
+GhcBuilderVersion 	= @GhcBuilderVersion@
+GhcWithRegisterised 	= @GhcWithRegisterised@
+GhcWithNativeCodeGen 	= @GhcWithNativeCodeGen@
+
+GhcWithDeforester	= @GhcWithDeforester@
+GhcWithReadline 	= @GhcWithReadline@
+GhcWithSockets 		= @GhcWithSockets@
+
+# =====================================================================
+# Utilties for ghc project
+
+ifeq ($(GhcWithHscOptimised), YES)
+__hsc_opt 		= -O
+else
+__hsc_opt 		=
+endif
+
+ifeq ($(HaskellCompilerType), HC_CHALMERS_HBC)
+SETUP_HC_OPTS 		= $(__hsc_opt) -fpbu
+else
+ifeq ($(HaskellCompilerType), HC_GLASGOW_GHC)
+SETUP_HC_OPTS 		= $(__hsc_opt) -hi-diffs -link-chk
+else
+ifeq ($(HaskellCompilerType),HC_ROJEMO_NHC)
+SETUP_HC_OPTS 		=
+else
+SETUP_HC_OPTS 		=
+endif
+endif
+endif
+
+ifeq ($(HaveGcc), YES)
+ifeq ($(UseGcc),  YES)
+PROJECT_CC_OPTS 	= -O
+endif
+endif
+
+PROJECT_MSUB_OPTS	= -f $(TOP)/ghc/mk/ghcconfig.mk -f $(TOP)/ghc/mk/buildinfo.mk -f $(TOP)/ghc/mk/site-ghc.mk
+
+#-----------------------------------------------------------------------------
+# MkDependHS
+
+ifdef UseInstalledUtils
+MKDEPENDHS		= mkdependHS
+else
+MKDEPENDHS 		= $(MKDEPENDHSSRC)/mkdependHS
+MKDEPENDHSSRC 		= $(GHC_UTILSRC)/mkdependHS
+endif
+
+# Temp until we bootstrap to 2.01 properly
+ifeq ($(Ghc2_0),YES)
+  MKDEPENDHS = mkdependHS
+else
+  MKDEPENDHS = mkdependHS-1.2
+endif
+
+#-----------------------------------------------------------------------------
+# Unlit
+
+UNLIT	 		= $(GHC_UNLITSRC)/unlit
+
+#ToDo: unlitNeededHere
+
+GHC_UNLIT    		= $(UNLIT)
+GHC_UNLITSRC 		= $(GHC_UTILSRC)/unlit
+
+#-----------------------------------------------------------------------------
+# HsTags
+
+ifdef UseInstalledUtils
+HSTAGS	 		= hstags
+else
+HSTAGS	 		= $(HSTAGSSRC)/hstags
+HSTAGSSRC 		= $(GHC_UTILSRC)/hstags
+endif
+
+GLUED_HSTAGS_OPTS = \
+	$(ALL_PROJECTS_HSTAGS_OPTS) \
+	$(PLATFORM_HSTAGS_OPTS) \
+	$(PROJECT_HSTAGS_OPTS) \
+	$(SETUP_HSTAGS_OPTS) \
+	$(HSTAGS_OPTS) \
+	$(EXTRA_HSTAGS_OPTS)
+
+HSTAGSFLAGS        = $(GLUED_HSTAGS_OPTS)
+
+#-----------------------------------------------------------------------------
+# Ugen
+
+ifdef UseInstalledUtils
+UGEN		=  ugen
+else
+UGEN		= $(UGENSRC)/ugen
+UGENSRC 	= $(GHC_UTILSRC)/ugen
+endif
+
+#-----------------------------------------------------------------------------
+# Extra things ``only for'' for the ghc project
+
+PROJECTNAME		= The Glorious Glasgow Haskell Compilation System
+PROJECTVERSION		= 2.01
+PROJECTPATCHLEVEL	= patchlevel 0
+GhcBuildeeVersion	= 201
+
+GHC_DRIVERSRC	    	= $(TOP)/ghc/driver
+GHC_COMPILERSRC  	= $(TOP)/ghc/compiler
+GHC_RUNTIMESRC   	= $(TOP)/ghc/runtime
+GHC_LIBSRC	 	= $(TOP)/ghc/lib
+GHC_INCLUDESRC   	= $(TOP)/ghc/includes
+GHC_UTILSRC	 	= $(TOP)/ghc/utils
+GHC_BOOKSRC	 	= $(TOP)/ghc/book
+
+GHC_INCLUDES		= $(GHC_INCLUDESRC)
+
+ifeq ($(HaskellCompilerType), HC_CHALMERS_HBC)
+GHC_RTS_STYLE = 'hbc'
+else
+ifeq ($(HaskellCompilerType), HC_ROJEMO_NHC)
+GHC_RTS_STYLE = 'ghc' /* wrong, but more likely to trigger something */
+else
+GHC_RTS_STYLE = 'ghc'
+endif
+endif
+
+PROJECT_GHC_OPTS	= -hi-diffs -dcore-lint -link-chk
+
+GLUED_GHC_OPTS = \
+	$(ALL_PROJECTS_GHC_OPTS) \
+	$(PLATFORM_GHC_OPTS) \
+	$(PROJECT_GHC_OPTS) \
+	$(SETUP_GHC_OPTS) \
+	$(GHC_OPTS) \
+	$(EXTRA_GHC_OPTS)
+
+GHCFLAGS=$(GLUED_CPP_DEFINES) $(GLUED_GHC_OPTS)
+
+#-----------------------------------------------------------------------------
+# What to build
+
+BuildYorkInterpreter 	= NO
+UseSemantiqueStrictnessAnalyser = NO
+
+#-----------------------------------------------------------------------------
+# Installation: whether to, where to, what to
+
+AT_GLASGOW 		= @AT_GLASGOW@
+
+ifeq ($(AT_GLASGOW),1)
+GHC_DRIVER_INST_NAME	= ghc-$(PROJECTVERSION)
+else
+GHC_DRIVER_INST_NAME	= ghc
+endif
+
+# Make sure we install things with group 'grasp' at Glasgow
+
+ifeq ($(AT_GLASGOW),1)
+INSTGROUP		= -g grasp
+endif
+
+# At Glasgow, we would rather the installed binaries were stripped.
+# (Delete if you feel otherwise.)
+
+INSTSTRIP		= -s
+
+# Installation directories --------------------------------------------------
+
+prefix_GHC 		= @prefix@
+exec_prefix_GHC 	= @exec_prefix@
+
+ifeq ($(AT_GLASGOW), 1)
+INSTBINDIR_GHC 		= $(exec_prefix_GHC)/bin/`/usr/local/gnu/bin/hw_os`
+else
+INSTBINDIR_GHC 		= $(exec_prefix_GHC)/bin
+endif
+
+INSTSCRIPDIR_GHC   = $(exec_prefix_GHC)/bin
+INSTLIBDIR_GHC 	   = $(prefix_GHC)/lib/ghc/$(PROJECTVERSION)/$(HOSTPLATFORM)
+INSTDATADIR_GHC    = $(prefix_GHC)/lib/ghc/$(PROJECTVERSION)
+INSTIMPORTSDIR_GHC = $(INSTDATADIR_GHC)/imports
+
+# -----------------------------------------------------------------------------
+# Where to find the programs for the various phases
+
+GHC 			= $(GHC_DRIVERSRC)/ghc
+GHC_HSCPP    		= $(GHC_HSCPPSRC)/hscpp $(ALLPROJ_CPP_DEFINES)
+GHC_HSCPPSRC 		= $(GHC_UTILSRC)/hscpp
+GHC_HSP    		= $(GHC_HSPSRC)/hsp
+GHC_HSPSRC 		= $(GHC_HSCSRC)
+GHC_HSC    		= $(GHC_HSCSRC)/hsc
+GHC_HSCSRC 		= $(GHC_COMPILERSRC)
+GHC_SYSMAN    		= $(GHC_RUNTIMESRC)/gum/SysMan
+GHC_SYSMANSRC 		= $(GHC_RUNTIMESRC)
+
+#-----------------------------------------------------------------------------
+# Stuff for the C-compiling phase in particular...
+
+# NON-OPTIMISING C COMPILATION: =================================
+
+ifeq ($(HaveGcc), YES)
+GhcUseGccForDebuggingAsm 	= YES
+GHC_DEBUG_HILEV_ASM 		= $(WhatGccIsCalled)
+else
+GhcUseGccForDebuggingAsm 	= NO
+GHC_DEBUG_HILEV_ASM 		= $(CC)
+endif
+
+# OPTIMISING C COMPILATION (regs, etc): ==========================
+
+ifeq ($(HaveGcc), YES)
+GhcUseGccForOptAsm 		= YES
+GHC_OPT_HILEV_ASM 		= $(WhatGccIsCalled)
+GHC_GCC_IS_AVAILABLE 		= 1
+else
+GhcUseGccForOptAsm	 	= NO
+GHC_OPT_HILEV_ASM 		= $(CC)
+GHC_GCC_IS_AVAILABLE 		= 0
+endif
+
diff --git a/ghc/mk/site-ghc.mk b/ghc/mk/site-ghc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0a338b2b02087bb96b3715c09c27272aa5998bba
--- /dev/null
+++ b/ghc/mk/site-ghc.mk
@@ -0,0 +1,99 @@
+#-----------------------------------------------------------------------------
+# $Id: site-ghc.mk,v 1.2 1996/11/21 16:48:03 simonm Exp $
+
+# GHC_BUILD_FLAG_x
+#	these are alternative flag names that can be given
+# 	to the driver to indicate build x.
+
+# GHC_BUILD_OPTS_x
+#	these are lists of flags to be added when the driver
+#	receives a $(GHC_BUILD_FLAG_x) flag.  Only valid for
+#	user build ways.
+
+# ================================================================
+# Set WAYS according to which ways you want to build ghc and its libs
+
+WAYS =
+
+#WAYS = mc mr mt mp mg 2s 1s du p t a b c d e f g h i j k l m n o p A B
+
+# ================================================================
+# BUILDS stuff: main sequential ones
+
+GHC_BUILD_FLAG_normal =
+GHC_BUILD_FLAG_p      =
+GHC_BUILD_FLAG_t      =
+GHC_BUILD_FLAG_u      =
+
+# === builds: concurrent and parallel ============================
+
+GHC_BUILD_FLAG_mc =
+GHC_BUILD_FLAG_mr =
+GHC_BUILD_FLAG_mt =
+GHC_BUILD_FLAG_mp =
+GHC_BUILD_FLAG_mg =
+
+# === builds: non-std garbage collectors ==========================
+
+GHC_BUILD_FLAG_2s = -gc-2s
+GHC_BUILD_FLAG_1s = -gc-1s
+GHC_BUILD_FLAG_du = -gc-du
+
+# === builds: "user ways" =======================================
+
+GHC_BUILD_FLAG_a =
+GHC_BUILD_OPTS_a =
+		  
+GHC_BUILD_FLAG_b =
+GHC_BUILD_OPTS_b =
+		  
+GHC_BUILD_FLAG_c =
+GHC_BUILD_OPTS_c =
+		  
+GHC_BUILD_FLAG_d =
+GHC_BUILD_OPTS_d =
+		  
+GHC_BUILD_FLAG_e =
+GHC_BUILD_OPTS_e =
+		  
+GHC_BUILD_FLAG_f =
+GHC_BUILD_OPTS_f =
+		  
+GHC_BUILD_FLAG_g =
+GHC_BUILD_OPTS_g =
+		  
+GHC_BUILD_FLAG_h =
+GHC_BUILD_OPTS_h =
+		  
+GHC_BUILD_FLAG_i =
+GHC_BUILD_OPTS_i =
+		  
+GHC_BUILD_FLAG_j =
+GHC_BUILD_OPTS_j =
+		  
+GHC_BUILD_FLAG_k =
+GHC_BUILD_OPTS_k =
+		  
+GHC_BUILD_FLAG_l =
+GHC_BUILD_OPTS_l =
+		  
+GHC_BUILD_FLAG_m =
+GHC_BUILD_OPTS_m =
+		  
+GHC_BUILD_FLAG_n =
+GHC_BUILD_OPTS_n =
+		  
+GHC_BUILD_FLAG_o =
+GHC_BUILD_OPTS_o =
+		  
+GHC_BUILD_FLAG_A =
+GHC_BUILD_OPTS_A =
+		  
+GHC_BUILD_FLAG_B =
+GHC_BUILD_OPTS_B =
+
+# ======= END OF BUILD INFO ====================================
+
+# Temp until we reliable bootstrap
+
+Ghc2_0 = NO
diff --git a/ghc/mk/suffixes-ghc.mk b/ghc/mk/suffixes-ghc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6965e16a3ca7a4e7d57853d2b9b07e45d9520fc4
--- /dev/null
+++ b/ghc/mk/suffixes-ghc.mk
@@ -0,0 +1,40 @@
+# -----------------------------------------------------------------------------
+# suffxies-ghc.mk
+
+# suffix rules needed for compiling bits of ghc.
+
+# -----------------------------------------------------------------------------
+
+ifdef UnlitSuffixRules
+
+define UnlitSuffixCmds
+	$(RM) $@
+	$(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
+	@chmod 444 $@
+endef
+
+.lprl.prl:
+	$(UnlitSuffixCmds)
+
+.lh.h:
+	$(UnlitSuffixCmds)
+
+.lc.c:
+	$(UnlitSuffixCmds)
+
+.lhc.hc:
+	$(UnlitSuffixCmds)
+
+endif
+
+# -----------------------------------------------------------------------------
+
+ifdef UgenSuffixRules
+
+%.h %.c %.U.hs : %.ugn
+	@$(RM) $@ $*.hs $*.U.hs $*.h
+	$(UGEN) $< || $(RM) $*.h $@ $*.hs
+	@$(MV) -f $*.hs $*.U.hs
+	@chmod 444 $*.h $@ $*.U.hs
+
+endif
diff --git a/ghc/mkworld/GHC_OPTS b/ghc/mkworld/GHC_OPTS
deleted file mode 100644
index 6c537e4c30de14c01f0607ad78a48d36bab767ab..0000000000000000000000000000000000000000
--- a/ghc/mkworld/GHC_OPTS
+++ /dev/null
@@ -1,64 +0,0 @@
-/* included in ghc/{lib,runtime}/Jmakefile so that
-   each build is compiled consistently
-*/
-
-GHC_OPTS_norm=-O rts_or_lib(-optc-DGCap,)
-GHC_OPTS_p =-O -prof -GPrelude rts_or_lib(-optc-DGCap,) -hisuf p_hi -hisuf-prelude p_hi
-GHC_OPTS_t =-O -ticky -optc-DDEBUG rts_or_lib(-optc-DGCap,) -hisuf t_hi -hisuf-prelude t_hi
-GHC_OPTS_u =-O -unregisterised ???? -ticky rts_or_lib(-optc-DGCap,) -hisuf u_hi -hisuf-prelude u_hi
-GHC_OPTS_mc=-O -concurrent rts_or_lib(-optc-DGCap,) -hisuf mc_hi -hisuf-prelude mc_hi
-GHC_OPTS_mr=-O -concurrent -prof -GPrelude rts_or_lib(-optc-DGCap,) -hisuf mr_hi -hisuf-prelude mr_hi
-GHC_OPTS_mt=-O -concurrent -ticky -optc-DDEBUG rts_or_lib(-optc-DGCap,) -hisuf mt_hi -hisuf-prelude mt_hi
-GHC_OPTS_mp=-O -parallel rts_or_lib(-optc-DGCap,) -hisuf mp_hi -hisuf-prelude mp_hi
-GHC_OPTS_mg=-O -gransim rts_or_lib(-optc-DGCap,) -hisuf mg_hi -hisuf-prelude mg_hi
-GHC_OPTS_2s=-O -gc-2s rts_or_lib(-optc-DGC2s,) -hisuf 2s_hi -hisuf-prelude 2s_hi
-GHC_OPTS_1s=-O -gc-1s rts_or_lib(-optc-DGC1s,) -hisuf 1s_hi -hisuf-prelude 1s_hi
-GHC_OPTS_du=-O -gc-du rts_or_lib(-optc-DGCdu,) -hisuf du_hi -hisuf-prelude du_hi
-GHC_OPTS_a =-user-setup-a rts_or_lib(-optc-DGCap,) -hisuf a_hi -hisuf-prelude a_hi
-GHC_OPTS_b =-user-setup-b rts_or_lib(-optc-DGCap,) -hisuf b_hi -hisuf-prelude b_hi
-GHC_OPTS_c =-user-setup-c rts_or_lib(-optc-DGCap,) -hisuf c_hi -hisuf-prelude c_hi
-GHC_OPTS_d =-user-setup-d rts_or_lib(-optc-DGCap,) -hisuf d_hi -hisuf-prelude d_hi
-GHC_OPTS_e =-user-setup-e rts_or_lib(-optc-DGCap,) -hisuf e_hi -hisuf-prelude e_hi
-GHC_OPTS_f =-user-setup-f rts_or_lib(-optc-DGCap,) -hisuf f_hi -hisuf-prelude f_hi
-GHC_OPTS_g =-user-setup-g rts_or_lib(-optc-DGCap,) -hisuf g_hi -hisuf-prelude g_hi
-GHC_OPTS_h =-user-setup-h rts_or_lib(-optc-DGCap,) -hisuf h_hi -hisuf-prelude h_hi
-GHC_OPTS_i =-user-setup-i rts_or_lib(-optc-DGCap,) -hisuf i_hi -hisuf-prelude i_hi
-GHC_OPTS_j =-user-setup-j rts_or_lib(-optc-DGCap,) -hisuf j_hi -hisuf-prelude j_hi
-GHC_OPTS_k =-user-setup-k rts_or_lib(-optc-DGCap,) -hisuf k_hi -hisuf-prelude k_hi
-GHC_OPTS_l =-user-setup-l rts_or_lib(-optc-DGCap,) -hisuf l_hi -hisuf-prelude l_hi
-GHC_OPTS_m =-user-setup-m rts_or_lib(-optc-DGCap,) -hisuf m_hi -hisuf-prelude m_hi
-GHC_OPTS_n =-user-setup-n rts_or_lib(-optc-DGCap,) -hisuf n_hi -hisuf-prelude n_hi
-GHC_OPTS_o =-user-setup-o rts_or_lib(-optc-DGCap,) -hisuf o_hi -hisuf-prelude o_hi
-GHC_OPTS_A =-user-setup-A rts_or_lib(-optc-DGCap,) -hisuf A_hi -hisuf-prelude A_hi
-GHC_OPTS_B =-user-setup-B rts_or_lib(-optc-DGCap,) -hisuf B_hi -hisuf-prelude B_hi
-
-/* used in hslibs: */
-HC_OPTS_norm= $(GHC_OPTS_norm)
-HC_OPTS_p = $(GHC_OPTS_p)
-HC_OPTS_t = $(GHC_OPTS_t)
-HC_OPTS_u = $(GHC_OPTS_u)
-HC_OPTS_mc= $(GHC_OPTS_mc)
-HC_OPTS_mr= $(GHC_OPTS_mr)
-HC_OPTS_mt= $(GHC_OPTS_mt)
-HC_OPTS_mp= $(GHC_OPTS_mp)
-HC_OPTS_mg= $(GHC_OPTS_mg)
-HC_OPTS_2s= $(GHC_OPTS_2s)
-HC_OPTS_1s= $(GHC_OPTS_1s)
-HC_OPTS_du= $(GHC_OPTS_du)
-HC_OPTS_a = $(GHC_OPTS_a)
-HC_OPTS_b = $(GHC_OPTS_b)
-HC_OPTS_c = $(GHC_OPTS_c)
-HC_OPTS_d = $(GHC_OPTS_d)
-HC_OPTS_e = $(GHC_OPTS_e)
-HC_OPTS_f = $(GHC_OPTS_f)
-HC_OPTS_g = $(GHC_OPTS_g)
-HC_OPTS_h = $(GHC_OPTS_h)
-HC_OPTS_i = $(GHC_OPTS_i)
-HC_OPTS_j = $(GHC_OPTS_j)
-HC_OPTS_k = $(GHC_OPTS_k)
-HC_OPTS_l = $(GHC_OPTS_l)
-HC_OPTS_m = $(GHC_OPTS_m)
-HC_OPTS_n = $(GHC_OPTS_n)
-HC_OPTS_o = $(GHC_OPTS_o)
-HC_OPTS_A = $(GHC_OPTS_A)
-HC_OPTS_B = $(GHC_OPTS_B)
diff --git a/ghc/mkworld/Jmakefile b/ghc/mkworld/Jmakefile
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/ghc/mkworld/install-ghc.jm b/ghc/mkworld/install-ghc.jm
deleted file mode 100644
index abcb9162b31ed372cdfce3c2cc6dae749cd0db3b..0000000000000000000000000000000000000000
--- a/ghc/mkworld/install-ghc.jm
+++ /dev/null
@@ -1,9 +0,0 @@
-#if 0
-%************************************************************************
-%*									*
-\section[mkworld-install-ghc]{Installation stuff for @ghc@ project}
-%*									*
-%************************************************************************
-
-NONE.
-#endif
diff --git a/ghc/mkworld/macros-ghc.jm b/ghc/mkworld/macros-ghc.jm
deleted file mode 100644
index 18d33290a23b0361a40d22b81bb4ff5d8e8cf2cf..0000000000000000000000000000000000000000
--- a/ghc/mkworld/macros-ghc.jm
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ToDo: cmp -> $(CMP) */
-
-#ifndef UgenTarget
-#define UgenTarget(dir,fileroot)					@@\
-ExtraStuffToBeVeryClean(dir/fileroot.c dir/fileroot.h dir/fileroot.hs)		@@\
-dir/fileroot.c dir/CAT3(U_,fileroot,.hs): dir/fileroot.ugn						@@\
-	$(RM) dir/fileroot.c dir/fileroot.hs dir/CAT3(U_,fileroot,.hs) dir/fileroot.h-SAVE 	@@\
-	if [ -f dir/fileroot.h ] ; then $(MV) -f dir/fileroot.h dir/fileroot.h-SAVE ; else exit 0 ; fi @@\
-	$(UGEN) dir/fileroot.ugn || ( $(RM) dir/fileroot.h dir/fileroot.c dir/CAT3(U_,fileroot,.hs); $(MV) -f dir/fileroot.h-SAVE dir/fileroot.h )						@@\
-	if cmp -s dir/fileroot.h-SAVE dir/fileroot.h ; then \			@@\
-	    $(MV) -f dir/fileroot.h-SAVE dir/fileroot.h ; \			@@\
-	else \									@@\
-	    chmod 444 dir/fileroot.h dir/fileroot.c dir/fileroot.hs ; \		@@\
-	fi									@@\
-	@$(RM) dir/fileroot.h-SAVE						@@\
-	$(MV) -f dir/fileroot.hs dir/CAT3(U_,fileroot,.hs)			@@\
-										@@\
-dir/fileroot.h : dir/fileroot.c							@@\
-	@: /* no-op */
-#endif /* UgenTarget */
diff --git a/ghc/mkworld/only4-ghc.jm b/ghc/mkworld/only4-ghc.jm
deleted file mode 100644
index 15b1c0f4096986b4bf5a77e89f35f7c125fd66f6..0000000000000000000000000000000000000000
--- a/ghc/mkworld/only4-ghc.jm
+++ /dev/null
@@ -1,391 +0,0 @@
-#if 0
-%************************************************************************
-%*									*
-\section[mkworld-only4-ghc]{Extra things ``only for'' for the @ghc@ project}
-%*									*
-%************************************************************************
-
-\begin{code}
-#endif /* 0 */
-/* Project identification - name and version */
-
-#ifndef ProjectName
-#define ProjectName     The Glorious Glasgow Haskell Compilation System
-#endif
-/* ProjectVersion is something printable */
-#ifndef ProjectVersion
-#define ProjectVersion  2.01
-#endif
-/* A patchlevel change is something *very minor* */
-#ifndef ProjectPatchLevel
-#define ProjectPatchLevel patchlevel 0
-#endif
-/* GhcBuildeeVersion is something CPP-testable (ProjectVersion * 100) */
-#ifndef GhcBuildeeVersion
-#define GhcBuildeeVersion  201
-#endif
-#if 0
-\end{code}
-
-Make variables that say where the source to main pieces of the system live:
-\begin{code}
-#endif /* 0 */
-/* state of the source world */
-GHC_DRIVERSRC    = $(TOP)/ghc/driver
-GHC_COMPILERSRC  = $(TOP)/ghc/compiler
-GHC_RUNTIMESRC   = $(TOP)/ghc/runtime
-GHC_LIBSRC	 = $(TOP)/ghc/lib
-GHC_INCLUDESRC   = $(TOP)/ghc/includes
-GHC_UTILSRC	 = $(TOP)/ghc/utils
-GHC_BOOKSRC	 = $(TOP)/ghc/book
-#if 0
-\end{code}
-
-Include definitions (usually to go with generated C):
-\begin{code}
-#endif /* 0 */
-#ifndef GhcIncludesDir
-#define GhcIncludesDir $(GHC_INCLUDESRC)
-#endif
-GHC_INCLUDES = GhcIncludesDir
-#if 0
-\end{code}
-
-A make variable that's occasionally very important: we use \tr{GHC_*}
-when we really mean GHC, rather than \tr{HC*}, which just means ``the
-standard Haskell compiler'' (whatever that is).
-\begin{code}
-#endif /* 0 */
-#ifndef AllProjectsGhcOpts
-#define AllProjectsGhcOpts /*none*/
-#endif
-
-#ifndef PlatformGhcOpts
-#define PlatformGhcOpts /*none*/
-#endif
-
-#if HaskellCompilerType == HC_CHALMERS_HBC
-GHC_RTS_STYLE = 'hbc'
-#else
-# if HaskellCompilerType == HC_ROJEMO_NHC
-GHC_RTS_STYLE = 'ghc' /* wrong, but more likely to trigger something */
-# else
-GHC_RTS_STYLE = 'ghc'
-# endif
-#endif
-
-#ifndef ProjectGhcOpts
-#define ProjectGhcOpts -hi-diffs -dcore-lint -link-chk
-#endif /* ! ProjectGhcOpts */
-
-#ifndef SetupGhcOpts
-#define SetupGhcOpts /*none*/
-#endif
-
-GenerateOptionsMakeVars(GHC,OPTS,AllProjectsGhcOpts,PlatformGhcOpts,ProjectGhcOpts,SetupGhcOpts)
-
-GHCFLAGS=$(GLUED_CPP_DEFINES) $(GLUED_GHC_OPTS)
-#if 0
-\end{code}
-
-%************************************************************************
-%*									*
-\subsection{What to build}
-%*									*
-%************************************************************************
-
-%************************************************************************
-%*									*
-\subsubsection{Include or leave out these individual ``features''}
-%*									*
-%************************************************************************
-
-\begin{code}
-#endif /* 0 */
-/* build York interpreter as well as Glasgow compiler
-*/
-#ifndef BuildYorkInterpreter
-#define BuildYorkInterpreter NO
-#endif
-
-/* incorporate Semantique strictness analyser into the compiler;
-   it analyses, but the info generated is *UNUSED* :-(
- */
-#ifndef UseSemantiqueStrictnessAnalyser
-#define UseSemantiqueStrictnessAnalyser NO
-#endif
-#if 0
-\end{code}
-
-%************************************************************************
-%*									*
-\subsection{Installation: whether to, where to, what to}
-%*									*
-%************************************************************************
-
-\begin{code}
-#endif /* 0 */
-/* defaults for which pieces should be installed */
-/* ToDo: possibly obsolete */
-#ifndef DoInstallGHCSystem
-#define DoInstallGHCSystem	YES
-#endif /* DoInstallGHCSystem */
-
-/* ------------------------------------------------------------------ */
-/* compiler-proper subsystem:
-    the lib/data bits are installed w/ a version number as well
-*/
-
-#ifndef InstBinDir_GHC
-# if AT_GLASGOW
-#  define InstBinDir_GHC $(exec_prefix_GHC)/bin/`/usr/local/gnu/bin/hw_os`
-# else
-#  define InstBinDir_GHC $(exec_prefix_GHC)/bin
-# endif
-#endif
-
-/* scripts are platform-independent */
-#ifndef InstScriptDir_GHC
-#define InstScriptDir_GHC $(exec_prefix_GHC)/bin
-#endif
-
-/* main "internally-used-by-GHC" stuff */
-#ifndef InstLibDir_GHC
-#define InstLibDir_GHC $(prefix_GHC)/lib/ghc/$(PROJECTVERSION)/$(HOSTPLATFORM)
-#endif
-
-/* "data" is defined (by WDP) to be platform-independent library stuff */
-#ifndef InstDataDir_GHC
-#define InstDataDir_GHC $(prefix_GHC)/lib/ghc/$(PROJECTVERSION)
-#endif
-
-prefix_GHC	  = InstRootDir_GHC	/* set by configure */
-exec_prefix_GHC   = InstBinRootDir_GHC  /* ditto */
-INSTBINDIR_GHC    = InstBinDir_GHC
-INSTSCRIPTDIR_GHC = InstScriptDir_GHC
-INSTLIBDIR_GHC    = InstLibDir_GHC
-INSTDATADIR_GHC   = InstDataDir_GHC
-#if 0
-\end{code}
-
-%************************************************************************
-%*									*
-\subsection{Configuring the driver}
-%*									*
-%************************************************************************
-
-The driver script is the thing that glues the compilation system
-together.  It needs to know what is/isn't included in the system,
-e.g., what garbage-collectors are catered for.
-
-Mkworld records the needed information in make variables (e.g.,
-\tr{$(GHC_HSCPP)}), and we then `msub' that into the driver (perl)
-script.  Note: ALL configuration info should be HERE (not hacked into
-the script)!
-
-The first chunk of stuff here is mkworld boilerplate and probably
-doesn't need fiddling.  Once we get into what C compiler(s) to use for
-compiling .hc files, what libraries are available, etc., there may be
-something to tweak (but not here -- in a `setup' file, please!)  There
-are further comments where the tweakables begin...
-
-First, the driver can be installed under any old name; here's the default:
-\begin{code}
-#endif /* 0 */
-#ifndef GhcDriverInstallName
-#define GhcDriverInstallName ghc
-#endif /* ! GhcDriverInstallName */
-GHC_DRIVER_INST_NAME = GhcDriverInstallName
-#if 0
-\end{code}
-
-%************************************************************************
-%*									*
-\subsubsection{Where to find the programs for the various phases}
-%*									*
-%************************************************************************
-
-First, the driver itself:
-\begin{code}
-#endif /* 0 */
-/* ghc: std driver for compilation system */
-#ifndef GhcDriverCmd
-#define GhcDriverCmd $(GHC_DRIVERSRC)/ghc
-#endif
-
-/* macro to make sure it has been built */
-#ifndef GhcDriverNeededHere
-#define GhcDriverNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC),$(GHC_DRIVERSRC),all)
-#endif
-
-/* could be GHC_DRIVER, but GHC is its common name */
-GHC = GhcDriverCmd
-#if 0
-\end{code}
-
-\tr{unlit}, to de-literatise a source file, is from the HBC
-distribution.  See utils-ghc.
-
-\tr{hscpp}: runs C pre-processor but converts \tr{#line}s to Haskell pragmas;
-is platform-independent.
-\begin{code}
-#endif /* 0 */
-#ifndef HsCppCmd
-#define HsCppCmd $(GHC_HSCPPSRC)/hscpp
-#endif
-
-#ifndef HsCppNeededHere
-#define HsCppNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC_HSCPP),$(GHC_HSCPPSRC),hscpp)
-#endif
-
-GHC_HSCPP    = HsCppCmd $(ALLPROJ_CPP_DEFINES)
-GHC_HSCPPSRC = $(GHC_UTILSRC)/hscpp
-#if 0
-\end{code}
-
-\tr{hsp}: std Haskell parser.
-\begin{code}
-#endif /* 0 */
-#ifndef HsParserCmd
-#define HsParserCmd $(GHC_HSPSRC)/hsp
-#endif
-
-#ifndef HsParserNeededHere
-#define HsParserNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC_HSP),$(GHC_HSPSRC),hsp)
-#endif /* HsParserNeededHere */
-
-GHC_HSP    = HsParserCmd
-GHC_HSPSRC = $(GHC_HSCSRC)
-#if 0
-\end{code}
-
-\tr{hsc}: std Haskell compiler.
-\begin{code}
-#endif /* 0 */
-#ifndef HsCompilerCmd
-#define HsCompilerCmd $(GHC_HSCSRC)/hsc
-#endif
-
-#ifndef HsCompilerNeededHere
-#define HsCompilerNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC_HSC),$(GHC_HSCSRC),hsc)
-#endif /* HsCompilerNeededHere */
-
-GHC_HSC    = HsCompilerCmd
-GHC_HSCSRC = $(GHC_COMPILERSRC)
-#if 0
-\end{code}
-
-\tr{SysMan}: PVM-controlling program for parallel Haskell.
-\begin{code}
-#endif /* 0 */
-#ifndef SysManCmd
-#define SysManCmd $(GHC_RUNTIMESRC)/gum/SysMan
-#endif
-
-#ifndef SysManNeededHere
-#define SysManNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC_SYSMAN),$(GHC_SYSMANSRC),gum/SysMan)
-#endif /* SysManNeededHere */
-
-GHC_SYSMAN    = SysManCmd
-GHC_SYSMANSRC = $(GHC_RUNTIMESRC)
-#if 0
-\end{code}
-
-For an ``assembler'' and a ``linker,'' the driver uses the same
-program as it used for C compilation; this means libraries and things
-are likely to be picked up correctly.
-
-%************************************************************************
-%*									*
-\subsubsection{Stuff for the C-compiling phase in particular...}
-%*									*
-%************************************************************************
-
-{\em High-level assembler}: C compiler with which to compile \tr{.hc} files.
-
-There are {\em three} things to set:
-\begin{enumerate}
-\item
-C compilers to use:
-\begin{itemize}
-\item
-compiler to use for ``debugging'' compilation (@GHC_DEBUG_HILEV_ASM@)
-\item
-compiler to use for ``optimising'' compiling (w/ regs magic, etc)
-(@GHC_OPT_HILEV_ASM@)
-This must be GCC; otherwise opt compiling must be turned off.
-\end{itemize}
-
-\item
-Whether or not you can do the ``optimising''-style compilation (set
-@GHC_GCC_IS_AVAILABLE@).
-\end{enumerate}
-
-For options that should always be applied {\em for this project},
-set the @ProjectGhcOpts@ variable...
-      
-Similarly, for a particular {\em setup}, use @SetupGhcOpts@...
-
-%************************************************************************
-%*									*
-\subsubsubsection{Which C compiler to use (GCC is best)}
-%*									*
-%************************************************************************
-
-\begin{code}
-#endif /* 0 */
-/*  NON-OPTIMISING C COMPILATION: ==================================
-
-    We can use GCC 2.n for the non-optimising (normal) .hc C
-    compilation [use it if we have it]
-*/
-#ifndef GhcUseGccForDebuggingAsm
-#if HaveGcc == YES
-#define GhcUseGccForDebuggingAsm YES
-#else
-#define GhcUseGccForDebuggingAsm NO
-#endif
-#endif
-
-#ifndef GhcDebuggingHighLevelAsmCmd
-#if GhcUseGccForDebuggingAsm == YES
-#define GhcDebuggingHighLevelAsmCmd WhatGccIsCalled
-#else
-#define GhcDebuggingHighLevelAsmCmd $(CC)
-#endif /* ! gcc */
-#endif /* GhcDebuggingHighLevelAsmCmd */
-GHC_DEBUG_HILEV_ASM = GhcDebuggingHighLevelAsmCmd
-
-/*  OPTIMISING C COMPILATION (regs, etc): ==========================
-
-    Must use GCC 2.n for this
-    compilation [OFF by default]
-*/
-/* We have GCC, which is necessary for optimising the Haskell
-    compiler's C output.
-*/
-#ifndef GhcUseGccForOptAsm
-#if HaveGcc == YES
-#define GhcUseGccForOptAsm YES
-#else
-#define GhcUseGccForOptAsm NO
-#endif
-#endif
-
-#ifndef GhcOptHighLevelAsmCmd
-#if GhcUseGccForOptAsm == YES
-#define GhcOptHighLevelAsmCmd WhatGccIsCalled
-GHC_GCC_IS_AVAILABLE = 1
-#else
-GHC_GCC_IS_AVAILABLE = 0
-#endif /* ! gcc */
-#endif /* GhcOptHighLevelAsmCmd */
-GHC_OPT_HILEV_ASM = GhcOptHighLevelAsmCmd
-#if 0
-\end{code}
-#endif /* 0 */
diff --git a/ghc/mkworld/site-ghc.jm.in b/ghc/mkworld/site-ghc.jm.in
deleted file mode 100644
index 41b8289375153f0c18853dd12ad638af179e3462..0000000000000000000000000000000000000000
--- a/ghc/mkworld/site-ghc.jm.in
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
-    @configure_input@
-
-    TargetPlatform.
-    BuildPlatform, HostPlatform are in general site file
-    (e.g. <top>/mkworld/site.jm[.in])
- */
-#ifndef TargetPlatform
-/* use Host* because of 99-cmd-limit brain-dead seds */
-#define TargetPlatform @HostPlatform@
-#endif
-
-/* --------------- "standard" Haskell compiler --------------------------- */
-
-#define WithHc @WithHc@
-#define WithHcType @WithHcType@
-
-#define WithGhcHc @WithGhcHc@
-#define WithGhcHcType @WithGhcHcType@
-
-#if ! (defined(HaskellCompilerCmd) && defined(HaskellCompilerType))
-# if WithGhcHcType != HC_UNSPECIFIED
-#  define HaskellCompilerCmd  WithGhcHc
-#  define HaskellCompilerType WithGhcHcType
-# else
-#  if WithHcType != HC_UNSPECIFIED
-#   define HaskellCompilerCmd  WithHc
-#   define HaskellCompilerType WithHcType
-#  else				  
-#   define HaskellCompilerCmd  haskell-compiler-not-specified
-#   define HaskellCompilerType HC_UNSPECIFIED
-#  endif
-# endif
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-/* Info for booting the Haskell compiler proper (written in Haskell):
-
-   If you're going to use a Haskell compiler for booting:
-    hbc -- set GhcWithHscBuiltViaC to NO
-    ghc -- ditto; and set WhatGhcForBootingIsCalled
-    [well, maybe...]
-
-   If you're going to boot from distributed .hc files (the *default*),
-   you needn't set anything here.
-*/
-#ifndef GhcWithHscBuiltViaC
-#define GhcWithHscBuiltViaC @GhcWithHscBuiltViaC@
-#endif
-#ifndef GhcWithHscOptimised
-#define GhcWithHscOptimised @GhcWithHscOptimised@
-#endif
-#ifndef GhcWithHscDebug
-#define GhcWithHscDebug @GhcWithHscDebug@
-#endif
-#ifndef GhcBuilderVersion
-#define GhcBuilderVersion @GhcBuilderVersion@
-#endif
-#ifndef GhcWithRegisterised
-#define GhcWithRegisterised @GhcWithRegisterised@
-#endif
-#ifndef GhcWithNativeCodeGen
-#define GhcWithNativeCodeGen @GhcWithNativeCodeGen@
-#endif
-GHC_WITH_NATIVE_CODEGEN=GhcWithNativeCodeGen
-
-#ifndef GhcWithDeforester
-#define GhcWithDeforester @GhcWithDeforester@
-#endif
-#ifndef GhcWithReadline
-#define GhcWithReadline @GhcWithReadline@
-#endif
-#ifndef GhcWithSockets
-#define GhcWithSockets @GhcWithSockets@
-#endif
-
-/* ================================================================
-   BUILDS stuff: main sequential ones
-
-   The configure script dumps all the what-builds-to-do info
-   into a file called "buildinfo.jm", in this directory.  We
-   do it this way, rather than AC_SUBSTing the info into this file
-   because some sed's (notably OSF and maybe HP-UX) only allow
-   99 commands (!!!), which is way too few if we want to do the
-   Build_ stuff as well as everything else.  WDP 96/04
-*/
-
-#include "buildinfo.jm"
-
-/* normal sequential */
-#if Build_normal == YES
-# define IfBuild_normal(x) x
-GHC_BUILD_FLAG_normal = -build-normal-defined
-#else
-# define IfBuild_normal(x) /**/
-GHC_BUILD_FLAG_normal = -build-normal-not-defined
-#endif
-
-/* profiled sequential */
-#if Build_p == YES
-# define IfBuild_p(x) x
-GHC_BUILD_FLAG_p = -build-p-defined
-#else
-# define IfBuild_p(x) /**/
-GHC_BUILD_FLAG_p = -build-p-not-defined
-#endif
-
-/* ticky-ticky "profiling" (sequential) */
-#if Build_t == YES	
-# define IfBuild_t(x) x
-GHC_BUILD_FLAG_t = -build-t-defined
-#else
-# define IfBuild_t(x) /**/
-GHC_BUILD_FLAG_t = -build-t-not-defined
-#endif
-
-/* unregisterized (most basic boot) */
-#if Build_u == YES	
-# define IfBuild_u(x) x
-GHC_BUILD_FLAG_u = -build-u-defined
-#else
-# define IfBuild_u(x) /**/
-GHC_BUILD_FLAG_u = -build-u-not-defined
-#endif
-
-/* === builds: concurrent and parallel ============================ */
-
-/* concurrent */
-#if Build_mc == YES
-# define IfBuild_mc(x) x
-GHC_BUILD_FLAG_mc = -build-mc-defined
-#else
-# define IfBuild_mc(x) /**/
-GHC_BUILD_FLAG_mc = -build-mc-not-defined
-#endif
-
-/* profiled concurrent */
-#if Build_mr == YES
-# define IfBuild_mr(x) x
-GHC_BUILD_FLAG_mr = -build-mr-defined
-#else
-# define IfBuild_mr(x) /**/
-GHC_BUILD_FLAG_mr = -build-mr-not-defined
-#endif
-
-/* ticky concurrent */
-#if Build_mt == YES
-# define IfBuild_mt(x) x
-GHC_BUILD_FLAG_mt = -build-mt-defined
-#else
-# define IfBuild_mt(x) /**/
-GHC_BUILD_FLAG_mt = -build-mt-not-defined
-#endif
-
-/* parallel (GUM, PVM-based) */
-#if Build_mp == YES
-# define IfBuild_mp(x) x
-GHC_BUILD_FLAG_mp = -build-mp-defined
-#else
-# define IfBuild_mp(x) /**/
-GHC_BUILD_FLAG_mp = -build-mp-not-defined
-#endif
-
-/* GranSim */
-#if Build_mg == YES
-# define IfBuild_mg(x) x
-GHC_BUILD_FLAG_mg = -build-mg-defined
-#else
-# define IfBuild_mg(x) /**/
-GHC_BUILD_FLAG_mg = -build-mg-not-defined
-#endif
-
-/* === builds: non-std garbage collectors ==========================
-   These use the same mechanism as user ways
-   but do not have any "fed back" options.
-*/
-
-/* sequential -- 2-space collector */
-#if Build_2s == YES
-# define IfBuild_2s(x) x
-GHC_BUILD_FLAG_2s = -gc-2s
-#else
-# define IfBuild_2s(x) /**/
-GHC_BUILD_FLAG_2s = -build-2s-not-defined
-#endif
-
-/* sequential -- 1-space collector */
-#if Build_1s == YES
-# define IfBuild_1s(x) x
-GHC_BUILD_FLAG_1s = -gc-1s
-#else
-# define IfBuild_1s(x) /**/
-GHC_BUILD_FLAG_1s = -build-1s-not-defined
-#endif
-
-/* sequential -- dual-mode collector */
-#if Build_du == YES
-# define IfBuild_du(x) x
-GHC_BUILD_FLAG_du = -gc-du
-#else
-# define IfBuild_du(x) /**/
-GHC_BUILD_FLAG_du = -build-du-not-defined
-#endif
-
-/* === builds: "user ways" ======================================= */
-
-#if Build_a == YES	
-# define IfBuild_a(x) x
-GHC_BUILD_FLAG_a = -build-a-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_a = -build-a-not-defined-error
-#else
-# define IfBuild_a(x) /**/
-GHC_BUILD_FLAG_a = -build-a-not-defined
-GHC_BUILD_OPTS_a = -build-a-not-defined-error
-#endif
-
-#if Build_b == YES
-# define IfBuild_b(x) x
-GHC_BUILD_FLAG_b = -build-b-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_b = -build-b-not-defined-error
-#else
-# define IfBuild_b(x) /**/
-GHC_BUILD_FLAG_b = -build-b-not-defined
-GHC_BUILD_OPTS_b = -build-b-not-defined-error
-#endif
-
-#if Build_c == YES
-# define IfBuild_c(x) x
-GHC_BUILD_FLAG_c = -build-c-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_c = -build-c-not-defined-error
-#else
-# define IfBuild_c(x) /**/
-GHC_BUILD_FLAG_c = -build-c-not-defined
-GHC_BUILD_OPTS_c = -build-c-not-defined-error
-#endif
-
-#if Build_d == YES
-# define IfBuild_d(x) x
-GHC_BUILD_FLAG_d = -build-d-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_d = -build-d-not-defined-error
-#else
-# define IfBuild_d(x) /**/
-GHC_BUILD_FLAG_d = -build-d-not-defined
-GHC_BUILD_OPTS_d = -build-d-not-defined-error
-#endif
-
-#if Build_e == YES
-# define IfBuild_e(x) x
-GHC_BUILD_FLAG_e = -build-e-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_e = -build-e-not-defined-error
-#else
-# define IfBuild_e(x) /**/
-GHC_BUILD_FLAG_e = -build-e-not-defined
-GHC_BUILD_OPTS_e = -build-e-not-defined-error
-#endif
-
-#if Build_f == YES
-# define IfBuild_f(x) x
-GHC_BUILD_FLAG_f = -build-f-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_f = -build-f-not-defined-error
-#else
-# define IfBuild_f(x) /**/
-GHC_BUILD_FLAG_f = -build-f-not-defined
-GHC_BUILD_OPTS_f = -build-f-not-defined-error
-#endif
-
-#if Build_g == YES
-# define IfBuild_g(x) x
-GHC_BUILD_FLAG_g = -build-g-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_g = -build-g-not-defined-error
-#else
-# define IfBuild_g(x) /**/
-GHC_BUILD_FLAG_g = -build-g-not-defined
-GHC_BUILD_OPTS_g = -build-g-not-defined-error
-#endif
-
-#if Build_h == YES	
-# define IfBuild_h(x) x
-GHC_BUILD_FLAG_h = -build-h-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_h = -build-h-not-defined-error
-#else
-# define IfBuild_h(x) /**/
-GHC_BUILD_FLAG_h = -build-h-not-defined
-GHC_BUILD_OPTS_h = -build-h-not-defined-error
-#endif
-
-#if Build_i == YES
-# define IfBuild_i(x) x
-GHC_BUILD_FLAG_i = -build-i-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_i = -build-i-not-defined-error
-#else
-# define IfBuild_i(x) /**/
-GHC_BUILD_FLAG_i = -build-i-not-defined
-GHC_BUILD_OPTS_i = -build-i-not-defined-error
-#endif
-
-#if Build_j == YES
-# define IfBuild_j(x) x
-GHC_BUILD_FLAG_j = -build-j-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_j = -build-j-not-defined-error
-#else
-# define IfBuild_j(x) /**/
-GHC_BUILD_FLAG_j = -build-j-not-defined
-GHC_BUILD_OPTS_j = -build-j-not-defined-error
-#endif
-
-#if Build_k == YES
-# define IfBuild_k(x) x
-GHC_BUILD_FLAG_k = -build-k-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_k = -build-k-not-defined-error
-#else
-# define IfBuild_k(x) /**/
-GHC_BUILD_FLAG_k = -build-k-not-defined
-GHC_BUILD_OPTS_k = -build-k-not-defined-error
-#endif
-
-#if Build_l == YES
-# define IfBuild_l(x) x
-GHC_BUILD_FLAG_l = -build-l-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_l = -build-l-not-defined-error
-#else
-# define IfBuild_l(x) /**/
-GHC_BUILD_FLAG_l = -build-l-not-defined
-GHC_BUILD_OPTS_l = -build-l-not-defined-error
-#endif
-
-#if Build_m == YES
-# define IfBuild_m(x) x
-GHC_BUILD_FLAG_m = -build-m-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_m = -build-m-not-defined-error
-#else
-# define IfBuild_m(x) /**/
-GHC_BUILD_FLAG_m = -build-m-not-defined
-GHC_BUILD_OPTS_m = -build-m-not-defined-error
-#endif
-
-#if Build_n == YES
-# define IfBuild_n(x) x
-GHC_BUILD_FLAG_n = -build-n-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_n = -build-n-not-defined-error
-#else
-# define IfBuild_n(x) /**/
-GHC_BUILD_FLAG_n = -build-n-not-defined
-GHC_BUILD_OPTS_n = -build-n-not-defined-error
-#endif
-
-#if Build_o == YES
-# define IfBuild_o(x) x
-GHC_BUILD_FLAG_o = -build-o-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_o = -build-o-not-defined-error
-#else
-# define IfBuild_o(x) /**/
-GHC_BUILD_FLAG_o = -build-o-not-defined
-GHC_BUILD_OPTS_o = -build-o-not-defined-error
-#endif
-
-#if Build_A == YES
-# define IfBuild_A(x) x
-GHC_BUILD_FLAG_A = -build-A-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_A = -build-A-not-defined-error
-#else
-# define IfBuild_A(x) /**/
-GHC_BUILD_FLAG_A = -build-A-not-defined
-GHC_BUILD_OPTS_A = -build-A-not-defined-error
-#endif
-
-#if Build_B == YES
-# define IfBuild_B(x) x
-GHC_BUILD_FLAG_B = -build-B-not-defined /* >>>change here<<< if required */
-GHC_BUILD_OPTS_B = -build-B-not-defined-error
-#else
-# define IfBuild_B(x) /**/
-GHC_BUILD_FLAG_B = -build-B-not-defined
-GHC_BUILD_OPTS_B = -build-B-not-defined-error
-#endif
-
-/* ======= END OF BUILD INFO ==================================== */
-
-
-/* As of 0.19, our parser won't go through Sun's /usr/bin/yacc
-   (due to an utterly hardwired limit on the number of states [1000]).
-   You can use: (1) their unbundled /usr/lang/yacc; or (2) the GNU
-   "bison -y".  Do not try Berkeley yacc -- it willnae work.
-*/
-#ifndef YaccCmd
-#define YaccCmd @YaccCmd@
-#endif
-
-/* ================================================================
-   INSTALL stuff:
-*/
-
-/* WHERE TO INSTALL IT:
-
-    By default, the root prefix for where everything is installed is
-    "/usr/local".  Assume you are installing for the <arch>
-    architecture...  Beneath that, things look like this:
-
-    bin/<arch>          for executables the user invokes, e.g., driver "ghc"
-			[InstBinDir_GHC]
-    bin			we might install some scripts (not platform-dependent)
-			here... [InstScriptDir_GHC]
-    lib/ghc/<version>   for support-bits for "ghc" (architecture-independent),
-			for a specific version. [InstDataDir_GHC]
-    lib/ghc/<version>/<arch>
-			ditto, but the <arch>itecture-dependent bits
-			[InstLibDir_GHC]
-    man/man<ext>/       man pages [InstManRoot]
-    info		Info files [InstInfoDir]
-
-    You may alter mkworld's ideas about GHC installation by changing
-    the above-mentioned settings, as shown below.
-
-    The default values are set in only4-ghc.ljm, if you are interested.
-
-    If you are going to install the utility bits (literate, mkworld,
-    glafp-utils) as well as the GHC system itself, you should do
-    similar installation fiddling in your "mkworld/site.jm" file,
-    setting the variables InstRootDir, InstBinDir, InstLibDir, etc.
-    (the non-project-specific ones).
-*/
-
-/*
-    "AT_GLASGOW"  -- Are we installing at Glasgow?
-    (also set in site.jm.in, but we get here and try to use it first)
- */
-#ifndef AT_GLASGOW
-#define AT_GLASGOW @AT_GLASGOW@
-#endif
-
-/* only the "prefix" things are set here */
-#ifndef InstRootDir_GHC
-#define InstRootDir_GHC @prefix@
-#endif
-#ifndef InstBinRootDir_GHC
-#define InstBinRootDir_GHC @exec_prefix@
-#endif
-
-/* install the compilation system driver as "ghc-<version>" at Glasgow 
-   (default is: "ghc" elsewhere) 
- */
-#ifndef GhcDriverInstallName
-#if AT_GLASGOW
-#define GhcDriverInstallName ghc-$(PROJECTVERSION)
-#else
-#define GhcDriverInstallName ghc
-#endif
-#endif
-
-/* At Glasgow, make sure things are installed for group "grasp".
-
-   If you do not care what group it is installed for, delete
-   this stuff altogether.  If you leave it in, be sure it is a
-   group that exists at your site!
- */
-#if AT_GLASGOW && !defined(InstGroup)
-#define InstGroup -g grasp
-#endif
-
-/* At Glasgow, we would rather the installed binaries were stripped.
-   (Delete if you feel otherwise.)
-*/
-#ifndef InstStrip
-#define InstStrip -s
-#endif
-
diff --git a/ghc/mkworld/suffixes-ghc.jm b/ghc/mkworld/suffixes-ghc.jm
deleted file mode 100644
index 4d6f41975ed0f013f75f3f4278daff8d5599dbe1..0000000000000000000000000000000000000000
--- a/ghc/mkworld/suffixes-ghc.jm
+++ /dev/null
@@ -1,27 +0,0 @@
-#if 0
-%************************************************************************
-%*									*
-\section[mkworld-suffix-ghc]{Suffix rules for @ghc@ project}
-%*									*
-%************************************************************************
-
-The \tr{ghc} project tends to ask for specific suffix rules on
-a per-directory basis.
-
-\begin{code}
-#endif /* 0 */
-#ifndef SuffixRules_WantStdOnes
-#define SuffixRules_WantStdOnes NO
-#endif
-
-#ifndef UnlitSuffixRule
-#define UnlitSuffixRule(beforesuff,aftersuff)		@@\
-CAT2(beforesuff,aftersuff):				@@\
-	$(RM) $@					@@\
-	$(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )	@@\
-	@chmod 444 $@
-#endif /* UnlitSuffixRule */
-
-#if 0
-\end{code}
-#endif /* 0 */
diff --git a/ghc/mkworld/utils-ghc.jm b/ghc/mkworld/utils-ghc.jm
deleted file mode 100644
index 480d54f07b5cfbaaf2401ef8c26b89c4bf490d54..0000000000000000000000000000000000000000
--- a/ghc/mkworld/utils-ghc.jm
+++ /dev/null
@@ -1,141 +0,0 @@
-#if 0
-%************************************************************************
-%*									*
-\section[mkworld-utils-ghc]{``Utilities'' stuff for @ghc@ project}
-%*									*
-%************************************************************************
-
-It's become sorta traditional to change the project-wide
-Haskell-compiler options with @SetupHcOpts@ (rather than
-@ProjectHcOpts@).
-\begin{code}
-#endif /* 0 */
-#if GhcWithHscOptimised == YES
-#define __hsc_opt -O
-#else
-#define __hsc_opt /**/
-#endif
-
-#ifndef SetupHcOpts
-#if HaskellCompilerType == HC_CHALMERS_HBC
-#define SetupHcOpts __hsc_opt -fpbu
-#else
-#if HaskellCompilerType == HC_GLASGOW_GHC
-#define SetupHcOpts __hsc_opt -hi-diffs -link-chk
-#else
-#if HaskellCompilerType == HC_ROJEMO_NHC
-#define SetupHcOpts /*nothing*/
-#else
-#define SetupHcOpts /*nothing*/
-#endif
-#endif
-#endif
-#endif /* SetupHcOpts */
-
-#ifndef ProjectCcOpts
-#if HaveGcc == YES && UseGcc == YES
-/* can cope w/ "-g -O" ...; but leave out -g to avoid bloated libs */
-#define ProjectCcOpts -O /*-g*/
-#else
-#define ProjectCcOpts /*-g*/
-#endif /* Gcc whatnot */
-#endif /* ProjectCcOpts */
-
-#ifndef ProjectJmakeDefines
-#define ProjectJmakeDefines /*none*/
-#endif
-
-#ifndef MkDependHSSrc
-#define MkDependHSSrc $(GHC_UTILSRC)/mkdependHS
-#endif
-
-#ifndef MkDependHSCmd
-#if     defined(UseInstalledUtils)
-#define MkDependHSCmd mkdependHS
-#else
-#define MkDependHSCmd $(MKDEPENDHSSRC)/mkdependHS
-#endif
-#endif /* ! MkDependHSCmd */
-
-#ifndef MkDependHSNeededHere
-#if defined(UseInstalledUtils)
-#define MkDependHSNeededHere(target) /**/
-#else
-#define MkDependHSNeededHere(target) \
-__SomeUtilNeededHere(target,$(MKDEPENDHS),$(MKDEPENDHSSRC),mkdependHS)
-#endif /* UseInstalledUtils */
-#endif /* MkDependHSNeededHere */
-
-#ifndef UseInstalledUtils
-MKDEPENDHSSRC = MkDependHSSrc
-#endif
-
-#ifndef UnlitCmd
-#define UnlitCmd $(GHC_UNLITSRC)/unlit
-#endif
-
-#ifndef UnlitNeededHere
-#define UnlitNeededHere(target) \
-__SomeUtilNeededHere(target,$(GHC_UNLIT),$(GHC_UNLITSRC),unlit)
-#endif /* UnlitNeededHere */
-
-GHC_UNLIT    = UnlitCmd
-GHC_UNLITSRC = $(GHC_UTILSRC)/unlit
-
-#ifndef HsTagsSrc
-#define HsTagsSrc $(GHC_UTILSRC)/hstags
-#endif
-#if     defined(UseInstalledUtils)
-#define HsTagsCmd hstags
-#else
-#define HsTagsCmd $(HSTAGSSRC)/hstags
-#endif
-
-#ifndef HsTagsNeededHere
-#if defined(UseInstalledUtils)
-#define HsTagsNeededHere(target) /**/
-#else
-#define HsTagsNeededHere(target) \
-__SomeUtilNeededHere(target,$(HSTAGS),$(HSTAGSSRC),hstags)
-#endif /* UseInstalledUtils */
-#endif /* HsTagsNeededHere */
-HSTAGS = HsTagsCmd
-#ifndef UseInstalledUtils
-HSTAGSSRC = HsTagsSrc
-#endif
-
-#ifndef AllProjectsHsTagsOpts
-#define AllProjectsHsTagsOpts /*none*/
-#endif
-#ifndef PlatformHsTagsOpts
-#define PlatformHsTagsOpts /*none*/
-#endif
-#ifndef ProjectHsTagsOpts
-#define ProjectHsTagsOpts /*none*/
-#endif
-#ifndef SetupHsTagsOpts
-#define SetupHsTagsOpts /*none*/
-#endif
-GenerateOptionsMakeVars(HSTAGS,OPTS,AllProjectsHsTagsOpts,PlatformHsTagsOpts,ProjectHsTagsOpts,SetupHsTagsOpts)
-HSTAGSFLAGS        = $(GLUED_HSTAGS_OPTS)
-
-/* ugen: allegedly generally-useful util from LML distribution */
-#ifndef UgenCmd
-#if     defined(UseInstalledUtils)
-#define UgenCmd ugen
-#else
-#define UgenCmd $(UGENSRC)/ugen
-#endif
-#endif
-#ifndef UgenNeededHere
-#if defined(UseInstalledUtils)
-#define UgenNeededHere(target) /**/
-#else
-#define UgenNeededHere(target) \
-__SomeUtilNeededHere(target,$(UGEN),$(UGENSRC),ugen)
-#endif /* ! UseInstalledUtils */
-#endif /* UgenNeededHere */
-UGEN = UgenCmd
-#ifndef UseInstalledUtils
-UGENSRC = $(GHC_UTILSRC)/ugen
-#endif
diff --git a/ghc/runtime/Jmakefile b/ghc/runtime/Jmakefile
deleted file mode 100644
index 713eda0cc308d245832d83ad02fb7a7e208c3d0c..0000000000000000000000000000000000000000
--- a/ghc/runtime/Jmakefile
+++ /dev/null
@@ -1,440 +0,0 @@
-/* This is the Jmakefile for the runtime-system stuff.
-   This stuff is written in C (and cannot be written in Haskell).
-
-   Things are organised into exactly one level of subdirs.
-
-   At the moment, there are a few such subdirs:
-	c-as-asm	-- mini-interpreter & register hackery
-	gum		-- GUM-specific stuff
-	main		-- "main", associated startup stuff, & MISC things
-	prims		-- code for primitives that must be written in C
-	profiling	-- cost-centre profiling
-	storage		-- the storage manager(s)
-
-   We create two libraries.  One, libHSrts<tag>.a, is built separately
-   for each "build".  The other, libHSclib.a is built once: it is just
-   .lc files that end up the same no matter what, i.e. completely
-   ordinary C.
-
-   Other sorta independent, compile-once subdirs are:
-
-	gmp		-- GNU multi-precision library (for Integer)
-*/
-
-#define IHaveSubdirs
-
-SUBDIRS = gmp
-
-/****************************************************************
-*								*
-* Jmakefile preamble-y things					*
-*								*
-****************************************************************/
-
-GhcDriverNeededHere(depend all) /* we use its C-compiling know-how */
-EtagsNeededHere(tags)
-UnlitNeededHere(depend)
-
-/****************************************************************
-*								*
-* options used for compiling/etc. things			*
-*								*
-****************************************************************/
-
-/*
-If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
-strictly speaking), it will probably work -- it is pinned onto
-GHC_OPTS, just for fun.
-*/
-
-GHC_OPTS = $(EXTRA_HC_OPTS)
-
-/* per-build options: shared with libraries */
-#define rts_or_lib(r,l) r
-#include "../mkworld/GHC_OPTS"
-
-MKDEPENDC_OPTS= \
-	-I$(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
-
-/****************************************************************
-*								*
-* what it is we are compiling;					*
-*   these are long and tedious lists, but c'est la guerre	*
-*								*
-****************************************************************/
-
-RTS_LH =				\
-	storage/SMmarkDefs.lh 		\
-	storage/SMcopying.lh		\
-	storage/SMcompacting.lh		\
-	storage/SMextn.lh		\
-	storage/SMinternal.lh
-
-RTS_LC = 				\
-	c-as-asm/CallWrap_C.lc		\
-	c-as-asm/HpOverflow.lc		\
-	c-as-asm/StablePtr.lc		\
-	c-as-asm/StablePtrOps.lc	\
-	c-as-asm/StgDebug.lc		\
-	c-as-asm/StgMiniInt.lc		\
-	gum/GlobAddr.lc			\
-	gum/HLComms.lc			\
-	gum/Hash.lc			\
-	gum/LLComms.lc			\
-	gum/Pack.lc			\
-	gum/ParInit.lc			\
-	gum/RBH.lc			\
-	gum/Sparks.lc			\
-	gum/Unpack.lc			\
-	main/GranSim.lc			\
-	main/Itimer.lc			\
-	main/Ticky.lc			\
-	main/SMRep.lc			\
-	main/Select.lc			\
-	main/Signals.lc			\
-	main/StgOverflow.lc		\
-	main/Threads.lc			\
-	main/RtsFlags.lc		\
-	main/main.lc			\
-	prims/PrimArith.lc		\
-	prims/PrimMisc.lc		\
-	profiling/CostCentre.lc		\
-	profiling/Hashing.lc		\
-	profiling/HeapProfile.lc	\
-	profiling/Indexing.lc		\
-	profiling/Timer.lc		\
-	storage/SM1s.lc			\
-	storage/SM2s.lc			\
-	storage/SMap.lc			\
-	storage/SMcheck.lc		\
-	storage/SMcompacting.lc 	\
-	storage/SMcopying.lc 		\
-	storage/SMdu.lc			\
-	storage/SMevac.lc 		\
-	storage/SMextn.lc		\
-	storage/SMinit.lc /*could clib except for GCdu option! */ \
-	storage/SMmarking.lc 		\
-	storage/SMscan.lc		\
-	storage/SMscav.lc		\
-	storage/SMstacks.lc		\
-	storage/SMstatic.lc		\
-	storage/SMstats.lc /*could clib except GCap affects printing*/ \
-	storage/mprotect.lc
-
-/*LATER?: storage/SMgen.lc */
-
-RTS_LHC = 				\
-	main/StgStartup.lhc		\
-	main/StgUpdate.lhc		\
-	main/StgThreads.lhc		\
-	c-as-asm/PerformIO.lhc		\
-	storage/SMmark.lhc		\
-	gum/FetchMe.lhc
-
-CLIB_LC = 				\
-	hooks/ErrorHdr.lc		\
-	hooks/FreeForeignObj.lc		\
-	hooks/OutOfHeap.lc		\
-	hooks/OutOfStk.lc		\
-	hooks/OutOfVM.lc		\
-	hooks/NoRunnableThrds.lc	\
-	hooks/PatErrorHdr.lc		\
-	hooks/TraceHooks.lc		\
-	hooks/SizeHooks.lc		\
-	hooks/InitEachPE.lc		\
-	main/Mallocs.lc
-
-H_FILES = $(RTS_LH:.lh=.h)
-C_FILES = $(RTS_LC:.lc=.c) $(RTS_LHC:.lhc=.hc) $(CLIB_LC:.lc=.c)
-
-/* Header files */
-
-all depend :: $(H_FILES)
-
-ExtraStuffToClean ( $(C_FILES) )
-
-/* Literate-pgmming suffix rules used herein */
-UnlitSuffixRule(.lhc,.hc)
-UnlitSuffixRule(.lc,.c)
-UnlitSuffixRule(.lh,.h)
-
-/****************************************************************
-*								*
-* interesting collections of .o files				*
-*								*
-****************************************************************/
-
-RTS_OBJS_norm = $(RTS_LC:.lc=.o)    $(RTS_LHC:.lhc=.o)
-RTS_OBJS_p    = $(RTS_LC:.lc=.p_o)  $(RTS_LHC:.lhc=.p_o)
-RTS_OBJS_t    = $(RTS_LC:.lc=.t_o)  $(RTS_LHC:.lhc=.t_o)
-RTS_OBJS_u    = $(RTS_LC:.lc=.u_o)  $(RTS_LHC:.lhc=.u_o)
-RTS_OBJS_mc   = $(RTS_LC:.lc=.mc_o) $(RTS_LHC:.lhc=.mc_o)
-RTS_OBJS_mr   = $(RTS_LC:.lc=.mr_o) $(RTS_LHC:.lhc=.mr_o)
-RTS_OBJS_mt   = $(RTS_LC:.lc=.mt_o) $(RTS_LHC:.lhc=.mt_o)
-RTS_OBJS_mp   = $(RTS_LC:.lc=.mp_o) $(RTS_LHC:.lhc=.mp_o)
-RTS_OBJS_mg   = $(RTS_LC:.lc=.mg_o) $(RTS_LHC:.lhc=.mg_o)
-RTS_OBJS_2s   = $(RTS_LC:.lc=.2s_o) $(RTS_LHC:.lhc=.2s_o)
-RTS_OBJS_1s   = $(RTS_LC:.lc=.1s_o) $(RTS_LHC:.lhc=.1s_o)
-RTS_OBJS_du   = $(RTS_LC:.lc=.du_o) $(RTS_LHC:.lhc=.du_o)
-RTS_OBJS_a    = $(RTS_LC:.lc=.a_o)  $(RTS_LHC:.lhc=.a_o)
-RTS_OBJS_b    = $(RTS_LC:.lc=.b_o)  $(RTS_LHC:.lhc=.b_o)
-RTS_OBJS_c    = $(RTS_LC:.lc=.c_o)  $(RTS_LHC:.lhc=.c_o)
-RTS_OBJS_d    = $(RTS_LC:.lc=.d_o)  $(RTS_LHC:.lhc=.d_o)
-RTS_OBJS_e    = $(RTS_LC:.lc=.e_o)  $(RTS_LHC:.lhc=.e_o)
-RTS_OBJS_f    = $(RTS_LC:.lc=.f_o)  $(RTS_LHC:.lhc=.f_o)
-RTS_OBJS_g    = $(RTS_LC:.lc=.g_o)  $(RTS_LHC:.lhc=.g_o)
-RTS_OBJS_h    = $(RTS_LC:.lc=.h_o)  $(RTS_LHC:.lhc=.h_o)
-RTS_OBJS_i    = $(RTS_LC:.lc=.i_o)  $(RTS_LHC:.lhc=.i_o)
-RTS_OBJS_j    = $(RTS_LC:.lc=.j_o)  $(RTS_LHC:.lhc=.j_o)
-RTS_OBJS_k    = $(RTS_LC:.lc=.k_o)  $(RTS_LHC:.lhc=.k_o)
-RTS_OBJS_l    = $(RTS_LC:.lc=.l_o)  $(RTS_LHC:.lhc=.l_o)
-RTS_OBJS_m    = $(RTS_LC:.lc=.m_o)  $(RTS_LHC:.lhc=.m_o)
-RTS_OBJS_n    = $(RTS_LC:.lc=.n_o)  $(RTS_LHC:.lhc=.n_o)
-RTS_OBJS_o    = $(RTS_LC:.lc=.o_o)  $(RTS_LHC:.lhc=.o_o)
-RTS_OBJS_A    = $(RTS_LC:.lc=.A_o)  $(RTS_LHC:.lhc=.A_o)
-RTS_OBJS_B    = $(RTS_LC:.lc=.B_o)  $(RTS_LHC:.lhc=.B_o)
-
-CLIB_OBJS     = $(CLIB_LC:.lc=.o)
-
-/****************************************************************
-*								*
-* knock the "clib" (completely ordinary C, compiled once)	*
-* stuff over the head first...					*
-*								*
-****************************************************************/
-
-NormalLibraryTarget(HSclib,$(CLIB_OBJS))
-ExtraStuffToClean($(CLIB_OBJS))
-#if DoInstallGHCSystem == YES
-InstallLibraryTarget(HSclib,$(INSTLIBDIR_GHC))
-#endif
-
-/* all .lc files, so far */
-CompileCBitsly(GHC,hooks/ErrorHdr,)
-CompileCBitsly(GHC,hooks/FreeForeignObj,)
-CompileCBitsly(GHC,hooks/OutOfHeap,)
-CompileCBitsly(GHC,hooks/OutOfStk,)
-CompileCBitsly(GHC,hooks/OutOfVM,)
-CompileCBitsly(GHC,hooks/NoRunnableThrds,)
-CompileCBitsly(GHC,hooks/PatErrorHdr,)
-CompileCBitsly(GHC,hooks/TraceHooks,)
-CompileCBitsly(GHC,hooks/SizeHooks,)
-CompileCBitsly(GHC,hooks/InitEachPE,)
-CompileCBitsly(GHC,main/Mallocs,)
-CompileCBitsly(GHC,main/TopClosure,)
-
-ExtraStuffToClean(main/TopClosure.o)
-
-all :: main/TopClosure.o
-
-install :: main/TopClosure.o
-	$(INSTALL) -c $(INSTLIBFLAGS) main/TopClosure.o   $(INSTLIBDIR_GHC)/TopClosure.o
-
-#if Build_mp == YES
-# if solaris2_TARGET_OS
-#  define __socket_libs -lsocket -lnsl
-# else
-#  define __socket_libs /*none*/
-# endif
-
-AllTarget(gum/SysMan)
-gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o
-	$(RM) $@
-	$(CC) -o $@ gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o -L$$PVM_ROOT/lib/$$PVM_ARCH -lpvm3 -lgpvm3 __socket_libs
-ExtraStuffToClean(gum/SysMan.mp_o gum/SysMan)
-# if DoInstallGHCSystem == YES
-install :: gum/SysMan
-	$(INSTALL) -c $(INSTBINFLAGS) gum/SysMan $(INSTLIBDIR_GHC)/SysMan
-# endif
-#endif
-
-/****************************************************************
-*								*
-* special local make-world macros				*
-*								*
-****************************************************************/
-
-/* to build and install the per-build rts stuff */
-
-#ifndef SpecialGhcRtsLibTarget
-#define SpecialGhcRtsLibTarget(tag,objs)	@@\
-AllTarget(CAT3(libHSrts,tag,.a))		@@\
-ExtraStuffToClean(objs CAT3(libHSrts,tag,.a))	@@\
-CAT3(libHSrts,tag,.a):: $(H_FILES) objs 	@@\
-	$(RM) $@				@@\
-	$(AR) $@ objs				@@\
-	$(RANLIB) $@
-#endif /* SpecialGhcRtsLibTarget */
-
-#ifndef SpecialGhcRtsLibInstallTarget
-#if DoInstallGHCSystem == YES
-#define SpecialGhcRtsLibInstallTarget(tag)			@@\
-install :: CAT3(libHSrts,tag,.a)				@@\
-	$(INSTALL) $(INSTLIBFLAGS) \				@@\
-		CAT3(libHSrts,tag,.a) \				@@\
-		$(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a)		@@\
-	$(RANLIB) $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a)
-#else /* ! DoInstallGHC... */
-#define SpecialGhcRtsLibInstallTarget(tag) /*nothing*/
-#endif /* ! DoInstallGHC... */
-#endif /* SpecialGhcRtsLibInstallTarget */
-
-#define BigBuildRtsTarget(tag,objs)	\
-SpecialGhcRtsLibTarget(tag,objs)	@@\
-SpecialGhcRtsLibInstallTarget(tag)
-
-/****************************************************************
-*								*
-* creating and installing libHSrts.a (in its many flavors)	*
-*								*
-****************************************************************/
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC))
-#endif /* DoInstallGHCSystem */
-
-IfBuild_normal(BigBuildRtsTarget(,$(RTS_OBJS_norm)))
-IfBuild_p(BigBuildRtsTarget(_p,   $(RTS_OBJS_p)))
-IfBuild_t(BigBuildRtsTarget(_t,   $(RTS_OBJS_t)))
-IfBuild_u(BigBuildRtsTarget(_u,   $(RTS_OBJS_u)))
-IfBuild_mc(BigBuildRtsTarget(_mc, $(RTS_OBJS_mc)))
-IfBuild_mr(BigBuildRtsTarget(_mr, $(RTS_OBJS_mr)))
-IfBuild_mt(BigBuildRtsTarget(_mt, $(RTS_OBJS_mt)))
-IfBuild_mp(BigBuildRtsTarget(_mp, $(RTS_OBJS_mp)))
-IfBuild_mg(BigBuildRtsTarget(_mg, $(RTS_OBJS_mg)))
-IfBuild_2s(BigBuildRtsTarget(_2s, $(RTS_OBJS_2s)))
-IfBuild_1s(BigBuildRtsTarget(_1s, $(RTS_OBJS_1s)))
-IfBuild_du(BigBuildRtsTarget(_du, $(RTS_OBJS_du)))
-IfBuild_a(BigBuildRtsTarget(_a,   $(RTS_OBJS_a)))
-IfBuild_b(BigBuildRtsTarget(_b,   $(RTS_OBJS_b)))
-IfBuild_c(BigBuildRtsTarget(_c,   $(RTS_OBJS_c)))
-IfBuild_d(BigBuildRtsTarget(_d,   $(RTS_OBJS_d)))
-IfBuild_e(BigBuildRtsTarget(_e,   $(RTS_OBJS_e)))
-IfBuild_f(BigBuildRtsTarget(_f,   $(RTS_OBJS_f)))
-IfBuild_g(BigBuildRtsTarget(_g,   $(RTS_OBJS_g)))
-IfBuild_h(BigBuildRtsTarget(_h,   $(RTS_OBJS_h)))
-IfBuild_i(BigBuildRtsTarget(_i,   $(RTS_OBJS_i)))
-IfBuild_j(BigBuildRtsTarget(_j,   $(RTS_OBJS_j)))
-IfBuild_k(BigBuildRtsTarget(_k,   $(RTS_OBJS_k)))
-IfBuild_l(BigBuildRtsTarget(_l,   $(RTS_OBJS_l)))
-IfBuild_m(BigBuildRtsTarget(_m,   $(RTS_OBJS_m)))
-IfBuild_n(BigBuildRtsTarget(_n,   $(RTS_OBJS_n)))
-IfBuild_o(BigBuildRtsTarget(_o,   $(RTS_OBJS_o)))
-IfBuild_A(BigBuildRtsTarget(_A,   $(RTS_OBJS_A)))
-IfBuild_B(BigBuildRtsTarget(_B,   $(RTS_OBJS_B)))
-
-
-/****************************************************************
-*								*
-* compile the individual RTS files				*
-*								*
-****************************************************************/
-
-#define DoRtsFile(file,isuf,way,vsuf,flags)				 @@\
-CAT3(file.,way,o) : CAT2(file,isuf)					 @@\
-	$(RM) $@							 @@\
-	$(GHC) -c -o CAT3(file.,way,o) $(GHCFLAGS) flags $(CAT3(GHC,_OPTS,vsuf)) CAT2(file,isuf)
-
-#define CompileRTSishly(file,isuf,flags)		@@\
-IfBuild_normal(DoRtsFile(file,isuf,,_norm,flags))	\
-IfBuild_p(DoRtsFile(file,isuf,p_,_p,   	  flags))	\
-IfBuild_t(DoRtsFile(file,isuf,t_,_t,   	  flags))	\
-IfBuild_u(DoRtsFile(file,isuf,u_,_u,   	  flags))	\
-IfBuild_mc(DoRtsFile(file,isuf,mc_,_mc,   flags))	\
-IfBuild_mr(DoRtsFile(file,isuf,mr_,_mr,   flags))	\
-IfBuild_mt(DoRtsFile(file,isuf,mt_,_mt,   flags))	\
-IfBuild_mp(DoRtsFile(file,isuf,mp_,_mp,   flags))	\
-IfBuild_mg(DoRtsFile(file,isuf,mg_,_mg,   flags))	\
-IfBuild_2s(DoRtsFile(file,isuf,2s_,_2s,   flags))	\
-IfBuild_1s(DoRtsFile(file,isuf,1s_,_1s,   flags))	\
-IfBuild_du(DoRtsFile(file,isuf,du_,_du,   flags))	\
-IfBuild_a(DoRtsFile(file,isuf,a_,_a,   	  flags))	\
-IfBuild_b(DoRtsFile(file,isuf,b_,_b,   	  flags))	\
-IfBuild_c(DoRtsFile(file,isuf,c_,_c,   	  flags))	\
-IfBuild_d(DoRtsFile(file,isuf,d_,_d,   	  flags))	\
-IfBuild_e(DoRtsFile(file,isuf,e_,_e,   	  flags))	\
-IfBuild_f(DoRtsFile(file,isuf,f_,_f,   	  flags))	\
-IfBuild_g(DoRtsFile(file,isuf,g_,_g,   	  flags))	\
-IfBuild_h(DoRtsFile(file,isuf,h_,_h,   	  flags))	\
-IfBuild_i(DoRtsFile(file,isuf,i_,_i,   	  flags))	\
-IfBuild_j(DoRtsFile(file,isuf,j_,_j,   	  flags))	\
-IfBuild_k(DoRtsFile(file,isuf,k_,_k,   	  flags))	\
-IfBuild_l(DoRtsFile(file,isuf,l_,_l,   	  flags))	\
-IfBuild_m(DoRtsFile(file,isuf,m_,_m,   	  flags))	\
-IfBuild_n(DoRtsFile(file,isuf,n_,_n,   	  flags))	\
-IfBuild_o(DoRtsFile(file,isuf,o_,_o,   	  flags))	\
-IfBuild_A(DoRtsFile(file,isuf,A_,_A,   	  flags))	\
-IfBuild_B(DoRtsFile(file,isuf,B_,_B,   	  flags))
-
-/* here we go: */
-
-CompileRTSishly(c-as-asm/CallWrap_C,.c,)
-CompileRTSishly(c-as-asm/HpOverflow,.c,)
-CompileRTSishly(c-as-asm/PerformIO,.hc,-optc-DIN_GHC_RTS=1)
-CompileRTSishly(c-as-asm/StablePtr,.c,)
-CompileRTSishly(c-as-asm/StablePtrOps,.c,)
-CompileRTSishly(c-as-asm/StgDebug,.c,)
-CompileRTSishly(c-as-asm/StgMiniInt,.c,)
-CompileRTSishly(gum/FetchMe,.hc,-optc-DIN_GHC_RTS=1)
-CompileRTSishly(gum/GlobAddr,.c,)
-CompileRTSishly(gum/HLComms,.c,)
-CompileRTSishly(gum/Hash,.c,)
-CompileRTSishly(gum/LLComms,.c,)
-CompileRTSishly(gum/Pack,.c,)
-CompileRTSishly(gum/ParInit,.c,)
-CompileRTSishly(gum/RBH,.c,)
-CompileRTSishly(gum/Sparks,.c,)
-CompileRTSishly(gum/SysMan,.c,) /* NB: not in library */
-CompileRTSishly(gum/Unpack,.c,)
-CompileRTSishly(main/GranSim,.c,)
-CompileRTSishly(main/Itimer,.c,)
-CompileRTSishly(main/Ticky,.c,)
-CompileRTSishly(main/SMRep,.c,)
-CompileRTSishly(main/Select,.c,)
-CompileRTSishly(main/Signals,.c,)
-CompileRTSishly(main/StgOverflow,.c,)
-CompileRTSishly(main/StgStartup,.hc,-optc-DIN_GHC_RTS=1)
-CompileRTSishly(main/StgThreads,.hc,-optc-DIN_GHC_RTS=1)
-CompileRTSishly(main/StgUpdate,.hc,-optc-DIN_GHC_RTS=1)
-CompileRTSishly(main/Threads,.c,)
-CompileRTSishly(main/RtsFlags,.c,)
-CompileRTSishly(main/main,.c,)
-CompileRTSishly(profiling/CostCentre,.c,)
-CompileRTSishly(profiling/Hashing,.c,)
-CompileRTSishly(profiling/HeapProfile,.c,)
-CompileRTSishly(profiling/Indexing,.c,)
-CompileRTSishly(profiling/Timer,.c,)
-CompileRTSishly(prims/PrimArith,.c,)
-CompileRTSishly(prims/PrimMisc,.c,)
-CompileRTSishly(storage/SM1s,.c,)
-CompileRTSishly(storage/SM2s,.c,)
-CompileRTSishly(storage/SMap,.c,)
-CompileRTSishly(storage/SMcheck,.c,)
-CompileRTSishly(storage/SMcompacting,.c,)
-CompileRTSishly(storage/SMcopying,.c,)
-CompileRTSishly(storage/SMdu,.c,)
-CompileRTSishly(storage/SMevac,.c,)
-CompileRTSishly(storage/SMextn,.c,)
-CompileRTSishly(storage/SMgen,.c,)
-CompileRTSishly(storage/SMinit,.c,)
-CompileRTSishly(storage/SMmark,.hc,-optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP)
-CompileRTSishly(storage/SMmarking,.c,)
-CompileRTSishly(storage/SMscan,.c,)
-CompileRTSishly(storage/SMscav,.c,)
-CompileRTSishly(storage/SMstacks,.c,)
-CompileRTSishly(storage/SMstatic,.c,)
-CompileRTSishly(storage/SMstats,.c,)
-CompileRTSishly(storage/mprotect,.c,)
-
-/****************************************************************
-*								*
-* misc "make" targets -- depend, clean, tags			*
-*								*
-****************************************************************/
-
-ClearTagsFile()
-/* this is not the way we should do this [WDP [lazy] 94/09] */
-CTagsTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
-CTagsTarget( gmp/[a-z]*.c )
-
-CDependTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
diff --git a/ghc/runtime/Makefile b/ghc/runtime/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3399ebc0da9a3d7a408101ea0c184da58338f614
--- /dev/null
+++ b/ghc/runtime/Makefile
@@ -0,0 +1,114 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:48:17 simonm Exp $
+
+#  This is the Makefile for the runtime-system stuff.
+#  This stuff is written in C (and cannot be written in Haskell).
+#
+#  Things are organised into exactly one level of subdirs.
+#
+#  At the moment, there are a few such subdirs:
+#	c-as-asm	-- mini-interpreter & register hackery
+#	gum		-- GUM-specific stuff
+#	main		-- "main", associated startup stuff, & MISC things
+#	prims		-- code for primitives that must be written in C
+#	profiling	-- cost-centre profiling
+#	storage		-- the storage manager(s)
+#
+#  We create two libraries.  One, libHSrts<tag>.a, is built separately
+#  for each "build".  The other, libHSclib.a is built once: it is just
+#  .lc files that end up the same no matter what, i.e. completely
+#  ordinary C.
+
+#  Other sorta independent, compile-once subdirs are:
+
+#	gmp		-- GNU multi-precision library (for Integer)
+
+#-----------------------------------------------------------------------------
+
+TOP=../..
+SuffixRules_WantStdOnes = NO
+UnlitSuffixRules = YES_PLEASE
+include $(TOP)/ghc/mk/ghc.mk
+
+SUBDIRS = gmp
+include $(TOP)/mk/subdir.mk
+
+# If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
+# strictly speaking), it will probably work -- it is pinned onto
+# GHC_OPTS, just for fun.
+
+GHC_OPTS = $(EXTRA_HC_OPTS)
+
+# per-build options: shared with libraries
+DoingRTS = YES
+include ../mk/buildflags.mk
+
+#-----------------------------------------------------------------------------
+# knock the "clib" (completely ordinary C, compiled once)
+# stuff over the head first...
+
+CLIB_LC = 				\
+	hooks/ErrorHdr.lc		\
+	hooks/FreeForeignObj.lc		\
+	hooks/OutOfHeap.lc		\
+	hooks/OutOfStk.lc		\
+	hooks/OutOfVM.lc		\
+	hooks/NoRunnableThrds.lc	\
+	hooks/PatErrorHdr.lc		\
+	hooks/TraceHooks.lc		\
+	hooks/SizeHooks.lc		\
+	hooks/InitEachPE.lc		\
+	main/Mallocs.lc
+
+ARCHIVE = libHSclib.a
+LIBOBJS = $(CLIB_LC:.lc=.o)
+DESTDIR	= $(INSTLIBDIR_GHC)
+
+include $(TOP)/mk/lib.mk
+
+#-----------------------------------------------------------------------------
+# Rules for building various types of objects from C files
+
+RTS_GHC = $(GHC) -c -o $@ $(GHCFLAGS) $($*_flags) 
+
+%.o : %.c
+	@$(RM) $@
+	$(RTS_GHC) $*.c
+
+#-----------------------------------------------------------------------------
+# the TopClosure
+
+all :: main/TopClosure.o
+
+clean ::
+	$(RM) main/TopClosure.o
+
+install :: main/TopClosure.o
+	$(INSTALL) $(INSTLIBFLAGS) main/TopClosure.o $(INSTLIBDIR_GHC)/TopClosure.o
+
+#-----------------------------------------------------------------------------
+# libHSrts.a, in several different 'ways'
+
+all ::
+	@for i in $(WAY_SUFFIXES); do \
+		echo; \
+		echo =========== Making runtime system for way $$i; \
+		echo; \
+		$(MAKE) -f Makefile.libHSrts suffix=$$i; \
+	done
+
+install ::
+	@for i in $(WAY_SUFFIXES); do \
+		$(MAKE) -f Makefile.libHSrts suffix=$$i install; \
+	done
+
+clean ::
+	@$(MAKE) -f Makefile.libHSrts clean
+	@for i in $(WAY_SUFFIXES); do \
+		$(MAKE) -f Makefile.libHSrts suffix=$$i cleanobj; \
+	done
+
+# Dependencies are done by Makefile.libHSrts
+
+depend ::
+	@$(MAKE) -f Makefile.libHSrts depend
diff --git a/ghc/runtime/Makefile.libHSrts b/ghc/runtime/Makefile.libHSrts
new file mode 100644
index 0000000000000000000000000000000000000000..10c8bf5dfef5ea9de219913248d7726abbc370db
--- /dev/null
+++ b/ghc/runtime/Makefile.libHSrts
@@ -0,0 +1,220 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile.libHSrts,v 1.2 1996/11/21 16:48:19 simonm Exp $
+
+# The is the makefile for libHSrts, invoked once for each different build.
+
+# The variable $(suffix) defines the current build.
+
+# To make libHSrts for a specific build, you can do 
+#	make -f Makefile.libHSrts suffix=<build>
+
+#-----------------------------------------------------------------------------
+
+TOP=../..
+SuffixRules_WantStdOnes = NO
+UnlitSuffixRules = YES_PLEASE
+include $(TOP)/ghc/mk/ghc.mk
+
+# If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
+# strictly speaking), it will probably work -- it is pinned onto
+# GHC_OPTS, just for fun.
+
+GHC_OPTS = $(EXTRA_HC_OPTS)
+
+# per-build options: shared with libraries
+DoingRTS = YES
+include ../mk/buildflags.mk
+
+#-----------------------------------------------------------------------------
+# what it is we are compiling;
+# these are long and tedious lists, but c'est la guerre
+
+RTS_LH =				\
+	storage/SMmarkDefs.lh 		\
+	storage/SMcopying.lh		\
+	storage/SMcompacting.lh		\
+	storage/SMextn.lh		\
+	storage/SMinternal.lh
+
+RTS_LC = 				\
+	c-as-asm/CallWrap_C.lc		\
+	c-as-asm/HpOverflow.lc		\
+	c-as-asm/StablePtr.lc		\
+	c-as-asm/StablePtrOps.lc	\
+	c-as-asm/StgDebug.lc		\
+	c-as-asm/StgMiniInt.lc		\
+	gum/GlobAddr.lc			\
+	gum/HLComms.lc			\
+	gum/Hash.lc			\
+	gum/LLComms.lc			\
+	gum/Pack.lc			\
+	gum/ParInit.lc			\
+	gum/RBH.lc			\
+	gum/Sparks.lc			\
+	gum/Unpack.lc			\
+	main/GranSim.lc			\
+	main/Itimer.lc			\
+	main/Ticky.lc			\
+	main/SMRep.lc			\
+	main/Select.lc			\
+	main/Signals.lc			\
+	main/StgOverflow.lc		\
+	main/Threads.lc			\
+	main/RtsFlags.lc		\
+	main/main.lc			\
+	prims/PrimArith.lc		\
+	prims/PrimMisc.lc		\
+	profiling/CostCentre.lc		\
+	profiling/Hashing.lc		\
+	profiling/HeapProfile.lc	\
+	profiling/Indexing.lc		\
+	profiling/Timer.lc		\
+	storage/SM1s.lc			\
+	storage/SM2s.lc			\
+	storage/SMap.lc			\
+	storage/SMcheck.lc		\
+	storage/SMcompacting.lc 	\
+	storage/SMcopying.lc 		\
+	storage/SMdu.lc			\
+	storage/SMevac.lc 		\
+	storage/SMextn.lc		\
+	storage/SMinit.lc 		\
+	storage/SMmarking.lc 		\
+	storage/SMscan.lc		\
+	storage/SMscav.lc		\
+	storage/SMstacks.lc		\
+	storage/SMstatic.lc		\
+	storage/SMstats.lc 		\
+	storage/mprotect.lc
+
+# LATER?: storage/SMgen.lc
+
+RTS_LHC = 				\
+	main/StgStartup.lhc		\
+	main/StgUpdate.lhc		\
+	main/StgThreads.lhc		\
+	c-as-asm/PerformIO.lhc		\
+	storage/SMmark.lhc		\
+	gum/FetchMe.lhc
+
+CLIB_LC = 				\
+	hooks/ErrorHdr.lc		\
+	hooks/FreeForeignObj.lc		\
+	hooks/OutOfHeap.lc		\
+	hooks/OutOfStk.lc		\
+	hooks/OutOfVM.lc		\
+	hooks/NoRunnableThrds.lc	\
+	hooks/PatErrorHdr.lc		\
+	hooks/TraceHooks.lc		\
+	hooks/SizeHooks.lc		\
+	hooks/InitEachPE.lc		\
+	main/Mallocs.lc
+
+CLIB_LC = 				\
+	hooks/ErrorHdr.lc		\
+	hooks/FreeForeignObj.lc		\
+	hooks/OutOfHeap.lc		\
+	hooks/OutOfStk.lc		\
+	hooks/OutOfVM.lc		\
+	hooks/NoRunnableThrds.lc	\
+	hooks/PatErrorHdr.lc		\
+	hooks/TraceHooks.lc		\
+	hooks/SizeHooks.lc		\
+	hooks/InitEachPE.lc		\
+	main/Mallocs.lc
+
+H_FILES = $(RTS_LH:.lh=.h)
+C_FILES = $(RTS_LC:.lc=.c) $(RTS_LHC:.lhc=.hc) $(CLIB_LC:.lc=.c)
+
+# Header files
+
+all depend :: $(H_FILES)
+
+clean ::
+	$(RM) $(H_FILES)
+	$(RM) $(C_FILES)
+
+#-----------------------------------------------------------------------------
+# Rules for building various types of objects from C files
+
+RTS_GHC = $(GHC) -c -o $@ $(GHCFLAGS) $($*_flags) 
+
+%.o : %.c
+	@$(RM) $@
+	$(RTS_GHC) $*.c
+
+%.$(suffix)_o : %.c
+	@$(RM) $@
+	$(RTS_GHC) $(GHC_OPTS_$(suffix)) $*.c
+
+%.$(suffix)_o : %.hc
+	@$(RM) $@
+	$(RTS_GHC) $(GHC_OPTS_$(suffix)) $*.hc
+
+#-----------------------------------------------------------------------------
+
+ifeq ($(suffix), mp)
+ifdef solaris2_TARGET_OS
+__socket_libs = -lsocket -lnsl
+else
+__socket_libs =
+endif
+
+all :: gum/SysMan
+
+gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o
+	$(RM) $@
+	$(CC) -o $@ gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o -L$$PVM_ROOT/lib/$$PVM_ARCH -lpvm3 -lgpvm3 $(__socket_libs)
+
+clean ::
+	$(RM) gum/SysMan.mp_o gum/SysMan
+
+install :: gum/SysMan
+	$(INSTALL) -c $(INSTBINFLAGS) gum/SysMan $(INSTLIBDIR_GHC)/SysMan
+endif
+
+#-----------------------------------------------------------------------------
+# creating and installing libHSrts.a (in its many flavors)
+
+ifeq ($(suffix), norm)
+RTS_LIB = libHSrts.a 		# this one is special
+else
+RTS_LIB = libHSrts_$(suffix).a
+endif 
+
+RTS_OBJS = $(RTS_LC:.lc=.$(suffix)_o)  $(RTS_LHC:.lhc=.$(suffix)_o)
+
+all :: $(RTS_LIB) 
+
+install :: $(RTS_LIB)
+	$(INSTALL) $(INSTLIBFLAGS) $(RTS_LIB) $(INSTLIBDIR_GHC)/$(RTS_LIB)
+	$(RANLIB) $(INSTLIBDIR_GHC)/$(RTS_LIB)
+
+cleanobj ::
+	$(RM) $(RTS_OBJS)
+	$(RM) $(RTS_LIB)
+
+$(RTS_LIB) :: $(H_FILES) $(RTS_OBJS)
+	$(RM) $@
+	$(AR) $@ $(RTS_OBJS)
+	$(RANLIB) $@
+
+c-as-asm/PerformIO_flags 	= -optc-DIN_GHC_RTS=1
+gum/FetchMe_flags	 	= -optc-DIN_GHC_RTS=1
+main/StgStartup_flags 		= -optc-DIN_GHC_RTS=1
+main/StgThreads_flags 		= -optc-DIN_GHC_RTS=1
+main/StgUpdate_flags		= -optc-DIN_GHC_RTS=1
+storage/SMmark_flags		= -optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP
+
+# ToDo:
+# /* this is not the way we should do this [WDP [lazy] 94/09] */
+# CTagsTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
+# CTagsTarget( gmp/[a-z]*.c )
+
+#-----------------------------------------------------------------------------
+# Do dependencies
+
+MKDEPENDC_OPTS= -I$(GHC_INCLUDES)
+
+C_DEP_SRCS = $(RTS_LC) $(RTS_LHC) $(CLIB_LC)
+include $(TOP)/mk/cdepend.mk
diff --git a/ghc/runtime/gmp/Jmakefile b/ghc/runtime/gmp/Makefile
similarity index 82%
rename from ghc/runtime/gmp/Jmakefile
rename to ghc/runtime/gmp/Makefile
index 37b990f60efdd14e432716fa132e0898e2cc0562..26729659b8d153fca3210a205ef65755b2b4467b 100644
--- a/ghc/runtime/gmp/Jmakefile
+++ b/ghc/runtime/gmp/Makefile
@@ -1,4 +1,8 @@
-/* based on the Makefile that comes with "gmp" */
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:48:25 simonm Exp $
+
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
 
 GMP_OBJS = $(MPZ_OBJS) $(MPQ_OBJS) $(MPN_OBJS) $(IMPL_OBJS) mp_bases.o
 
@@ -48,28 +52,26 @@ MPN_OBJS = mpn_add.o mpn_sub.o mpn_cmp.o mpn_mul.o mpn_div.o mpn_dm_1.o \
 
 CC_OPTS = -I.
 
-SuffixRule_c_o()
-
 all depend :: gmp-mparam.h
-
 libgmp.a :: stamp-stddefh
 
-NormalLibraryTarget(gmp,$(GMP_OBJS))
+ARCHIVE = libgmp.a
+LIBOBJS = $(GMP_OBJS)
+DESTDIR = $(INSTLIBDIR_GHC)
+C_DEP_SRCS = $(IMPL_SRCS) $(MPZ_SRCS) $(MPQ_SRCS) $(MPN_SRCS)
 
-#if DoInstallGHCSystem == YES
-InstallLibraryTarget(gmp,$(INSTLIBDIR_GHC))
-#endif /* DoInstallGHCSystem */
+clean ::
+	$(RM) test-with-stddefh.c stamp-stddefh \
+		cre-mparam gmp-mparam.h mp_bases.c cre-conv-tab
 
-ExtraStuffToClean(test-with-stddefh.c stamp-stddefh cre-mparam gmp-mparam.h mp_bases.c cre-conv-tab)
+# ToDo: something to make the doc
 
-/* ToDo: something to make the doc */
+# from here on, it is magic from the original Makefile
 
-/* from here on, it is magic from the original Makefile */
-
-XCOMM If you cross compile on a machine with the same sizes of the integral
-XCOMM types ("int", "long int", "short int", and "char") define this as the
-XCOMM local compiler.  Otherwise, you need look for the uses of LOCAL_CC below,
-XCOMM and handle those cases manually.
+# If you cross compile on a machine with the same sizes of the integral
+# types ("int", "long int", "short int", and "char") define this as the
+# local compiler.  Otherwise, you need look for the uses of LOCAL_CC below,
+# and handle those cases manually.
 
 LOCAL_CC = $(CC)
 
@@ -103,6 +105,4 @@ gmp-mparam.h: cre-mparam
 cre-mparam: cre-mparam.c stamp-stddefh gmp.h
 	$(LOCAL_CC) $(CFLAGS) cre-mparam.c -o $@
 
-/* OK, this is my own idea again: */
-
-CDependTarget( $(IMPL_SRCS) $(MPZ_SRCS) $(MPQ_SRCS) $(MPN_SRCS) )
+include $(TOP)/mk/lib.mk
diff --git a/ghc/runtime/gmp/tests/Jmakefile b/ghc/runtime/gmp/tests/Jmakefile
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/ghc/utils/Jmakefile b/ghc/utils/Jmakefile
deleted file mode 100644
index eac3396d58ebbad3a0e0b866681db8ab7e6960ef..0000000000000000000000000000000000000000
--- a/ghc/utils/Jmakefile
+++ /dev/null
@@ -1,19 +0,0 @@
-#define IHaveSubdirs
-
-SUBDIRS = hp2ps		\
-	  hscpp		\
-	  mkdependHS	\
-	  parallel	\
-	  stat2resid	\
-	  ugen		\
-	  unlit
-
-/*	  hstags
-    not ready to go for 2.01
-*/
-
-/* "heap-view" is not in the list because (a) it requires
-   a Haskell compiler (which you may not have yet), and (b) you are
-   unlikely to want it desperately.  It is easy to build once you have
-   a Haskell compiler and if you want it.
-*/
diff --git a/ghc/utils/Makefile b/ghc/utils/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..44553974936b81323e3d01c63c1d9e9af2f09a77
--- /dev/null
+++ b/ghc/utils/Makefile
@@ -0,0 +1,20 @@
+TOP=../..
+include $(TOP)/ghc/mk/ghc.mk
+
+SUBDIRS = hp2ps		\
+	  hscpp		\
+	  mkdependHS	\
+	  stat2resid	\
+	  ugen		\
+	  unlit
+#	  parallel	\
+
+#	  hstags
+#    not ready to go for 2.01
+
+# "heap-view" is not in the list because (a) it requires
+#  a Haskell compiler (which you may not have yet), and (b) you are
+#  unlikely to want it desperately.  It is easy to build once you have
+#  a Haskell compiler and if you want it.
+
+include $(TOP)/mk/subdir.mk
diff --git a/ghc/utils/heap-view/Jmakefile b/ghc/utils/heap-view/Jmakefile
deleted file mode 100644
index c3d6b5f6645a74df16c52c13fcc27761d2c07d70..0000000000000000000000000000000000000000
--- a/ghc/utils/heap-view/Jmakefile
+++ /dev/null
@@ -1,21 +0,0 @@
-PROGRAMS =  graph hpView hpView2
-
-OBJS_graph   = Graph.o           HaskXLib.o
-OBJS_hpView  = HpView.o  Parse.o HaskXLib.o
-OBJS_hpView2 = HpView2.o Parse.o HaskXLib.o
-
-HC_OPTS = -hi-diffs -fglasgow-exts -fhaskell-1.3 -O -L/usr/X11/lib -cpp
-CC_OPTS = -ansi -I/usr/X11/include
-
-HaskellSuffixRules()
-
-all :: $(PROGRAMS)
-
-BuildPgmFromHaskellModules(graph,  $(OBJS_graph),  -lX11,)
-BuildPgmFromHaskellModules(hpView, $(OBJS_hpView), -lX11,)
-BuildPgmFromHaskellModules(hpView2,$(OBJS_hpView2),-lX11,)
-
-HaskXLib.o : HaskXLib.c
-	$(CC) -c $(CFLAGS) HaskXLib.c
-
-HaskellDependTarget(Graph.lhs HpView.lhs HpView2.lhs Parse.lhs)
diff --git a/ghc/utils/heap-view/Makefile b/ghc/utils/heap-view/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..c35ae45977573e4ff786bfa4aa975f7e2c64cd85
--- /dev/null
+++ b/ghc/utils/heap-view/Makefile
@@ -0,0 +1,56 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:48:45 simonm Exp $
+
+# Todo: generalise this to use HSprog.mk or something.
+
+TOP=../../..
+HaskellSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+PROGRAMS =  graph hpView hpView2
+
+HC_OPTS = -hi-diffs -fglasgow-exts -fhaskell-1.3 -O -L/usr/X11/lib -cpp
+CC_OPTS = -ansi -I/usr/X11/include
+
+# ToDo: use AC_PATH_X in configure to get lib/include dirs for X.
+
+OBJS_graph   = Graph.o           HaskXLib.o
+OBJS_hpView  = HpView.o  Parse.o HaskXLib.o
+OBJS_hpView2 = HpView2.o Parse.o HaskXLib.o
+
+all :: $(PROGRAMS)
+
+graph : $(OBJS_graph)
+	$(HC) -o $@ $(HCFLAGS) $(LDOPTIONS) $(OBJS_graph) -lX11
+
+hpView : $(OBJS_hpView)
+	$(HC) -o $@ $(HCFLAGS) $(LDOPTIONS) $(OBJS_hpView) -lX11
+
+hpView2 : $(OBJS_hpView2)
+	$(HC) -o $@ $(HCFLAGS) $(LDOPTIONS) $(OBJS_hpView2) -lX11
+
+HaskXLib.o : HaskXLib.c
+	$(CC) -c $(CFLAGS) HaskXLib.c
+
+install :: $(PROGRAMS)
+	$(INSTALL) $(INSTBINFLAGS) graph   $(DESTDIR)
+	$(INSTALL) $(INSTBINFLAGS) hpView  $(DESTDIR)
+	$(INSTALL) $(INSTBINFLAGS) hpView2 $(DESTDIR)
+
+clean ::
+	$(RM) $(PROGRAMS)
+
+HS_DEP_SRCS = Graph.lhs HpView.lhs HpView2.lhs Parse.lhs
+include $(TOP)/mk/hsdepend.mk
+
+tags 	:: $(HS_DEP_SRCS)
+	$(HSTAGS) $(HSTAGSFLAGS) $(HS_DEP_SRCS)
+
+# DO NOT DELETE: Beginning of Haskell dependencies
+Graph.o : Graph.lhs
+HpView.o : HpView.lhs
+HpView.o : ./Parse.hi
+HpView2.o : HpView2.lhs
+HpView2.o : ./Parse.hi
+Parse.o : Parse.lhs
+# DO NOT DELETE: End of Haskell dependencies
diff --git a/ghc/utils/hp2ps/Jmakefile b/ghc/utils/hp2ps/Jmakefile
deleted file mode 100644
index 347c799ff505ab8b899a604e939e1b55d2153d12..0000000000000000000000000000000000000000
--- a/ghc/utils/hp2ps/Jmakefile
+++ /dev/null
@@ -1,50 +0,0 @@
-SRCS_C =	 	\
-	AuxFile.c	\
-	Axes.c		\
-	AreaBelow.c	\
-	Curves.c 	\
-	Deviation.c	\
-	Dimensions.c	\
-	Error.c 	\
-	HpFile.c	\
-	Key.c		\
-	Main.c 		\
-	Marks.c		\
-	TopTwenty.c	\
-	TraceElement.c	\
-	PsFile.c 	\
-	Reorder.c	\
-	Scale.c		\
-	Shade.c 	\
-	Utilities.c
-
-OBJS_C =	 	\
-	AuxFile.o	\
-	Axes.o		\
-	AreaBelow.o	\
-	Curves.o 	\
-	Deviation.o	\
-	Dimensions.o	\
-	Error.o 	\
-	HpFile.o	\
-	Key.o		\
-	Main.o 		\
-	Marks.o		\
-	TopTwenty.o	\
-	TraceElement.o	\
-	PsFile.o 	\
-	Reorder.o	\
-	Scale.o		\
-	Shade.o 	\
-	Utilities.o
-
-SuffixRule_c_o()
-
-BuildPgmFromCFiles(hp2ps,$(OBJS_C),-lm,)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTBINDIR_GHC))
-InstallBinaryTarget(hp2ps,$(INSTBINDIR_GHC))
-#endif /* DoInstall... */
-
-CDependTarget( $(SRCS_C) )
diff --git a/ghc/utils/hp2ps/Makefile b/ghc/utils/hp2ps/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..728a8ac41ad834f80b8a22a30ac6200492690344
--- /dev/null
+++ b/ghc/utils/hp2ps/Makefile
@@ -0,0 +1,28 @@
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+SRCS = 	\
+	AuxFile.c	\
+	Axes.c		\
+	AreaBelow.c	\
+	Curves.c 	\
+	Deviation.c	\
+	Dimensions.c	\
+	Error.c 	\
+	HpFile.c	\
+	Key.c		\
+	Main.c 		\
+	Marks.c		\
+	TopTwenty.c	\
+	TraceElement.c	\
+	PsFile.c 	\
+	Reorder.c	\
+	Scale.c		\
+	Shade.c 	\
+	Utilities.c
+
+PROG 	= hp2ps
+DESTDIR	= $(INSTBINDIR_GHC)
+LIBS	= -lm
+
+include $(TOP)/mk/Cprog.mk
diff --git a/ghc/utils/hscpp/Jmakefile b/ghc/utils/hscpp/Jmakefile
deleted file mode 100644
index c40e9e5e28a4a0367459191bf427ee87af8c1da6..0000000000000000000000000000000000000000
--- a/ghc/utils/hscpp/Jmakefile
+++ /dev/null
@@ -1,30 +0,0 @@
-PROGRAMS = hscpp
-
-all:: $(PROGRAMS)
-/* stuff to have before we get going */
-MsubNeededHere($(PROGRAMS))
-
-/* === BUILD STUFF (installation, etc., below) ========== */
-
-Makefile ::
-	$(RM) hscpp
-
-/* do *not* want #! script stuck on the front */
-MsubTarget(hscpp,hscpp.prl,/*no flags*/,/*Makefile*/)
-
-hscpp ::
-	@chmod a+x $@
-
-/* === INSTALLATION ======== */
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC))
-InstallScriptTarget(hscpp, $(INSTLIBDIR_GHC))
-#endif /* DoInstall... */
-
-/* === OTHER STUFF ========= */
-
-ExtraStuffToClean($(PROGRAMS))
-
-ClearTagsFile()
-PerlTagsTarget( *.prl ) /* nothing for the Bourne shell scripts */
diff --git a/ghc/utils/hscpp/Makefile b/ghc/utils/hscpp/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..28316c5e565da403c9add368688c7665a593cf4c
--- /dev/null
+++ b/ghc/utils/hscpp/Makefile
@@ -0,0 +1,12 @@
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+PROG=hscpp
+# no INTERP: do *not* want #! script stuck on the front
+SRC=hscpp.prl
+DESTDIR=$(INSTLIBDIR_GHC)
+
+# PerlTagsTarget( *.prl ) /* nothing for the Bourne shell scripts */
+
+include $(TOP)/mk/script.mk
+
diff --git a/ghc/utils/hstags/Jmakefile b/ghc/utils/hstags/Jmakefile
deleted file mode 100644
index ae1d844ba97763c4c71090ef9f38f70d254d4472..0000000000000000000000000000000000000000
--- a/ghc/utils/hstags/Jmakefile
+++ /dev/null
@@ -1,20 +0,0 @@
-PROGRAMS = hstags hstags-help
-
-SuffixRule_c_o()
-
-all:: $(PROGRAMS)
-/* stuff to have before we get going */
-MsubNeededHere(hstags)
-
-MsubMakefileDependentProgramScriptTarget(PerlCmd,hstags,hstags.prl,/*no flags*/,/*Makefile*/)
-BuildPgmFromOneCFile(hstags-help)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC) $(INSTBINDIR_GHC))
-InstallMsubbedScriptTarget(PerlCmd,hstags,hstags.prl,$(INSTBINDIR_GHC))
-InstallBinaryTarget(hstags-help, $(INSTLIBDIR_GHC))
-#endif /* DoInstall... */
-
-ExtraStuffToClean($(PROGRAMS))
-ClearTagsFile()
-PerlTagsTarget( hstags.prl )
diff --git a/ghc/utils/mkdependHS/Jmakefile b/ghc/utils/mkdependHS/Jmakefile
deleted file mode 100644
index 093861787b950b02c55fae0b5b6890c2d67d6d78..0000000000000000000000000000000000000000
--- a/ghc/utils/mkdependHS/Jmakefile
+++ /dev/null
@@ -1,16 +0,0 @@
-PROGRAMS = mkdependHS
-
-all:: $(PROGRAMS)
-MsubNeededHere($(PROGRAMS))
-UnlitNeededHere($(PROGRAMS))
-
-MsubMakefileDependentProgramScriptTarget(PerlCmd,mkdependHS,mkdependHS.prl,/*no flags*/,/*Makefile*/)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTBINDIR_GHC))
-InstallMsubbedScriptTarget(PerlCmd,mkdependHS,mkdependHS.prl,$(INSTBINDIR_GHC))
-#endif /* DoInstall... */
-
-ExtraStuffToClean($(PROGRAMS))
-ClearTagsFile()
-PerlTagsTarget( mkdependHS.prl )
diff --git a/ghc/utils/mkdependHS/Makefile b/ghc/utils/mkdependHS/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..7473e524d2782ed2d67ad4cf17912fcecdb91ce1
--- /dev/null
+++ b/ghc/utils/mkdependHS/Makefile
@@ -0,0 +1,9 @@
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+PROG=mkdependHS
+SRC=mkdependHS.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTBINDIR_GHC)
+
+include $(TOP)/mk/script.mk
diff --git a/ghc/utils/mkdependHS/mkdependHS.prl b/ghc/utils/mkdependHS/mkdependHS.prl
index 4e08e5cdcb349d0cf539b5cc972a65951a36bebc..5335f8ca6abd7cb0c0d275fbb4059d42b2786e85 100644
--- a/ghc/utils/mkdependHS/mkdependHS.prl
+++ b/ghc/utils/mkdependHS/mkdependHS.prl
@@ -99,7 +99,7 @@ if (! $ENV{'GLASGOW_HASKELL_ROOT'}) { # good -- death to environment variables
 }
 
 $Unlit = ( $(INSTALLING) ) ? "$InstLibDirGhc/unlit"
-			     : "$TopPwd/$(CURRENT_DIR)/$(GHC_UNLIT)";
+			   : "$TopPwd/ghc/utils/unlit/unlit";
 
 $Begin_magic_str = "# DO NOT DELETE: Beginning of Haskell dependencies\n";
 $End_magic_str = "# DO NOT DELETE: End of Haskell dependencies\n";
@@ -257,7 +257,7 @@ sub read_MODULES {
 
     local($m_dir) = '';
     if ($flavor eq 'prelude') {    
-	$m_dir = ( $(INSTALLING) ) ? "$InstDataDirGhc/imports" : "$TopPwd/$(CURRENT_DIR)/$(GHC_LIBSRC)";
+	$m_dir = ( $(INSTALLING) ) ? "$InstDataDirGhc/imports" : "$TopPwd/ghc/lib";
     } else {
 	$m_dir = ( $(INSTALLING) ) ? "$InstSysLibDir/$lib"     : "$TopPwd/hslibs/$lib";
     }
diff --git a/ghc/utils/parallel/Jmakefile b/ghc/utils/parallel/Jmakefile
deleted file mode 100644
index 3967047e520ec51360f7e1d62a70219a0e774e61..0000000000000000000000000000000000000000
--- a/ghc/utils/parallel/Jmakefile
+++ /dev/null
@@ -1,97 +0,0 @@
-PROGRAMS = grs2gr \
-	   gr2ps \
-	   gr2qp \
-	   qp2ps \
-	   ghc-fool-sort ghc-unfool-sort \
-	   gr2pe \
-	   gr2java \
-	   gr2jv \
-	   gr2ap \
-	   qp2ap \
-	   gr2gran \
-	   gr2RTS \
-	   RTS2gran \
-	   gran-extr \
-	   gp-ext-imp \
-	   tf \
-	   avg-RTS \
-	   SPLIT \
-	   AVG \
-	   SN \
-	   get_SN \
-	   sn_filter \
-	   ps-scale-y
-
-all:: $(PROGRAMS)
-/* stuff to have before we get going */
-MsubNeededHere($(PROGRAMS))
-
-/* === BUILD STUFF (installation, etc., below) ========== */
-
-MsubProgramScriptTarget(PerlCmd,grs2gr,grs2gr.pl,,)
-MsubProgramScriptTarget(/usr/local/bin/bash,gr2ps,gr2ps.bash,,)
-MsubProgramScriptTarget(PerlCmd,gr2qp,gr2qp.pl,,)
-MsubProgramScriptTarget(PerlCmd,qp2ps,qp2ps.pl,,)
-MsubProgramScriptTarget(PerlCmd,ghc-fool-sort,ghc-fool-sort.pl,,)
-MsubProgramScriptTarget(PerlCmd,ghc-unfool-sort,ghc-unfool-sort.pl,,)
-
-MsubProgramScriptTarget(PerlCmd,gr2pe,gr2pe.pl,,)
-MsubProgramScriptTarget(PerlCmd,gr2java,gr2java.pl,,)
-MsubProgramScriptTarget(/usr/local/bin/bash,gr2jv,gr2jv.bash,,)
-MsubProgramScriptTarget(/usr/local/bin/bash,gr2ap,gr2ap.bash,,)
-MsubProgramScriptTarget(PerlCmd,qp2ap,qp2ap.pl,,)
-
-MsubProgramScriptTarget(/usr/local/bin/bash,gr2gran,gr2gran.bash,,)
-MsubProgramScriptTarget(PerlCmd,gr2RTS,gr2RTS.pl,,)
-MsubProgramScriptTarget(PerlCmd,RTS2gran,RTS2gran.pl,,)
-MsubProgramScriptTarget(PerlCmd,gran-extr,gran-extr.pl,,)
-
-MsubProgramScriptTarget(PerlCmd,gp-ext-imp,gp-ext-imp.pl,,)
-MsubProgramScriptTarget(PerlCmd,tf,tf.pl,,)
-MsubProgramScriptTarget(PerlCmd,avg-RTS,avg-RTS.pl,,)
-MsubProgramScriptTarget(PerlCmd,SPLIT,SPLIT.pl,,)
-MsubProgramScriptTarget(PerlCmd,AVG,AVG.pl,,)
-MsubProgramScriptTarget(PerlCmd,SN,SN.pl,,)
-MsubProgramScriptTarget(PerlCmd,get_SN,get_SN.pl,,)
-MsubProgramScriptTarget(PerlCmd,sn_filter,sn_filter.pl,,)
-MsubProgramScriptTarget(PerlCmd,ps-scale-y,ps-scale-y.pl,,)
-
-/* === INSTALLATION ======== */
-
-/* the rest of these vary from std/useful to hackish dans le extreme */
-
-MakeDirectories(install,    $(INSTSCRIPTDIR))
-InstallScriptTarget(grs2gr, $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2ps,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2qp,  $(INSTSCRIPTDIR))
-InstallScriptTarget(qp2ps,  $(INSTSCRIPTDIR))
-InstallScriptTarget(ghc-fool-sort,  $(INSTSCRIPTDIR))
-InstallScriptTarget(ghc-unfool-sort,$(INSTSCRIPTDIR))
-
-InstallScriptTarget(gr2pe,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2java,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2jv,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2ap,  $(INSTSCRIPTDIR))
-InstallScriptTarget(qp2ap,  $(INSTSCRIPTDIR))
-
-InstallScriptTarget(gr2gran,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gr2RTS,  $(INSTSCRIPTDIR))
-InstallScriptTarget(RTS2gran,  $(INSTSCRIPTDIR))
-InstallScriptTarget(gran-extr,  $(INSTSCRIPTDIR))
-
-InstallScriptTarget(gp-ext-imp,  $(INSTSCRIPTDIR))
-InstallScriptTarget(tf,  $(INSTSCRIPTDIR))
-InstallScriptTarget(avg-RTS,  $(INSTSCRIPTDIR))
-InstallScriptTarget(SPLIT,  $(INSTSCRIPTDIR))
-InstallScriptTarget(AVG,  $(INSTSCRIPTDIR))
-InstallScriptTarget(SN,  $(INSTSCRIPTDIR))
-InstallScriptTarget(get_SN,  $(INSTSCRIPTDIR))
-InstallScriptTarget(sn_filter,  $(INSTSCRIPTDIR))
-InstallScriptTarget(ps-scale-y,  $(INSTSCRIPTDIR))
-
-/* === OTHER STUFF ========= */
-
-ExtraStuffToClean($(PROGRAMS))
-
-ClearTagsFile()
-PerlTagsTarget( *.pl )
diff --git a/ghc/utils/parallel/Makefile b/ghc/utils/parallel/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..30718e6046732d43c23911b64e4f0d5dba41e4e7
--- /dev/null
+++ b/ghc/utils/parallel/Makefile
@@ -0,0 +1,64 @@
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+PROGRAMS = \
+  grs2gr gr2ps gr2qp qp2ps ghc-fool-sort ghc-unfool-sort gr2pe gr2java gr2jv \
+  gr2ap qp2ap gr2gran gr2RTS RTS2gran gran-extr gp-ext-imp tf avg-RTS SPLIT \
+  AVG SN get_SN sn_filter ps-scale-y
+
+#MsubProgramScriptTarget(PerlCmd,grs2gr,grs2gr.pl,,)
+#MsubProgramScriptTarget(/usr/local/bin/bash,gr2ps,gr2ps.bash,,)
+#MsubProgramScriptTarget(PerlCmd,gr2qp,gr2qp.pl,,)
+#MsubProgramScriptTarget(PerlCmd,qp2ps,qp2ps.pl,,)
+#MsubProgramScriptTarget(PerlCmd,ghc-fool-sort,ghc-fool-sort.pl,,)
+#MsubProgramScriptTarget(PerlCmd,ghc-unfool-sort,ghc-unfool-sort.pl,,)
+
+#MsubProgramScriptTarget(PerlCmd,gr2pe,gr2pe.pl,,)
+#MsubProgramScriptTarget(PerlCmd,gr2java,gr2java.pl,,)
+#MsubProgramScriptTarget(/usr/local/bin/bash,gr2jv,gr2jv.bash,,)
+#MsubProgramScriptTarget(/usr/local/bin/bash,gr2ap,gr2ap.bash,,)
+#MsubProgramScriptTarget(PerlCmd,qp2ap,qp2ap.pl,,)
+
+#MsubProgramScriptTarget(/usr/local/bin/bash,gr2gran,gr2gran.bash,,)
+#MsubProgramScriptTarget(PerlCmd,gr2RTS,gr2RTS.pl,,)
+#MsubProgramScriptTarget(PerlCmd,RTS2gran,RTS2gran.pl,,)
+#MsubProgramScriptTarget(PerlCmd,gran-extr,gran-extr.pl,,)
+
+#MsubProgramScriptTarget(PerlCmd,gp-ext-imp,gp-ext-imp.pl,,)
+#MsubProgramScriptTarget(PerlCmd,tf,tf.pl,,)
+#MsubProgramScriptTarget(PerlCmd,avg-RTS,avg-RTS.pl,,)
+#MsubProgramScriptTarget(PerlCmd,SPLIT,SPLIT.pl,,)
+#MsubProgramScriptTarget(PerlCmd,AVG,AVG.pl,,)
+#MsubProgramScriptTarget(PerlCmd,SN,SN.pl,,)
+#MsubProgramScriptTarget(PerlCmd,get_SN,get_SN.pl,,)
+#MsubProgramScriptTarget(PerlCmd,sn_filter,sn_filter.pl,,)
+#MsubProgramScriptTarget(PerlCmd,ps-scale-y,ps-scale-y.pl,,)
+
+#MakeDirectories(install,    $(INSTSCRIPTDIR))
+#InstallScriptTarget(grs2gr, $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2ps,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2qp,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(qp2ps,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(ghc-fool-sort,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(ghc-unfool-sort,$(INSTSCRIPTDIR))
+
+#InstallScriptTarget(gr2pe,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2java,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2jv,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2ap,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(qp2ap,  $(INSTSCRIPTDIR))
+
+#InstallScriptTarget(gr2gran,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gr2RTS,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(RTS2gran,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(gran-extr,  $(INSTSCRIPTDIR))
+
+#InstallScriptTarget(gp-ext-imp,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(tf,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(avg-RTS,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(SPLIT,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(AVG,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(SN,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(get_SN,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(sn_filter,  $(INSTSCRIPTDIR))
+#InstallScriptTarget(ps-scale-y,  $(INSTSCRIPTDIR))
diff --git a/ghc/utils/stat2resid/Jmakefile b/ghc/utils/stat2resid/Jmakefile
deleted file mode 100644
index aed1c169ccde5a97d51c89566bf7c1c20006ad7d..0000000000000000000000000000000000000000
--- a/ghc/utils/stat2resid/Jmakefile
+++ /dev/null
@@ -1,26 +0,0 @@
-/* stuff to have before we get going */
-MsubNeededHere(stat2resid)
-
-DYN_LOADABLE_BITS = \
-	parse-gcstats.prl \
-	process-gcstats.prl
-
-MsubMakefileDependentProgramScriptTarget(PerlCmd,stat2resid,stat2resid.prl,/*no flags*/,/*Makefile*/)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTBINDIR_GHC) $(INSTLIBDIR_GHC))
-
-InstallMsubbedScriptTarget(PerlCmd,stat2resid-v-temp-name,stat2resid.prl,$(INSTBINDIR_GHC))
-/* and continuing ... */
-install::
-	$(MV) $(INSTBINDIR_GHC)/stat2resid-v-temp-name $(INSTBINDIR_GHC)/stat2resid
-	$(RM) $(INSTBINDIR_GHC)/stat2resid-v-temp-name
-
-dyn_loadable_bits : $(DYN_LOADABLE_BITS)
-
-InstallMultNonExecTargets(dyn_loadable_bits, $(DYN_LOADABLE_BITS), $(INSTLIBDIR_GHC))
-
-install :: install_dyn_loadable_bits
-
-#endif /* DoInstallGHCSystem */
-
diff --git a/ghc/utils/stat2resid/Makefile b/ghc/utils/stat2resid/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..13afc5ddffb7e694659ccfa0b545339991327bb5
--- /dev/null
+++ b/ghc/utils/stat2resid/Makefile
@@ -0,0 +1,19 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:49:10 simonm Exp $
+
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+DYN_LOADABLE_BITS = \
+	parse-gcstats.prl \
+	process-gcstats.prl
+
+PROG=stat2resid
+SRC=stat2resid.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTBINDIR_GHC)
+
+install ::
+	$(INSTALL) $(INSTDATAFLAGS) $(DYN_LOADABLE_BITS) $(INSTLIBDIR_GHC)
+
+include $(TOP)/mk/script.mk
diff --git a/ghc/utils/ugen/Jmakefile b/ghc/utils/ugen/Jmakefile
deleted file mode 100644
index 55fc9536450f994e0e19dc539f466f3feed119c5..0000000000000000000000000000000000000000
--- a/ghc/utils/ugen/Jmakefile
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SRCS_C is for mkdependC's benefit */
-/* lex.c is from lex.l
-   syntax.tab.c is from syntax.y
-   tree.c is from tree.u (but a version is provided for bootstrapping)
-
-   if it tries to run "ugen tree.u" while trying to build here, then
-   you are what is technically known as "dead in the water".
-*/
-YFLAGS = -d
-
-SRCS_C = main.c gen.c lex.c syntax.tab.c id.c tree.c yyerror.c
-OBJS_C = main.o gen.o lex.o syntax.tab.o id.o tree.o yyerror.o
-
-SuffixRule_c_o()
-
-BuildPgmFromCFiles(ugen,$(OBJS_C),,)
-
-/* InstallBinaryTarget(ugen,$(INSTBINDIR)) */
-
-YaccRunWithExpectMsg(syntax,no,no)
-
-UgenTarget(.,tree)
-
-CDependTarget( $(SRCS_C) )
-
-ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) lex.c syntax.tab.c syntax.tab.h )
diff --git a/ghc/utils/ugen/Makefile b/ghc/utils/ugen/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..59b56ef5bd726aa2a08cd1ae346fb5ed792f6753
--- /dev/null
+++ b/ghc/utils/ugen/Makefile
@@ -0,0 +1,18 @@
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.2 1996/11/21 16:49:13 simonm Exp $
+
+TOP=../../..
+FlexSuffixRules = YES
+YaccSuffixRules = YES
+include $(TOP)/ghc/mk/ghc.mk
+
+YFLAGS = -d
+SRCS = syntax.tab.c lex.c id.c tree.c yyerror.c gen.c main.c
+PROG = ugen
+LIBS = $(FLEX_LIB)
+DESTDIR = $(INSTBINDIR)
+
+clean ::
+	$(RM) lex.c syntax.tab.c syntax.tab.h
+
+include $(TOP)/mk/Cprog.mk
diff --git a/ghc/utils/ugen/lex.c b/ghc/utils/ugen/lex.c
deleted file mode 100644
index 51c41fe2089eab9afbf9ad21e2cf327d5f9b3473..0000000000000000000000000000000000000000
--- a/ghc/utils/ugen/lex.c
+++ /dev/null
@@ -1,514 +0,0 @@
-# include "stdio.h"
-# define U(x) x
-# define NLSTATE yyprevious=YYNEWLINE
-# define BEGIN yybgin = yysvec + 1 +
-# define INITIAL 0
-# define YYLERR yysvec
-# define YYSTATE (yyestate-yysvec-1)
-# define YYOPTIM 1
-# define YYLMAX BUFSIZ
-# define output(c) putc(c,yyout)
-# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
-# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
-# define yymore() (yymorfg=1)
-# define ECHO fprintf(yyout, "%s",yytext)
-# define REJECT { nstr = yyreject(); goto yyfussy;}
-int yyleng; extern char yytext[];
-int yymorfg;
-extern char *yysptr, yysbuf[];
-int yytchar;
-FILE *yyin = {stdin}, *yyout = {stdout};
-extern int yylineno;
-struct yysvf { 
-	struct yywork *yystoff;
-	struct yysvf *yyother;
-	int *yystops;};
-struct yysvf *yyestate;
-extern struct yysvf yysvec[], *yybgin;
-#define YYSTYPE long
-
-#ifdef __STDC__
-#define PROTO(x)	x
-#else
-#define PROTO(x)	()
-#endif
-
-# include "syntax.tab.h"
-# include <stdio.h>
-# include "id.h"
-# include "tree.h"
-# include "funs.h"
-extern	YYSTYPE yylval;
-extern  FILE *fc, *fhs;
-#undef ECHO /* partain */
-#define ECHO /*fprintf(stderr, "%s", yytext)*/
-
-# define YYNEWLINE 10
-yylex(){
-int nstr; extern int yyprevious;
-while((nstr = yylook()) >= 0)
-yyfussy: switch(nstr){
-case 0:
-if(yywrap()) return(0); break;
-case 1:
-		{ ECHO; return(SEMICOL); }
-break;
-case 2:
-		{ ECHO; return(COLON); }
-break;
-case 3:
-		{ ECHO; return(STDEF); }
-break;
-case 4:
-		{ ECHO; return(ENDDEF); }
-break;
-case 5:
- 		{ ECHO; return(TYPE); }
-break;
-case 6:
- 		{ ECHO; return(END); }
-break;
-case 7:
-{
-				ECHO;
-				yylval = (YYSTYPE) installid(yytext);
-				return(ID);
-			}
-break;
-case 8:
-		ECHO;
-break;
-case 9:
-		ECHO;
-break;
-case 10:
-ECHO;
-break;
-case 11:
-{ /* partain: for Haskell includes */
-				ECHO;
-				yytext[yyleng-3] = '\0';
-				fprintf(fhs, "\n%s",  &yytext[3]);
-			}
-break;
-case 12:
-{
-				ECHO;
-				yytext[yyleng-2] = '\0';
-				fprintf(fc, "\n%s",  &yytext[2]);
-			}
-break;
-case -1:
-break;
-default:
-fprintf(yyout,"bad switch yylook %d",nstr);
-} return(0); }
-/* end of yylex */
-int
-yywrap()
-{
-	return(1);
-}
-int yyvstop[] = {
-0,
-
-8,
-0,
-
-9,
-0,
-
-8,
-0,
-
-8,
-0,
-
-2,
-8,
-0,
-
-1,
-8,
-0,
-
-3,
-8,
-0,
-
-4,
-8,
-0,
-
-7,
-8,
-0,
-
-7,
-8,
-0,
-
-7,
-8,
-0,
-
-7,
-0,
-
-7,
-0,
-
-7,
-0,
-
-6,
-7,
-0,
-
-7,
-0,
-
-12,
-0,
-
-10,
-0,
-
-5,
-7,
-0,
-
-12,
-0,
-
-11,
-0,
-0};
-# define YYTYPE char
-struct yywork { YYTYPE verify, advance; } yycrank[] = {
-0,0,	0,0,	1,3,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	1,4,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	1,5,	0,0,	
-0,0,	0,0,	0,0,	1,3,	
-6,15,	0,0,	0,0,	15,15,	
-1,6,	1,3,	20,19,	26,21,	
-0,0,	0,0,	0,0,	0,0,	
-15,15,	22,15,	0,0,	1,7,	
-1,8,	1,9,	22,27,	1,10,	
-0,0,	0,0,	1,11,	2,7,	
-2,8,	2,9,	0,0,	2,10,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	15,15,	
-0,0,	0,0,	0,0,	0,0,	
-15,22,	0,0,	0,0,	0,0,	
-0,0,	15,15,	15,15,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	1,12,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	2,12,	15,15,	
-17,23,	24,28,	0,0,	0,0,	
-0,0,	1,13,	0,0,	0,0,	
-12,17,	0,0,	0,0,	18,24,	
-5,14,	2,13,	1,3,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	13,18,	20,25,	26,29,	
-29,30,	0,0,	0,0,	0,0,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	0,0,	15,15,	
-0,0,	0,0,	11,16,	0,0,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	11,16,	11,16,	
-11,16,	11,16,	14,19,	0,0,	
-19,19,	0,0,	21,21,	0,0,	
-0,0,	0,0,	0,0,	14,19,	
-0,0,	19,19,	0,0,	21,21,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	14,20,	0,0,	
-19,20,	0,0,	21,26,	14,19,	
-0,0,	19,19,	0,0,	21,21,	
-14,19,	14,19,	19,19,	19,19,	
-21,21,	21,21,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	14,19,	0,0,	
-19,19,	0,0,	21,21,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-0,0,	0,0,	0,0,	0,0,	
-14,21,	0,0,	14,19,	0,0,	
-19,19,	0,0,	21,21,	0,0,	
-0,0};
-struct yysvf yysvec[] = {
-0,	0,	0,
-yycrank+-1,	0,		0,	
-yycrank+-9,	yysvec+1,	0,	
-yycrank+0,	0,		yyvstop+1,
-yycrank+0,	0,		yyvstop+3,
-yycrank+1,	0,		yyvstop+5,
-yycrank+2,	0,		yyvstop+7,
-yycrank+0,	0,		yyvstop+9,
-yycrank+0,	0,		yyvstop+12,
-yycrank+0,	0,		yyvstop+15,
-yycrank+0,	0,		yyvstop+18,
-yycrank+79,	0,		yyvstop+21,
-yycrank+10,	yysvec+11,	yyvstop+24,
-yycrank+16,	yysvec+11,	yyvstop+27,
-yycrank+-201,	0,		0,	
-yycrank+-46,	0,		0,	
-yycrank+0,	yysvec+11,	yyvstop+30,
-yycrank+12,	yysvec+11,	yyvstop+32,
-yycrank+11,	yysvec+11,	yyvstop+34,
-yycrank+-203,	0,		0,	
-yycrank+-13,	yysvec+19,	0,	
-yycrank+-205,	0,		0,	
-yycrank+-15,	yysvec+15,	0,	
-yycrank+0,	yysvec+11,	yyvstop+36,
-yycrank+12,	yysvec+11,	yyvstop+39,
-yycrank+0,	0,		yyvstop+41,
-yycrank+-14,	yysvec+21,	0,	
-yycrank+0,	0,		yyvstop+43,
-yycrank+0,	yysvec+11,	yyvstop+45,
-yycrank+15,	0,		yyvstop+48,
-yycrank+0,	0,		yyvstop+50,
-0,	0,	0};
-struct yywork *yytop = yycrank+330;
-struct yysvf *yybgin = yysvec+1;
-char yymatch[] = {
-00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
-01  ,01  ,012 ,01  ,01  ,01  ,01  ,01  ,
-01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
-01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
-01  ,01  ,01  ,01  ,01  ,'%' ,01  ,01  ,
-01  ,01  ,'*' ,01  ,01  ,01  ,01  ,'/' ,
-'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
-'0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,
-01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,'0' ,
-01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
-'A' ,'A' ,'A' ,01  ,01  ,'}' ,01  ,01  ,
-0};
-char yyextra[] = {
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0};
-#ifndef lint
-static	char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */
-#endif
-
-int yylineno =1;
-# define YYU(x) x
-# define NLSTATE yyprevious=YYNEWLINE
-char yytext[YYLMAX];
-struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
-char yysbuf[YYLMAX];
-char *yysptr = yysbuf;
-int *yyfnd;
-extern struct yysvf *yyestate;
-int yyprevious = YYNEWLINE;
-yylook(){
-	register struct yysvf *yystate, **lsp;
-	register struct yywork *yyt;
-	struct yysvf *yyz;
-	int yych, yyfirst;
-	struct yywork *yyr;
-# ifdef LEXDEBUG
-	int debug;
-# endif
-	char *yylastch;
-	/* start off machines */
-# ifdef LEXDEBUG
-	debug = 0;
-# endif
-	yyfirst=1;
-	if (!yymorfg)
-		yylastch = yytext;
-	else {
-		yymorfg=0;
-		yylastch = yytext+yyleng;
-		}
-	for(;;){
-		lsp = yylstate;
-		yyestate = yystate = yybgin;
-		if (yyprevious==YYNEWLINE) yystate++;
-		for (;;){
-# ifdef LEXDEBUG
-			if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
-# endif
-			yyt = yystate->yystoff;
-			if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
-				yyz = yystate->yyother;
-				if(yyz == 0)break;
-				if(yyz->yystoff == yycrank)break;
-				}
-			*yylastch++ = yych = input();
-			yyfirst=0;
-		tryagain:
-# ifdef LEXDEBUG
-			if(debug){
-				fprintf(yyout,"char ");
-				allprint(yych);
-				putchar('\n');
-				}
-# endif
-			yyr = yyt;
-			if ( (int)yyt > (int)yycrank){
-				yyt = yyr + yych;
-				if (yyt <= yytop && yyt->verify+yysvec == yystate){
-					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
-						{unput(*--yylastch);break;}
-					*lsp++ = yystate = yyt->advance+yysvec;
-					goto contin;
-					}
-				}
-# ifdef YYOPTIM
-			else if((int)yyt < (int)yycrank) {		/* r < yycrank */
-				yyt = yyr = yycrank+(yycrank-yyt);
-# ifdef LEXDEBUG
-				if(debug)fprintf(yyout,"compressed state\n");
-# endif
-				yyt = yyt + yych;
-				if(yyt <= yytop && yyt->verify+yysvec == yystate){
-					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
-						{unput(*--yylastch);break;}
-					*lsp++ = yystate = yyt->advance+yysvec;
-					goto contin;
-					}
-				yyt = yyr + YYU(yymatch[yych]);
-# ifdef LEXDEBUG
-				if(debug){
-					fprintf(yyout,"try fall back character ");
-					allprint(YYU(yymatch[yych]));
-					putchar('\n');
-					}
-# endif
-				if(yyt <= yytop && yyt->verify+yysvec == yystate){
-					if(yyt->advance+yysvec == YYLERR)	/* error transition */
-						{unput(*--yylastch);break;}
-					*lsp++ = yystate = yyt->advance+yysvec;
-					goto contin;
-					}
-				}
-			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
-# ifdef LEXDEBUG
-				if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
-# endif
-				goto tryagain;
-				}
-# endif
-			else
-				{unput(*--yylastch);break;}
-		contin:
-# ifdef LEXDEBUG
-			if(debug){
-				fprintf(yyout,"state %d char ",yystate-yysvec-1);
-				allprint(yych);
-				putchar('\n');
-				}
-# endif
-			;
-			}
-# ifdef LEXDEBUG
-		if(debug){
-			fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
-			allprint(yych);
-			putchar('\n');
-			}
-# endif
-		while (lsp-- > yylstate){
-			*yylastch-- = 0;
-			if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
-				yyolsp = lsp;
-				if(yyextra[*yyfnd]){		/* must backup */
-					while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
-						lsp--;
-						unput(*yylastch--);
-						}
-					}
-				yyprevious = YYU(*yylastch);
-				yylsp = lsp;
-				yyleng = yylastch-yytext+1;
-				yytext[yyleng] = 0;
-# ifdef LEXDEBUG
-				if(debug){
-					fprintf(yyout,"\nmatch ");
-					sprint(yytext);
-					fprintf(yyout," action %d\n",*yyfnd);
-					}
-# endif
-				return(*yyfnd++);
-				}
-			unput(*yylastch);
-			}
-		if (yytext[0] == 0  /* && feof(yyin) */)
-			{
-			yysptr=yysbuf;
-			return(0);
-			}
-		yyprevious = yytext[0] = input();
-		if (yyprevious>0)
-			output(yyprevious);
-		yylastch=yytext;
-# ifdef LEXDEBUG
-		if(debug)putchar('\n');
-# endif
-		}
-	}
-yyback(p, m)
-	int *p;
-{
-if (p==0) return(0);
-while (*p)
-	{
-	if (*p++ == m)
-		return(1);
-	}
-return(0);
-}
-	/* the following are only used in the lex library */
-yyinput(){
-	return(input());
-	}
-yyoutput(c)
-  int c; {
-	output(c);
-	}
-yyunput(c)
-   int c; {
-	unput(c);
-	}
diff --git a/ghc/utils/ugen/lex.flex b/ghc/utils/ugen/lex.flex
new file mode 100644
index 0000000000000000000000000000000000000000..4f2e9ad0e3a176991393be06a4566748670f4cc8
--- /dev/null
+++ b/ghc/utils/ugen/lex.flex
@@ -0,0 +1,53 @@
+%{
+#define YYSTYPE long
+
+#ifdef __STDC__
+#define PROTO(x)	x
+#else
+#define PROTO(x)	()
+#endif
+
+# include "syntax.tab.h"
+# include <stdio.h>
+# include "id.h"
+# include "tree.h"
+# include "funs.h"
+extern	YYSTYPE yylval;
+extern  FILE *fc, *fhs;
+int lineno;
+
+void countNewlines (char *s)
+{
+  while (*s) if (*s++ == '\n') lineno += 1;
+}
+
+%}
+
+%%
+";"			{ return(SEMICOL); }
+":"			{ return(COLON); }
+"<"			{ return(STDEF); }
+">"			{ return(ENDDEF); }
+"type"	 		{ return(TYPE); }
+"end"	 		{ return(END); }
+[A-Za-z][A-Za-z0-9_]*	{ yylval = (YYSTYPE) installid(yytext); return(ID); }
+"\n"			{ lineno += 1; }
+.			{ }
+"/*"([^*]|"*"[^/]|\n)*"*/" { countNewlines(yytext); }
+"%{{"([^%]|"%"[^}]|\n)*"%}}" {
+				/* For Haskell includes */
+				countNewlines(yytext);
+				yytext[yyleng-3] = '\0';
+				fprintf(fhs, "\n%s", yytext+3);
+			      }
+"%{"([^%]|"%"[^}]|\n)*"%}"  {
+			      countNewlines(yytext);
+			      yytext[yyleng-2] = '\0';
+			      fprintf(fc, "\n%s",  &yytext[2]);
+			    }
+%%
+int
+yywrap()
+{
+	return(1);
+}
diff --git a/ghc/utils/ugen/main.c b/ghc/utils/ugen/main.c
index 324ed5052b3637806f2a586ab0c9304a805b5baf..a22fcd26187b999d84e9ddeae0ec9fb2704b2be5 100644
--- a/ghc/utils/ugen/main.c
+++ b/ghc/utils/ugen/main.c
@@ -11,6 +11,7 @@
 #include "funs.h"
 
 FILE *fh, *fc, *fhs;
+extern int lineno;
 
 tree root; /* The root of the built syntax tree. */
 
@@ -50,6 +51,7 @@ main(argc, argv)
 	fhs = fopen(argv[1], "w"); /* .hs file */
 	argv[1][i-1] = '\0';
 
+	lineno = 1;
 	if(yyparse() == 0) {
 		/* No syntax errors. */
 
diff --git a/ghc/utils/ugen/syntax.tab.c b/ghc/utils/ugen/syntax.tab.c
deleted file mode 100644
index 9cb6e564490463f92007b71919a4fb2de020dcd4..0000000000000000000000000000000000000000
--- a/ghc/utils/ugen/syntax.tab.c
+++ /dev/null
@@ -1,858 +0,0 @@
-
-/*  A Bison parser, made from syntax.y with Bison version GNU Bison version 1.21
-  */
-
-#define YYBISON 1  /* Identify Bison output.  */
-
-#define	ID	258
-#define	TYPE	259
-#define	SEMICOL	260
-#define	COLON	261
-#define	END	262
-#define	STDEF	263
-#define	ENDDEF	264
-
-#line 1 "syntax.y"
-
-#define YYSTYPE long
-# include "id.h"
-# include "tree.h"
-extern tree root;
-
-#ifndef YYLTYPE
-typedef
-  struct yyltype
-    {
-      int timestamp;
-      int first_line;
-      int first_column;
-      int last_line;
-      int last_column;
-      char *text;
-   }
-  yyltype;
-
-#define YYLTYPE yyltype
-#endif
-
-#ifndef YYSTYPE
-#define YYSTYPE int
-#endif
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define	YYFINAL		25
-#define	YYFLAG		-32768
-#define	YYNTBASE	10
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 264 ? yytranslate[x] : 15)
-
-static const char yytranslate[] = {     0,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
-     6,     7,     8,     9
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = {     0,
-     0,     7,     9,    12,    19,    25,    27,    30
-};
-
-static const short yyrhs[] = {     4,
-     3,     5,    11,     7,     5,     0,    12,     0,    11,    12,
-     0,     3,     6,     8,    13,     9,     5,     0,     3,     6,
-     8,     9,     5,     0,    14,     0,    13,    14,     0,     3,
-     6,     3,     5,     0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
-    10,    16,    20,    26,    30,    36,    40,    46
-};
-
-static const char * const yytname[] = {   "$","error","$illegal.","ID","TYPE",
-"SEMICOL","COLON","END","STDEF","ENDDEF","typdef","deflist","def","itemlist",
-"item",""
-};
-#endif
-
-static const short yyr1[] = {     0,
-    10,    11,    11,    12,    12,    13,    13,    14
-};
-
-static const short yyr2[] = {     0,
-     6,     1,     2,     6,     5,     1,     2,     4
-};
-
-static const short yydefact[] = {     0,
-     0,     0,     0,     0,     0,     2,     0,     0,     3,     0,
-     1,     0,     0,     0,     6,     0,     5,     0,     7,     0,
-     4,     8,     0,     0,     0
-};
-
-static const short yydefgoto[] = {    23,
-     5,     6,    14,    15
-};
-
-static const short yypact[] = {    -1,
-     2,     4,     7,    -4,     1,-32768,     3,     8,-32768,    -3,
--32768,     6,     9,    -2,-32768,    12,-32768,    11,-32768,    13,
--32768,-32768,    17,    19,-32768
-};
-
-static const short yypgoto[] = {-32768,
--32768,    15,-32768,    10
-};
-
-
-#define	YYLAST		24
-
-
-static const short yytable[] = {    12,
-    12,     7,     1,     4,     2,    13,    18,     8,     3,     4,
-    10,    16,    11,    17,    20,    21,    24,    22,    25,     9,
-     0,     0,     0,    19
-};
-
-static const short yycheck[] = {     3,
-     3,     6,     4,     3,     3,     9,     9,     7,     5,     3,
-     8,     6,     5,     5,     3,     5,     0,     5,     0,     5,
-    -1,    -1,    -1,    14
-};
-/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
-#line 3 "/usr/local/gnu/lib/bison.simple"
-
-/* Skeleton output parser for bison,
-   Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
-
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C.  */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#include <malloc.h>
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-#include <malloc.h>
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca (unsigned int);
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc.  */
-#endif /* not GNU C.  */
-#endif /* alloca not defined.  */
-
-/* This is the parser code that is written into each bison parser
-  when the %semantic_parser declaration is not specified in the grammar.
-  It was written by Richard Stallman by simplifying the hairy parser
-  used when %semantic_parser is specified.  */
-
-/* Note: there must be only one dollar sign in this file.
-   It is replaced by the list of actions, each action
-   as one case of the switch.  */
-
-#define yyerrok		(yyerrstatus = 0)
-#define yyclearin	(yychar = YYEMPTY)
-#define YYEMPTY		-2
-#define YYEOF		0
-#define YYACCEPT	return(0)
-#define YYABORT 	return(1)
-#define YYERROR		goto yyerrlab1
-/* Like YYERROR except do call yyerror.
-   This remains here temporarily to ease the
-   transition to the new meaning of YYERROR, for GCC.
-   Once GCC version 2 has supplanted version 1, this can go.  */
-#define YYFAIL		goto yyerrlab
-#define YYRECOVERING()  (!!yyerrstatus)
-#define YYBACKUP(token, value) \
-do								\
-  if (yychar == YYEMPTY && yylen == 1)				\
-    { yychar = (token), yylval = (value);			\
-      yychar1 = YYTRANSLATE (yychar);				\
-      YYPOPSTACK;						\
-      goto yybackup;						\
-    }								\
-  else								\
-    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
-while (0)
-
-#define YYTERROR	1
-#define YYERRCODE	256
-
-#ifndef YYPURE
-#define YYLEX		yylex()
-#endif
-
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#define YYLEX		yylex(&yylval, &yylloc)
-#else
-#define YYLEX		yylex(&yylval)
-#endif
-#endif
-
-/* If nonreentrant, generate the variables here */
-
-#ifndef YYPURE
-
-int	yychar;			/*  the lookahead symbol		*/
-YYSTYPE	yylval;			/*  the semantic value of the		*/
-				/*  lookahead symbol			*/
-
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc;			/*  location data for the lookahead	*/
-				/*  symbol				*/
-#endif
-
-int yynerrs;			/*  number of parse errors so far       */
-#endif  /* not YYPURE */
-
-#if YYDEBUG != 0
-int yydebug;			/*  nonzero means print parse trace	*/
-/* Since this is uninitialized, it does not stop multiple parsers
-   from coexisting.  */
-#endif
-
-/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
-
-#ifndef	YYINITDEPTH
-#define YYINITDEPTH 200
-#endif
-
-/*  YYMAXDEPTH is the maximum size the stacks can grow to
-    (effective only if the built-in stack extension method is used).  */
-
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
-#endif
-
-/* Prevent warning if -Wstrict-prototypes.  */
-#ifdef __GNUC__
-int yyparse (void);
-#endif
-
-#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
-#define __yy_bcopy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
-#else				/* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
-   in available built-in functions on various systems.  */
-static void
-__yy_bcopy (from, to, count)
-     char *from;
-     char *to;
-     int count;
-{
-  register char *f = from;
-  register char *t = to;
-  register int i = count;
-
-  while (i-- > 0)
-    *t++ = *f++;
-}
-
-#else /* __cplusplus */
-
-/* This is the most reliable way to avoid incompatibilities
-   in available built-in functions on various systems.  */
-static void
-__yy_bcopy (char *from, char *to, int count)
-{
-  register char *f = from;
-  register char *t = to;
-  register int i = count;
-
-  while (i-- > 0)
-    *t++ = *f++;
-}
-
-#endif
-#endif
-
-#line 184 "/usr/local/gnu/lib/bison.simple"
-int
-yyparse()
-{
-  register int yystate;
-  register int yyn;
-  register short *yyssp;
-  register YYSTYPE *yyvsp;
-  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
-  int yychar1;		/*  lookahead token as an internal (translated) token number */
-
-  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
-  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
-
-  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
-  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
-  YYLTYPE *yyls = yylsa;
-  YYLTYPE *yylsp;
-
-#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK   (yyvsp--, yyssp--)
-#endif
-
-  int yystacksize = YYINITDEPTH;
-
-#ifdef YYPURE
-  int yychar;
-  YYSTYPE yylval;
-  int yynerrs;
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylloc;
-#endif
-#endif
-
-  YYSTYPE yyval;		/*  the variable used to return		*/
-				/*  semantic values from the action	*/
-				/*  routines				*/
-
-  int yylen;
-
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Starting parse\n");
-#endif
-
-  yystate = 0;
-  yyerrstatus = 0;
-  yynerrs = 0;
-  yychar = YYEMPTY;		/* Cause a token to be read.  */
-
-  /* Initialize stack pointers.
-     Waste one element of value and location stack
-     so that they stay on the same level as the state stack.
-     The wasted elements are never initialized.  */
-
-  yyssp = yyss - 1;
-  yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
-  yylsp = yyls;
-#endif
-
-/* Push a new state, which is found in  yystate  .  */
-/* In all cases, when you get here, the value and location stacks
-   have just been pushed. so pushing a state here evens the stacks.  */
-yynewstate:
-
-  *++yyssp = yystate;
-
-  if (yyssp >= yyss + yystacksize - 1)
-    {
-      /* Give user a chance to reallocate the stack */
-      /* Use copies of these so that the &'s don't force the real ones into memory. */
-      YYSTYPE *yyvs1 = yyvs;
-      short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
-      YYLTYPE *yyls1 = yyls;
-#endif
-
-      /* Get the current used size of the three stacks, in elements.  */
-      int size = yyssp - yyss + 1;
-
-#ifdef yyoverflow
-      /* Each stack pointer address is followed by the size of
-	 the data in use in that stack, in bytes.  */
-      yyoverflow("parser stack overflow",
-		 &yyss1, size * sizeof (*yyssp),
-		 &yyvs1, size * sizeof (*yyvsp),
-#ifdef YYLSP_NEEDED
-		 &yyls1, size * sizeof (*yylsp),
-#endif
-		 &yystacksize);
-
-      yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
-      yyls = yyls1;
-#endif
-#else /* no yyoverflow */
-      /* Extend the stack our own way.  */
-      if (yystacksize >= YYMAXDEPTH)
-	{
-	  yyerror("parser stack overflow");
-	  return 2;
-	}
-      yystacksize *= 2;
-      if (yystacksize > YYMAXDEPTH)
-	yystacksize = YYMAXDEPTH;
-      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
-      __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
-      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
-      __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
-      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
-      __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
-#endif
-#endif /* no yyoverflow */
-
-      yyssp = yyss + size - 1;
-      yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
-      yylsp = yyls + size - 1;
-#endif
-
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
-
-      if (yyssp >= yyss + yystacksize - 1)
-	YYABORT;
-    }
-
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Entering state %d\n", yystate);
-#endif
-
-  goto yybackup;
- yybackup:
-
-/* Do appropriate processing given the current state.  */
-/* Read a lookahead token if we need one and don't already have one.  */
-/* yyresume: */
-
-  /* First try to decide what to do without reference to lookahead token.  */
-
-  yyn = yypact[yystate];
-  if (yyn == YYFLAG)
-    goto yydefault;
-
-  /* Not known => get a lookahead token if don't already have one.  */
-
-  /* yychar is either YYEMPTY or YYEOF
-     or a valid token in external form.  */
-
-  if (yychar == YYEMPTY)
-    {
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Reading a token: ");
-#endif
-      yychar = YYLEX;
-    }
-
-  /* Convert token to internal form (in yychar1) for indexing tables with */
-
-  if (yychar <= 0)		/* This means end of input. */
-    {
-      yychar1 = 0;
-      yychar = YYEOF;		/* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Now at end of input.\n");
-#endif
-    }
-  else
-    {
-      yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
-      if (yydebug)
-	{
-	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
-	  /* Give the individual parser a way to print the precise meaning
-	     of a token, for further debugging info.  */
-#ifdef YYPRINT
-	  YYPRINT (stderr, yychar, yylval);
-#endif
-	  fprintf (stderr, ")\n");
-	}
-#endif
-    }
-
-  yyn += yychar1;
-  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
-    goto yydefault;
-
-  yyn = yytable[yyn];
-
-  /* yyn is what to do for this token type in this state.
-     Negative => reduce, -yyn is rule number.
-     Positive => shift, yyn is new state.
-       New state is final state => don't bother to shift,
-       just return success.
-     0, or most negative number => error.  */
-
-  if (yyn < 0)
-    {
-      if (yyn == YYFLAG)
-	goto yyerrlab;
-      yyn = -yyn;
-      goto yyreduce;
-    }
-  else if (yyn == 0)
-    goto yyerrlab;
-
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
-  /* Shift the lookahead token.  */
-
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
-
-  /* Discard the token being shifted unless it is eof.  */
-  if (yychar != YYEOF)
-    yychar = YYEMPTY;
-
-  *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
-  *++yylsp = yylloc;
-#endif
-
-  /* count tokens shifted since error; after three, turn off error status.  */
-  if (yyerrstatus) yyerrstatus--;
-
-  yystate = yyn;
-  goto yynewstate;
-
-/* Do the default action for the current state.  */
-yydefault:
-
-  yyn = yydefact[yystate];
-  if (yyn == 0)
-    goto yyerrlab;
-
-/* Do a reduction.  yyn is the number of a rule to reduce with.  */
-yyreduce:
-  yylen = yyr2[yyn];
-  yyval = yyvsp[1-yylen]; /* implement default value of the action */
-
-#if YYDEBUG != 0
-  if (yydebug)
-    {
-      int i;
-
-      fprintf (stderr, "Reducing via rule %d (line %d), ",
-	       yyn, yyrline[yyn]);
-
-      /* Print the symbols being reduced, and their result.  */
-      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
-	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
-      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
-    }
-#endif
-
-
-  switch (yyn) {
-
-case 1:
-#line 12 "syntax.y"
-{
-		root = mktypdef(yyvsp[-4], yyvsp[-2]);
-	;
-    break;}
-case 2:
-#line 18 "syntax.y"
-{
-		yyval = yyvsp[0];
-	;
-    break;}
-case 3:
-#line 22 "syntax.y"
-{
-		yyval = (long) mkdeflist(yyvsp[-1], yyvsp[0]);
-	;
-    break;}
-case 4:
-#line 28 "syntax.y"
-{
-		yyval = (long) mkdef(yyvsp[-5], yyvsp[-2]);
-	;
-    break;}
-case 5:
-#line 32 "syntax.y"
-{
-		yyval = (long) mkdef(yyvsp[-4], mkemitemlist());
-	;
-    break;}
-case 6:
-#line 38 "syntax.y"
-{
-		yyval = yyvsp[0];
-	;
-    break;}
-case 7:
-#line 42 "syntax.y"
-{
-		yyval = (long) mkitemlist(yyvsp[-1], yyvsp[0]);
-	;
-    break;}
-case 8:
-#line 48 "syntax.y"
-{
-		yyval = (long) mkitem(yyvsp[-3], yyvsp[-1]);
-	;
-    break;}
-}
-   /* the action file gets copied in in place of this dollarsign */
-#line 457 "/usr/local/gnu/lib/bison.simple"
-
-  yyvsp -= yylen;
-  yyssp -= yylen;
-#ifdef YYLSP_NEEDED
-  yylsp -= yylen;
-#endif
-
-#if YYDEBUG != 0
-  if (yydebug)
-    {
-      short *ssp1 = yyss - 1;
-      fprintf (stderr, "state stack now");
-      while (ssp1 != yyssp)
-	fprintf (stderr, " %d", *++ssp1);
-      fprintf (stderr, "\n");
-    }
-#endif
-
-  *++yyvsp = yyval;
-
-#ifdef YYLSP_NEEDED
-  yylsp++;
-  if (yylen == 0)
-    {
-      yylsp->first_line = yylloc.first_line;
-      yylsp->first_column = yylloc.first_column;
-      yylsp->last_line = (yylsp-1)->last_line;
-      yylsp->last_column = (yylsp-1)->last_column;
-      yylsp->text = 0;
-    }
-  else
-    {
-      yylsp->last_line = (yylsp+yylen-1)->last_line;
-      yylsp->last_column = (yylsp+yylen-1)->last_column;
-    }
-#endif
-
-  /* Now "shift" the result of the reduction.
-     Determine what state that goes to,
-     based on the state we popped back to
-     and the rule number reduced by.  */
-
-  yyn = yyr1[yyn];
-
-  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
-  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
-    yystate = yytable[yystate];
-  else
-    yystate = yydefgoto[yyn - YYNTBASE];
-
-  goto yynewstate;
-
-yyerrlab:   /* here on detecting error */
-
-  if (! yyerrstatus)
-    /* If not already recovering from an error, report this error.  */
-    {
-      ++yynerrs;
-
-#ifdef YYERROR_VERBOSE
-      yyn = yypact[yystate];
-
-      if (yyn > YYFLAG && yyn < YYLAST)
-	{
-	  int size = 0;
-	  char *msg;
-	  int x, count;
-
-	  count = 0;
-	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
-	  for (x = (yyn < 0 ? -yyn : 0);
-	       x < (sizeof(yytname) / sizeof(char *)); x++)
-	    if (yycheck[x + yyn] == x)
-	      size += strlen(yytname[x]) + 15, count++;
-	  msg = (char *) malloc(size + 15);
-	  if (msg != 0)
-	    {
-	      strcpy(msg, "parse error");
-
-	      if (count < 5)
-		{
-		  count = 0;
-		  for (x = (yyn < 0 ? -yyn : 0);
-		       x < (sizeof(yytname) / sizeof(char *)); x++)
-		    if (yycheck[x + yyn] == x)
-		      {
-			strcat(msg, count == 0 ? ", expecting `" : " or `");
-			strcat(msg, yytname[x]);
-			strcat(msg, "'");
-			count++;
-		      }
-		}
-	      yyerror(msg);
-	      free(msg);
-	    }
-	  else
-	    yyerror ("parse error; also virtual memory exceeded");
-	}
-      else
-#endif /* YYERROR_VERBOSE */
-	yyerror("parse error");
-    }
-
-  goto yyerrlab1;
-yyerrlab1:   /* here on error raised explicitly by an action */
-
-  if (yyerrstatus == 3)
-    {
-      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
-
-      /* return failure if at end of input */
-      if (yychar == YYEOF)
-	YYABORT;
-
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
-
-      yychar = YYEMPTY;
-    }
-
-  /* Else will try to reuse lookahead token
-     after shifting the error token.  */
-
-  yyerrstatus = 3;		/* Each real token shifted decrements this */
-
-  goto yyerrhandle;
-
-yyerrdefault:  /* current state does not do anything special for the error token. */
-
-#if 0
-  /* This is wrong; only states that explicitly want error tokens
-     should shift them.  */
-  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
-  if (yyn) goto yydefault;
-#endif
-
-yyerrpop:   /* pop the current state because it cannot handle the error token */
-
-  if (yyssp == yyss) YYABORT;
-  yyvsp--;
-  yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
-  yylsp--;
-#endif
-
-#if YYDEBUG != 0
-  if (yydebug)
-    {
-      short *ssp1 = yyss - 1;
-      fprintf (stderr, "Error: state stack now");
-      while (ssp1 != yyssp)
-	fprintf (stderr, " %d", *++ssp1);
-      fprintf (stderr, "\n");
-    }
-#endif
-
-yyerrhandle:
-
-  yyn = yypact[yystate];
-  if (yyn == YYFLAG)
-    goto yyerrdefault;
-
-  yyn += YYTERROR;
-  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
-    goto yyerrdefault;
-
-  yyn = yytable[yyn];
-  if (yyn < 0)
-    {
-      if (yyn == YYFLAG)
-	goto yyerrpop;
-      yyn = -yyn;
-      goto yyreduce;
-    }
-  else if (yyn == 0)
-    goto yyerrpop;
-
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Shifting error token, ");
-#endif
-
-  *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
-  *++yylsp = yylloc;
-#endif
-
-  yystate = yyn;
-  goto yynewstate;
-}
-#line 51 "syntax.y"
diff --git a/ghc/utils/ugen/syntax.tab.h b/ghc/utils/ugen/syntax.tab.h
deleted file mode 100644
index f7ab22163c6fd1bcbc1248612db9480e8a0951a1..0000000000000000000000000000000000000000
--- a/ghc/utils/ugen/syntax.tab.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef YYSTYPE
-#define YYSTYPE int
-#endif
-#define	ID	258
-#define	TYPE	259
-#define	SEMICOL	260
-#define	COLON	261
-#define	END	262
-#define	STDEF	263
-#define	ENDDEF	264
-
-
-extern YYSTYPE yylval;
diff --git a/ghc/utils/ugen/syntax.y b/ghc/utils/ugen/syntax.y
index 2b1482376469754df8efff0a66b38b2def8ea891..25f3081de68219ba12f6058f47672df97c0fe95b 100644
--- a/ghc/utils/ugen/syntax.y
+++ b/ghc/utils/ugen/syntax.y
@@ -10,7 +10,7 @@ extern tree root;
 typdef	: 
 	TYPE ID SEMICOL deflist END SEMICOL =
 	{
-		root = mktypdef($2, $4);
+		root = mktypdef((id)$2,(tree)$4);
 	};
 
 deflist	:
@@ -20,17 +20,17 @@ deflist	:
 	} |
 	deflist def =
 	{
-		$$ = (long) mkdeflist($1, $2);
+		$$ = (long)mkdeflist((tree)$1,(tree)$2);
 	};
 
 def	:
 	ID COLON STDEF itemlist ENDDEF SEMICOL =
 	{
-		$$ = (long) mkdef($1, $4);
+		$$ = (long)mkdef((id)$1,(tree)$4);
 	} |
 	ID COLON STDEF ENDDEF SEMICOL =
 	{
-		$$ = (long) mkdef($1, mkemitemlist());
+		$$ = (long)mkdef((id)$1,mkemitemlist());
 	};
 
 itemlist:
@@ -40,11 +40,11 @@ itemlist:
 	} |
 	itemlist item =
 	{
-		$$ = (long) mkitemlist($1, $2);
+		$$ = (long)mkitemlist((tree)$1,(tree)$2);
 	};
 
 item	:
 	ID COLON ID SEMICOL =
 	{
-		$$ = (long) mkitem($1, $3);
+		$$ = (long)mkitem((id)$1,(id)$3);
 	};
diff --git a/ghc/utils/ugen/tree.c b/ghc/utils/ugen/tree.c
index 38e34206029279f409ea3e1e22f67954f282049c..093e18d112ba0920c47ed358c5cecf0d0bfea61d 100644
--- a/ghc/utils/ugen/tree.c
+++ b/ghc/utils/ugen/tree.c
@@ -1,8 +1,8 @@
-
-
 #include "id.h"
 #include "tree.h"
 
+extern char *malloc ();
+
 Ttree ttree(t)
  tree t;
 {
diff --git a/ghc/utils/ugen/tree.ugn b/ghc/utils/ugen/tree.ugn
index c27ca65997a49f9dd321c568e5370e2f045136cc..d76e137365a826a5ccd9e55b5d78c4679e6073c6 100644
--- a/ghc/utils/ugen/tree.ugn
+++ b/ghc/utils/ugen/tree.ugn
@@ -1,4 +1,5 @@
 %{
+extern char *malloc ();
 #include "id.h"
 %}
 type tree;
diff --git a/ghc/utils/ugen/yyerror.c b/ghc/utils/ugen/yyerror.c
index 4b9a0380d11932956fb0bf0e4c85288f3c96f8f8..c7314f59ea843e45a8ddf58923168f53edfabc6b 100644
--- a/ghc/utils/ugen/yyerror.c
+++ b/ghc/utils/ugen/yyerror.c
@@ -1,24 +1,12 @@
 #include <stdio.h>
-extern int yylineno;
+extern int lineno;
+extern char *yytext;
 
-void
-yyerror(s)
-    char *s;
+void yyerror(s)
+     char *s;
 {
-	extern int yychar;
-	extern char yytext[1];
-
-	fprintf(stderr, "\n%s", s);
-	if(yylineno)
-		fprintf(stderr, ", line %d, ", yylineno);
-	fprintf(stderr, "on input: ");
-	if( yychar >= 0400 )
-		fprintf(stderr, "%s\n", &yytext[0]);
-	else
-		switch(yychar) {
-		  case '\t' : fprintf(stderr, "\\t\n"); break;
-		  case '\n' : fprintf(stderr, "\\n\n"); break;
-		  case '\0' : fprintf(stderr, "$end\n"); break;
-		  default   : fprintf(stderr, "%c\n", yychar); break;
-		}
+  fprintf(stderr, "\n%s", s);
+  if (lineno) fprintf(stderr, ", line %d, ", lineno);
+  fprintf(stderr, "on input: ");
+  fprintf(stderr, "%s\n", yytext);
 }
diff --git a/ghc/utils/unlit/Jmakefile b/ghc/utils/unlit/Jmakefile
deleted file mode 100644
index 83502b5247778c632c2134c521c5e9f07abbbf73..0000000000000000000000000000000000000000
--- a/ghc/utils/unlit/Jmakefile
+++ /dev/null
@@ -1,10 +0,0 @@
-SuffixRule_c_o()
-
-BuildPgmFromOneCFile(unlit)
-
-#if DoInstallGHCSystem == YES
-MakeDirectories(install, $(INSTLIBDIR_GHC))
-InstallBinaryTarget(unlit, $(INSTLIBDIR_GHC))
-#endif /* DoInstall... */
-
-CDependTarget( $(SRCS_C) )
diff --git a/ghc/utils/unlit/Makefile b/ghc/utils/unlit/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..7a7b3c2533162a638906285220b26005945c09a2
--- /dev/null
+++ b/ghc/utils/unlit/Makefile
@@ -0,0 +1,8 @@
+TOP=../../..
+include $(TOP)/ghc/mk/ghc.mk
+
+SRCS=unlit.c
+PROG=unlit
+DESTDIR=$(INSTLIBDIR_GHC)
+
+include $(TOP)/mk/Cprog.mk
diff --git a/glafp-utils/Jmakefile b/glafp-utils/Jmakefile
deleted file mode 100644
index 964c80f11c861f5b5a555905c8b0f45930a2e82d..0000000000000000000000000000000000000000
--- a/glafp-utils/Jmakefile
+++ /dev/null
@@ -1,4 +0,0 @@
-#define IHaveSubdirs
-
-SUBDIRS = scripts \
-	  msub
diff --git a/glafp-utils/Makefile b/glafp-utils/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..24f2b6bed845e1ec00cd61a9fc9eabb547152251
--- /dev/null
+++ b/glafp-utils/Makefile
@@ -0,0 +1,15 @@
+TOP=..
+include $(TOP)/mk/gen.mk
+
+# We need to boot msub and mkdependC (in that order), to be sure that
+# make depend will succeed in all the other directories.
+
+SUBDIRS = msub mkdependC fastmake lndir ltx mkdirhier runstdtest
+
+boot ::
+	$(MAKE) -C msub all
+	$(MAKE) -C mkdependC all
+	$(MAKE) depend
+	$(MAKE) all
+
+include $(TOP)/mk/subdir.mk
diff --git a/glafp-utils/Makefile.BOOT b/glafp-utils/Makefile.BOOT
deleted file mode 100644
index 7ba6e1662cefabae846ca59bb88ad5e48e036a45..0000000000000000000000000000000000000000
--- a/glafp-utils/Makefile.BOOT
+++ /dev/null
@@ -1,58 +0,0 @@
-# hand-hacked Makefile to boot the "make world" process
-#---------------------------------------------------------------------
-
-# Platform-specific configuration stuff was read from: sun.cf
-
-SHELL = /bin/sh
-PATHSEP = /
-
-TOP = ..
-CURRENT_DIR = ./glafp-utils
-
-RM=rm -f
-MV=mv -f
-BOOTSTRAPCFLAGS =
-
-# Project identification -- name, version, and stuff
-
-PROJECTNAME      = Booting the Make World System
-PROJECTVERSION   = none
-PROJECTLABEL     = none
-SETUPLABEL       = std
-
-PROJECTCONFIGDIR =
-
-###########################################################################
-# Configuration stuff (jmake, its friends and templates)
-
-JMKMF         = jmkmf_used_only_with_installed_utils
-JRESTOREDEPS  = $(JMAKESRC)/jrestoredeps
-JMAKE         = $(JMAKESRC)/jmake
-JMAKE_DEFINES =
-
-JMAKESRC = $(TOP)/mkworld
-
-JMAKE_CMD = $(NEWTOP)$(JMAKE) -I$(NEWTOP)$(JMAKESRC) $(BOOTSTRAPCFLAGS) -DTopDir=$(TOP) -DCurDir=$(CURRENT_DIR) $(BOOT_DEFINES)
-
-###########################################################################
-
-Makefile:: $(JMAKE)
-
-$(JMAKE):
-	@(cd $(JMAKESRC) && if [ -f Makefile ]; then \
-	echo "checking $@ in $(JMAKESRC) first..."; $(MAKE) all; else \
-	echo "bootstrapping $@ from Makefile.BOOT in $(JMAKESRC) first..."; \
-	$(MAKE) -f Makefile.BOOT BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \
-	echo "okay, continuing in $(CURRENT_DIR)")
-
-Makefile::
-	-@if [ -f Makefile ]; then \
-	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
-	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
-	else exit 0; fi
-	$(JMAKE_CMD)
-	$(JRESTOREDEPS)
-	@if cmp -s Makefile Makefile.bak; then $(RM) Makefile.bak ; else exit 0 ; fi
-	@chmod 444 Makefile
-	@echo ==== The new Makefile is for\: ====
-	@$(MAKE) whoami
diff --git a/glafp-utils/fastmake/Makefile b/glafp-utils/fastmake/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..902012ade01783c8658397958951bd64d0406331
--- /dev/null
+++ b/glafp-utils/fastmake/Makefile
@@ -0,0 +1,9 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+PROG=fastmake
+SRC=fastmake.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTSCRIPTDIR)
+
+include $(TOP)/mk/script.mk
diff --git a/glafp-utils/scripts/fastmake.prl b/glafp-utils/fastmake/fastmake.prl
similarity index 100%
rename from glafp-utils/scripts/fastmake.prl
rename to glafp-utils/fastmake/fastmake.prl
diff --git a/glafp-utils/lndir/Makefile b/glafp-utils/lndir/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3e3117195309f624a309a33552d7cd0058aad35f
--- /dev/null
+++ b/glafp-utils/lndir/Makefile
@@ -0,0 +1,8 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+SRCS=lndir.c
+PROG=lndir
+DESTDIR=$(INSTBINDIR)
+
+include $(TOP)/mk/Cprog.mk
diff --git a/glafp-utils/scripts/lndir-Xos.h b/glafp-utils/lndir/lndir-Xos.h
similarity index 100%
rename from glafp-utils/scripts/lndir-Xos.h
rename to glafp-utils/lndir/lndir-Xos.h
diff --git a/glafp-utils/scripts/lndir-Xosdefs.h b/glafp-utils/lndir/lndir-Xosdefs.h
similarity index 100%
rename from glafp-utils/scripts/lndir-Xosdefs.h
rename to glafp-utils/lndir/lndir-Xosdefs.h
diff --git a/glafp-utils/scripts/lndir.c b/glafp-utils/lndir/lndir.c
similarity index 100%
rename from glafp-utils/scripts/lndir.c
rename to glafp-utils/lndir/lndir.c
diff --git a/glafp-utils/ltx/Makefile b/glafp-utils/ltx/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..08fb2509bb3a0092548fc8377380178d974ef3c0
--- /dev/null
+++ b/glafp-utils/ltx/Makefile
@@ -0,0 +1,9 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+PROG=ltx
+SRC=ltx.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTBINDIR)
+
+include $(TOP)/mk/script.mk
diff --git a/glafp-utils/scripts/ltx.prl b/glafp-utils/ltx/ltx.prl
similarity index 100%
rename from glafp-utils/scripts/ltx.prl
rename to glafp-utils/ltx/ltx.prl
diff --git a/glafp-utils/mkdependC/Makefile b/glafp-utils/mkdependC/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..f711d77d36273556ab785c0ce50c3ad2ec32365b
--- /dev/null
+++ b/glafp-utils/mkdependC/Makefile
@@ -0,0 +1,9 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+PROG=mkdependC
+SRC=mkdependC.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTBINDIR)
+
+include $(TOP)/mk/script.mk
diff --git a/glafp-utils/scripts/mkdependC.prl b/glafp-utils/mkdependC/mkdependC.prl
similarity index 100%
rename from glafp-utils/scripts/mkdependC.prl
rename to glafp-utils/mkdependC/mkdependC.prl
diff --git a/glafp-utils/mkdirhier/Makefile b/glafp-utils/mkdirhier/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..92146a2ca0a3319c724aa214dea2f1d351891eab
--- /dev/null
+++ b/glafp-utils/mkdirhier/Makefile
@@ -0,0 +1,9 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+PROG=mkdirhier
+SRC=mkdirhier.sh
+INTERP=$(SHELL)
+DESTDIR=$(INSTSCRIPTDIR)
+
+include $(TOP)/mk/script.mk
diff --git a/glafp-utils/scripts/mkdirhier.sh b/glafp-utils/mkdirhier/mkdirhier.sh
similarity index 100%
rename from glafp-utils/scripts/mkdirhier.sh
rename to glafp-utils/mkdirhier/mkdirhier.sh
diff --git a/glafp-utils/msub/Jmakefile b/glafp-utils/msub/Jmakefile
deleted file mode 100644
index 52c3bb7b3e8f698cb461b1e00147b8ae40014d5d..0000000000000000000000000000000000000000
--- a/glafp-utils/msub/Jmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-BuildPgmFromOneCFile(msub)
-
-InstallBinaryTarget(msub,$(INSTBINDIR))
-
-CDependTarget( $(SRCS_C) )
-
-RunStdTest(msub001,msub,-o1 test.out -f test.makefile testfile)
diff --git a/glafp-utils/msub/Makefile b/glafp-utils/msub/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..0aeddfa28dd4b7131c6e95384cb09738d100b320
--- /dev/null
+++ b/glafp-utils/msub/Makefile
@@ -0,0 +1,12 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+SRCS=msub.c
+PROG=msub
+DESTDIR=$(INSTBINDIR)
+
+# No need for dependencies, which is just as well since
+# mkdependC can't be built until msub has been build!
+OmitCDepend = YES
+
+include $(TOP)/mk/Cprog.mk
diff --git a/glafp-utils/runstdtest/Makefile b/glafp-utils/runstdtest/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..aba1193d8e33b2363dfb8e368efd066667564b6c
--- /dev/null
+++ b/glafp-utils/runstdtest/Makefile
@@ -0,0 +1,9 @@
+TOP=../..
+include $(TOP)/mk/gen.mk
+
+PROG=runstdtest
+SRC=runstdtest.prl
+INTERP=$(PERL)
+DESTDIR=$(INSTBINDIR)
+
+include $(TOP)/mk/script.mk
diff --git a/glafp-utils/scripts/runstdtest.prl b/glafp-utils/runstdtest/runstdtest.prl
similarity index 100%
rename from glafp-utils/scripts/runstdtest.prl
rename to glafp-utils/runstdtest/runstdtest.prl
diff --git a/glafp-utils/scripts/Jmakefile b/glafp-utils/scripts/Jmakefile
deleted file mode 100644
index b3589a3fb07788aedd460d2599d5997d44afb111..0000000000000000000000000000000000000000
--- a/glafp-utils/scripts/Jmakefile
+++ /dev/null
@@ -1,50 +0,0 @@
-PROGRAMS = lndir \
-	   runstdtest \
-	   mkdependC \
-	   mkdirhier \
-	   fastmake \
-	   ltx
-
-all:: $(PROGRAMS)
-/* stuff to have before we get going */
-MsubNeededHere($(PROGRAMS))
-
-/* === BUILD STUFF (installation, etc., below) ========== */
-
-/* std X11 stuff: used in installing ghc/hslibs */
-MsubProgramScriptTarget(BourneShell,mkdirhier,mkdirhier.sh,,)
-
-BuildPgmFromOneCFile(lndir)
-
-MsubMakefileDependentProgramScriptTarget(PerlCmd,runstdtest,runstdtest.prl,,)
-MsubMakefileDependentProgramScriptTarget(PerlCmd,ltx,ltx.prl,,)
-MsubProgramScriptTarget(PerlCmd,fastmake,fastmake.prl,,)
-
-/*
-mkdependC has to go in "bin" directory, because there may be
-machine-dependent ideas of what CC to use, etc.
-
-ltx, runstdtest: ditto, but only because of TMPDIR
-*/
-MsubMakefileDependentProgramScriptTarget(PerlCmd,mkdependC,mkdependC.prl,/*noflags*/,/*Makefile*/)
-
-/* === INSTALLATION ======== */
-
-/* the rest of these vary from std/useful to hackish dans le extreme */
-
-MakeDirectories(install, $(INSTBINDIR) $(INSTSCRIPTDIR))
-InstallScriptTarget(fastmake,	  $(INSTSCRIPTDIR))
-InstallBinaryTarget(lndir,	  $(INSTBINDIR))
-InstallScriptTarget(ltx,	  $(INSTBINDIR))
-InstallScriptTarget(mkdependC,	  $(INSTBINDIR))
-InstallScriptTarget(runstdtest,  $(INSTBINDIR))
-
-InstallManPageTarget(lndir,$(INSTCOMMANDIR),$(COMMANSUFFIX))
-InstallManPageTarget(mkdirhier,$(INSTCOMMANDIR),$(COMMANSUFFIX))
-
-/* === OTHER STUFF ========= */
-
-ExtraStuffToClean($(PROGRAMS))
-
-ClearTagsFile()
-PerlTagsTarget( *.prl ) /* nothing for the Bourne shell scripts */
diff --git a/mk/Cprog.mk b/mk/Cprog.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2d6015603d723b0c4a2136ce16b5af9a92629157
--- /dev/null
+++ b/mk/Cprog.mk
@@ -0,0 +1,42 @@
+#-----------------------------------------------------------------------------
+# $Id: Cprog.mk,v 1.2 1996/11/21 16:50:26 simonm Exp $
+
+# Useful variables:
+
+#	PROG =			program name
+# 	SRCS =			list of sources (optional for one file)
+# 	LIBS =			libraries
+#	DEPLIBS =		more libraries (may depend on $(LIBS)
+#	DESTDIR =		where to install
+#	INSTALLED_NAME =	name to install as (default = $(PROG))
+
+#-----------------------------------------------------------------------------
+
+ifndef INSTALLED_NAME
+INSTALLED_NAME	= $(PROG)
+endif
+
+ifndef SRCS
+SRCS = $(PROG).c
+endif
+
+OBJS = $(SRCS:.c=.o)
+
+all 	:: $(PROG)
+
+$(PROG) :: $(OBJS)
+	$(CC) -o $@ $(CFLAGS) $(LDOPTIONS) $(OBJS) $(DEPLIBS) $(LIBS)
+
+install	:: $(PROG)
+	$(INSTALL) $(INSTBINFLAGS) $(PROG) $(DESTDIR)/$(INSTALLED_NAME)
+
+clean 	:: 
+	$(RM) $(PROG)
+
+tags	::
+	$(CTAGS) -a $(CTAGSFLAGS) $(SRCS)
+
+ifndef OmitCDepend
+  C_DEP_SRCS = $(SRCS)
+  include $(TOP)/mk/cdepend.mk
+endif
diff --git a/mk/HSprog.mk b/mk/HSprog.mk
new file mode 100644
index 0000000000000000000000000000000000000000..27cb8d1f92a92e5b2cd6e0f1a6da26105df62603
--- /dev/null
+++ b/mk/HSprog.mk
@@ -0,0 +1,38 @@
+#-----------------------------------------------------------------------------
+# $Id: HSprog.mk,v 1.2 1996/11/21 16:50:28 simonm Exp $
+
+# Useful variables:
+
+#	PROG =			program name
+# 	SRCS =			list of source files
+# 	LIBS =			libraries
+#	DEPLIBS =		more libraries (may depend on $(LIBS)
+#	DESTDIR =		where to install
+#	INSTALLED_NAME =	name to install as (default = $(PROG))
+
+#-----------------------------------------------------------------------------
+
+ifndef INSTALLED_NAME
+INSTALLED_NAME = $(PROG)
+endif
+
+OBJS = $($(SRCS:.hs.o):.lhs.o)
+
+all 	:: $(PROG)
+
+$(PROG) :: $(OBJS)
+	$(HC) -o $@ $(HCFLAGS) $(LDOPTIONS) $(OBJS) $(DEPLIBS) $(LIBS)
+
+install :: $(PROG)
+	$(INSTALL) $(INSTBINFLAGS) $(PROG) $(DESTDIR)/$(INSTALLED_NAME)
+
+clean 	::
+	$(RM) $(PROG)
+
+tags 	:: $(SRCS)
+	$(HSTAGS) $(HSTAGSFLAGS) $(SRCS)
+
+ifndef OmitHSDepend
+  HS_DEP_SRCS = $(SRCS)
+  include $(TOP)/mk/hsdepend.mk
+endif
diff --git a/mk/cdepend.mk b/mk/cdepend.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9915f72b7e0e34ba47f28f6da0ab0b25cf957303
--- /dev/null
+++ b/mk/cdepend.mk
@@ -0,0 +1,14 @@
+#-----------------------------------------------------------------------------
+# $Id: cdepend.mk,v 1.2 1996/11/21 16:50:30 simonm Exp $
+
+# Useful variables:
+
+# 	C_DEP_SRCS = 	C sources for make depend
+
+#-----------------------------------------------------------------------------
+
+depend	:: $(C_DEP_SRCS)
+	@$(RM) .depend
+	@touch .depend
+	$(MKDEPENDC) $(MKDEPENDCFLAGS) -- $(CFLAGS) -- $(C_DEP_SRCS)
+
diff --git a/mk/clib.mk b/mk/clib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2f91da23780ca398c726155242e3c41c97281381
--- /dev/null
+++ b/mk/clib.mk
@@ -0,0 +1,34 @@
+#-----------------------------------------------------------------------------
+# $Id: clib.mk,v 1.2 1996/11/21 16:50:31 simonm Exp $
+
+# Useful variables:
+
+#	ARCHIVE =		archive name
+# 	LIBOBJS = 		list of object files
+#	DESTDIR =		where to install
+#	INSTALLED_NAME =	name to install as (default = $(ARCHIVE))
+#	DEP_SRCS =		sources for make depend (optional)
+
+#-----------------------------------------------------------------------------
+
+ifndef INSTALLED_NAME
+INSTALLED_NAME	= $(ARCHIVE)
+endif
+
+all :: $(ARCHIVE)
+
+$(ARCHIVE) :: $(LIBOBJS)
+	@$(RM) $@
+	$(AR) $@ $(LIBOBJS)
+	$(RANLIB) $@
+
+install	:: $(ARCHIVE)
+	$(INSTALL) $(INSTDATAFLAGS) $(ARCHIVE) $(DESTDIR)/$(INSTALLED_NAME)
+	cd $(DESTDIR)/$(INSTALLED_NAME); $(RANLIB) $(INSTALLED_NAME)
+
+clean 	:: 
+	$(RM) $(ARCHIVE)
+
+ifdef DEP_SRCS
+include $(TOP)/mk/cdepend.mk
+endif
diff --git a/mk/gen.mk b/mk/gen.mk
new file mode 100644
index 0000000000000000000000000000000000000000..95ba44dbbaa016a180ff86b8b9ef36a92c74f576
--- /dev/null
+++ b/mk/gen.mk
@@ -0,0 +1,37 @@
+#-----------------------------------------------------------------------------
+# $Id: gen.mk,v 1.2 1996/11/21 16:50:32 simonm Exp $
+
+# General include file for the top of a Makefile.
+
+# So `all' is the default target...
+
+all ::
+	@:
+
+include $(TOP)/mk/platform.mk
+include $(TOP)/mk/utils.mk
+include $(TOP)/mk/rules.mk
+include $(TOP)/mk/install.mk
+
+# fastmake omits the dependencies
+
+ifndef FAST
+-include .depend
+endif
+
+whoami::
+	@echo $(PROJECTNAME), version $(PROJECTVERSION) $(PROJECTPATCHLEVEL)
+	@echo project\: $(PROJECTLABEL)\; setup\: $(SETUPLABEL)
+	@echo now building on a \`$(BUILDPLATFORM)\' host
+	@echo hoping to run on a \`$(HOSTPLATFORM)\' host
+
+clean::
+	$(RM) $(FilesToClean) \#*
+
+veryclean::
+	$(RM) $(FilesToClean) $(ExtraFilesToBeVeryClean) \#*
+
+tags::
+	$(RM) TAGS; touch TAGS
+
+depend::
diff --git a/mk/hsdepend.mk b/mk/hsdepend.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0e5d388ebfd36f774a4e6f8ad63a8ceb2697f7ac
--- /dev/null
+++ b/mk/hsdepend.mk
@@ -0,0 +1,14 @@
+#-----------------------------------------------------------------------------
+# $Id: hsdepend.mk,v 1.2 1996/11/21 16:50:33 simonm Exp $
+
+# Useful variables:
+
+# 	HS_DEP_SRCS = 	C sources for make depend
+
+#-----------------------------------------------------------------------------
+
+depend	:: $(HS_DEP_SRCS)
+	@$(RM) .depend
+	@touch .depend
+	$(MKDEPENDHS) $(MKDEPENDHSFLAGS) -- $(HCFLAGS) -- $(HS_DEP_SRCS)
+
diff --git a/mk/install.mk.in b/mk/install.mk.in
new file mode 100644
index 0000000000000000000000000000000000000000..2d4580764883f091b18aae7dad4ae4cb05ae139c
--- /dev/null
+++ b/mk/install.mk.in
@@ -0,0 +1,83 @@
+#-----------------------------------------------------------------------------
+# $Id: install.mk.in,v 1.2 1996/11/21 16:50:34 simonm Exp $
+
+AT_GLASGOW 	= @AT_GLASGOW@
+prefix	 	= @prefix@
+exec_prefix	= @exec_prefix@
+
+ifeq ($(AT_GLASGOW), 1)
+INSTBINDIR 	= $(exec_prefix)/bin/`/usr/local/gnu/bin/hw_os`
+else
+INSTBINDIR 	= $(exec_prefix)/bin
+endif
+
+INSTSCRIPTDIR 	= $(exec_prefix)/bin
+INSTLIBDIR 	= $(prefix)/lib/$(HOSTPLATFORM)
+INSTDATADIR 	= $(prefix)/lib
+
+#-----------------------------------------------------------------------------
+# Man pages & Documentation
+
+# top of manual page tree to install in
+# NB: not necessarily the same place as to look for man pages (?)
+INSTMANROOT	= $(prefix)
+
+# prefix for man page _sources_ (vs .../cat)
+INSTMANSRCROOT 	= $(INSTMANROOT)/man
+
+# man pages for commands
+INSTCOMMANDIR 	= $(INSTMANSRCROOT)$(COMMANSUFFIX)
+
+# man pages for library routines
+INSTLIBMANDIR 	= $(INSTMANSRCROOT)$(LIBMANSUFFIX)
+
+# man pages for system commands
+INSTSYSMANDIR 	= $(INSTMANSRCROOT)$(SYSMANSUFFIX)
+
+# suffix for installing commands'/etcs' man pages
+COMMANSUFFIX 	= 1
+LIBMANSUFFIX 	= 3
+SYSMANSUFFIX 	= 8
+
+ifeq ($(AT_GLASGOW), 1)
+INSTINFODIR 	= /local/doc/info
+else
+INSTINFODIR 	= $(prefix)/info
+endif
+
+#-----------------------------------------------------------------------------
+# How to install things
+
+# this stuff about "who" does the installing doesn't have make vars
+# as it is not intended to be runtime-changeable.
+#
+ifdef OWNER
+INSTOWNER 	= -o $(OWNER)
+else
+INSTOWNER	=
+endif
+
+ifdef GROUP
+INSTGROUP	= -g $(GROUP)
+else
+INSTGROUP	=
+endif
+
+INSTFILEFLAGS	=
+INSTSTRIP	=
+INSTBINFLAGS	= \
+	-m 0755 $(INSTOWNER) $(INSTGROUP) $(INSTFILEFLAGS) $(INSTSTRIP)
+
+
+#	No strip flags on rest of these -- avoids message from install
+#	about stripping non-binaries.
+
+GENINSTALLFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTFILEFLAGS)
+
+INSTSCRIPTFLAGS 	= -m 0755 $(GENINSTALLFLAGS)
+INSTLIBFLAGS 		= -m 0644 $(GENINSTALLFLAGS)
+INSTDATALIBFLAGS 	= -m 0644 $(GENINSTALLFLAGS)
+INSTINCFLAGS 		= -m 0644 $(GENINSTALLFLAGS)
+INSTDATAFLAGS 		= -m 0644 $(GENINSTALLFLAGS)
+INSTMANFLAGS 		= -m 0644 $(GENINSTALLFLAGS)
+INSTRANLIBFLAGS 	=
diff --git a/mk/lib.mk b/mk/lib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3c8270e30e1c9557cce99553e4193fdd29f51eec
--- /dev/null
+++ b/mk/lib.mk
@@ -0,0 +1,39 @@
+#-----------------------------------------------------------------------------
+# $Id: lib.mk,v 1.2 1996/11/21 16:50:35 simonm Exp $
+
+# Useful variables:
+
+#	ARCHIVE =		archive name
+# 	LIBOBJS = 		list of object files
+#	DESTDIR =		where to install
+#	INSTALLED_NAME =	name to install as (default = $(ARCHIVE))
+#	C_DEP_SRCS =		sources for C make depend (optional)
+#	HS_DEP_SRCS =		sources for Haskell make depend (optional)
+
+#-----------------------------------------------------------------------------
+
+ifndef INSTALLED_NAME
+INSTALLED_NAME	= $(ARCHIVE)
+endif
+
+all :: $(ARCHIVE)
+
+$(ARCHIVE) :: $(LIBOBJS)
+	@$(RM) $@
+	$(AR) $@ $(LIBOBJS)
+	$(RANLIB) $@
+
+install	:: $(ARCHIVE)
+	$(INSTALL) $(INSTLIBFLAGS) $(ARCHIVE) $(DESTDIR)/$(INSTALLED_NAME)
+	cd $(DESTDIR); $(RANLIB) $(INSTALLED_NAME)
+
+clean 	:: 
+	$(RM) $(ARCHIVE)
+
+ifdef C_DEP_SRCS
+include $(TOP)/mk/cdepend.mk
+endif
+
+ifdef HS_DEP_SRCS
+include $(TOP)/mk/hsdepend.mk
+endif
diff --git a/mk/platform.mk.in b/mk/platform.mk.in
new file mode 100644
index 0000000000000000000000000000000000000000..bf320426241a6170c39928fe809d66f829d7daf4
--- /dev/null
+++ b/mk/platform.mk.in
@@ -0,0 +1,22 @@
+#-----------------------------------------------------------------------------
+# $Id: platform.mk.in,v 1.2 1996/11/21 16:50:36 simonm Exp $
+
+HOSTPLATFORM			= @HostPlatform@
+TARGETPLATFORM			= @HostPlatform@
+BUILDPLATFORM			= @HostPlatform@
+
+@HostPlatform_CPP@_HOST	        = 1
+@HostPlatform_CPP@_TARGET       = 1
+@HostPlatform_CPP@_BUILD        = 1
+
+@HostArch_CPP@_HOST_ARCH        = 1
+@HostArch_CPP@_TARGET_ARCH	= 1
+@HostArch_CPP@_BUILD_ARCH       = 1
+
+@HostOS_CPP@_HOST_OS            = 1
+@HostOS_CPP@_TARGET_OS          = 1
+@HostOS_CPP@_BUILD_OS           = 1
+
+@HostVendor_CPP@_HOST_VENDOR    = 1
+@HostVendor_CPP@_TARGET_VENDOR  = 1
+@HostVendor_CPP@_BUILD_VENDOR   = 1
diff --git a/mk/rules.mk b/mk/rules.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3026bdb4fae395792cd6f840ec26fb3d3091a057
--- /dev/null
+++ b/mk/rules.mk
@@ -0,0 +1,313 @@
+#-----------------------------------------------------------------------------
+# $Id: rules.mk,v 1.2 1996/11/21 16:50:38 simonm Exp $
+
+# This file defines the default suffix rules.  It replaces suffixes.jm in the
+# jmake system.
+
+.SUFFIXES: .xdvi .ps .dvi .tex .fig .tib .verb .itex .itxi .ihtml .lit \
+	.p_o .o .s .hi .hc .lhc .lhs .hs .prl .lprl .sh .lsh \
+	.c .lc .h .lh .flex .lflex .y
+
+ifndef SuffixRules_WantStdOnes
+SuffixRules_WantStdOnes = YES /* but you can turn it off */
+endif
+
+#-----------------------------------------------------------------------------
+# Doc processing suffix rules
+
+ifdef DocProcessingSuffixRules
+
+.tex.dvi:
+	@$(RM) $@
+	$(LTX) $<
+
+.verb.tex:
+	@$(RM) $*.tex
+	expand $*.verb | $(VERBATIM) > $*.tex
+
+.tib.tex:
+	@$(RM) $*.tex $*.verb-t.tex
+	$(TIB) $*.tib
+	expand $*.tib-t.tex | $(VERBATIM) > $*.tex
+	@$(RM) $*.tib-t.tex
+
+.fig.ps:
+	@$(RM) $@
+	fig2dev -L ps $< $@
+
+.fig.tex:
+	@$(RM) $@
+	fig2dev -L latex $< $@
+
+endif
+
+#-----------------------------------------------------------------------------
+# Literate suffix rules
+
+# ToDo: somehow macroize this lot.
+
+ifdef LiterateSuffixRules
+
+.lit:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lit.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lit.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lit.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhs.hs:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhs.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhs.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhs.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhc.hc:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhc.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhc.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lhc.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lprl.prl:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lprl.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lprl.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lprl.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lsh.sh:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lsh.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lsh.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lsh.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lc.c:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lc.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lc.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lc.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lh.h:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lh.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lh.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lh.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lflex.flex:
+	@$(RM) $@
+	$(LIT2PGM) $(LIT2PGMFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lflex.itxi:
+	@$(RM) $@
+	$(LIT2TEXI) -c $(LIT2TEXIFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lflex.ihtml:
+	@$(RM) $@
+	$(LIT2HTML) -c $(LIT2HTMLFLAGS) -o $@ $<
+	@chmod 444 $@
+
+.lflex.itex:
+	@$(RM) $@
+	$(LIT2LATEX) -c $(LIT2LATEXFLAGS) -o $@ $<
+	@chmod 444 $@
+
+endif
+
+#-----------------------------------------------------------------------------
+# C-related suffix rules
+
+ifdef CSuffixRules
+
+.s.o:
+	@$(RM) $@
+	$(AS) $(ASFLAGS) -o $@ $< || ( $(RM) $@ && exit 1 )
+
+.c.o:
+	@$(RM) $@
+	$(CC) $(CFLAGS) -c $< -o $@
+
+.c.s:
+	@$(RM) $@
+	$(CC) $(CFLAGS) -S $< -o $@
+
+endif
+
+ifdef FlexSuffixRules
+
+.flex.c:
+	@$(RM) $@
+	$(FLEX) -t $(LFLAGS) $< > $@ || ( $(RM) $@ && exit 1 )
+
+endif
+
+#-----------------------------------------------------------------------------
+# Yacc stuff
+
+ifdef YaccSuffixRules
+
+%.tab.c %.tab.h : %.y
+	@$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
+	$(YACC) $(YFLAGS) $<
+	$(MV) y.tab.c $*.tab.c
+	@chmod 444 $*.tab.c
+	$(MV) y.tab.h $*.tab.h
+	@chmod 444 $*.tab.h
+
+endif
+
+#-----------------------------------------------------------------------------
+# Haskell Suffix Rules
+
+# ToDo: these don't do the .hi-file games for hbc etc.
+
+ifdef HaskellSuffixRules 
+SuffixRule_o_hi		= YES
+SuffixRule_lhs_o	= YES
+SuffixRule_hs_o		= YES
+endif
+
+ifdef SuffixRule_lhs_o
+%.o : %.hs
+	$(HC) $(HCFLAGS) $($*_flags) -c $< -o $@
+endif
+
+ifdef SuffixRule_hs_o
+%.o : %.lhs
+	$(HC) $(HCFLAGS) $($*_flags) -c $< -o $@
+endif
+
+ifdef SuffixRule_lhs_hc
+%.hc : %.lhs
+	$(HC) $(HCFLAGS) $($*_flags) -C $< -o $@
+endif
+
+ifdef SuffixRule_hc_o
+%.o : %.hc
+	$(HC) $(HCFLAGS) $($*_flags) -c $< -o $@
+endif
+
+ifdef SuffixRule_o_hi
+%.hi : %.o
+	@if [ ! -f $@ ] ; then \
+	    echo You need to create an initial $@ by hand ; \
+	    exit 1; \
+	else exit 0 ; \
+	fi							
+endif
+
+ifdef SuffixRule_hc_hi
+%.hi : %.hc
+	@if [ ! -f $@ ] ; then \
+	    echo You need to create an initial $@ by hand ; \
+	    exit 1; \
+	else exit 0 ; \
+	fi
+endif
+
+#-----------------------------------------------------------------------------
+# Runtest rules for calling $(GHC) on a single-file Haskell program
+
+ifdef GhcRunTestRules
+
+%.runtest : %.hs
+	$(TIME) $(RUNSTDTEST) $(GHC) $(RUNSTDTEST_FLAGS) \
+	  -o2 $*.stderr $($*_flags) $<
+
+endif
diff --git a/mk/script.mk b/mk/script.mk
new file mode 100644
index 0000000000000000000000000000000000000000..d06c422397e5fde69dd1cf8d03d341e7d711fba1
--- /dev/null
+++ b/mk/script.mk
@@ -0,0 +1,53 @@
+#-----------------------------------------------------------------------------
+# $Id: script.mk,v 1.2 1996/11/21 16:50:39 simonm Exp $
+
+# Useful variables:
+
+#	PROG =			program name
+#	DEPLIST =		(optional) dependencies
+# 	SRC =			source file
+#	INTERP = 		(optional) interpretter
+#	DESTDIR =		where to install
+#	INSTALLED_NAME =	(optional) name to install as
+
+#-----------------------------------------------------------------------------
+
+ifndef INSTALLED_NAME
+INSTALLED_NAME	= $(PROG)
+endif
+
+all 	:: $(PROG)
+
+# Hack alert!  Since the variables msub needs aren't in the immediate
+# Makefile, we must include the relevant files directly.
+
+MSUB_OPTS = -f Makefile -f $(TOP)/mk/platform.mk -f $(TOP)/mk/utils.mk
+
+$(PROG) ::  $(SRC) $(DEPLIST)
+	$(RM) $@
+ifdef INTERP
+	echo "#!"$(INTERP) > $@
+endif
+	$(MSUB) $(MSUBFLAGS) INSTALLING=0 $(SRC) >> $@ \
+		|| ( $(RM) $@ && exit 1 )
+	chmod a+x $@
+
+# aaargh: scripts sometimes do different things depending on whether they
+# are installed versions or not (eg. use installed programs rather than
+# those in the source tree) hence the following hack:
+
+install	:: $(PROG)_tmp
+	$(INSTALL) $(INSTSCRIPTFLAGS) $(PROG)_tmp $(DESTDIR)/$(INSTALLED_NAME)
+	$(RM) $(PROG)_tmp
+
+$(PROG)_tmp :  $(SRC)
+	$(RM) $@
+ifdef INTERP
+	echo "#!"$(INTERP) > $@
+endif
+	$(MSUB) $(MSUBFLAGS) INSTALLING=1 $(SRC) >> $@ \
+		|| ( $(RM) $@ && exit 1 )
+	chmod a+x $@
+
+clean 	:: 
+	$(RM) $(PROG) $(PROG)_tmp
diff --git a/mk/subdir.mk b/mk/subdir.mk
new file mode 100644
index 0000000000000000000000000000000000000000..63cde769d936664d2a74f94585fa9e83625dbbec
--- /dev/null
+++ b/mk/subdir.mk
@@ -0,0 +1,110 @@
+#-----------------------------------------------------------------------------
+# $Id: subdir.mk,v 1.2 1996/11/21 16:50:40 simonm Exp $
+
+# Rules for passing on make commands to sub-directories
+
+# Useful Variables to set
+
+# 	SUBDIRS = subdirectories to recurse into
+
+#	NoAllTargetForSubdirs			]
+#	NoDocsTargetForSubdirs			]
+#	NoInstallTargetForSubdirs		]
+#	NoInstallDocsTargetForSubdirs		] omit specified rules
+#	NoDependTargetForSubdirs		]
+#	NoCleanTargetForSubdirs			]
+#	NoVeryCleanTargetForSubdirs		]
+
+#	ProjectMakeVarsForAllInSubdirs		make variables to pass to
+#						Makefiles for the all target
+#						in the current project
+#	SetupMakeVarsForAllInSubdirs		same, but for the current
+#						setup
+
+#	ProjectMakeVarsForRunTestsInSubdirs	same, for project runtests
+#	SetupMakeVarsForRunTestsInSubdirs	same, for setup
+
+#-----------------------------------------------------------------------------
+# The rules...
+
+ifndef NoAllTargetForSubdirs
+all::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) all; \
+	done
+endif
+
+ifndef NoDocsTargetForSubdirs
+docs::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) docs; \
+	done
+else
+docs::
+endif
+
+ifndef NoRunTestsTargetForSubdirs
+runtests::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) runtests; \
+	done
+else
+runtests::
+endif
+
+ifndef NoInstallTargetForSubdirs
+install::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) prefix='$(prefix)' install; \
+	done
+else
+install::
+endif
+
+ifndef NoInstallDocsTargetForSubdirs
+install_docs::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) prefix='$(prefix)' install_docs; \
+	done
+else
+install_docs::
+endif
+
+ifndef NoDependTargetForSubdirs
+depend::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) depend; \
+	done
+else
+depend::
+endif
+
+ifndef NoTagTargetForSubdirs
+tags::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) tags; \
+	done
+endif
+
+ifndef NoCleanTargetForSubdirs
+clean::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) clean; \
+	done
+endif
+
+ifndef NoVeryCleanTargetForSubdirs
+veryclean::
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $(SUBDIRS) ; do \
+	  $(MAKE) -C $$i $(MFLAGS) veryclean; \
+	done
+endif
diff --git a/mk/utils.mk.in b/mk/utils.mk.in
new file mode 100644
index 0000000000000000000000000000000000000000..f0e27d501c26c12cfb5779c3f89285e47c73eac5
--- /dev/null
+++ b/mk/utils.mk.in
@@ -0,0 +1,402 @@
+#-----------------------------------------------------------------------------
+# $Id: utils.mk.in,v 1.2 1996/11/21 16:50:41 simonm Exp $
+
+# This file is automatically generated by configure, and should not be
+# changed.
+# 
+# Most of this stuff is designed to be overridable: just set the appropriate
+# variable in the Makefile after including ghc.mk.
+
+# This file replaces site.jm, site-DEF.jm, utils-GEN.jm in the jmake system.
+
+#-----------------------------------------------------------------------------
+# Random configuration stuff
+
+TOP_PWD			= @hardtop@
+TMPDIR			= @TmpDir@
+
+HcMaxHeapFlag		= @HcMaxHeapFlag@
+HcMaxStackFlag		= @HcMaxStackFlag@
+ALL_PROJECTS_HC_OPTS	+= $(HcMaxHeapFlag) $(HcMaxStackFlag)
+
+#-----------------------------------------------------------------------------
+# C compiler stuff
+
+HaveGcc			= @HaveGcc@
+UseGcc			= @HaveGcc@
+WhatGccIsCalled 	= @WhatGccIsCalled@
+CC			= cc
+ifeq ($(HaveGcc), YES)
+ifeq ($(UseGcc),  YES)
+CC 			= $(WhatGccIsCalled)
+endif
+endif
+
+LD			= ld
+LINT			= lint
+AS			= as
+STRIP 			= strip
+YACC			= @YaccCmd@
+
+CPP			= @RAWCPP@ $(GLUED_CPP_INCLUDES) $(GLUED_CPP_DEFINES)
+PREPROCESSCMD		= $(CC) -E $(GLUED_CPP_INCLUDES) $(GLUED_CPP_DEFINES)
+RAWCPP			= @RAWCPP@
+
+AR 			= @ArCmd@
+RANLIB			= @RANLIB@
+
+#-----------------------------------------------------------------------------
+# lex
+
+EightBitLexCmd		= @LEX@ -s -8
+FLEX    		= $(EightBitLexCmd) $(EXTRA_FLEX_OPTS)
+FLEX_LIB		= @LEXLIB@
+
+#-----------------------------------------------------------------------------
+# general utilities
+
+PERL 			= @PerlCmd@
+SHELL			= /bin/sh
+COMPRESS		= compress
+CONTEXT_DIFF		= @ContextDiffCmd@
+CP			= cp
+LN			= ln -s
+MV			= mv
+RM			= rm -f
+TIME			= time
+CTAGS 			= $(ETAGS)
+INSTALL			= @INSTALL@
+MAKE			= @MakeCmd@
+UNAME			= uname
+
+#-----------------------------------------------------------------------------
+# Haskell compiler
+
+HC			= @WithHc@
+HaskellCompilerType	= @WithHcType@
+
+#-----------------------------------------------------------------------------
+# Document preparation
+
+TROFF			= troff
+NROFF			= nroff
+MANMACROS		= -man
+MSMACROS 		= -ms
+PIC			= pic
+TBL 			= tbl
+TGRIND 			= tgrind
+TGRIND_HELPER 		= /usr/local/lib/tgrind/tfontedpr # XXX
+
+PRINTER			= lpr
+
+TEX			= tex
+LATEX			= latex
+
+TIB			= tib
+
+#-----------------------------------------------------------------------------
+# sources
+
+ifndef UseInstalledUtils
+UTILSRC   		= $(TOP)/glafp-utils
+SCRIPTSRC 		= $(UTILSRC)/scripts
+endif
+
+#-----------------------------------------------------------------------------
+# Cleaning things.
+
+FilesToClean = \
+	*.CKP *.ln *.BAK *.bak *.o core a.out errs ,* *.a .emacs_*	    \
+	tags TAGS *.ind *.ilg *.idx *.idx-prev *.aux *.aux-prev *.dvi *.log \
+	*.toc *.lot *.lof *.blg *.info *.itxi *.itex *.cb
+
+ExtraFilesToBeVeryClean = \
+	 .??*~ *~ *.orig *.rej .depend
+
+#-----------------------------------------------------------------------------
+# Info stuff
+
+ifdef UseInstalledUtils
+INFO         		= info
+MAKEINFO     		= makeinfo
+POSTMAKEINFO 		= postmakeinfo
+else
+INFOSRC      		= $(LITSRC)/info-utils
+INFO			= $(UTILSRC)/info
+MAKEINFO		= $(INFOSRC)/makeinfo
+POSTMAKEINFO		= $(INFOSRC)/postmakeinfo
+endif
+
+#-----------------------------------------------------------------------------
+# literate programming stuff
+
+LIT2PGM 		= lit2pgm
+LIT2TEXI      		= lit2texi
+LIT2HTML      		= lit2html
+LIT2LATEX     		= lit2latex
+MKDEPENDLIT   		= mkdependlit
+LIT2CHANGELOG 		= lit2changelog
+
+ifndef UseInstalledUtils
+LITSRC        		= $(TOP)/literate
+endif
+
+#-----------------------------------------------------------------------------
+# Various scripts
+
+ifdef UseInstalledUtils
+MKDEPENDC 		= mkdependC -f .depend
+else
+MKDEPENDC 		= $(MKDEPENDCSRC)/mkdependC -f .depend
+MKDEPENDCSRC 		= $(UTILSRC)/mkdependC
+endif
+
+ifdef UseInstalledUtils
+FASTMAKE 		= fastmake
+else
+FASTMAKE 		= $(FASTMAKESRC)/fastmake
+FASTMAKESRC 		= $(UTILSRC)/fastmake
+endif
+
+ifdef UseInstalledUtils
+LTX 			= ltx
+else
+LTX 			= $(LTXSRC)/ltx
+LTXSRC 			= $(UTILSRC)/ltx
+endif
+
+ifdef UseInstalledUtils
+MKDIRHIER		= mkdirhier
+else
+MKDIRHIER		= $(MKDIRHIERSRC)/mkdirhier
+MKDIRHIERSRC		= $(UTILSRC)/mkdirhier
+endif
+
+ifdef UseInstalledUtils
+LNDIR			= lndir
+else
+LNDIR			= $(LNDIRSRC)/lndir
+LNDIRSRC		= $(UTILSRC)/lndir
+endif
+
+ifdef UseInstalledUtils
+MSUB			= msub
+else
+MSUB			= $(MSUBSRC)/msub
+MSUBSRC			= $(UTILSRC)/msub
+endif
+
+ifdef UseInstalledUtils
+ETAGS			= etags
+else
+ETAGS			= $(ETAGSSRC)/etags
+ETAGSSRC		= $(UTILSRC)/etags
+endif
+
+ifdef UseInstalledUtils
+VERBATIM		= verbatim
+else
+VERBATIM		= $(VERBATIMSRC)/verbatim
+VERBATIMSRC		= $(UTILSRC)/verbatim
+endif
+
+ifdef UseInstalledUtils
+RUNSTDTEST		= runstdtest
+else
+RUNSTDTEST		= $(RUNSTDTESTSRC)/runstdtest
+RUNSTDTESTSRC		= $(UTILSRC)/runstdtest
+endif
+
+#-----------------------------------------------------------------------------
+# glued flags lists
+
+GLUED_CPP_INCLUDES = \
+	$(ALL_PROJECTS_CPP_INCLUDES) \
+	$(PLATFORM_CPP_INCLUDES) \
+	$(PROJECT_CPP_INCLUDES) \
+	$(SETUP_CPP_INCLUDES) \
+	$(CPP_INCLUDES) \
+	$(EXTRA_CPP_INCLUDES)
+
+GLUED_CPP_DEFINES = \
+	$(ALL_PROJECTS_CPP_DEFINES) \
+	$(PLATFORM_CPP_DEFINES) \
+	$(PROJECT_CPP_DEFINES) \
+	$(SETUP_CPP_DEFINES) \
+	$(CPP_DEFINES) \
+	$(EXTRA_CPP_DEFINES)
+
+GLUED_CC_OPTS = \
+	$(ALL_PROJECTS_CC_OPTS) \
+	$(PLATFORM_CC_OPTS) \
+	$(PROJECT_CC_OPTS) \
+	$(SETUP_CC_OPTS) \
+	$(CC_OPTS) \
+	$(EXTRA_CC_OPTS)
+
+CFLAGS = $(GLUED_CPP_INCLUDES) $(GLUED_CPP_DEFINES) $(GLUED_CC_OPTS)
+
+GLUED_YACC_OPTS = \
+	$(ALL_PROJECTS_YACC_OPTS) \
+	$(PLATFORM_YACC_OPTS) \
+	$(PROJECT_YACC_OPTS) \
+	$(SETUP_YACC_OPTS) \
+	$(YACC_OPTS) \
+	$(EXTRA_YACC_OPTS)
+
+YFLAGS = $(GLUED_YACC_OPTS)
+
+GLUED_HC_OPTS = \
+	$(ALL_PROJECTS_HC_OPTS) \
+	$(PLATFORM_HC_OPTS) \
+	$(PROJECT_HC_OPTS) \
+	$(SETUP_HC_OPTS) \
+	$(HC_OPTS) \
+	$(EXTRA_HC_OPTS)
+
+GLUED_HC_IMPORTS = \
+	$(ALL_PROJECTS_HC_IMPORTS) \
+	$(PLATFORM_HC_IMPORTS) \
+	$(PROJECT_HC_IMPORTS) \
+	$(SETUP_HC_IMPORTS) \
+	$(HC_IMPORTS) \
+	$(EXTRA_HC_IMPORTS)
+
+HCFLAGS = $(GLUED_HC_IMPORTS) $(GLUED_CPP_DEFINES) $(GLUED_HC_OPTS)
+
+GLUED_LD_OPTS = \
+	$(ALL_PROJECTS_LD_OPTS) \
+	$(PLATFORM_LD_OPTS) \
+	$(PROJECT_LD_OPTS) \
+	$(SETUP_LD_OPTS) \
+	$(LD_OPTS) \
+	$(EXTRA_LD_OPTS)
+
+GLUED_LD_LIBRARIES = \
+	$(ALL_PROJECTS_LD_LIBRARIES) \
+	$(PLATFORM_LD_LIBRARIES) \
+	$(PROJECT_LD_LIBRARIES) \
+	$(SETUP_LD_LIBRARIES) \
+	$(LD_LIBRARIES) \
+	$(EXTRA_LD_LIBRARIES)
+
+LDOPTIONS = $(GLUED_LD_OPTS) $(GLUED_LD_LIBRARIES)
+
+# ToDo: lint stuff not tidied up yet
+
+LINTLIBFLAG = -C
+LINTOPTS = -axz
+LINTFLAGS = $(LINTOPTS) -DLINT $(GLUED_CPP_INCLUDES) $(GLUED_CPP_DEFINES)
+
+GLUED_GENLIT_OPTS = \
+	$(ALL_PROJECTS_GENLIT_OPTS) \
+	$(PLATFORM_GENLIT_OPTS) \
+	$(PROJECT_GENLIT_OPTS) \
+	$(SETUP_GENLIT_OPTS) \
+	$(GENLIT_OPTS) \
+	$(EXTRA_GENLIT_OPTS)
+
+GLUED_LIT2PGM_OPTS = \
+	$(ALL_PROJECTS_LIT2PGM_OPTS) \
+	$(PLATFORM_LIT2PGM_OPTS) \
+	$(PROJECT_LIT2PGM_OPTS) \
+	$(SETUP_LIT2PGM_OPTS) \
+	$(LIT2PGM_OPTS) \
+	$(EXTRA_LIT2PGM_OPTS)
+
+GLUED_LIT2TEXI_OPTS = \
+	$(ALL_PROJECTS_LIT2TEXI_OPTS) \
+	$(PLATFORM_LIT2TEXI_OPTS) \
+	$(PROJECT_LIT2TEXI_OPTS) \
+	$(SETUP_LIT2TEXI_OPTS) \
+	$(LIT2TEXI_OPTS) \
+	$(EXTRA_LIT2TEXI_OPTS)
+
+GLUED_LIT2HTML_OPTS = \
+	$(ALL_PROJECTS_LIT2HTML_OPTS) \
+	$(PLATFORM_LIT2HTML_OPTS) \
+	$(PROJECT_LIT2HTML_OPTS) \
+	$(SETUP_LIT2HTML_OPTS) \
+	$(LIT2HTML_OPTS) \
+	$(EXTRA_LIT2HTML_OPTS)
+
+GLUED_LIT2LATEX_OPTS = \
+	$(ALL_PROJECTS_LIT2LATEX_OPTS) \
+	$(PLATFORM_LIT2LATEX_OPTS) \
+	$(PROJECT_LIT2LATEX_OPTS) \
+	$(SETUP_LIT2LATEX_OPTS) \
+	$(LIT2LATEX_OPTS) \
+	$(EXTRA_LIT2LATEX_OPTS)
+
+GLUED_LIT2CHANGELOG_OPTS = \
+	$(ALL_PROJECTS_LIT2CHANGELOG_OPTS) \
+	$(PLATFORM_LIT2CHANGELOG_OPTS) \
+	$(PROJECT_LIT2CHANGELOG_OPTS) \
+	$(SETUP_LIT2CHANGELOG_OPTS) \
+	$(LIT2CHANGELOG_OPTS) \
+	$(EXTRA_LIT2CHANGELOG_OPTS)
+
+GLUED_MKDEPENDLIT_OPTS = \
+	$(ALL_PROJECTS_MKDEPENDLIT_OPTS) \
+	$(PLATFORM_MKDEPENDLIT_OPTS) \
+	$(PROJECT_MKDEPENDLIT_OPTS) \
+	$(SETUP_MKDEPENDLIT_OPTS) \
+	$(MKDEPENDLIT_OPTS) \
+	$(EXTRA_MKDEPENDLIT_OPTS)
+
+LIT2PGMFLAGS            = $(GLUED_GENLIT_OPTS) $(GLUED_LIT2PGM_OPTS)
+LIT2TEXIFLAGS           = $(GLUED_GENLIT_OPTS) $(GLUED_LIT2TEXI_OPTS)
+LIT2HTMLFLAGS           = $(GLUED_GENLIT_OPTS) $(GLUED_LIT2HTML_OPTS)
+LIT2LATEXFLAGS          = $(GLUED_GENLIT_OPTS) $(GLUED_LIT2LATEX_OPTS)
+LIT2CHANGELOGFLAGS      = $(GLUED_GENLIT_OPTS) $(GLUED_LIT2CHANGELOG_OPTS)
+MKDEPENDLITFLAGS        = $(GLUED_GENLIT_OPTS) $(GLUED_MKDEPENDLIT_OPTS)
+
+GLUED_MKDEPENDC_OPTS = \
+	$(ALL_PROJECTS_MKDEPENDC_OPTS) \
+	$(PLATFORM_MKDEPENDC_OPTS) \
+	$(PROJECT_MKDEPENDC_OPTS) \
+	$(SETUP_MKDEPENDC_OPTS) \
+	$(MKDEPENDC_OPTS) \
+	$(EXTRA_MKDEPENDC_OPTS)
+
+MKDEPENDCFLAGS        = $(GLUED_MKDEPENDC_OPTS)
+
+GLUED_MKDEPENDHS_OPTS = \
+	$(ALL_PROJECTS_MKDEPENDHS_OPTS) \
+	$(PLATFORM_MKDEPENDHS_OPTS) \
+	$(PROJECT_MKDEPENDHS_OPTS) \
+	$(SETUP_MKDEPENDHS_OPTS) \
+	$(MKDEPENDHS_OPTS) \
+	$(EXTRA_MKDEPENDHS_OPTS)
+
+MKDEPENDHSFLAGS        = $(GLUED_MKDEPENDHS_OPTS)
+
+GLUED_CTAGS_OPTS = \
+	$(ALL_PROJECTS_CTAGS_OPTS) \
+	$(PLATFORM_CTAGS_OPTS) \
+	$(PROJECT_CTAGS_OPTS) \
+	$(SETUP_CTAGS_OPTS) \
+	$(CTAGS_OPTS) \
+	$(EXTRA_CTAGS_OPTS)
+
+CTAGSFLAGS        = $(GLUED_CTAGS_OPTS)
+
+GLUED_RUNSTDTEST_OPTS = \
+	$(ALL_PROJECTS_RUNSTDTEST_OPTS) \
+	$(PLATFORM_RUNSTDTEST_OPTS) \
+	$(PROJECT_RUNSTDTEST_OPTS) \
+	$(SETUP_RUNSTDTEST_OPTS) \
+	$(RUNSTDTEST_OPTS) \
+	$(EXTRA_RUNSTDTEST_OPTS)
+
+RUNSTDTEST_FLAGS = $(GLUED_RUNSTDTEST_OPTS)
+
+GLUED_MSUB_OPTS = \
+	$(ALL_PROJECTS_MSUB_OPTS) \
+	$(PLATFORM_MSUB_OPTS) \
+	$(PROJECT_MSUB_OPTS) \
+	$(SETUP_MSUB_OPTS) \
+	$(MSUB_OPTS) \
+	$(EXTRA_MSUB_OPTS)
+
+MSUBFLAGS = $(GLUED_MSUB_OPTS)