1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
7 # To understand how the build system works and how to modify it, see
8 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 # -----------------------------------------------------------------------------
15 # This is a tiny program to fool Cabal's configure that we have a
16 # stage1 GHC, which lets us configure all the packages before we've
19 utils/dummy-ghc_dist-dummy-ghc_MODULES = dummy-ghc
20 utils/dummy-ghc_dist-dummy-ghc_PROG = dummy-ghc$(exeext)
22 # depend on project.mk, so we pick up the new version number if it changes.
23 utils/dummy-ghc/dist-dummy-ghc/build/dummy-ghc.hs : utils/dummy-ghc/ghc.mk $(MKDIRHIER) mk/project.mk compiler/main/DynFlags.hs
24 "$(MKDIRHIER)" $(dir $@)
26 echo 'import System.Environment' >> $@
27 echo 'import System.Cmd' >> $@
28 echo 'import System.Exit' >> $@
29 echo 'main :: IO ()' >> $@
30 echo 'main = do args <- getArgs' >> $@
31 echo ' case args of' >> $@
32 echo ' ["--numeric-version"] ->' >> $@
33 echo ' putStrLn "$(ProjectVersion)"' >> $@
34 echo ' ["--supported-languages"] ->' >> $@
35 echo ' mapM_ putStrLn extensions' >> $@
37 echo ' do e <- rawSystem "$(GHC_STAGE0)" args' >> $@
38 echo ' exitWith e' >> $@
39 # This unpleasant sed script grabs the lines between the
43 # line of compiler/main/DynFlags.hs, and if they look like
44 # ( "PostfixOperators", ...
45 # then it translates them into
46 # ["PostfixOperators", "NoPostfixOperators"] ++
47 # Tabs are a pain to handle portably with sed, so rather than worrying
48 # about them we just use tr to remove them all before we start.
49 echo 'extensions :: [String]' >> $@
50 echo 'extensions =' >> $@
51 '$(TR)' -d '\t' < compiler/main/DynFlags.hs | '$(SED)' '/^xFlags/,/]/s/^ *( *"\([^"]*\)"[^"]*/ ["\1", "No\1"] ++/p;d' >> $@
54 # We don't build dummy-ghc with Cabal, so we need to pass -package
56 utils/dummy-ghc_dist-dummy-ghc_HC_OPTS = -package process
57 $(eval $(call build-prog,utils/dummy-ghc,dist-dummy-ghc,0))