Add some -no-user-package-conf flags
[ghc-hetmet.git] / utils / ghc-cabal / 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 # Bootstrapping ghc-cabal
14
15 # Euch, hideous hack:
16 # XXX This should be in a different Makefile
17 CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal.cabal | sed "s/^Version: //")
18 CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION))
19 CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)"
20
21 $(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext) | $$(dir $$@)/.
22         "$(CP)" $< $@
23
24 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*/*/*.hs)
25 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*/*.hs)
26 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*.hs)
27
28 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs | $$(dir $$@)/. bootstrapping/.
29         "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \
30                -no-user-package-conf \
31                -Wall $(WERROR) \
32                -DCABAL_VERSION=$(CABAL_VERSION) \
33                -odir  bootstrapping \
34                -hidir bootstrapping \
35                -ilibraries/Cabal \
36                -ilibraries/filepath \
37                -ilibraries/hpc
38         touch $@
39
40 # touch is required, because otherwise if mkdirhier is newer, we
41 # repeatedly rebuild ghc-cabal.
42
43 $(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
44    $(GHC_CABAL_DIR)/dist bootstrapping))
45
46 $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
47
48 # -----------------------------------------------------------------------------
49 # dummy-ghc
50
51 # This is a tiny program to fool Cabal's configure that we have a
52 # stage1 GHC, which lets us configure all the packages before we've
53 # build stage1.
54
55 $(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc
56 $(GHC_CABAL_DIR)_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
57
58 # depend on project.mk, so we pick up the new version number if it changes.
59 $(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER) mk/project.mk compiler/main/DynFlags.hs
60         "$(MKDIRHIER)" $(dir $@)
61         "$(RM)" $(RM_OPTS) $@
62         echo 'import System.Environment'                                  >> $@
63         echo 'import System.Cmd'                                          >> $@
64         echo 'import System.Exit'                                         >> $@
65         echo 'main :: IO ()'                                              >> $@
66         echo 'main = do args <- getArgs'                                  >> $@
67         echo '          case args of'                                     >> $@
68         echo '              ["--numeric-version"] ->'                     >> $@
69         echo '                  putStrLn "$(ProjectVersion)"'             >> $@
70         echo '              ["--supported-languages"] ->'                 >> $@
71         echo '                  mapM_ putStrLn extensions'                >> $@
72         echo '              _ ->'                                         >> $@
73         echo '                  do e <- rawSystem "$(GHC_STAGE0)" args'   >> $@
74         echo '                     exitWith e'                            >> $@
75 # This unpleasant sed script grabs the lines between the
76 #       xFlags ::
77 # line and the
78 #   ]
79 # line of compiler/main/DynFlags.hs, and if they look like
80 #   ( "PostfixOperators", ...
81 # then it translates them into
82 #   ["PostfixOperators"] ++
83 # Tabs are a pain to handle portably with sed, so rather than worrying
84 # about them we just use tr to remove them all before we start.
85         echo 'extensions :: [String]'                                     >> $@
86         echo 'extensions ='                                               >> $@
87         '$(TR)' -d '\t' < compiler/main/DynFlags.hs | '$(SED)' '/^xFlags/,/]/s/^ *( *\("[^"]*"\)[^"]*/  [\1] ++/p;d' >> $@
88         echo '  []'                                                       >> $@
89
90 # We don't build dummy-ghc with Cabal, so we need to pass -package
91 # flags manually
92 utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process
93 $(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0))
94