GHC new build system megapatch
[ghc-hetmet.git] / rules / distdir-opts.mk
1
2 # Set compilation flags that depend on a particular directory/distdir
3
4 define distdir-opts # args: $1 = dir, $2 = distdir
5 # $3 = GHC stage to use (0 == bootstrapping compiler)
6
7 ifeq "$3" "0"
8 # This is a bit of a hack.
9 # If we are compiling something with the bootstrapping compiler on
10 # cygwin, and it uses an include file from the rts (say), then we
11 # need to stop mkdependC from generating a dependincy on
12 #     c:/ghc/rts/include/Rts.h
13 # as that confuses make. So we use -isystem instead of -I, which stops
14 # these dependencies from being generated. Technically this is wrong if
15 # we depend on a library that is built inside the build tree, and we
16 # use headers from that library, but currently I don't think that's the
17 # case.
18 $1_$2_DEP_INCLUDE_DIRS_FLAG = -isystem
19 else
20 $1_$2_DEP_INCLUDE_DIRS_FLAG = -I
21 endif
22
23 $1_$2_BUILD_CC_OPTS = \
24  $$(SRC_CC_OPTS) \
25  $$($1_CC_OPTS) \
26  $$(foreach dir,$$($1_$2_INCLUDE_DIRS),-I$1/$$(dir)) \
27  $$($1_$2_CC_OPTS) \
28  $$($1_$2_CPP_OPTS) \
29  $$(foreach dir,$$($1_$2_DEP_INCLUDE_DIRS),$$($1_$2_DEP_INCLUDE_DIRS_FLAG)$$(dir)) \
30  $$($1_$2_DEP_CC_OPTS)
31
32 $1_$2_BUILD_LD_OPTS = \
33  $$(SRC_LD_OPTS) \
34  $$($1_LD_OPTS) \
35  $$($1_$2_LD_OPTS) \
36  $$(foreach opt,$$($1_$2_DEP_LIB_DIRS),-L$$(opt)) \
37  $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
38  $$($1_$2_DEP_LD_OPTS)
39
40 # c.f. Cabal's Distribution.Simple.GHC.ghcOptions
41 $1_$2_BUILD_HC_OPTS = \
42  $$(SRC_HC_OPTS) \
43  $$($1_HC_OPTS) \
44  $$($1_$2_HC_PKGCONF) \
45  $$(if $$($1_$2_PROG),, \
46         $$(if $$($1_PACKAGE),-package-name $$($1_PACKAGE)-$$($1_$2_VERSION))) \
47  $$(if $$($1_PACKAGE),-hide-all-packages) \
48  -i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
49  -i$1/$2/build -i$1/$2/build/autogen \
50  -I$1/$2/build -I$1/$2/build/autogen \
51  $$(foreach dir,$$($1_$2_INCLUDE_DIRS),-I$1/$$(dir)) \
52  $$(foreach inc,$$($1_$2_INCLUDE),-\#include "$$(inc)") \
53  $$(foreach opt,$$($1_$2_CPP_OPTS),-optP$$(opt)) \
54  $$(if $$($1_PACKAGE),-optP-include -optP$1/$2/build/autogen/cabal_macros.h) \
55  $$(foreach pkg,$$($1_$2_DEPS),-package $$(pkg)) \
56  $$(if $$(findstring YES,$$($1_$2_SplitObjs)),-split-objs,) \
57  $$($1_$2_HC_OPTS)
58
59 endef
60