Whitespace tweak
[ghc-hetmet.git] / utils / dummy-ghc / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
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
10 #
11 # -----------------------------------------------------------------------------
12
13 # dummy-ghc
14
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
17 # build stage1.
18
19 utils/dummy-ghc_dist-dummy-ghc_MODULES = dummy-ghc
20 utils/dummy-ghc_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
21
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 $@)
25         "$(RM)" $(RM_OPTS) $@
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'                >> $@
36         echo '              _ ->'                                         >> $@
37         echo '                  do e <- rawSystem "$(GHC_STAGE0)" args'   >> $@
38         echo '                     exitWith e'                            >> $@
39 # This unpleasant sed script grabs the lines between the
40 #       xFlags ::
41 # line and the
42 #   ]
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' >> $@
52         echo '  []'                                                       >> $@
53
54 # We don't build dummy-ghc with Cabal, so we need to pass -package
55 # flags manually
56 utils/dummy-ghc_dist-dummy-ghc_HC_OPTS = -package process
57 $(eval $(call build-prog,utils/dummy-ghc,dist-dummy-ghc,0))
58