c0fd0f336d7930f134e90d9e07bff89bb7c8fab3
[ghc-hetmet.git] / utils / ghc-cabal / ghc.mk
1 # -----------------------------------------------------------------------------
2 # Bootstrapping ghc-cabal
3
4 # Euch, hideous hack:
5 # XXX This should be in a different Makefile
6 CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal.cabal | sed "s/^Version: //")
7 CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION))
8 CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)"
9
10 $(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext)
11         $(MKDIRHIER) $(dir $@)
12         $(CP) $< $@
13
14 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs $(MKDIRHIER)
15         $(MKDIRHIER) bootstrapping
16         $(MKDIRHIER) $(dir $@)
17         $(GHC) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \
18                -Wall $(WERROR) \
19                -DCABAL_VERSION=$(CABAL_VERSION) \
20                -odir  bootstrapping \
21                -hidir bootstrapping \
22                -ilibraries/Cabal \
23                -ilibraries/filepath \
24                -ilibraries/hpc
25         touch $@
26
27 # touch is required, because otherwise if mkdirhier is newer, we
28 # repeatedly rebuild ghc-cabal.
29
30 $(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
31    $(GHC_CABAL_DIR)/dist bootstrapping))
32
33 $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
34
35 # -----------------------------------------------------------------------------
36 # dummy-ghc
37
38 # This is a tiny program to fool Cabal's configure that we have a
39 # stage1 GHC, which lets us configure all the packages before we've
40 # build stage1.
41
42 $(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc
43 $(GHC_CABAL_DIR)_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
44
45 $(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER)
46         $(MKDIRHIER) $(dir $@)
47         echo "import System.Environment; import System.Cmd; import System.Exit" >$@
48         echo "main = do args <- getArgs; if args == [\"--numeric-version\"] then putStrLn \"$(ProjectVersion)\" else do e <- rawSystem \"$(GHC_STAGE0)\" args; exitWith e" >>$@
49
50 # We don't build dummy-ghc with Cabal, so we need to pass -package
51 # flags manually
52 utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process
53 $(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0))
54