Use bracket in `withCurrentDirectory`
[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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.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) \
35 $(addprefix -optc, $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)) \
36 $(addprefix -optl, $(SRC_LD_OPTS) $(CONF_LD_OPTS_STAGE0)) \
37 --make utils/ghc-cabal/Main.hs -o $@ \
38 -no-user-$(GHC_PACKAGE_DB_FLAG) \
39 -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
40 -DCABAL_VERSION=$(CABAL_VERSION) \
41 -DBOOTSTRAPPING \
42 -odir bootstrapping \
43 -hidir bootstrapping \
44 -ilibraries/Cabal/Cabal \
45 -ilibraries/binary/src -DGENERICS \
46 -ilibraries/filepath \
47 -ilibraries/hpc \
48 $(utils/ghc-cabal_dist_EXTRA_HC_OPTS)
49 "$(TOUCH_CMD)" $@
50 endif
51
52 # touch is required, because otherwise if mkdirhier is newer, we
53 # repeatedly rebuild ghc-cabal.
54
55 $(eval $(call clean-target,utils/ghc-cabal,dist,\
56 utils/ghc-cabal/dist bootstrapping))
57
58 $(eval $(call all-target,utils/ghc-cabal,$(ghc-cabal_INPLACE)))
59
60 # -----------------------------------------------------------------------------
61 # Now make another copy that goes in bindists. This needs to be built
62 # with the in-tree compiler.
63
64 utils/ghc-cabal_USES_CABAL = YES
65 utils/ghc-cabal_PACKAGE = ghc-cabal
66 utils/ghc-cabal_dist-install_PROGNAME = ghc-cabal
67 utils/ghc-cabal_dist-install_INSTALL_INPLACE = NO
68 utils/ghc-cabal_dist-install_WANT_BINDIST_WRAPPER = YES
69 utils/ghc-cabal_dist-install_MODULES = Main
70
71 $(eval $(call build-prog,utils/ghc-cabal,dist-install,1))