Use "order only constraints" for directories
[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): $(GHC_CABAL_DIR)/ghc-cabal.hs | $$(dir $$@)/. bootstrapping/.
25         "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \
26                -Wall $(WERROR) \
27                -DCABAL_VERSION=$(CABAL_VERSION) \
28                -odir  bootstrapping \
29                -hidir bootstrapping \
30                -ilibraries/Cabal \
31                -ilibraries/filepath \
32                -ilibraries/hpc
33         touch $@
34
35 # touch is required, because otherwise if mkdirhier is newer, we
36 # repeatedly rebuild ghc-cabal.
37
38 $(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
39    $(GHC_CABAL_DIR)/dist bootstrapping))
40
41 $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
42
43 # -----------------------------------------------------------------------------
44 # dummy-ghc
45
46 # This is a tiny program to fool Cabal's configure that we have a
47 # stage1 GHC, which lets us configure all the packages before we've
48 # build stage1.
49
50 $(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc
51 $(GHC_CABAL_DIR)_dist-dummy-ghc_PROG    = dummy-ghc$(exeext)
52
53 # depend on project.mk, so we pick up the new version number if it changes.
54 $(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk mk/project.mk | $$(dir $$@)/.
55         echo "import System.Environment; import System.Cmd; import System.Exit" >$@
56         echo "main :: IO ()" >>$@
57         echo "main = do args <- getArgs; if args == [\"--numeric-version\"] then putStrLn \"$(ProjectVersion)\" else do e <- rawSystem \"$(GHC_STAGE0)\" args; exitWith e" >>$@
58
59 # We don't build dummy-ghc with Cabal, so we need to pass -package
60 # flags manually
61 utils/ghc-cabal_dist-dummy-ghc_HC_OPTS = -package process
62 $(eval $(call build-prog,utils/ghc-cabal,dist-dummy-ghc,0))
63