2248e2986f1568ee9c118d73367a7c420a66d1cb
[ghc-hetmet.git] / rules / distdir-way-opts.mk
1
2 # Set compilation flags that additionally depend on a particular way
3
4 define distdir-way-opts # args: $1 = dir, $2 = distdir, $3 = way
5
6 # Options for a Haskell compilation:
7 #   - SRC_HC_OPTS                  source-tree-wide options
8 #   - WAY_v_HC_OPTS                options for this way
9 #   - libraries/base_BUILD_HC_OPTS options from the build system for this dir
10 #   - -Idir1 -Idir2 ...            include-dirs from this package
11 #   - -odir/-hidir/-stubdir        put the output files under $3/build
12 #   - -osuf/-hisuf/-hcsuf          suffixes for the output files in this way
13 #   - EXTRA_HC_OPTS                options from the command-line
14
15 $1_$2_$3_MOST_HC_OPTS = \
16  $$(WAY_$3_HC_OPTS) \
17  $$($1_$2_BUILD_HC_OPTS) \
18  $$($1_$2_$3_HC_OPTS) \
19  $$($$*_HC_OPTS) \
20  $$(EXTRA_HC_OPTS)
21
22 # For real Haskell compilations we add -hidir etc.
23 $1_$2_$3_ALL_HC_OPTS = \
24  $$($1_$2_$3_MOST_HC_OPTS) \
25  -odir $1/$2/build -hidir $1/$2/build -stubdir $1/$2/build \
26  -hisuf $$($3_hisuf) -osuf  $$($3_osuf) -hcsuf $$($3_hcsuf)
27
28 # c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs
29 # We use '' around cflags and lflags to handle paths with backslashes in
30 # on Windows
31 $1_$2_$3_ALL_HSC2HS_OPTS = \
32  --cc=$$(WhatGccIsCalled) \
33  --ld=$$(WhatGccIsCalled) \
34  $$(SRC_HSC2HS_OPTS) \
35  $$(WAY_$3_HSC2HS_OPTS) \
36  --cflag=-D__GLASGOW_HASKELL__=$$(ProjectVersionInt) \
37  $$(foreach opt,$$($1_$2_BUILD_CC_OPTS),'--cflag=$$(opt)') \
38  $$(foreach opt,$$($1_$2_BUILD_LD_OPTS),'--lflag=$$(opt)') \
39  $$($$*_HSC2HS_OPTS) \
40  $$(EXTRA_HSC2HS_OPTS)
41
42 $1_$2_$3_ALL_CC_OPTS = \
43  $$(WAY_$3_CC_OPTS) \
44  $$($1_$2_BUILD_CC_OPTS) \
45  $$($1_$2_$3_CC_OPTS) \
46  $$($$*_CC_OPTS) \
47  $$(EXTRA_CC_OPTS)
48
49 $1_$2_$3_GHC_CC_OPTS = \
50  $$(addprefix -optc, $$($1_$2_$3_ALL_CC_OPTS)) \
51  $$($1_$2_$3_MOST_HC_OPTS)
52
53 $1_$2_$3_ALL_AS_OPTS = \
54  $$(SRC_AS_OPTS)
55  $$(WAY_$3_AS_OPTS) \
56  $$($1_AS_OPTS) \
57  $$($1_$2_AS_OPTS) \
58  $$($1_$2_$3_AS_OPTS) \
59  $$(EXTRA_AS_OPTS)
60
61 $1_$2_$3_ALL_ALEX_OPTS = \
62  $$(SRC_ALEX_OPTS)
63  $$(WAY_$3_ALEX_OPTS) \
64  $$($1_ALEX_OPTS) \
65  $$($1_$2_ALEX_OPTS) \
66  $$($1_$2_$3_ALEX_OPTS) \
67  $$(EXTRA_ALEX_OPTS)
68
69 $1_$2_$3_ALL_HAPPY_OPTS = \
70  $$(SRC_HAPPY_OPTS) \
71  $$(WAY_$3_HAPPY_OPTS) \
72  $$($1_HAPPY_OPTS) \
73  $$($1_$2_HAPPY_OPTS) \
74  $$($1_$2_$3_HAPPY_OPTS) \
75  $$(EXTRA_HAPPY_OPTS)
76
77 endef
78