further fixes to the inplace scripts
[ghc-hetmet.git] / compiler / Makefile
index 536ed0f..e4860ea 100644 (file)
@@ -702,14 +702,17 @@ SRC_LD_OPTS += -no-link-chk
 # See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
 # a real binary here rather than a shell script.
 
-all :: $(odir)/ghc-inplace ghc-inplace
-
 INPLACE_HS   = $(odir)/ghc-inplace.hs
 INPLACE_PROG = $(odir)/ghc-inplace$(exeext)
+EXCLUDED_SRCS += $(INPLACE_HS)
+
+# 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" > $@
-       echo "main = getArgs >>= \args -> rawSystem \"$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(FPTOOLS_TOP_ABS_PLATFORM)\":args)" >> $@
+       echo "import System.Cmd; import System.Environment; import System.Exit" > $@
+       echo "main = getArgs >>= \args -> rawSystem \"$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(TOP_ABS)\":args) >>= exitWith" >> $@
 
 $(INPLACE_PROG): $(INPLACE_HS)
        $(GHC) --make $< -o $@
@@ -722,6 +725,8 @@ ifeq "$(stage)" "1"
 ghc-inplace : $(INPLACE_PROG)
        $(RM) -f $@ && $(LN_S) $< $@
 
+all :: ghc-inplace
+
 CLEAN_FILES += ghc-inplace
 endif