Quote some more arguments to cabal-bin
[ghc-hetmet.git] / mk / cabal-flags.mk
1
2 nothing=
3 space=$(nothing) $(nothing)
4 comma=,
5
6 GHC_PKG_INSTALL_PROG = $(FPTOOLS_TOP_ABS)/utils/ghc-pkg/dist-install/build/ghc-pkg/ghc-pkg
7
8 LIBRARIES_ABS = $(FPTOOLS_TOP_ABS)/libraries
9 UTILS_ABS     = $(FPTOOLS_TOP_ABS)/utils
10 CABAL = $(LIBRARIES_ABS)/cabal-bin $(GHC) $(LIBRARIES_ABS)/bootstrapping.conf $(CABAL_DOTTED_VERSION)
11 INSTALL_PACKAGE = \
12     $(UTILS_ABS)/installPackage/install-inplace/bin/installPackage
13 STAGE3_PACKAGE_CONF = $(FPTOOLS_TOP_ABS)/stage3.package.conf
14
15 # Euch, hideous hack:
16 CABAL_DOTTED_VERSION = $(shell grep "^Version:" $(LIBRARIES_ABS)/Cabal/Cabal.cabal | sed "s/^Version: //")
17 CABAL_VERSION = $(subst .,$(comma),$(CABAL_DOTTED_VERSION))
18 CABAL_CONSTRAINT = --constraint="Cabal == $(CABAL_DOTTED_VERSION)"
19
20 # We rely on all the CONFIGURE_ARGS being quoted with '...', and there
21 # being no 's inside the values.
22 FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
23                                  $(space)--configure-option=',\
24                                  $(space)$(CONFIGURE_ARGS))
25
26 COMMON_CONFIGURE_FLAGS =          \
27     --libsubdir='$$pkgid'         \
28     --with-gcc=$(WhatGccIsCalled) \
29     --with-ld=$(LD)               \
30     $(addprefix --hsc2hs-option=,$(SRC_HSC2HS_OPTS))
31
32 ifneq "$(HSCOLOUR)" ""
33 COMMON_CONFIGURE_FLAGS += --with-hscolour=$(HSCOLOUR)
34 endif
35
36 ifneq "$(ALEX)" ""
37 COMMON_CONFIGURE_FLAGS += --with-alex="$(ALEX)"
38 endif
39
40 ifneq "$(HAPPY)" ""
41 COMMON_CONFIGURE_FLAGS += --with-happy="$(HAPPY)"
42 endif
43
44 COMMON_CONFIGURE_FLAGS += $(FLAGGED_CONFIGURE_ARGS) \
45                           --configure-option=--with-cc="$(CC)"
46
47 COMMON_CONFIGURE_FLAGS += $(shell [ -f $(HSC2HS_INPLACE) ] && \
48                                   echo --with-hsc2hs=$(HSC2HS_INPLACE) )
49
50 ifeq "$(Windows)" "YES"
51 NONEXISTENT=c:/NONEXISTENT
52 else
53 NONEXISTENT=/NONEXISTENT
54 endif
55
56 # We put non-existant paths in when configuring things that we plan to
57 # install, as we require that builds don't depend on these paths when
58 # making bindists.
59 INSTALL_DIRS_CONFIGURE_FLAGS = \
60     --prefix=$(NONEXISTENT) \
61     --bindir=$(NONEXISTENT) \
62     --libdir=$(NONEXISTENT) \
63     --libexecdir=$(NONEXISTENT) \
64     --datadir=$(NONEXISTENT) \
65     --docdir=$(NONEXISTENT) \
66     --haddockdir=$(NONEXISTENT) \
67     --htmldir=$(NONEXISTENT)
68
69 INPLACE_GHC_DATADIR_CONFIGURE_FLAGS = \
70     --datadir=$(FPTOOLS_TOP_ABS)/inplace-datadir \
71     --datasubdir=.
72
73 INPLACE_DIRS_CONFIGURE_FLAGS = \
74     --prefix=`$(FPTOOLS_TOP_ABS)/utils/pwd/pwd forwardslash`/install-inplace
75
76 USE_BOOT_CONFIGURE_FLAGS = \
77     --with-compiler=$(GHC) \
78     --with-hc-pkg=$(GHC_PKG) \
79         --package-db $(FPTOOLS_TOP_ABS)/libraries/bootstrapping.conf
80
81 USE_STAGE_CONFIGURE_FLAGS = \
82     --with-hc-pkg=$(GHC_PKG_INPLACE) \
83     $(addprefix --cc-option=,$(MACOSX_DEPLOYMENT_CC_OPTS)) \
84     $(addprefix --ld-option=,$(MACOSX_DEPLOYMENT_LD_OPTS))
85
86 USE_STAGE1_CONFIGURE_FLAGS = \
87     --with-compiler=$(GHC_STAGE1) \
88     $(USE_STAGE_CONFIGURE_FLAGS)
89
90 USE_STAGE2_CONFIGURE_FLAGS =            \
91     --with-compiler=$(GHC_STAGE2)       \
92     $(USE_STAGE_CONFIGURE_FLAGS)        \
93         --package-db $(STAGE3_PACKAGE_CONF)
94
95 BUILD_FLAGS = $(addprefix --ghc-option=,$(SRC_HC_OPTS))
96
97
98 # We now define various i* variables, which are used for the paths
99 # when installing Cabal libraries
100 ifeq "$(RelocatableBuild)" "YES"
101 # On Windows we want to make moveable bindists, but we need to tell
102 # ghc-pkg where the haddock docs are. Therefore we completely ignore
103 # where the user tells us to put the haddock documentation and put it
104 # somewhere whose relative location we know. When installing we need
105 # to give Cabal a real path, though.
106 iprefix             = $$topdir
107 ibindir             = $$topdir
108 ilibdir             = $$topdir
109 ilibexecdir         = $$topdir
110 idynlibdir          = $$topdir
111 idatadir            = $$topdir
112 idocdir             = $$topdir/doc/libraries/$$pkg
113 ihaddockdir         = $$topdir/doc/libraries/$$pkg
114 ihtmldir            = $$httptopdir/doc/libraries/$$pkg
115 html_installed_root = $(prefix)/doc/libraries
116 else
117 # On non-Windows we can just give absolute paths all the time, and
118 # thus obey the htmldir that we are given.
119 iprefix             = $(prefix)
120 ibindir             = $(bindir)
121 ilibdir             = $(libdir)
122 ilibexecdir         = $(libexecdir)
123 idynlibdir          = $(dynlibdir)
124 idatadir            = $(datadir)
125 idocdir             = $(docdir)/libraries/$$pkg
126 ihaddockdir         = $(htmldir)/libraries/$$pkg
127 ihtmldir            = $(htmldir)/libraries/$$pkg
128 html_installed_root = $(htmldir)/libraries
129 endif
130