circleci: Bump down thread count
[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 ifeq "$(V)" "0"
22 $1_$2_CONFIGURE_OPTS += -v0 --configure-option=--quiet
23
24 # Cabal always passes --with-compiler and --with-gcc to library configure
25 # scripts, resulting in the following useless (for us) warning in the logs:
26 # "configure: WARNING: unrecognized options: --with-compiler, --with-gcc"
27 $1_$2_CONFIGURE_OPTS += --configure-option=--disable-option-checking
28
29 $1_$2_GHC_PKG_OPTS += -v0
30 endif
31
32 $1_$2_CONFIGURE_OPTS += --disable-library-for-ghci
33 ifeq "$$(filter v,$$($1_$2_WAYS))" "v"
34 $1_$2_CONFIGURE_OPTS += --enable-library-vanilla
35 # Build the GHCi lib even if GHCi is dynamic (and therefore won't use
36 # these by default), because they will be used by
37 # (a) ghci -fexternal-interpreter
38 # (b) statically-linked binaries that use the GHC package
39 ifeq "$$(GhcWithInterpreter)" "YES"
40 $1_$2_CONFIGURE_OPTS += --enable-library-for-ghci
41 endif
42 else
43 $1_$2_CONFIGURE_OPTS += --disable-library-vanilla
44 endif
45
46 ifeq "$$(filter p,$$($1_$2_WAYS))" "p"
47 $1_$2_CONFIGURE_OPTS += --enable-library-profiling
48 else
49 $1_$2_CONFIGURE_OPTS += --disable-library-profiling
50 endif
51
52 ifeq "$$(filter dyn,$$($1_$2_WAYS))" "dyn"
53 $1_$2_CONFIGURE_OPTS += --enable-shared
54 else
55 $1_$2_CONFIGURE_OPTS += --disable-shared
56 endif
57
58 ifeq "$$(HSCOLOUR_SRCS)" "YES"
59 $1_$2_CONFIGURE_OPTS += --with-hscolour="$$(HSCOLOUR_CMD)"
60 endif
61
62 # We filter out -Werror from SRC_CC_OPTS, because when configure tests
63 # for a feature it may not generate warning-free C code, and thus may
64 # think that the feature doesn't exist if -Werror is on.
65 $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)
66 $1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)
67 $1_$2_CONFIGURE_CPPFLAGS = $$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS)
68
69 $1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$($1_$2_CONFIGURE_CFLAGS)"
70 $1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$($1_$2_CONFIGURE_LDFLAGS)"
71 $1_$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="$$($1_$2_CONFIGURE_CPPFLAGS)"
72
73 # Also pass these as gcc-options, because Cabal uses them to check for
74 # the existence of foreign libraries.
75 $1_$2_CONFIGURE_OPTS += --gcc-options="$$($1_$2_CONFIGURE_CFLAGS) $$($1_$2_CONFIGURE_LDFLAGS)"
76
77 ifneq "$$(ICONV_INCLUDE_DIRS)" ""
78 $1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="$$(ICONV_INCLUDE_DIRS)"
79 endif
80
81 ifneq "$$(ICONV_LIB_DIRS)" ""
82 $1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="$$(ICONV_LIB_DIRS)"
83 endif
84
85 ifneq "$$(GMP_INCLUDE_DIRS)" ""
86 $1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="$$(GMP_INCLUDE_DIRS)"
87 endif
88
89 ifneq "$$(GMP_LIB_DIRS)" ""
90 $1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="$$(GMP_LIB_DIRS)"
91 endif
92
93 ifneq "$$(CURSES_LIB_DIRS)" ""
94 $1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)"
95 endif
96
97 ifeq "$$(CrossCompiling)" "YES"
98 $1_$2_CONFIGURE_OPTS += --configure-option=--host=$(TargetPlatformFull)
99 endif
100
101 ifeq "$3" "0"
102 $1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS)
103 endif
104
105 $1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)"
106 $1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)"
107 $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)"
108 $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)")
109 $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")
110
111 ifneq "$$(BINDIST)" "YES"
112 ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
113 $1/$2/inplace-pkg-config : $1/$2/package-data.mk
114 $1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h : $1/$2/package-data.mk
115
116 # This rule configures the package, generates the package-data.mk file
117 # for our build system, and registers the package for use in-place in
118 # the build tree.
119 $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)
120 # Checking packages built with the bootstrapping compiler would
121 # generally be a waste of time. Either we will rebuild them with
122 # stage1/stage2, or we don't really care about them.
123 ifneq "$3" "0"
124 ifneq "$$($1_NO_CHECK)" "YES"
125 "$$(ghc-cabal_INPLACE)" check $1
126 endif
127 endif
128 "$$(ghc-cabal_INPLACE)" configure $1 $2 --with-ghc="$$($1_$2_HC_CONFIG)" --with-ghc-pkg="$$($1_$2_GHC_PKG)" $$($1_CONFIGURE_OPTS) $$($1_$2_CONFIGURE_OPTS)
129 ifeq "$$($1_$2_PROG)" ""
130 $$(call cmd,$1_$2_GHC_PKG) update -v0 --force $$($1_$2_GHC_PKG_OPTS) $1/$2/inplace-pkg-config
131 endif
132 endif # NO_GENERATED_MAKEFILE_RULES
133 endif # BINDIST
134
135 PACKAGE_DATA_MKS += $1/$2/package-data.mk
136
137 $(call profEnd, build-package-data($1,$2,$3))
138 endef