-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-# MSys (...and cygwin with a mingw toolchain)
-SCRIPT_SHELL = $(shell cd /bin; pwd -W 2>/dev/null || echo "/bin")/sh
-else
-# Cygwin and Unix
-SCRIPT_SHELL = /bin/sh
-endif
-
-# Note 2
-# On MSys, we must use the following script for ghc-inplace:
-# exec /c/darcs/fc-branch-2/compiler/stage1/ghc -Bc:/darcs/fc-branch-2 "$@"
-# That is,
-# (a) You *must* use the /c/ form for the first arg to exec. Using the
-# c:/ form makes exec complain that it can't find $pwd/c:/darcs/.../ghc
-# The /c/ form is $(FPTOOLS_TOP_ABS)
-# (b) You *must* use the c:/ form for the -B argument, else the testsuite
-# doesn't work. I think that's something to do with ghc-inplace being
-# invoked by Python
-# The c:/ form is $(FPTOOLS_TOP_ABS_PLATFORM)
-
-$(odir)/ghc-inplace : $(GHC_PROG)
- @$(RM) $@
- echo '#!$(SCRIPT_SHELL)' >>$@
-# Re SCRIPT_SHELL, see note 1 above
- echo exec $(GHC_COMPILER_DIR_ABS)/$(GHC_PROG) \
- '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
-# Re exec, see note 2 above
- chmod 755 $@
-
-ghc-inplace : stage1/ghc-inplace
- $(RM) -f $@ && $(LN_S) $< $@
+# FPTOOLS_TOP_ABS platform uses backslashes, at least on Cygwin, but that
+# will go wrong when we use it in a Haskell string below.
+TOP_ABS=$(subst \\,/,$(FPTOOLS_TOP_ABS_PLATFORM))
+
+$(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk
+ echo "import System.Cmd; import System.Environment; import System.Exit" > $@
+ echo "main = do args <- getArgs; rawSystem \"$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(TOP_ABS)\":args) >>= exitWith" >> $@
+
+$(INPLACE_PROG): $(INPLACE_HS)
+ $(HC) --make $< -o $@
+
+all :: $(INPLACE_PROG)
+
+CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG)