summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-10-06 20:14:15 +0000
committerIan Lynagh <igloo@earth.li>2009-10-06 20:14:15 +0000
commit49fb21e21496611dc2ccfd311e2b64fc4eb93023 (patch)
tree1459dba8e480b03910f48c1863ce8716837b184b /utils
parentf0bc4086b3b8447792b2d7f2fbfc9232826f4f14 (diff)
downloadhaskell-49fb21e21496611dc2ccfd311e2b64fc4eb93023.tar.gz
Add --supported-languages support to dummy-ghc
We used to call the bootstrapping compiler to get its --supported-languages but that doesn't work when it doesn't support all the extensions that we need. In particular, compiling the new bytestring which needs NamedFieldPuns broken when building with 6.8.2. There's now a rather ugly sed script to extract the extensions from DynFlags.hs.
Diffstat (limited to 'utils')
-rw-r--r--utils/ghc-cabal/ghc.mk32
1 files changed, 28 insertions, 4 deletions
diff --git a/utils/ghc-cabal/ghc.mk b/utils/ghc-cabal/ghc.mk
index 71232fb422..b4b599d111 100644
--- a/utils/ghc-cabal/ghc.mk
+++ b/utils/ghc-cabal/ghc.mk
@@ -51,10 +51,34 @@ $(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 mk/project.mk | $$(dir $$@)/.
- echo "import System.Environment; import System.Cmd; import System.Exit" >$@
- echo "main :: IO ()" >>$@
- echo "main = do args <- getArgs; if args == [\"--numeric-version\"] then putStrLn \"$(ProjectVersion)\" else do e <- rawSystem \"$(GHC_STAGE0)\" args; exitWith e" >>$@
+$(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"] ++
+ echo 'extensions :: [String]' >> $@
+ echo 'extensions =' >> $@
+ sed '/^xFlags/,/]/{/^ (/{s/^[^"]*"/ ["/; s/"[^"]*$$/"] ++/; p}}; d' compiler/main/DynFlags.hs >> $@
+ echo ' []' >> $@
# We don't build dummy-ghc with Cabal, so we need to pass -package
# flags manually