Testsuite: mark T8089 expect_broken(#7325) on Windows
[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 additionally 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 ifeq "$3" "0"
23 # This is a bit of a hack.
24 # If we are compiling something with the bootstrapping compiler on
25 # cygwin, and it uses an include file from the rts (say), then we
26 # need to stop mkdependC from generating a dependincy on
27 # c:/ghc/rts/include/Rts.h
28 # as that confuses make. So we use -isystem instead of -I, which stops
29 # these dependencies from being generated. Technically this is wrong if
30 # we depend on a library that is built inside the build tree, and we
31 # use headers from that library, but currently I don't think that's the
32 # case.
33 $1_$2_DEP_INCLUDE_DIRS_FLAG = -isystem
34 else
35 $1_$2_DEP_INCLUDE_DIRS_FLAG = -I
36 endif
37
38 ifneq ($$(strip $$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED)),)
39 $1_$2_CC_INC_FLAGS := $$(subst $$(space)',$$(space)$$($1_$2_DEP_INCLUDE_DIRS_FLAG)',$$(space)$$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED))
40 endif
41
42 # The CONF_CC_OPTS_STAGE$3 options are what we use to get gcc to
43 # behave correctly, but they are specific to the gcc that we are using.
44 # If GHC is compiling C code then it will take care of that for us,
45 # and in the case of the stage 0 compiler it may be using a different
46 # gcc, so we don't want to use our gcc-specific options.
47 $1_$2_DIST_GCC_CC_OPTS = \
48 $$(CONF_CC_OPTS_STAGE$3) \
49 $$($1_$2_DIST_CC_OPTS)
50
51 $1_$2_DIST_CC_OPTS = \
52 $$(SRC_CC_OPTS) \
53 $$($1_CC_OPTS) \
54 -I$1/$2/build/autogen \
55 $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
56 $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
57 $$($1_$2_CC_OPTS) \
58 $$($1_$2_CPP_OPTS) \
59 $$($1_$2_CC_INC_FLAGS) \
60 $$($1_$2_DEP_CC_OPTS) \
61 $$(SRC_CC_WARNING_OPTS)
62
63 ifneq ($$(strip $$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED)),)
64 $1_$2_DIST_LD_LIB_DIRS := $$(subst $$(space)',$$(space)-L',$$(space)$$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED))
65 endif
66
67 $1_$2_DIST_LD_OPTS = \
68 $$(SRC_LD_OPTS) \
69 $$($1_LD_OPTS) \
70 $$($1_$2_LD_OPTS) \
71 $$($1_$2_DIST_LD_LIB_DIRS) \
72 $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
73 $$($1_$2_DEP_LD_OPTS)
74
75 # c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs
76 # We use '' around cflags and lflags to handle paths with backslashes in
77 # on Windows
78 ifneq ($$(strip $$($1_$2_DIST_GCC_CC_OPTS)),)
79 $1_$2_HSC2HS_CC_OPTS:=$$(shell for i in $$($1_$2_DIST_GCC_CC_OPTS); do echo \'--cflag=$$$$i\'; done)
80 endif
81 ifneq ($$(strip $$($1_$2_DIST_LD_OPTS)),)
82 $1_$2_HSC2HS_LD_OPTS:=$$(shell for i in $$($1_$2_DIST_LD_OPTS); do echo \'--lflag=$$$$i\'; done)
83 endif
84
85 $1_$2_ALL_HSC2HS_OPTS = \
86 '--cc=$$(CC_STAGE$3)' \
87 '--ld=$$(CC_STAGE$3)' \
88 $$(CONF_HSC2HS_OPTS) \
89 $$(SRC_HSC2HS_OPTS) \
90 $$(SRC_HSC2HS_OPTS_STAGE$3) \
91 --cflag=-D__GLASGOW_HASKELL__=$$(if $$(filter 0,$3),$$(GhcCanonVersion),$$(ProjectVersionInt)) \
92 $$($1_$2_HSC2HS_CC_OPTS) \
93 $$($1_$2_HSC2HS_LD_OPTS) \
94 --cflag=-I$1/$2/build/autogen \
95 $$(if $$($1_PACKAGE),--cflag=-include --cflag=$1/$2/build/autogen/cabal_macros.h) \
96 $$($$(basename $$<)_HSC2HS_OPTS) \
97 $$(EXTRA_HSC2HS_OPTS)
98
99 $1_$2_ALL_ALEX_OPTS = \
100 $$(CONF_ALEX_OPTS) \
101 $$(SRC_ALEX_OPTS) \
102 $$($1_ALEX_OPTS) \
103 $$($1_$2_ALEX_OPTS) \
104 $$(EXTRA_ALEX_OPTS)
105
106 $1_$2_ALL_HAPPY_OPTS = \
107 $$(CONF_HAPPY_OPTS) \
108 $$(SRC_HAPPY_OPTS) \
109 $$($1_HAPPY_OPTS) \
110 $$($1_$2_HAPPY_OPTS) \
111 $$(EXTRA_HAPPY_OPTS)
112
113 endef
114