Implement the RTS side of GHC.Environment.getFullArgs
[ghc-hetmet.git] / compiler / Makefile
index 9edd7a0..0b84536 100644 (file)
@@ -367,7 +367,7 @@ SRC_HC_OPTS += -Istage$(stage)
 
 ALL_DIRS = \
   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
-  specialise simplCore stranal stgSyn simplStg codeGen main \
+  vectorise specialise simplCore stranal stgSyn simplStg codeGen main \
   profiling parser cprAnalysis ndpFlatten iface cmm
 
 # Make sure we include Config.hs even if it doesn't exist yet...
@@ -406,15 +406,15 @@ endif
 # -----------------------------------------------------------------------------
 # Building a compiler with interpreter support
 #
-# The interpreter, GHCi interface, and Template Haskell are only
+# The interpreter, GHCi interface, Template Haskell and Hpc are only
 # enabled when we are bootstrapping with the same version of GHC, and
 # the interpreter is supported on this platform.
 
 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
 
 # Yes, include the interepreter, readline, and Template Haskell extensions
-SRC_HC_OPTS += -DGHCI -package template-haskell
-PKG_DEPENDS += template-haskell
+SRC_HC_OPTS += -DGHCI -package template-haskell -package hpc
+PKG_DEPENDS += template-haskell hpc
 
 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
 # or not?
@@ -702,17 +702,28 @@ 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))
+
+ifeq "$(stage)" "1"
+EnvImport = System.Environment
+GetArgs = getArgs
+else
+EnvImport = GHC.Environment
+GetArgs = getFullArgs
+endif
 
 $(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 $(EnvImport); 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)
-       $(GHC) --make $< -o $@
+       $(HC) --make $< -o $@
 
 all :: $(INPLACE_PROG)
 
@@ -722,6 +733,8 @@ ifeq "$(stage)" "1"
 ghc-inplace : $(INPLACE_PROG)
        $(RM) -f $@ && $(LN_S) $< $@
 
+all :: ghc-inplace
+
 CLEAN_FILES += ghc-inplace
 endif
 
@@ -861,35 +874,6 @@ docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $
        $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
 endif
 
-include $(TOP)/mk/package.mk
-
-#-----------------------------------------------------------------------------
-# binary-dist
-
-ifeq "$(DOING_BIN_DIST)" "YES"
-# This is derived from the sources when we are in a source tree, but we
-# don't have any sources in a bindist, so we have to shortcut it
-HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
-endif
-
-binary-dist:
-       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler
-       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler/stage$(stage)
-       echo "stage=$(stage)"                > $(BIN_DIST_DIR)/compiler/Makefile
-       cat Makefile                        >> $(BIN_DIST_DIR)/compiler/Makefile
-       $(INSTALL_DATA)    package.conf.in     $(BIN_DIST_DIR)/compiler/
-       set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
-       set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
-ifneq "$(INSTALL_LIBS)" ""
-       set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
-endif
-ifneq "$(INSTALL_PROGS)" ""
-       set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
-endif
-ifneq "$(INSTALL_LIBEXECS)" ""
-       set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
-endif
-
 #-----------------------------------------------------------------------------
 #              clean
 
@@ -919,6 +903,33 @@ include $(TOP)/mk/target.mk
 
 $(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE='"$(stage)"'
 
+#-----------------------------------------------------------------------------
+# binary-dist
+
+ifeq "$(DOING_BIN_DIST)" "YES"
+# This is derived from the sources when we are in a source tree, but we
+# don't have any sources in a bindist, so we have to shortcut it
+HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
+endif
+
+binary-dist:
+       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler
+       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler/stage$(stage)
+       echo "stage=$(stage)"                > $(BIN_DIST_DIR)/compiler/Makefile
+       cat Makefile                        >> $(BIN_DIST_DIR)/compiler/Makefile
+       $(INSTALL_DATA)    package.conf.in     $(BIN_DIST_DIR)/compiler/
+       set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
+       set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
+ifneq "$(INSTALL_LIBS)" ""
+       set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
+endif
+ifneq "$(INSTALL_PROGS)" ""
+       set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
+endif
+ifneq "$(INSTALL_LIBEXECS)" ""
+       set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
+endif
+
 # -----------------------------------------------------------------------------
 # Explicit dependencies