-# XXX This should be defined somewhere more central
-INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir
+ifeq "$(CLEAN_ALL_STAGES)" "YES"
+clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3
+else
+clean distclean maintainer-clean:: clean.stage.$(stage)
+endif
+
+ifeq "$(CLEAN_ALL_STAGES)" "YES"
+distclean maintainer-clean::
+ $(RM) -f ghc-bin.cabal
+endif
+
+clean.stage.%:
+ $(RM) -rf stage$*-inplace
+# This is a bit naughty. We ought to use:
+# -$(CABAL) clean --distpref dist-stage$*
+# but that won't work if the Cabal file (a generated file) doesn't
+# exist. So we do this instead:
+ $(RM) -rf dist-stage$*