remove a TODO now done
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index 2821649..dd11adf 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -39,8 +39,6 @@
 #
 #   * per-source-file dependencies instead of one .depend file?
 #   * eliminate undefined variables, and use --warn-undefined-variables?
-#   * perhaps we should make all the output dirs in the .depend rule, to
-#     avoid all these mkdirhier calls?
 #   * put outputs from different ways in different subdirs of distdir/build,
 #     then we don't have to use -osuf/-hisuf.  We would have to install
 #     them in different places too, so we'd need ghc-pkg support for packages
 
 .PHONY: default all haddock
 
+# We need second expansion for the way we handle directories, so that
+#     | $$$$(dir $$$$@)/.
+# expands to the directoy of a rule that uses a % pattern.
+.SECONDEXPANSION:
+
 default : all
 
 # Catch make if it runs away into an infinite loop
@@ -398,6 +401,15 @@ rts/package.conf.inplace : libffi/package.conf.inplace
 endif
 
 # -----------------------------------------------------------------------------
+# Directories
+
+# Don't try to delete directories:
+.PRECIOUS: %/.
+
+%/. : $(MKDIRHIER)
+       "$(MKDIRHIER)" $@
+
+# -----------------------------------------------------------------------------
 # Special magic for the ghc-prim package
 
 # We want the ghc-prim package to include the GHC.Prim module when it
@@ -417,8 +429,7 @@ endef
 
 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
 
-libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
-       "$(MKDIRHIER)" $(dir $@)
+libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT) | $$(dir $$@)/.
        "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
 
 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
@@ -702,13 +713,13 @@ libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
     libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
 
 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
-                            $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
-       "$(MKDIRHIER)" $(dir $@)
+                            $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) \
+                          | $$(dir $$@)/.
        "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
 
 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
-                            $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
-       "$(MKDIRHIER)" $(dir $@)
+                            $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) \
+                          | $$(dir $$@)/.
        "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $< > $@
 
 # -----------------------------------------------------------------------------
@@ -803,6 +814,9 @@ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
 endif
 
+INSTALLED_PACKAGES = $(filter-out haskeline mtl terminfo,$(PACKAGES))
+HIDDEN_PACKAGES = binary
+
 install_packages: install_libexecs
 install_packages: libffi/package.conf.install rts/package.conf.install
        $(INSTALL_DIR) $(DESTDIR)$(topdir)
@@ -810,7 +824,7 @@ install_packages: libffi/package.conf.install rts/package.conf.install
        $(INSTALL_DIR) $(INSTALLED_PACKAGE_CONF)
        "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
        "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
-       $(foreach p, $(PACKAGES) $(PACKAGES_STAGE2),\
+       $(foreach p, $(INSTALLED_PACKAGES) $(PACKAGES_STAGE2),\
            "$(GHC_CABAL_INPLACE)" install \
                 $(INSTALLED_GHC_REAL) \
                 $(INSTALLED_GHC_PKG_REAL) \
@@ -818,6 +832,9 @@ install_packages: libffi/package.conf.install rts/package.conf.install
                 libraries/$p dist-install \
                 '$(DESTDIR)' '$(prefix)' '$(ghclibdir)' '$(docdir)/html/libraries' \
                 $(RelocatableBuild) &&) true
+       $(foreach p, $(HIDDEN_PACKAGES),\
+           $(INSTALLED_GHC_PKG_REAL) --global-conf $(INSTALLED_PACKAGE_CONF) \
+                                     hide $p &&) true
        "$(GHC_CABAL_INPLACE)" install \
                 $(INSTALLED_GHC_REAL) \
                 $(INSTALLED_GHC_PKG_REAL) \
@@ -975,6 +992,8 @@ sdist-prep :
        cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
        cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done
        cd $(SRC_DIST_DIR) && $(MAKE) distclean
+       rm -rf $(SRC_DIST_DIR)/libraries/tarballs/
+       rm -rf $(SRC_DIST_DIR)/libraries/stamp/
        cd $(SRC_DIST_DIR) && if test -f $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs; then "$(CP)" $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs libraries/haskell-src/Language/Haskell/ ; mv libraries/haskell-src/Language/Haskell/Parser.ly libraries/haskell-src/Language/Haskell/Parser.ly.source ; fi
        cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
        cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,cmm,CmmParse,y)