Keep C main separate from rts lib and link it in for standalone progs
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index 4d2a29a..2bea829 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -53,7 +53,6 @@
 #
 #   * 2966 make sure --with-gcc does the right thing (#2966)
 #   * 1693 make distclean
-#   * 2689 make maintainer-clean
 #   * 3173 make install with DESTDIR
 
 # Possible cleanups:
@@ -134,9 +133,9 @@ show:
 # -----------------------------------------------------------------------------
 # Include subsidiary build-system bits
 
-ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
--include mk/config.mk
-else
+include mk/tree.mk
+
+ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
 include mk/config.mk
 ifeq "$(ProjectVersion)" ""
 $(error Please run ./configure first)
@@ -173,6 +172,10 @@ ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
 NO_INCLUDE_DEPS = YES
 NO_INCLUDE_PKGDATA = YES
 endif
+ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
+NO_INCLUDE_DEPS = YES
+NO_INCLUDE_PKGDATA = YES
+endif
 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
 NO_INCLUDE_DEPS = YES
 # We want package-data.mk for show
@@ -213,6 +216,10 @@ include rules/c-objs.mk
 # -----------------------------------------------------------------------------
 # Suffix rules
 
+# Suffix rules cause "make clean" to fail on Windows (trac #3233)
+# so we don't make any when cleaning.
+ifneq "$(CLEANING)" "YES"
+
 include rules/hs-suffix-rules-srcdir.mk
 include rules/hs-suffix-rules.mk
 
@@ -229,6 +236,8 @@ $(foreach way,$(ALL_WAYS),\
 
 include rules/c-suffix-rules.mk
 
+endif
+
 # -----------------------------------------------------------------------------
 # Building package-data.mk files from .cabal files
 
@@ -320,7 +329,7 @@ endif
 
 PACKAGES += haskeline
 
-ifneq "$(wildcard libraries/dph)" ""
+ifneq "$(BootingFromHc)" "YES"
 PACKAGES_STAGE2 += \
        dph/dph-base \
        dph/dph-prim-interface \
@@ -344,7 +353,8 @@ ifeq "$(BuildSharedLibs)" "YES"
 OTHER_LIBS  += libffi/libHSffi$(dyn_libsuf)
 endif
 ifeq "$(HaveLibGmp)" "NO"
-OTHER_LIBS += gmp/libgmp.a
+GMP_LIB = gmp/libgmp.a
+OTHER_LIBS += $(GMP_LIB)
 endif
 
 # We cannot run ghc-cabal to configure a package until we have
@@ -485,13 +495,21 @@ endif
 
 BUILD_DIRS += \
    utils/haddock \
-   utils/haddock/doc \
-   $(patsubst %, libraries/%, $(PACKAGES)) \
-   $(patsubst %, libraries/%, $(PACKAGES_STAGE2)) \
+   utils/haddock/doc
+
+ifneq "$(CLEANING)" "YES"
+BUILD_DIRS += \
+   $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
+ifneq "$(BootingFromHc)" "YES"
+BUILD_DIRS += \
+   libraries/dph
+endif
+endif
+
+BUILD_DIRS += \
    compiler \
    $(GHC_HSC2HS_DIR) \
    $(GHC_PKG_DIR) \
-   utils/hasktags \
    utils/hpc \
    utils/runghc \
    ghc
@@ -522,7 +540,6 @@ ifneq "$(findstring $(phase),0 1 2 3)" ""
 utils/haddock_dist_DISABLE = YES
 utils/runghc_dist_DISABLE = YES
 utils/hpc_dist_DISABLE = YES
-utils/hasktags_dist_DISABLE = YES
 utils/hsc2hs_dist-install_DISABLE = YES
 utils/ghc-pkg_dist-install_DISABLE = YES
 compiler_stage2_DISABLE = YES
@@ -533,9 +550,6 @@ $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
   libraries/$(lib)_dist-install_DISABLE = YES))
 endif
 
-ifneq "$(wildcard libraries/dph)" ""
-include libraries/dph/ghc.mk
-endif
 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
 
 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
@@ -550,7 +564,7 @@ $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-instal
 # XXX Hack; remove this
 $(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
 
-# XXX we configure packages with the bootsrapping compiler (for
+# XXX we configure packages with the bootstrapping compiler (for
 # dependency reasons, see the phase ordering), which doesn't
 # necessarily support all the extensions we need, and Cabal filters
 # out the ones it thinks aren't supported.
@@ -744,6 +758,7 @@ $(eval $(call bindist,.,\
     $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
        mk/fix_install_names.sh \
        mk/project.mk \
+       libraries/dph/LICENSE \
  ))
 # mk/project.mk gets an absolute path, so we manually include it in
 # the bindist with a relative path
@@ -860,7 +875,7 @@ publish-sdist :
 endif
 
 ifeq "$(GhcUnregisterised)" "YES"
-SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
+SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
 endif
 
 # -----------------------------------------------------------------------------
@@ -877,6 +892,9 @@ clean : clean_files
 .PHONY: clean_files
 clean_files :
        $(RM) $(CLEAN_FILES)
+       $(RM) -r $(patsubst %, libraries/%/dist, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) -r $(patsubst %, libraries/%/dist-install, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) -r $(patsubst %, libraries/%/dist-boot, $(PACKAGES) $(PACKAGES_STAGE2))
 
 distclean : clean
        $(RM) config.cache config.status config.log mk/config.h mk/stamp-h
@@ -888,12 +906,20 @@ distclean : clean
        $(RM) libraries/process/include/HsProcessConfig.h
        $(RM) libraries/unix/include/HsUnixConfig.h
        $(RM) libraries/old-time/include/HsTimeConfig.h
+       $(RM) $(patsubst %, libraries/%/config.log, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) $(patsubst %, libraries/%/config.status, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) -r $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES) $(PACKAGES_STAGE2))
 
 maintainer-clean : distclean
        $(RM) configure mk/config.h.in
        $(RM) -r autom4te.cache libraries/*/autom4te.cache
        $(RM) ghc.spec
-       $(RM) libraries/*/GNUmakefile libraries/*/ghc.mk libraries/*/configure 
+       $(RM) $(patsubst %, libraries/%/GNUmakefile, \
+               $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES) $(PACKAGES_STAGE2))
+       $(RM) $(patsubst %, libraries/%/configure, \
+               $(PACKAGES) $(PACKAGES_STAGE2))
        $(RM) libraries/base/include/HsBaseConfig.h.in
        $(RM) libraries/directory/include/HsDirectoryConfig.h.in
        $(RM) libraries/process/include/HsProcessConfig.h.in
@@ -902,3 +928,9 @@ maintainer-clean : distclean
 
 .PHONY: all_libraries
 
+.PHONY: bootstrapping-files
+bootstrapping-files: $(OTHER_LIBS)
+bootstrapping-files: includes/ghcautoconf.h
+bootstrapping-files: includes/DerivedConstants.h
+bootstrapping-files: includes/GHCConstants.h
+