Remove redundant imports
[ghc.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index f933ce7..4aea480 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -14,8 +14,6 @@
 #
 #   * remove old Makefiles, add new stubs for building in subdirs
 #     * docs/Makefile
-#     * docs/docbook-cheat-sheet/Makefile
-#     * docs/man/Makefile
 #     * docs/storage-mgmt/Makefile
 #     * docs/vh/Makefile
 #     * rts/dotnet/Makefile
@@ -140,14 +138,22 @@ endif
 endif
 
 include mk/ways.mk
-include mk/warnings.mk
 
 # (Optional) build-specific configuration
 include mk/custom-settings.mk
-SRC_CC_OPTS     += $(WERROR)
-SRC_HC_OPTS     += $(WERROR)
+
+# The user can reset SRC_HC_OPTS from mk/build.mk. Since we try to append
+# '-Wall' to it in mk/warnings.mk, we have to include mk/warnings.mk after
+# mk/custom-settings.mk.
+include mk/warnings.mk
+
+# -----------------------------------------------------------------------------
+# Check for inconsistent settings, after reading mk/build.mk.
+# Although mk/config.mk should always contain consistent settings (set by
+# configure), mk/build.mk can contain pretty much anything.
 
 ifneq "$(CLEANING)" "YES"
+
 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
 ifeq "$(findstring dyn,$(GhcLibWays))" ""
 $(error dyn is not in $$(GhcLibWays), but $$(DYNAMIC_GHC_PROGRAMS) is YES)
@@ -157,13 +163,42 @@ ifeq "$(findstring v,$(GhcLibWays))" ""
 $(error v is not in $$(GhcLibWays), and $$(DYNAMIC_GHC_PROGRAMS) is not YES)
 endif
 endif
+
 ifeq "$(GhcProfiled)" "YES"
 ifeq "$(findstring p,$(GhcLibWays))" ""
 $(error p is not in $$(GhcLibWays), and $$(GhcProfiled) is YES)
 endif
 endif
+
+ifeq "$(BUILD_SPHINX_HTML)" "YES"
+ifeq "$(SPHINXBUILD)" ""
+$(error BUILD_SPHINX_HTML=YES, but `sphinx-build` was not found. \
+  Create a file `mk/validate.mk` containing `BUILD_SPHINX_HTML=NO` \
+  (when validating), or install `sphinx-build` and rerun `./configure`. \
+  See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
+endif
+endif
+
+ifeq "$(BUILD_SPHINX_PDF)" "YES"
+ifeq "$(XELATEX)" ""
+$(error BUILD_SPHINX_PDF=YES, but `xelatex` was not found. \
+  Install `xelatex`, then rerun `./configure`. \
+  See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
+endif
 endif
 
+ifeq "$(HSCOLOUR_SRCS)" "YES"
+ifeq "$(HSCOLOUR_CMD)" ""
+$(error HSCOLOUR_SRCS=YES, but HSCOLOUR_CMD is empty. \
+  Run `cabal install hscolour`, then rerun `./configure`. \
+  See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
+endif
+endif
+
+endif # CLEANING
+
+# -----------------------------------------------------------------------------
+
 ifeq "$(phase)" ""
 phase = final
 endif
@@ -308,7 +343,7 @@ include rules/manual-package-config.mk
 # -----------------------------------------------------------------------------
 # Docs
 
-include rules/docbook.mk
+include rules/sphinx.mk
 
 # -----------------------------------------------------------------------------
 # Making bindists and sdists
@@ -377,7 +412,7 @@ else # CLEANING
 # programs such as GHC and ghc-pkg, that we do not assume the stage0
 # compiler already has installed (or up-to-date enough).
 
-PACKAGES_STAGE0 = binary Cabal/Cabal hpc bin-package-db hoopl transformers template-haskell
+PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot hoopl transformers template-haskell
 ifeq "$(Windows_Host)" "NO"
 ifneq "$(HostOS_CPP)" "ios"
 PACKAGES_STAGE0 += terminfo
@@ -405,10 +440,10 @@ PACKAGES_STAGE1 += directory
 PACKAGES_STAGE1 += process
 PACKAGES_STAGE1 += hpc
 PACKAGES_STAGE1 += pretty
-PACKAGES_STAGE1 += template-haskell
 PACKAGES_STAGE1 += binary
 PACKAGES_STAGE1 += Cabal/Cabal
-PACKAGES_STAGE1 += bin-package-db
+PACKAGES_STAGE1 += ghc-boot
+PACKAGES_STAGE1 += template-haskell
 PACKAGES_STAGE1 += hoopl
 PACKAGES_STAGE1 += transformers
 
@@ -482,7 +517,6 @@ $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install
 # eachother, so we can configure them in parallel.
 utils/ghc-pwd/dist-install/package-data.mk: $(fixed_pkg_prev)
 utils/ghc-cabal/dist-install/package-data.mk: $(fixed_pkg_prev)
-utils/dll-split/dist-install/package-data.mk: $(fixed_pkg_prev)
 utils/hpc/dist-install/package-data.mk: $(fixed_pkg_prev)
 utils/ghc-pkg/dist-install/package-data.mk: $(fixed_pkg_prev)
 utils/hsc2hs/dist-install/package-data.mk: $(fixed_pkg_prev)
@@ -505,6 +539,7 @@ ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
 # all the other libraries' package-data.mk files.
 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
 utils/ghctags/dist-install/package-data.mk: compiler/stage2/package-data.mk
+utils/check-api-annotations/dist-install/package-data.mk: compiler/stage2/package-data.mk
 utils/mkUserGuidePart/dist/package-data.mk: compiler/stage2/package-data.mk
 
 # add the final package.conf dependency: ghc-prim depends on RTS
@@ -619,6 +654,7 @@ BUILD_DIRS += utils/hsc2hs
 BUILD_DIRS += utils/ghc-pkg
 BUILD_DIRS += utils/testremove
 BUILD_DIRS += utils/ghctags
+BUILD_DIRS += utils/check-api-annotations
 BUILD_DIRS += utils/dll-split
 BUILD_DIRS += utils/ghc-pwd
 BUILD_DIRS += utils/ghc-cabal
@@ -627,7 +663,6 @@ BUILD_DIRS += utils/runghc
 BUILD_DIRS += ghc
 BUILD_DIRS += utils/mkUserGuidePart
 BUILD_DIRS += docs/users_guide
-BUILD_DIRS += docs/man
 BUILD_DIRS += utils/count_lines
 BUILD_DIRS += utils/compare_sizes
 
@@ -650,7 +685,7 @@ ifeq "$(HADDOCK_DOCS)" "NO"
 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
 endif
-ifeq "$(BUILD_DOCBOOK_HTML) $(BUILD_DOCBOOK_PS) $(BUILD_DOCBOOK_PDF)" "NO NO NO"
+ifeq "$(BUILD_SPHINX_HTML) $(BUILD_SPHINX_PDF)" "NO NO NO"
 # Don't to build this little utility if we're not building the User's Guide.
 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
 endif
@@ -673,6 +708,7 @@ ifneq "$(CrossCompiling) $(Stage1Only)" "NO NO"
 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
 BUILD_DIRS := $(filter-out utils/ghctags,$(BUILD_DIRS))
+BUILD_DIRS := $(filter-out utils/check-api-annotations,$(BUILD_DIRS))
 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
 endif
 endif # CLEANING
@@ -707,7 +743,7 @@ ifneq "$(BINDIST)" "YES"
 
 ifneq "$(BOOTSTRAPPING_CONF)" ""
 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
-$(shell $(GHC_PKG) init $(BOOTSTRAPPING_CONF))
+$(shell "$(GHC_PKG)" init $(BOOTSTRAPPING_CONF))
 endif
 endif
 
@@ -720,7 +756,7 @@ fixed_pkg_prev=
 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
 # ghc-pkg, unlike other utils that we build with the stage0 compiler (TODO: is
 # this really true?), depends on several boot packages (e.g. Cabal and
-# bin-package-db). They need to be configured before ghc-pkg, so we add a
+# ghc-boot). They need to be configured before ghc-pkg, so we add a
 # dependency between their package-data.mk files. See also Note
 # [Dependencies between package-data.mk files].
 utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
@@ -839,17 +875,17 @@ install_bins: $(INSTALL_BINS) $(INSTALL_SCRIPTS)
        for i in $(INSTALL_BINS); do \
                $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(bindir)" ;  \
        done
+ifneq "$(INSTALL_SCRIPTS)" ""
        for i in $(INSTALL_SCRIPTS); do \
                $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(bindir)" ;  \
        done
+endif
 
 install_libs: $(INSTALL_LIBS)
        $(call installLibsTo, $(INSTALL_LIBS), "$(DESTDIR)$(ghclibdir)")
 
 install_libexecs:  $(INSTALL_LIBEXECS)
-ifeq "$(INSTALL_LIBEXECS)" ""
-       @:
-else
+ifneq "$(INSTALL_LIBEXECS)" ""
        $(INSTALL_DIR) "$(DESTDIR)$(ghclibexecdir)/bin"
        for i in $(INSTALL_LIBEXECS); do \
                $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(ghclibexecdir)/bin"; \
@@ -864,9 +900,11 @@ install_topdirs: $(INSTALL_TOPDIR_BINS) $(INSTALL_TOPDIR_SCRIPTS)
        for i in $(INSTALL_TOPDIR_BINS); do \
                $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(topdir)"; \
        done
+ifneq "$(INSTALL_TOPDIR_SCRIPTS)" ""
        for i in $(INSTALL_TOPDIR_SCRIPTS); do \
                $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(topdir)"; \
        done
+endif
 
 install_docs: $(INSTALL_DOCS)
        $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
@@ -886,9 +924,14 @@ ifneq "$(INSTALL_LIBRARY_DOCS)" ""
        $(INSTALL_SCRIPT) $(INSTALL_OPTS) libraries/gen_contents_index "$(DESTDIR)$(docdir)/html/libraries/"
 endif
 ifneq "$(INSTALL_HTML_DOC_DIRS)" ""
+# We need to filter out the directories so install doesn't choke on them
        for i in $(INSTALL_HTML_DOC_DIRS); do \
                $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
-               $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
+               for f in $$i/*; do \
+                       if test -f $$f; then \
+                               $(INSTALL_DOC) $(INSTALL_OPTS) "$$f" "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
+                       fi \
+               done \
        done
 endif
 
@@ -1013,9 +1056,8 @@ unix-binary-dist-prep:
        "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
        set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
        echo "HADDOCK_DOCS       = $(HADDOCK_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)
+       echo "BUILD_SPHINX_HTML  = $(BUILD_SPHINX_HTML)"  >> $(BIN_DIST_MK)
+       echo "BUILD_SPHINX_PDF   = $(BUILD_SPHINX_PDF)"   >> $(BIN_DIST_MK)
        echo "BUILD_MAN          = $(BUILD_MAN)"          >> $(BIN_DIST_MK)
        echo "override ghc-cabal_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" >> $(BIN_DIST_MK)
        echo "UseSystemLibFFI    = $(UseSystemLibFFI)"    >> $(BIN_DIST_MK)
@@ -1301,6 +1343,7 @@ distclean : clean
        $(call removeFiles,settings)
        $(call removeFiles,docs/users_guide/ug-book.xml)
        $(call removeFiles,docs/users_guide/ug-ent.xml)
+       $(call removeFiles,docs/users_guide/ghc_config.py)
        $(call removeFiles,docs/index.html)
        $(call removeFiles,libraries/prologue.txt)
        $(call removeFiles,distrib/configure.ac)
@@ -1340,8 +1383,10 @@ distclean : clean
 # Not sure why this is being cleaned here.
        $(call removeTrees,includes/dist-derivedconstants)
 
-# Finally, clean the inplace tree.
-       $(call removeTrees,inplace)
+# Also clean Windows-only inplace directories.
+# Don't delete 'inplace' itself, it contains source files.
+       $(call removeTrees,inplace/mingw)
+       $(call removeTrees,inplace/perl)
 
 maintainer-clean : distclean
        $(call removeFiles,configure mk/config.h.in)