Build a copy of ghc-cabal with the in-tree compiler, for the bindist
authorIan Lynagh <igloo@earth.li>
Fri, 10 Dec 2010 18:11:23 +0000 (18:11 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 10 Dec 2010 18:11:23 +0000 (18:11 +0000)
ghc.mk
utils/dummy-ghc/ghc.mk [new file with mode: 0644]
utils/ghc-cabal/Main.hs [moved from utils/ghc-cabal/ghc-cabal.hs with 100% similarity]
utils/ghc-cabal/ghc-cabal.cabal [new file with mode: 0644]
utils/ghc-cabal/ghc.mk

diff --git a/ghc.mk b/ghc.mk
index e7ae4d3..f5b77a1 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -436,6 +436,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-pwd/dist/package-data.mk: compiler/stage2/package-data.mk
+utils/ghc-cabal/dist-install/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
@@ -595,7 +596,6 @@ BUILD_DIRS += \
 ifneq "$(BINDIST)" "YES"
 BUILD_DIRS += \
    bindisttest \
-   $(GHC_CABAL_DIR) \
    $(GHC_GENAPPLY_DIR)
 endif
 
@@ -617,6 +617,8 @@ BUILD_DIRS += \
    utils/testremove \
    utils/ghctags \
    utils/ghc-pwd \
+   utils/dummy-ghc \
+   $(GHC_CABAL_DIR) \
    utils/hpc \
    utils/runghc \
    ghc
@@ -663,6 +665,7 @@ utils/runghc_dist_DISABLE = YES
 utils/ghctags_dist_DISABLE = YES
 utils/hpc_dist_DISABLE = YES
 utils/hsc2hs_dist-install_DISABLE = YES
+utils/ghc-cabal_dist-install_DISABLE = YES
 utils/ghc-pkg_dist-install_DISABLE = YES
 utils/ghc-pwd_dist_DISABLE = YES
 utils/mkUserGuidePart_dist_DISABLE = YES
@@ -985,7 +988,7 @@ $(eval $(call bindist,.,\
     Makefile \
     mk/config.mk.in \
     $(INPLACE_BIN)/mkdirhier \
-    $(INPLACE_BIN)/ghc-cabal \
+    utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
     utils/ghc-pwd/dist/build/tmp/ghc-pwd \
     $(BINDIST_WRAPPERS) \
     $(BINDIST_PERL_SOURCES) \
@@ -1038,6 +1041,7 @@ unix-binary-dist-prep:
        echo "BUILD_DOCBOOK_PS   = $(BUILD_DOCBOOK_PS)"   >> $(BIN_DIST_MK)
        echo "BUILD_DOCBOOK_PDF  = $(BUILD_DOCBOOK_PDF)"  >> $(BIN_DIST_MK)
        echo "BUILD_MAN          = $(BUILD_MAN)"          >> $(BIN_DIST_MK)
+       echo "GHC_CABAL_INPLACE  = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal" >> $(BIN_DIST_MK)
        cd $(BIN_DIST_PREP_DIR) && autoreconf
        "$(RM)" $(RM_OPTS) $(BIN_DIST_PREP_TAR)
 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
diff --git a/utils/dummy-ghc/ghc.mk b/utils/dummy-ghc/ghc.mk
new file mode 100644 (file)
index 0000000..72db6f0
--- /dev/null
@@ -0,0 +1,58 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2009 The University of Glasgow
+#
+# This file is part of the GHC build system.
+#
+# To understand how the build system works and how to modify it, see
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
+#
+# -----------------------------------------------------------------------------
+
+# dummy-ghc
+
+# This is a tiny program to fool Cabal's configure that we have a
+# stage1 GHC, which lets us configure all the packages before we've
+# build stage1.
+
+utils/dummy-ghc_dist-dummy-ghc_MODULES = dummy-ghc
+utils/dummy-ghc_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
+
+# depend on project.mk, so we pick up the new version number if it changes.
+utils/dummy-ghc/dist-dummy-ghc/build/dummy-ghc.hs : utils/dummy-ghc/ghc.mk $(MKDIRHIER) mk/project.mk compiler/main/DynFlags.hs
+       "$(MKDIRHIER)" $(dir $@)
+       "$(RM)" $(RM_OPTS) $@
+       echo 'import System.Environment'                                  >> $@
+       echo 'import System.Cmd'                                          >> $@
+       echo 'import System.Exit'                                         >> $@
+       echo 'main :: IO ()'                                              >> $@
+       echo 'main = do args <- getArgs'                                  >> $@
+       echo '          case args of'                                     >> $@
+       echo '              ["--numeric-version"] ->'                     >> $@
+       echo '                  putStrLn "$(ProjectVersion)"'             >> $@
+       echo '              ["--supported-languages"] ->'                 >> $@
+       echo '                  mapM_ putStrLn extensions'                >> $@
+       echo '              _ ->'                                         >> $@
+       echo '                  do e <- rawSystem "$(GHC_STAGE0)" args'   >> $@
+       echo '                     exitWith e'                            >> $@
+# This unpleasant sed script grabs the lines between the
+#      xFlags ::
+# line and the
+#   ]
+# line of compiler/main/DynFlags.hs, and if they look like
+#   ( "PostfixOperators", ...
+# then it translates them into
+#   ["PostfixOperators", "NoPostfixOperators"] ++
+# Tabs are a pain to handle portably with sed, so rather than worrying
+# about them we just use tr to remove them all before we start.
+       echo 'extensions :: [String]'                                     >> $@
+       echo 'extensions ='                                               >> $@
+       '$(TR)' -d '\t' < compiler/main/DynFlags.hs | '$(SED)' '/^xFlags/,/]/s/^ *( *"\([^"]*\)"[^"]*/  ["\1", "No\1"] ++/p;d' >> $@
+       echo '  []'                                                       >> $@
+
+# We don't build dummy-ghc with Cabal, so we need to pass -package
+# flags manually
+utils/dummy-ghc_dist-dummy-ghc_HC_OPTS = -package process
+$(eval $(call build-prog,utils/dummy-ghc,dist-dummy-ghc,0))
+
diff --git a/utils/ghc-cabal/ghc-cabal.cabal b/utils/ghc-cabal/ghc-cabal.cabal
new file mode 100644 (file)
index 0000000..cd8d550
--- /dev/null
@@ -0,0 +1,22 @@
+Name: ghc-cabal
+Version: 0.1
+Copyright: XXX
+License: BSD3
+-- XXX License-File: LICENSE
+Author: XXX
+Maintainer: XXX
+Synopsis: XXX
+Description:
+       XXX
+Category: Development
+build-type: Simple
+cabal-version: >=1.2
+
+Executable ghc-cabal
+    Main-Is: ghc-cabal.hs
+
+    Build-Depends: base       >= 3   && < 5,
+                   Cabal      >= 1.10 && < 1.12,
+                   directory  >= 1.1 && < 1.2,
+                   filepath   >= 1.2 && < 1.3
+
index cfe61b3..9026eb1 100644 (file)
@@ -25,8 +25,8 @@ $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/D
 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*/*.hs)
 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*.hs)
 
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs | $$(dir $$@)/. bootstrapping/.
-       "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \
+$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs | $$(dir $$@)/. bootstrapping/.
+       "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/Main.hs -o $@ \
               -no-user-package-conf \
               -Wall $(WERROR) \
               -DCABAL_VERSION=$(CABAL_VERSION) \
@@ -46,49 +46,14 @@ $(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
 $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
 
 # -----------------------------------------------------------------------------
-# dummy-ghc
+# Now make another copy that goes in bindists. This needs to be built
+# with the in-tree compiler.
 
-# This is a tiny program to fool Cabal's configure that we have a
-# stage1 GHC, which lets us configure all the packages before we've
-# build stage1.
+$(GHC_CABAL_DIR)_USES_CABAL                   = YES
+$(GHC_CABAL_DIR)_PACKAGE                      = ghc-cabal
+$(GHC_CABAL_DIR)_dist-install_PROG            = ghc-cabal$(exeext)
+$(GHC_CABAL_DIR)_dist-install_INSTALL_INPLACE = NO
+$(GHC_CABAL_DIR)_dist-install_MODULES         = Main
 
-$(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc
-$(GHC_CABAL_DIR)_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
-
-# depend on project.mk, so we pick up the new version number if it changes.
-$(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER) mk/project.mk compiler/main/DynFlags.hs
-       "$(MKDIRHIER)" $(dir $@)
-       "$(RM)" $(RM_OPTS) $@
-       echo 'import System.Environment'                                  >> $@
-       echo 'import System.Cmd'                                          >> $@
-       echo 'import System.Exit'                                         >> $@
-       echo 'main :: IO ()'                                              >> $@
-       echo 'main = do args <- getArgs'                                  >> $@
-       echo '          case args of'                                     >> $@
-       echo '              ["--numeric-version"] ->'                     >> $@
-       echo '                  putStrLn "$(ProjectVersion)"'             >> $@
-       echo '              ["--supported-languages"] ->'                 >> $@
-       echo '                  mapM_ putStrLn extensions'                >> $@
-       echo '              _ ->'                                         >> $@
-       echo '                  do e <- rawSystem "$(GHC_STAGE0)" args'   >> $@
-       echo '                     exitWith e'                            >> $@
-# This unpleasant sed script grabs the lines between the
-#      xFlags ::
-# line and the
-#   ]
-# line of compiler/main/DynFlags.hs, and if they look like
-#   ( "PostfixOperators", ...
-# then it translates them into
-#   ["PostfixOperators", "NoPostfixOperators"] ++
-# Tabs are a pain to handle portably with sed, so rather than worrying
-# about them we just use tr to remove them all before we start.
-       echo 'extensions :: [String]'                                     >> $@
-       echo 'extensions ='                                               >> $@
-       '$(TR)' -d '\t' < compiler/main/DynFlags.hs | '$(SED)' '/^xFlags/,/]/s/^ *( *"\([^"]*\)"[^"]*/  ["\1", "No\1"] ++/p;d' >> $@
-       echo '  []'                                                       >> $@
-
-# We don't build dummy-ghc with Cabal, so we need to pass -package
-# flags manually
-utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process
-$(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0))
+$(eval $(call build-prog,utils/ghc-cabal,dist-install,1))