Remove a TODO item that's been done
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index ddd1187..820c36c 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -13,7 +13,6 @@
 # ToDo List.
 #
 #   * finish installation
-#     * other documentation
 #     * create doc index and contents
 #     * Windows: should we have ghc-pkg-<version>?
 #     * should we be stripping things?
@@ -29,9 +28,7 @@
 #     * docs/vh/Makefile
 #     * rts/dotnet/Makefile
 #     * utils/Makefile
-#   * GhcProfiled
 #   * optionally install stage3?
-#   * shared libraries, way dyn
 #   * add Makefiles for the rest of the utils/ programs that aren't built
 #     by default (need to exclude them from 'make all' too)
 #
@@ -282,45 +279,56 @@ include rules/bindist.mk
 # -----------------------------------------------------------------------------
 # Building libraries
 
-# XXX generate from $(TOP)/packages
-PACKAGES = \
-       ghc-prim \
-       integer-gmp \
-       integer \
-       base \
-       filepath \
-       array \
-       bytestring \
-       containers
+define addPackage # args: $1 = package, $2 = condition
+    ifneq "$2" ""
+        ifeq "$$(CLEANING)" "YES"
+            PACKAGES += $1
+        else
+            ifeq $2
+                PACKAGES += $1
+            endif
+        endif
+    else
+        PACKAGES += $1
+    endif
+endef
 
-ifeq "$(Windows)" "YES"
-PACKAGES += Win32
+$(eval $(call addPackage,ghc-prim))
+ifeq "$(CLEANING)" "YES"
+$(eval $(call addPackage,integer-gmp))
+$(eval $(call addPackage,integer-simple))
 else
-PACKAGES += unix
-endif
-
-PACKAGES += \
-       old-locale \
-       old-time \
-       directory \
-       process \
-       random \
-       extensible-exceptions \
-       haskell98 \
-       hpc \
-       pretty \
-       syb \
-       template-haskell \
-       base3-compat \
-       Cabal \
-       mtl \
-       utf8-string
-
-ifneq "$(Windows)" "YES"
-PACKAGES += terminfo
-endif
-
-PACKAGES += haskeline
+$(eval $(call addPackage,$(INTEGER_LIBRARY)))
+endif
+$(eval $(call addPackage,base))
+$(eval $(call addPackage,filepath))
+$(eval $(call addPackage,array))
+$(eval $(call addPackage,bytestring))
+$(eval $(call addPackage,containers))
+
+$(eval $(call addPackage,Win32,($$(Windows),YES)))
+$(eval $(call addPackage,unix,($$(Windows),NO)))
+
+$(eval $(call addPackage,old-locale))
+$(eval $(call addPackage,old-time))
+$(eval $(call addPackage,time))
+$(eval $(call addPackage,directory))
+$(eval $(call addPackage,process))
+$(eval $(call addPackage,random))
+$(eval $(call addPackage,extensible-exceptions))
+$(eval $(call addPackage,haskell98))
+$(eval $(call addPackage,hpc))
+$(eval $(call addPackage,pretty))
+$(eval $(call addPackage,syb))
+$(eval $(call addPackage,template-haskell))
+$(eval $(call addPackage,base3-compat))
+$(eval $(call addPackage,Cabal))
+$(eval $(call addPackage,mtl))
+$(eval $(call addPackage,utf8-string))
+
+$(eval $(call addPackage,terminfo,($$(Windows),NO)))
+
+$(eval $(call addPackage,haskeline))
 
 ifneq "$(BootingFromHc)" "YES"
 PACKAGES_STAGE2 += \
@@ -498,8 +506,11 @@ BUILD_DIRS += \
 endif
 endif
 
+ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
+BUILD_DIRS += libraries/integer-gmp/gmp
+endif
+
 BUILD_DIRS += \
-   libraries/integer-gmp/gmp \
    compiler \
    $(GHC_HSC2HS_DIR) \
    $(GHC_PKG_DIR) \
@@ -528,6 +539,18 @@ 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
@@ -655,7 +678,7 @@ libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
 # Installation
 
 install: install_packages install_libs install_libexecs install_headers \
-        install_libexec_scripts install_bins
+         install_libexec_scripts install_bins install_docs
 
 install_bins: $(INSTALL_BINS)
        $(INSTALL_DIR) $(DESTDIR)$(bindir)
@@ -703,6 +726,17 @@ install_headers: $(INSTALL_HEADERS)
                $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
        done
 
+install_docs: $(INSTALL_HEADERS)
+       $(INSTALL_DIR) $(DESTDIR)$(docdir)
+       for i in $(INSTALL_DOCS); do \
+               $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir); \
+       done
+       $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html; \
+       for i in $(INSTALL_HTML_DOC_DIRS); do \
+               $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html/`basename $$i`; \
+               $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* $(DESTDIR)$(docdir)/html/`basename $$i`; \
+       done
+
 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
 
 # Install packages in the right order, so that ghc-pkg doesn't complain.
@@ -751,19 +785,29 @@ $(eval $(call bindist,.,\
     $(INSTALL_LIBEXECS) \
     $(INSTALL_LIBEXEC_SCRIPTS) \
     $(INSTALL_BINS) \
+    $(INSTALL_DOCS) \
+    $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
     $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
     $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
        mk/fix_install_names.sh \
        mk/project.mk \
+       bindist.mk \
        libraries/dph/LICENSE \
  ))
 # mk/project.mk gets an absolute path, so we manually include it in
 # the bindist with a relative path
 
+BIN_DIST_MK = $(BIN_DIST_NAME)/bindist.mk
+
 binary-dist:
        "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
        mkdir $(BIN_DIST_NAME)
        set -e; for i in LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh extra-gcc-opts.in ghc.mk inplace; do ln -s ../$$i $(BIN_DIST_NAME)/; done
+       echo "HADDOCK_DOCS       = $(HADDOCK_DOCS)"       >> $(BIN_DIST_MK)
+       echo "LATEX_DOCS         = $(LATEX_DOCS)"         >> $(BIN_DIST_MK)
+       echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
+       echo "BUILD_DOCBOOK_PS   = $(BUILD_DOCBOOK_PS)"   >> $(BIN_DIST_MK)
+       echo "BUILD_DOCBOOK_PDF  = $(BUILD_DOCBOOK_PDF)"  >> $(BIN_DIST_MK)
        ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
        cd $(BIN_DIST_NAME) && autoreconf
        "$(RM)" $(RM_OPTS) $(BIN_DIST_TAR)
@@ -788,6 +832,10 @@ ifeq "$(mingw32_TARGET_OS)" "1"
        $(call nTimes,10,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
 endif
 
+.PHONY: publish-docs
+publish-docs:
+       $(call nTimes,10,$(PublishCp) -r bindisttest/installed/share/doc/ghc/* $(PublishLocation)/docs)
+
 # -----------------------------------------------------------------------------
 # Source distributions
 
@@ -922,8 +970,10 @@ endif
 distclean : clean
        "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
        "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
+       "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
        "$(RM)" $(RM_OPTS) extra-gcc-opts docs/users_guide/ug-book.xml
-       "$(RM)" $(RM_OPTS) compiler/ghc.cabal ghc/ghc-bin.cabal
+       "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
+       "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
        "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
        "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
        "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h