Fold integer-gmp.git into ghc.git (re #8545)
[ghc.git] / rules / build-package-data.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 define build-package-data
14 $(call trace, build-package-data($1,$2,$3))
15 $(call profStart, build-package-data($1,$2,$3))
16 # args:
17 # $1 = dir
18 # $2 = distdir
19 # $3 = GHC stage to use (0 == bootstrapping compiler)
20
21 $1_$2_CONFIGURE_OPTS += --disable-library-for-ghci
22 ifeq "$$(filter v,$$($1_$2_WAYS))" "v"
23 $1_$2_CONFIGURE_OPTS += --enable-library-vanilla
24 ifeq "$$(GhcWithInterpreter)" "YES"
25 ifneq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
26 $1_$2_CONFIGURE_OPTS += --enable-library-for-ghci
27 endif
28 endif
29 else
30 $1_$2_CONFIGURE_OPTS += --disable-library-vanilla
31 endif
32
33 ifeq "$$(filter p,$$($1_$2_WAYS))" "p"
34 $1_$2_CONFIGURE_OPTS += --enable-library-profiling
35 else
36 $1_$2_CONFIGURE_OPTS += --disable-library-profiling
37 endif
38
39 ifeq "$$(filter dyn,$$($1_$2_WAYS))" "dyn"
40 $1_$2_CONFIGURE_OPTS += --enable-shared
41 else
42 $1_$2_CONFIGURE_OPTS += --disable-shared
43 endif
44
45 ifeq "$$(HSCOLOUR_SRCS)" "YES"
46 $1_$2_CONFIGURE_OPTS += --with-hscolour="$$(HSCOLOUR_CMD)"
47 endif
48
49 # We filter out -Werror from SRC_CC_OPTS, because when configure tests
50 # for a feature it may not generate warning-free C code, and thus may
51 # think that the feature doesn't exist if -Werror is on.
52 $1_$2_CONFIGURE_CFLAGS = $$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS) $$(SRC_CC_WARNING_OPTS)
53 $1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$(CONF_GCC_LINKER_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)
54 $1_$2_CONFIGURE_CPPFLAGS = $$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS)
55
56 $1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$($1_$2_CONFIGURE_CFLAGS)"
57 $1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$($1_$2_CONFIGURE_LDFLAGS)"
58 $1_$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="$$($1_$2_CONFIGURE_CPPFLAGS)"
59
60 # Also pass these as gcc-options, because Cabal uses them to check for
61 # the existence of foreign libraries.
62 $1_$2_CONFIGURE_OPTS += --gcc-options="$$($1_$2_CONFIGURE_CFLAGS) $$($1_$2_CONFIGURE_LDFLAGS)"
63
64 ifneq "$$(ICONV_INCLUDE_DIRS)" ""
65 $1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="$$(ICONV_INCLUDE_DIRS)"
66 endif
67
68 ifneq "$$(ICONV_LIB_DIRS)" ""
69 $1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="$$(ICONV_LIB_DIRS)"
70 endif
71
72 ifneq "$$(GMP_INCLUDE_DIRS)" ""
73 $1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="$$(GMP_INCLUDE_DIRS)"
74 endif
75
76 ifneq "$$(GMP_LIB_DIRS)" ""
77 $1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="$$(GMP_LIB_DIRS)"
78 endif
79
80 ifeq "$$(CrossCompiling)" "YES"
81 $1_$2_CONFIGURE_OPTS += --configure-option=--host=$(TargetPlatformFull)
82 endif
83
84 ifeq "$3" "0"
85 $1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS)
86 endif
87
88 $1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)"
89
90 ifneq "$3" "0"
91 # There is no LD_STAGE0, Cabal will figure it out
92 $1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)"
93 endif
94
95 $1_$2_CONFIGURE_OPTS += --configure-option=--with-cc="$$(CC_STAGE$3)"
96 $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)"
97 $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)")
98 $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")
99
100 ifneq "$$(BINDIST)" "YES"
101 ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
102 $1/$2/inplace-pkg-config : $1/$2/package-data.mk
103 $1/$2/build/autogen/cabal_macros.h : $1/$2/package-data.mk
104
105 # This rule configures the package, generates the package-data.mk file
106 # for our build system, and registers the package for use in-place in
107 # the build tree.
108 $1/$2/package-data.mk : $$$$(ghc-cabal_INPLACE) $$($1_$2_GHC_PKG_DEP) $1/$$($1_PACKAGE).cabal $$(wildcard $1/configure) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_CONFIG_DEP)
109 # Checking packages built with the bootstrapping compiler would
110 # generally be a waste of time. Either we will rebuild them with
111 # stage1/stage2, or we don't really care about them.
112 ifneq "$3" "0"
113 ifneq "$$($1_NO_CHECK)" "YES"
114 "$$(ghc-cabal_INPLACE)" check $1
115 endif
116 endif
117 "$$(ghc-cabal_INPLACE)" configure $1 $2 "$$($1_$2_dll0_MODULES)" --with-ghc="$$($1_$2_HC_CONFIG)" --with-ghc-pkg="$$($1_$2_GHC_PKG)" $$($1_CONFIGURE_OPTS) $$($1_$2_CONFIGURE_OPTS)
118 ifeq "$$($1_$2_PROG)" ""
119 ifneq "$$($1_$2_REGISTER_PACKAGE)" "NO"
120 $$(call cmd,$1_$2_GHC_PKG) update --force $$($1_$2_GHC_PKG_OPTS) $1/$2/inplace-pkg-config
121 endif
122 endif
123 endif
124 endif
125
126 PACKAGE_DATA_MKS += $1/$2/package-data.mk
127
128 $(call profEnd, build-package-data($1,$2,$3))
129 endef