add $(CONF_*_OPTS) for options that come from ./configure (fixes #3426)
[ghc-hetmet.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://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13
14 # Set compilation flags that depend on a particular directory/distdir
15
16 define distdir-opts # args: $1 = dir, $2 = distdir
17 # $3 = GHC stage to use (0 == bootstrapping compiler)
18
19 ifeq "$3" "0"
20 # This is a bit of a hack.
21 # If we are compiling something with the bootstrapping compiler on
22 # cygwin, and it uses an include file from the rts (say), then we
23 # need to stop mkdependC from generating a dependincy on
24 #     c:/ghc/rts/include/Rts.h
25 # as that confuses make. So we use -isystem instead of -I, which stops
26 # these dependencies from being generated. Technically this is wrong if
27 # we depend on a library that is built inside the build tree, and we
28 # use headers from that library, but currently I don't think that's the
29 # case.
30 $1_$2_DEP_INCLUDE_DIRS_FLAG = -isystem
31 else
32 $1_$2_DEP_INCLUDE_DIRS_FLAG = -I
33 endif
34
35 $1_$2_DIST_CC_OPTS = \
36  $$(CONF_CC_OPTS) \
37  $$(SRC_CC_OPTS) \
38  $$($1_CC_OPTS) \
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  $$(foreach dir,$$($1_$2_DEP_INCLUDE_DIRS),$$($1_$2_DEP_INCLUDE_DIRS_FLAG)$$(dir)) \
44  $$($1_$2_DEP_CC_OPTS)
45
46 $1_$2_DIST_LD_OPTS = \
47  $$(CONF_LD_OPTS) \
48  $$(SRC_LD_OPTS) \
49  $$($1_LD_OPTS) \
50  $$($1_$2_LD_OPTS) \
51  $$(foreach opt,$$($1_$2_DEP_LIB_DIRS),-L$$(opt)) \
52  $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
53  $$($1_$2_DEP_LD_OPTS)
54
55 # c.f. Cabal's Distribution.Simple.GHC.ghcOptions
56 $1_$2_DIST_HC_OPTS = \
57  $$(CONF_HC_OPTS) \
58  $$(SRC_HC_OPTS) \
59  $$($1_HC_OPTS) \
60  $$($1_$2_HC_PKGCONF) \
61  $$(if $$($1_$2_PROG),, \
62         $$(if $$($1_PACKAGE),-package-name $$($1_PACKAGE)-$$($1_$2_VERSION))) \
63  $$(if $$($1_PACKAGE),-hide-all-packages) \
64  -i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
65  -i$1/$2/build -i$1/$2/build/autogen \
66  -I$1/$2/build -I$1/$2/build/autogen \
67  $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
68  $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
69  $$(foreach inc,$$($1_$2_INCLUDE),-\#include "$$(inc)") \
70  $$(foreach opt,$$($1_$2_CPP_OPTS),-optP$$(opt)) \
71  $$(if $$($1_PACKAGE),-optP-include -optP$1/$2/build/autogen/cabal_macros.h) \
72  $$(foreach pkg,$$($1_$2_DEPS),-package $$(pkg)) \
73  $$(if $$(findstring YES,$$($1_$2_SplitObjs)),-split-objs,) \
74  $$($1_$2_HC_OPTS) \
75  $$($1_$2_EXTRA_HC_OPTS)
76
77 endef
78