-#
-# subdir dependencies:
-# everything needs utils
-# includes/ needs driver (to easily c.pile mkNativeGen.c)
-# make depend except in {utils,driver} needs includes
-# RTS and compiler need includes
-#
-
-#
-# Order is important! It's e.g. necessary to descend into include/
-# before the rest to have a config.h, etc.
-#
-# If we're booting from .hc files, swap the order
-# we descend into compiler/ and lib/
-#
-ifeq "$(BootingFromHc)" "YES"
-SUBDIRS = includes driver rts docs lib compiler
+ifeq "$(stage)" ""
+stage=1
+endif
+
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+INSTALL_FLAGS =
+else
+INSTALL_FLAGS = --enable-shell-wrappers
+endif
+
+boot:
+ @:
+
+all:: build.stage$(stage)
+
+stage1 ::
+ $(MAKE) stage=1
+
+stage2 ::
+ $(MAKE) stage=2
+
+stage3 ::
+ $(MAKE) stage=3
+
+clean distclean::
+ -$(CABAL) clean --distpref dist-stage1
+ -$(CABAL) clean --distpref dist-stage2
+ $(RM) -rf stage1-inplace
+ $(RM) -rf stage2-inplace
+
+# XXX Eugh, can we do this better? The problem is making extra-gcc-opts
+# infdable on both Linux and Windows. I guess this will go away when we
+# drop the mangler?
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+SET_DATA_SUBDIR = --datasubdir=.
+INPLACE_DATA_DIR = '$$prefix'