Make top-level "configure" accept and propagate --with-curses-{includes,libraries...
[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 ifneq "$$(CURSES_INCLUDE_DIRS)" ""
81 $1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-includes="$$(CURSES_INCLUDE_DIRS)"
82 endif
83
84 ifneq "$$(CURSES_LIB_DIRS)" ""
85 $1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)"
86 endif
87
88 ifeq "$$(CrossCompiling)" "YES"
89 $1_$2_CONFIGURE_OPTS += --configure-option=--host=$(TargetPlatformFull)
90 endif
91
92 ifeq "$3" "0"
93 $1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS)
94 endif
95
96 $1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)"
97
98 ifneq "$3" "0"
99 # There is no LD_STAGE0, Cabal will figure it out
100 $1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)"
101 endif
102
103 $1_$2_CONFIGURE_OPTS += --configure-option=--with-cc="$$(CC_STAGE$3)"
104 $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)"
105 $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)")
106 $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")
107
108 ifneq "$$(BINDIST)" "YES"
109 ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
110 $1/$2/inplace-pkg-config : $1/$2/package-data.mk
111 $1/$2/build/autogen/cabal_macros.h : $1/$2/package-data.mk
112
113 # This rule configures the package, generates the package-data.mk file
114 # for our build system, and registers the package for use in-place in
115 # the build tree.
116 $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)
117 # Checking packages built with the bootstrapping compiler would
118 # generally be a waste of time. Either we will rebuild them with
119 # stage1/stage2, or we don't really care about them.
120 ifneq "$3" "0"
121 ifneq "$$($1_NO_CHECK)" "YES"
122 "$$(ghc-cabal_INPLACE)" check $1
123 endif
124 endif
125 "$$(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)
126 ifeq "$$($1_$2_PROG)" ""
127 ifneq "$$($1_$2_REGISTER_PACKAGE)" "NO"
128 $$(call cmd,$1_$2_GHC_PKG) update --force $$($1_$2_GHC_PKG_OPTS) $1/$2/inplace-pkg-config
129 endif
130 endif
131 endif
132 endif
133
134 PACKAGE_DATA_MKS += $1/$2/package-data.mk
135
136 $(call profEnd, build-package-data($1,$2,$3))
137 endef