ghc-stage2 is now renamed to ghc when it is installed
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index d352d5c..94e9080 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -525,7 +525,7 @@ endif
 
 ifneq "$(CLEANING)" "YES"
 BUILD_DIRS += \
-   $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
+   $(patsubst %, libraries/%, $(PACKAGES))
 endif
 
 ifneq "$(BootingFromHc)" "YES"
@@ -549,6 +549,12 @@ BUILD_DIRS += \
    $(GHC_TOUCHY_DIR)
 endif
 
+ifneq "$(CLEANING)" "YES"
+# After compiler/, because these packages depend on it
+BUILD_DIRS += \
+   $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
+endif
+
 # XXX libraries/% must come before any programs built with stage1, see
 # Note [lib-depends].
 
@@ -685,6 +691,15 @@ libraries/bin-package-db/dist-boot/build/Distribution/InstalledPackageInfo/Binar
 
 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
 
+# Make sure we have all the GHCi libs by the time we've built
+# ghc-stage2.  DPH includes a bit of Template Haskell which needs the
+# GHCI libs, and we don't have a better way to express that dependency.
+#
+GHCI_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
+           $(compiler_stage2_GHCI_LIB)
+
+ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
+
 endif
 
 # -----------------------------------------------------------------------------
@@ -766,6 +781,9 @@ else
        for i in $(INSTALL_LIBEXECS); do \
                $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(ghclibexecdir)"; \
        done
+# We rename ghc-stage2, so that the right program name is used in error
+# messages etc.
+       "$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage2" "$(DESTDIR)$(ghclibexecdir)/ghc"
 endif
 
 install_topdir_scripts: $(INSTALL_TOPDIR_SCRIPTS)
@@ -812,7 +830,7 @@ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
 # Install packages in the right order, so that ghc-pkg doesn't complain.
 # Also, install ghc-pkg first.
 ifeq "$(Windows)" "NO"
-INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-stage2
+INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc
 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-pkg
 else
 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe