Remove (most of) the FiniteMap wrapper
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index b070777..f79732c 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -43,7 +43,7 @@
 #     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
 #     of different ways.
-#   * make PACKAGES generated by configure or sh boot?
+#   * make PACKAGES generated by './configure' or 'perl boot'?
 #   * we should use a directory of package.conf files rather than a single
 #     file for the inplace package database, so that we can express
 #     dependencies more accurately.  Otherwise it's possible to get into
@@ -101,6 +101,10 @@ endif
 just-makefiles:
        @:
 
+ifneq "$(CLEANING)" "YES"
+CLEANING = NO
+endif
+
 # -----------------------------------------------------------------------------
 # Misc GNU make utils
 
@@ -147,6 +151,11 @@ endif
 endif
 
 # -----------------------------------------------------------------------------
+# Utility definitions
+
+include rules/make-command.mk
+
+# -----------------------------------------------------------------------------
 # Macros for standard targets
 
 include rules/all-target.mk
@@ -303,6 +312,10 @@ define addPackage # args: $1 = package, $2 = condition
     endif
 endef
 
+INTREE_ONLY_PACKAGES := haskeline mtl terminfo utf8-string xhtml
+
+$(foreach p,$(INTREE_ONLY_PACKAGES),$(eval libraries/$p_dist-install_HADDOCK_ME = NO))
+
 $(eval $(call addPackage,ghc-prim))
 ifeq "$(CLEANING)" "YES"
 $(eval $(call addPackage,integer-gmp))
@@ -327,6 +340,7 @@ $(eval $(call addPackage,process))
 $(eval $(call addPackage,random))
 $(eval $(call addPackage,extensible-exceptions))
 $(eval $(call addPackage,haskell98))
+$(eval $(call addPackage,haskell2010))
 $(eval $(call addPackage,hpc))
 $(eval $(call addPackage,pretty))
 $(eval $(call addPackage,template-haskell))
@@ -335,6 +349,7 @@ $(eval $(call addPackage,binary))
 $(eval $(call addPackage,bin-package-db))
 $(eval $(call addPackage,mtl))
 $(eval $(call addPackage,utf8-string))
+$(eval $(call addPackage,xhtml))
 
 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
 
@@ -342,20 +357,35 @@ $(eval $(call addPackage,haskeline))
 
 $(foreach pkg,$(EXTRA_PACKAGES),$(eval $(call addPackage,$(pkg))))
 
+
+# -------------------  Adding DPH packaes ---------------
+
+# The DPH packages are added when:
+#   * not BootingFromHc (they aren't necessary for bootstrapping), and
+#     * not GhcProfiled (they need TH, so can't be compiled by a -prof GHC), or
+#     * CLEANING: when cleaning we always enable everything
+
+# if !BootingFromHc && (!GhcProfiled || CLEANING)
+
 ifneq "$(BootingFromHc)" "YES"
-PACKAGES_STAGE2 += \
-       dph/dph-base \
+ifneq "$(GhcProfiled) $(CLEANING)" "NO YES"
+PACKAGES_STAGE2 += dph/dph-base \
        dph/dph-prim-interface \
        dph/dph-prim-seq \
        dph/dph-prim-par \
        dph/dph-seq \
        dph/dph-par
 endif
+endif  # BootingFromHc
+# ------------------------------------------------------- 
+
 
 # We assume that the stage0 compiler has a suitable bytestring package,
 # so we don't have to include it below.
 BOOT_PKGS = Cabal hpc extensible-exceptions binary bin-package-db
 
+BOOT_PKG_CONSTRAINTS := $(foreach p,$(BOOT_PKGS),--constraint "$p == $(shell grep -i "^Version:" libraries/$p/$p.cabal | sed "s/[^0-9.]//g")")
+
 # The actual .a and .so/.dll files: needed for dependencies.
 ALL_STAGE1_LIBS  = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
 ifeq "$(BuildSharedLibs)" "YES"
@@ -400,6 +430,7 @@ ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
 # libraries
 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
 
+utils/ghc-pkg/dist-install/package-data.mk: compiler/stage2/package-data.mk
 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
 utils/compare_sizes/dist/package-data.mk: compiler/stage2/package-data.mk
 
@@ -515,6 +546,7 @@ BUILD_DIRS += \
    driver \
    driver/ghci \
    driver/ghc \
+   driver/haddock \
    libffi \
    includes \
    rts
@@ -526,11 +558,9 @@ BUILD_DIRS += \
    $(GHC_GENAPPLY_DIR)
 endif
 
-ifneq "$(HADDOCK_DOCS)" "NO"
 BUILD_DIRS += \
    utils/haddock \
    utils/haddock/doc
-endif
 
 ifneq "$(CLEANING)" "YES"
 BUILD_DIRS += \
@@ -560,6 +590,11 @@ BUILD_DIRS += \
    $(GHC_TOUCHY_DIR)
 endif
 
+ifneq "$(BINDIST)" "YES"
+BUILD_DIRS += \
+   utils/mkUserGuidePart
+endif
+
 BUILD_DIRS += utils/count_lines
 BUILD_DIRS += utils/compare_sizes
 
@@ -586,18 +621,6 @@ ifneq "$(findstring $(phase),0 1 2)" ""
 ghc_stage1_DISABLE = YES
 endif
 
-ifneq "$(CLEANING)" "YES"
-ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
-libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
-else
-    ifeq "$(INTEGER_LIBRARY)" "integer-simple"
-       libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
-    else
-$(error Unknown integer library: $(INTEGER_LIBRARY))
-    endif
-endif
-endif
-
 ifneq "$(findstring $(phase),0 1 2 3)" ""
 # In phases 0-3, we disable stage2-3, the full libraries and haddock
 utils/haddock_dist_DISABLE = YES
@@ -606,6 +629,7 @@ utils/ghctags_dist_DISABLE = YES
 utils/hpc_dist_DISABLE = YES
 utils/hsc2hs_dist-install_DISABLE = YES
 utils/ghc-pkg_dist-install_DISABLE = YES
+utils/mkUserGuidePart_dist_DISABLE = YES
 utils/compare_sizes_dist_DISABLE = YES
 compiler_stage2_DISABLE = YES
 compiler_stage3_DISABLE = YES
@@ -615,6 +639,18 @@ $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
   libraries/$(lib)_dist-install_DISABLE = YES))
 endif
 
+ifneq "$(CLEANING)" "YES"
+ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
+libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
+else
+    ifeq "$(INTEGER_LIBRARY)" "integer-simple"
+       libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
+    else
+$(error Unknown integer library: $(INTEGER_LIBRARY))
+    endif
+endif
+endif
+
 # These packages don't pass the Cabal checks because hs-source-dirs
 # points outside the source directory. This isn't a real problem in
 # these cases, so we just skip checking them.
@@ -642,15 +678,6 @@ GhcBootLibHcOpts += -fno-warn-deprecated-flags
 # Add $(GhcLibHcOpts) to all library builds
 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
 
-# XXX Hack; remove this
-# Use -Wwarn for dph
-$(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
-
-# XXX Hack; remove this
-# Use -Wwarn for 'binary' becuase it has redundant UNPACK pragmas
-libraries/binary_dist-install_HC_OPTS += -Wwarn
-libraries/binary_dist-boot_HC_OPTS += -Wwarn
-
 # ----------------------------------------------
 # A useful pseudo-target
 .PHONY: stage1_libs
@@ -874,7 +901,7 @@ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
 endif
 
-INSTALLED_PACKAGES := $(filter-out haskeline mtl terminfo utf8-string,$(PACKAGES))
+INSTALLED_PACKAGES := $(filter-out $(INTREE_ONLY_PACKAGES),$(PACKAGES))
 ifeq "$(InstallExtraPackages)" "NO"
 INSTALLED_PACKAGES := $(filter-out $(EXTRA_PACKAGES), $(INSTALLED_PACKAGES))
 endif
@@ -903,18 +930,23 @@ 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, $(ALL_INSTALLED_PACKAGES),\
-           "$(GHC_CABAL_INPLACE)" install \
-                "$(INSTALLED_GHC_REAL)" \
-                "$(INSTALLED_GHC_PKG_REAL)" \
-                "$(STRIP)" \
-                "$(DESTDIR)$(topdir)" \
-                $p $(INSTALL_DISTDIR_$p) \
-                '$(DESTDIR)' '$(prefix)' '$(ghclibdir)' '$(docdir)/html/libraries' \
-                $(RelocatableBuild) &&) true
-       $(foreach p, $(HIDDEN_PACKAGES),\
-           "$(INSTALLED_GHC_PKG_REAL)" --global-conf "$(INSTALLED_PACKAGE_CONF)" \
-                                     hide $p &&) true
+       $(foreach p, $(ALL_INSTALLED_PACKAGES),                       \
+           $(call make-command,                                      \
+                  "$(GHC_CABAL_INPLACE)" install                     \
+                                         "$(INSTALLED_GHC_REAL)"     \
+                                         "$(INSTALLED_GHC_PKG_REAL)" \
+                                         "$(STRIP_CMD)"              \
+                                         "$(DESTDIR)$(topdir)"       \
+                                         $p $(INSTALL_DISTDIR_$p)    \
+                                         '$(DESTDIR)'                \
+                                         '$(prefix)'                 \
+                                         '$(ghclibdir)'              \
+                                         '$(docdir)/html/libraries'  \
+                                         $(RelocatableBuild)))
+       $(foreach p, $(HIDDEN_PACKAGES),                                   \
+           $(call make-command,                                           \
+                  "$(INSTALLED_GHC_PKG_REAL)"                             \
+                      --global-conf "$(INSTALLED_PACKAGE_CONF)" hide $p))
 
 # -----------------------------------------------------------------------------
 # Binary distributions
@@ -986,18 +1018,18 @@ unix-binary-dist-prep:
        "$(RM)" $(RM_OPTS) $(BIN_DIST_PREP_TAR)
 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
 # tree then we want to include the real file, not a symlink to it
-       cd bindistprep && "$(TAR)" hcf - -T ../$(BIN_DIST_LIST) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
+       cd bindistprep && "$(TAR_CMD)" hcf - -T ../$(BIN_DIST_LIST) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
 
 windows-binary-dist-prep:
        "$(RM)" $(RM_OPTS_REC) bindistprep/
        $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
-       cd bindistprep && "$(TAR)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
+       cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
 
 windows-installer:
-ifeq "$(ISCC)" ""
-       @echo No ISCC, so not making installer
+ifeq "$(ISCC_CMD)" ""
+       @echo No ISCC_CMD, so not making installer
 else
-       "$(ISCC)" /O. /Fbindistprep/$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
+       "$(ISCC_CMD)" /O. /Fbindistprep/$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
 endif
 
 # tryTimes tries to run its third argument multiple times, until it
@@ -1101,7 +1133,7 @@ sdist-prep :
 
 .PHONY: sdist
 sdist : sdist-prep
-       "$(TAR)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
+       "$(TAR_CMD)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
 
 sdist-manifest : $(SRC_DIST_TARBALL)
        tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest