1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
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
11 # -----------------------------------------------------------------------------
14 # Set compilation flags that depend on a particular directory/distdir
16 define distdir-opts # args: $1 = dir, $2 = distdir
17 # $3 = GHC stage to use (0 == bootstrapping compiler)
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
30 $1_$2_DEP_INCLUDE_DIRS_FLAG = -isystem
32 $1_$2_DEP_INCLUDE_DIRS_FLAG = -I
35 $1_$2_BUILD_CC_OPTS = \
38 $$(foreach dir,$$($1_$2_INCLUDE_DIRS),-I$1/$$(dir)) \
41 $$(foreach dir,$$($1_$2_DEP_INCLUDE_DIRS),$$($1_$2_DEP_INCLUDE_DIRS_FLAG)$$(dir)) \
44 $1_$2_BUILD_LD_OPTS = \
48 $$(foreach opt,$$($1_$2_DEP_LIB_DIRS),-L$$(opt)) \
49 $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
52 # c.f. Cabal's Distribution.Simple.GHC.ghcOptions
53 $1_$2_BUILD_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,) \