Simplify ghc-cabal
[ghc.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.cabal | sed "s/^version: //")
18 CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION))
19 CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)"
20
21 ghc-cabal_DIST_BINARY_NAME = ghc-cabal$(exeext0)
22 ghc-cabal_DIST_BINARY = utils/ghc-cabal/dist/build/tmp/$(ghc-cabal_DIST_BINARY_NAME)
23 ghc-cabal_INPLACE = inplace/bin/$(ghc-cabal_DIST_BINARY_NAME)
24
25 ifneq "$(BINDIST)" "YES"
26 $(ghc-cabal_INPLACE) : $(ghc-cabal_DIST_BINARY) | $$(dir $$@)/.
27 "$(CP)" $< $@
28
29 $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs)
30 $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
31 $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
32
33 $(ghc-cabal_DIST_BINARY): utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
34 "$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-cabal/Main.hs -o $@ \
35 -no-user-$(GHC_PACKAGE_DB_FLAG) \
36 -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
37 -DCABAL_VERSION=$(CABAL_VERSION) \
38 -DBOOTSTRAPPING \
39 -odir bootstrapping \
40 -hidir bootstrapping \
41 -ilibraries/Cabal/Cabal \
42 -ilibraries/filepath \
43 -ilibraries/hpc \
44 $(utils/ghc-cabal_dist_EXTRA_HC_OPTS)
45 "$(TOUCH_CMD)" $@
46 endif
47
48 # touch is required, because otherwise if mkdirhier is newer, we
49 # repeatedly rebuild ghc-cabal.
50
51 $(eval $(call clean-target,utils/ghc-cabal,dist,\
52 utils/ghc-cabal/dist bootstrapping))
53
54 $(eval $(call all-target,utils/ghc-cabal,$(ghc-cabal_INPLACE)))
55
56 # -----------------------------------------------------------------------------
57 # Now make another copy that goes in bindists. This needs to be built
58 # with the in-tree compiler.
59
60 utils/ghc-cabal_USES_CABAL = YES
61 utils/ghc-cabal_PACKAGE = ghc-cabal
62 utils/ghc-cabal_dist-install_PROGNAME = ghc-cabal
63 utils/ghc-cabal_dist-install_INSTALL_INPLACE = NO
64 utils/ghc-cabal_dist-install_WANT_BINDIST_WRAPPER = YES
65 utils/ghc-cabal_dist-install_MODULES = Main
66
67 $(eval $(call build-prog,utils/ghc-cabal,dist-install,1))
68