Improve error messages for type functions
[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_BUILD_CC_OPTS = \
36  $$(SRC_CC_OPTS) \
37  $$($1_CC_OPTS) \
38  $$(foreach dir,$$($1_$2_INCLUDE_DIRS),-I$1/$$(dir)) \
39  $$($1_$2_CC_OPTS) \
40  $$($1_$2_CPP_OPTS) \
41  $$(foreach dir,$$($1_$2_DEP_INCLUDE_DIRS),$$($1_$2_DEP_INCLUDE_DIRS_FLAG)$$(dir)) \
42  $$($1_$2_DEP_CC_OPTS)
43
44 $1_$2_BUILD_LD_OPTS = \
45  $$(SRC_LD_OPTS) \
46  $$($1_LD_OPTS) \
47  $$($1_$2_LD_OPTS) \
48  $$(foreach opt,$$($1_$2_DEP_LIB_DIRS),-L$$(opt)) \
49  $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
50  $$($1_$2_DEP_LD_OPTS)
51
52 # c.f. Cabal's Distribution.Simple.GHC.ghcOptions
53 $1_$2_BUILD_HC_OPTS = \
54  $$(SRC_HC_OPTS) \
55  $$($1_HC_OPTS) \
56  $$($1_$2_HC_PKGCONF) \
57  $$(if $$($1_$2_PROG),, \
58         $$(if $$($1_PACKAGE),-package-name $$($1_PACKAGE)-$$($1_$2_VERSION))) \
59  $$(if $$($1_PACKAGE),-hide-all-packages) \
60  -i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
61  -i$1/$2/build -i$1/$2/build/autogen \
62  -I$1/$2/build -I$1/$2/build/autogen \
63  $$(foreach dir,$$($1_$2_INCLUDE_DIRS),-I$1/$$(dir)) \
64  $$(foreach inc,$$($1_$2_INCLUDE),-\#include "$$(inc)") \
65  $$(foreach opt,$$($1_$2_CPP_OPTS),-optP$$(opt)) \
66  $$(if $$($1_PACKAGE),-optP-include -optP$1/$2/build/autogen/cabal_macros.h) \
67  $$(foreach pkg,$$($1_$2_DEPS),-package $$(pkg)) \
68  $$(if $$(findstring YES,$$($1_$2_SplitObjs)),-split-objs,) \
69  $$($1_$2_HC_OPTS)
70
71 endef
72