1 # -----------------------------------------------------------------------------
2 # Bootstrapping ghc-cabal
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)"
10 $(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext)
11 $(MKDIRHIER) $(dir $@)
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 $@ \
19 -DCABAL_VERSION=$(CABAL_VERSION) \
21 -hidir bootstrapping \
23 -ilibraries/filepath \
27 # touch is required, because otherwise if mkdirhier is newer, we
28 # repeatedly rebuild ghc-cabal.
30 $(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
31 $(GHC_CABAL_DIR)/dist bootstrapping))
33 $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
35 # -----------------------------------------------------------------------------
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
42 $(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc
43 $(GHC_CABAL_DIR)_dist-dummy-ghc_PROG = dummy-ghc$(exeext)
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" >>$@
50 # We don't build dummy-ghc with Cabal, so we need to pass -package
52 utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process
53 $(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0))