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