Fix the test for #13938
[ghc.git] / rules / distdir-opts.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
14 # Set compilation flags that do not depend on a particular way
15
16 define distdir-opts # args: $1 = dir, $2 = distdir, $3 = stage
17
18 ifeq "$3" ""
19 $$(error Stage not given for distdir-opts $1 $2)
20 endif
21
22 ifneq ($$(strip $$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED)),)
23 $1_$2_CC_INC_FLAGS := $$(subst $$(space)',$$(space)-I',$$(space)$$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED))
24 endif
25
26 # The CONF_CC_OPTS_STAGE$3 options are what we use to get gcc to
27 # behave correctly, but they are specific to the gcc that we are using.
28 # If GHC is compiling C code then it will take care of that for us,
29 # and in the case of the stage 0 compiler it may be using a different
30 # gcc, so we don't want to use our gcc-specific options.
31 $1_$2_DIST_GCC_CC_OPTS = \
32 $$(CONF_CC_OPTS_STAGE$3) \
33 $$($1_$2_DIST_CC_OPTS)
34
35 $1_$2_DIST_CC_OPTS = \
36 $$(SRC_CC_OPTS) \
37 $$($1_CC_OPTS) \
38 -I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
39 $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
40 $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
41 $$($1_$2_CC_OPTS) \
42 $$($1_$2_CPP_OPTS) \
43 $$($1_$2_CC_INC_FLAGS) \
44 $$($1_$2_DEP_CC_OPTS) \
45 $$(SRC_CC_WARNING_OPTS)
46
47 $1_$2_DIST_LD_OPTS = \
48 $$(SRC_LD_OPTS) \
49 $$($1_LD_OPTS) \
50 $$($1_$2_LD_OPTS) \
51 $$($1_$2_DIST_LD_LIB_DIRS) \
52 $$($1_$2_DEP_LD_OPTS)
53
54 # c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs
55 # We use '' around cflags and lflags to handle paths with backslashes in
56 # on Windows
57 ifneq ($$(strip $$($1_$2_DIST_GCC_CC_OPTS)),)
58 $1_$2_HSC2HS_CC_OPTS:=$$(shell for i in $$($1_$2_DIST_GCC_CC_OPTS); do echo \'--cflag=$$$$i\'; done)
59 endif
60 ifneq ($$(strip $$($1_$2_DIST_LD_OPTS)),)
61 $1_$2_HSC2HS_LD_OPTS:=$$(shell for i in $$($1_$2_DIST_LD_OPTS); do echo \'--lflag=$$$$i\'; done)
62 endif
63
64 $1_$2_ALL_HSC2HS_OPTS = \
65 '--cc=$$(CC_STAGE$3)' \
66 '--ld=$$(CC_STAGE$3)' \
67 $$(CONF_HSC2HS_OPTS) \
68 $$(SRC_HSC2HS_OPTS) \
69 $$(SRC_HSC2HS_OPTS_STAGE$3) \
70 --cflag=-D__GLASGOW_HASKELL__=$$(if $$(filter 0,$3),$$(GhcCanonVersion),$$(ProjectVersionInt)) \
71 $$($1_$2_HSC2HS_CC_OPTS) \
72 $$($1_$2_HSC2HS_LD_OPTS) \
73 --cflag=-I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
74 $$(if $$($1_PACKAGE),--cflag=-include --cflag=$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h) \
75 $$($$(basename $$<)_HSC2HS_OPTS) \
76 $$(EXTRA_HSC2HS_OPTS)
77
78 $1_$2_ALL_ALEX_OPTS = \
79 $$(CONF_ALEX_OPTS) \
80 $$(SRC_ALEX_OPTS) \
81 $$($1_ALEX_OPTS) \
82 $$($1_$2_ALEX_OPTS) \
83 $$(EXTRA_ALEX_OPTS)
84
85 $1_$2_ALL_HAPPY_OPTS = \
86 $$(CONF_HAPPY_OPTS) \
87 $$(SRC_HAPPY_OPTS) \
88 $$($1_HAPPY_OPTS) \
89 $$($1_$2_HAPPY_OPTS) \
90 $$(EXTRA_HAPPY_OPTS)
91
92 # We don't bother splitting the bootstrap packages (built with stage 0)
93 ifeq "$$($1_$2_SplitObjs)" ""
94 ifeq "$$(SplitObjs) $3" "YES 1"
95 $1_$2_SplitObjs = YES
96 else
97 $1_$2_SplitObjs = NO
98 endif
99 endif
100 # Disable split sections when building with stage0, it won't be supported yet
101 # and it's probably not very relevant anyway (smaller stage1 ghc?).
102 ifeq "$$($1_$2_SplitSections)" ""
103 ifeq "$3" "1"
104 $1_$2_SplitSections = $(SplitSections)
105 else
106 $1_$2_SplitSections = NO
107 endif
108 endif
109
110 endef
111