4d5d82aa80b1f61d51d0b4ef477f4877265907c8
[ghc.git] / mk / config.mk.in
1 # -*-makefile-*-
2 # @configure_input@
3 #
4 ################################################################################
5 #
6 # config.mk.in
7 #
8 # This file supplies defaults for many tweakable build configuration
9 # options. Some of the defaults are filled in by the autoconf-generated
10 # configure script.
11 #
12 # DO NOT EDIT THIS FILE!
13 #
14 # - config.mk is auto-generated from config.mk.in by configure.
15 # If you edit config.mk your changes will be spammed.
16 #
17 # - Settings in this file may be overriden by giving replacement
18 # definitions in build.mk. See build.mk.sample for a good
19 # starting point for a build.mk file.
20 #
21 # If you don't have a build.mk file then you get defaults for everything.
22 # The defaults should provide a reasonable vanilla build.
23
24 # TOP: the top of the fptools hierarchy, absolute path.
25 # On Windows this is a c:/foo/bar style path.
26 TOP = @hardtop@
27
28 include $(TOP)/mk/project.mk
29
30 # By default, be verbose
31 V = 1
32
33 ################################################################################
34 #
35 # Global configuration options
36 #
37 ################################################################################
38
39 NO_INCLUDE_DEPS = NO
40 NO_INCLUDE_PKGDATA = NO
41
42 ################################################################################
43 #
44 # Variables that control how the compiler itself is built
45 #
46 ################################################################################
47
48 # The compiler used to build GHC is $(GHC). To change the actual compiler
49 # used, re-configure with --with-ghc=<path-to-ghc>.
50
51 # Extra option flags to pass to the compiler that compiles the compiler
52 # (Ones that are essential are wired into compiler/Makefile)
53 # Typical options to use here:
54 #
55 # -DDEBUG include debugging code and assertions (will make the
56 # compiler slower and produce debugging output, but useful
57 # for development)
58 #
59 # -dcore-lint check the types after every pass of the compiler;
60 # a pretty strong internal check of the compiler being
61 # used to compile GHC. Useful when bootstrapping.
62 GhcHcOpts=-Rghc-timing
63
64 # Extra options added to specific stages of the compiler bootstrap.
65 # These are placed later on the command line, and may therefore
66 # override options from $(GhcHcOpts).
67 #
68 # See Note [Stage number in build variables].
69 GhcStage1HcOpts=
70 GhcStage2HcOpts=-O2
71 GhcStage3HcOpts=-O2
72
73 # Disable -O2 optimization. Otherwise amount of generated C code
74 # makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.hs')
75 # and sometimes not compile at all (powerpc64 overflows something
76 # on 'compiler/hsSyn/HsExpr.hs').
77 ifeq "$(GhcUnregisterised)" "YES"
78 GhcStage1HcOpts=
79 GhcStage2HcOpts=
80 GhcStage3HcOpts=
81 endif
82
83 # Note [Stage number in build variables].
84 #
85 # There are (unfortunately) two different naming schemes for build variables
86 # specific to a certain stage.
87 #
88 # * GhcStage1HcOpts/GhcStage2HcOpts/GhcStage3HcOpts:
89 #
90 # The stage number refers to the compiler stage being built (ghc library
91 # and executable).
92 #
93 # * SRC_HC_OPTS_STAGE$4 and SRC_HC_WARNING_OPTS_STAGE$4:
94 #
95 # The stage number refers to the compiler stage the options are passed to.
96
97 GhcDebugged=NO
98 GhcDynamic=NO
99
100 # GhcProfiled=YES means compile a profiled stage-2 compiler
101 GhcProfiled=NO
102
103 # WITH_TERMINFO can be used to disable terminfo support throughout the compiler
104 # and its tools. This is handy in the case of cross-compilation, where we may
105 # not have an ncurses build for the target.
106 ifeq "$(TargetOS_CPP)" "ios"
107 # iOS has no terminfo support
108 WITH_TERMINFO=NO
109 else ifeq "$(Windows_Target)" "YES"
110 WITH_TERMINFO=NO
111 else
112 WITH_TERMINFO=YES
113 endif
114
115 ifeq "$(findstring $(TargetOS_CPP),linux freebsd dragonfly openbsd netbsd solaris2 kfreebsdgnu haiku linux-android)" ""
116 TargetElf = NO
117 else
118 TargetElf = YES
119 endif
120
121 # Some platforms don't support shared libraries
122 NoSharedLibsPlatformList = \
123 powerpc-ibm-aix \
124 x86_64-unknown-mingw32 \
125 i386-unknown-mingw32
126
127 ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
128 NoSharedLibsPlatformList += i386-unknown-solaris2
129 endif
130
131 PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
132 $(NoSharedLibsPlatformList)),NO,YES)
133
134 # DYNAMIC_BY_DEFAULT says whether this compiler will default to
135 # building dynamic executables, i.e. -dynamic is on. We do this for
136 # most platforms because it lets us use the system dynamic linker
137 # instead of our own linker for GHCi.
138 #
139 # Currently this isn't possible on Windows, and we have not yet enabled
140 # it on i386 while we consider the performance implications.
141 #
142 ifeq "$(TargetOS_CPP)" "mingw32"
143 DYNAMIC_BY_DEFAULT = NO
144 else ifeq "$(TargetArch_CPP)" "i386"
145 DYNAMIC_BY_DEFAULT = NO
146 else
147 DYNAMIC_BY_DEFAULT = YES
148 endif
149
150 # For now, we unconditionally disable dynamic-by-default, as the
151 # cabal-install's that are in the wild don't handle it properly.
152 DYNAMIC_BY_DEFAULT = NO
153
154 # If building both v and dyn ways, then use -dynamic-too to build them.
155 # This makes the build faster.
156 DYNAMIC_TOO = YES
157
158 # Use the dynamic way when building programs in the GHC tree. In
159 # particular, this means that GHCi will use DLLs rather than loading
160 # object files directly.
161 ifeq "$(TargetOS_CPP)" "mingw32"
162 # This doesn't work on Windows yet
163 DYNAMIC_GHC_PROGRAMS = NO
164 DYNAMIC_TOO=NO
165 else ifeq "$(PlatformSupportsSharedLibs)" "NO"
166 DYNAMIC_GHC_PROGRAMS = NO
167 else
168 DYNAMIC_GHC_PROGRAMS = YES
169 endif
170
171 # Build a compiler that will build *unregisterised* libraries and
172 # binaries by default. Unregisterised code is supposed to compile and
173 # run without any support for architecture-specific assembly mangling,
174 # register assignment or tail-calls, and is therefore a good way to get
175 # started when porting GHC to new architectures.
176 #
177 # NOTE: the stage1 compiler will be a registerised binary (assuming
178 # the compiler you build with is generating registerised binaries), but
179 # the stage2 compiler will be an unregisterised binary.
180 #
181 GhcUnregisterised=@Unregisterised@
182
183 # Build a compiler with a native code generator backend
184 # (as well as a C backend)
185 #
186 # Target platforms supported:
187 # i386, powerpc, powerpc64, sparc
188 # IOS is not supported
189 ArchSupportsNCG=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc)))
190 OsSupportsNCG=$(strip $(patsubst $(TargetOS_CPP), YES, $(patsubst ios,,$(TargetOS_CPP))))
191
192 GhcWithNativeCodeGen := $(strip\
193 $(if $(filter YESYESNO,\
194 $(OsSupportsNCG)$(ArchSupportsNCG)$(GhcUnregisterised)),YES,NO))
195
196 HaveLibDL = @HaveLibDL@
197
198 # ArchSupportsSMP should be set iff there is support for that arch in
199 # includes/stg/SMP.h
200 ifeq "$(TargetArch_CPP)" "arm"
201 # We don't support load/store barriers pre-ARMv7. See #10433.
202 ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES)
203 else
204 ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le aarch64)))
205 endif
206
207 # The THREADED_RTS requires `BaseReg` to be in a register and the
208 # `GhcUnregisterised` mode doesn't allow that.
209 GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
210
211 # Whether to include GHCi in the compiler. Depends on whether the RTS linker
212 # has support for this OS/ARCH combination.
213
214 OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
215 ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc sparc64 arm aarch64)))
216
217 ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
218 GhcWithInterpreter=YES
219 else
220 GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_GHC_PROGRAMS)),YES,NO)
221 endif
222
223 # GhcEnableTablesNextToCode tells us whether the target architecture
224 # supports placing info tables directly before the entry code
225 # (see TABLES_NEXT_TO_CODE in the RTS). Whether we actually compile for
226 # TABLES_NEXT_TO_CODE depends on whether we're building unregisterised
227 # code or not, which may be decided by options to the compiler later.
228 ifneq "$(findstring $(TargetArch_CPP)X, ia64X powerpc64X powerpc64leX)" ""
229 GhcEnableTablesNextToCode=NO
230 else
231 GhcEnableTablesNextToCode=YES
232 endif
233
234 # Whether to use libffi for adjustors (foreign import "wrapper") or
235 # not. If we have built-in support (rts/Adjustor.c) then we use that,
236 # otherwise we fall back on libffi, which is slightly slower.
237 ArchHasAdjustorSupport = $(if $(findstring $(TargetArch_CPP),i386 x86_64),YES,NO)
238 ifeq "$(ArchHasAdjustorSupport)" "YES"
239 UseLibFFIForAdjustors=NO
240 else
241 UseLibFFIForAdjustors=YES
242 endif
243
244 # On Windows we normally want to make a relocatable bindist, to we
245 # ignore flags like libdir
246 ifeq "$(Windows_Host)" "YES"
247 RelocatableBuild = YES
248 else
249 RelocatableBuild = NO
250 endif
251
252 # needs to be after $(RelocatableBuild) is set above
253 include $(TOP)/mk/install.mk
254
255 # When building bindists we set this to yes so that the binaries are as
256 # portable as possible.
257 BeConservative = NO
258
259 ExtraMakefileSanityChecks = NO
260
261 #------------------------------------------------------------------------------
262 # Options for Libraries
263
264 # Which directory (in libraries/) contains the integer library?
265 INTEGER_LIBRARY=integer-gmp
266
267 # We build the libraries at least the "vanilla" way (way "v")
268 # Technically we don't need the v way if DYNAMIC_GHC_PROGRAMS is YES,
269 # but with -dynamic-too it's cheap, and makes life easier.
270 GhcLibWays = v
271
272 # In addition to the normal sequential way, the default is to also build
273 # profiled prelude libraries
274 # $(if $(filter ...)) allows controlling this expression from build.mk.
275 GhcLibWays += $(if $(filter $(BUILD_PROF_LIBS),NO),,p)
276
277 # Backward compatibility: although it would be cleaner to test for
278 # PlatformSupportsSharedLibs, or perhaps a new variable BUILD_SHARED_LIBS,
279 # some users currently expect that DYNAMIC_GHC_PROGRAMS=NO in build.mk implies
280 # that dyn is not added to GhcLibWays.
281 GhcLibWays += $(if $(filter $(DYNAMIC_GHC_PROGRAMS),NO),,dyn)
282
283 # Handy way to test whether we're building shared libs or not.
284 BuildSharedLibs=$(strip $(if $(findstring dyn,$(GhcLibWays)),YES,NO))
285
286 # In addition, the RTS is built in some further variations. Ways that
287 # make sense here:
288 #
289 # thr : threaded
290 # thr_p : threaded + profiled + eventlog
291 # debug : debugging + eventlog
292 # thr_debug : debugging + threaded, + eventlog
293 # l : eventlog
294 # p : profiled + eventlog
295 # thr_l : threaded + eventlog
296 #
297 # Note how there are a few cases which are handled specially (in packageHsLibs)
298 # to reduce the number of distinct ways,
299 #
300 # debug implies eventlog
301 # profiled implies eventlog
302 #
303 # This means, for instance, that there is no debug_l way.
304 #
305 GhcRTSWays=l
306
307 # Usually want the debug version
308 GhcRTSWays += debug
309
310 # We always have the threaded versions, but note that SMP support may be disabled
311 # (see GhcWithSMP).
312 GhcRTSWays += thr thr_debug thr_l
313 GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p,)
314 GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,)
315
316 # We can only build GHCi threaded if we have a threaded RTS:
317 GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
318
319 # Option flags to pass to GHC when it's compiling modules in
320 # fptools/libraries. Typically these are things like -O or
321 # -dcore-lint or -H32m. The ones that are *essential* are wired into
322 # the build system.
323 #
324 # -O(2) is pretty desirable, otherwise no inlining of prelude
325 # things (incl "+") happens when compiling with this compiler
326
327 GhcLibHcOpts=-O2
328
329 # Strip local symbols from libraries? This can make the libraries smaller,
330 # but makes debugging somewhat more difficult. Doesn't work with all ld's.
331 #
332 StripLibraries=NO
333
334 # ----------------------------------------------------------------------------
335 # Object-file splitting
336 #
337 # Set SplitObjs=YES or NO in your build.mk
338 #
339 # Don't use -split-objs in in GhcLibHcOpts, because the build
340 # system needs to do other special magic if you are
341 # doing object-file splitting
342
343 ArchSupportsSplitObjs=$(if $(filter \
344 $(TargetArch_CPP),i386 x86_64 powerpc sparc),YES,NO)#
345
346 # We used to support splitting on Darwin, but there is no point, since Darwin
347 # uses subsections via symbols
348 OsSupportsSplitObjs=$(if $(filter $(TargetOS_CPP),\
349 mingw32 linux solaris2 freebsd dragonfly netbsd openbsd),YES,NO)
350 SplitObjsBroken = @SplitObjsBroken@
351
352 SupportsSplitObjs := $(if $(and $(filter YES,$(ArchSupportsSplitObjs)),\
353 $(filter YES,$(OsSupportsSplitObjs)),\
354 $(filter NO,$(SplitObjsBroken)),\
355 $(filter YES,$(GhcWithNativeCodeGen))),YES,NO)
356
357 # By default, enable SplitObjs for the libraries if this build supports it.
358 # Unless SplitSections is enabled - then let that take precedence.
359 SplitObjs = $(if $(and $(filter YES,$(SupportsSplitObjs)),\
360 $(filter NO,$(SplitSections))),YES,NO)
361
362 # ----------------------------------------------------------------------------
363 # Section splitting
364 #
365 # Similar to -ffunction-sections -fdata-sections in GCC. Provides space saving
366 # like SplitObjs, but doesn't require post-processing and splitting of object
367 # files.
368 #
369 # Set SplitSections=YES or NO in your build.mk to override the default.
370 #
371 # This is not supported on Darwin (where you can use subsections-via-symbols
372 # instead) and Windows is not yet working. (See #11445 and related tickets.)
373 OsSupportsSplitSections=$(if $(filter $(TargetOS_CPP),mingw32 darwin),NO,YES)
374 SupportsSplitSections=$(if $(and $(filter YES,$(OsSupportsSplitSections)),\
375 $(filter YES,$(LdIsGNULd))),YES,NO)
376 SplitSections ?= $(SupportsSplitSections)
377
378 # ----------------------------------------------------------------------------
379
380 # There are a number of things which technically depend on GHC (e.g. if
381 # ghc changes then Haskell files may be compiled differently, or Cabal
382 # packages may be configured differently). By default we therefore
383 # have dependencies on the compiler executable.
384
385 # However, in practice, having a dependency on GHC is just a pain: We
386 # normally don't want to spend time recompiling other things while
387 # we're working on the compiler, and even if we did, GHC will normally
388 # decide compilation isn't needed anyway. So by setting LAX_DEPENDENCIES
389 # to YES you can turn these dependencies into order-only dependencies,
390 # i.e. GHC must exist, but if it's newer than other targets then
391 # rebuilding is not necessary.
392
393 LAX_DEPENDENCIES = NO
394
395 # ----------------------------------------------------------------------------
396 # Options for GHC's RTS
397
398 # Build an optimised RTS. Remember that we need to turn on
399 # optimisation both for C code (-optc-O2) and .cmm code (-O2). For
400 # the debugging RTS flavour, rts/ghc.mk overrides these to turn off
401 # optimisation.
402 GhcRtsHcOpts=-O2
403 GhcRtsCcOpts=-O2 -fomit-frame-pointer -g
404
405 # Configuration for libffi
406 UseSystemLibFFI=@UseSystemLibFFI@
407 # Flags to go into package.conf for rts
408 FFILibDir=@FFILibDir@
409 FFIIncludeDir=@FFIIncludeDir@
410
411 # GHC needs arch-specific tweak at least in
412 # rts/Libdw.c:set_initial_registers()
413 GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64),@UseLibdw@,NO))
414
415 ################################################################################
416 #
417 # Paths (see paths.mk)
418 #
419 ################################################################################
420
421 BIN_DIST_NAME = ghc-$(ProjectVersion)
422 BIN_DIST_PREP_DIR = bindistprep/$(BIN_DIST_NAME)
423 BIN_DIST_PREP_TAR = bindistprep/$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
424 BIN_DIST_PREP_TAR_COMP = $(BIN_DIST_PREP_TAR).$(TAR_COMP_EXT)
425 BIN_DIST_TAR_COMP = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT)
426
427 # -----------------------------------------------------------------------------
428 # Utilities programs: flags
429
430 # If you want to give any standard flags to pretty much any utility
431 # (see utils.mk for a complete list), by adding a line here
432 #
433 # SRC_P_OPTS += ...
434 #
435 # where P is the utility. For example, to add -O to all Haskell
436 # compilations,
437 #
438 # SRC_HC_OPTS += -O
439
440
441 # SRC_HC_OPTS includes flags to be added to *every* Haskell
442 # compilation. Setting SRC_HC_OPTS is a good way to set the default
443 # optimisation level (-O) and heap size (-H<size>).
444 #
445 # SRC_HC_OPTS is *not* for adding flags that are required to make your
446 # build work. Examples:
447 #
448 # - instead of using -pgmc/-pgma-/-pgml, use the --with-gcc option to configure
449 #
450 # - if you need -optc, -opta, or -optl flags, the CONF_CC_* and CONF_LD_*
451 # variables are more appropriate (set via configure)
452 #
453 # Note that SRC_HC_OPTS are added to every Haskell compilation,
454 # including when using the bootstrapping compiler (stage 0), So don't
455 # put options here that are only supported by very recent GHCs.
456 #
457 SRC_HC_OPTS += -H32m -O
458
459
460 # See Note [Stage number in build variables].
461 SRC_HC_OPTS_STAGE0 =
462 SRC_HC_OPTS_STAGE1 =
463 SRC_HC_OPTS_STAGE2 =
464
465 # Warning suppression flags. See mk/warnings.mk.
466 SRC_CC_WARNING_OPTS =
467 SRC_HC_WARNING_OPTS =
468
469 # See Note [Stage number in build variables].
470 SRC_HC_WARNING_OPTS_STAGE0 =
471 SRC_HC_WARNING_OPTS_STAGE1 =
472 SRC_HC_WARNING_OPTS_STAGE2 =
473
474 # -----------------------------------------------------------------------------
475 # Names of programs in the GHC tree
476
477 MKDIRHIER = $(INPLACE_BIN)/mkdirhier
478
479 GENERATED_FILE = chmod a-w
480 EXECUTABLE_FILE = chmod +x
481
482 #-----------------------------------------------------------------------------
483 # Installed GHC
484
485 # $(GHC) points to installed version of the compiler.
486 #
487 # NOTE: Don't override $(GHC) in build.mk, use configure --with-ghc instead
488 # (because the version numbers have to be calculated).
489
490 GHC := @WithGhc@
491 # If we have a make dependency on c:/ghc/ghc, and the file is actually
492 # called c:/ghc/ghc.exe, then make will think that ghc doesn't exist
493 # and that it doesn't know how to create it.
494 ifneq "$(wildcard $(GHC).exe)" ""
495 GHC := $(GHC).exe
496 endif
497
498 GHC_STAGE0 = $(GHC)
499 GHC_STAGE1 = $(ghc-stage1_INPLACE)
500 GHC_STAGE2 = $(ghc-stage2_INPLACE)
501 GHC_STAGE3 = $(ghc-stage3_INPLACE)
502
503 BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
504
505 INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
506
507 GhcVersion = @GhcVersion@
508 GhcPatchLevel = @GhcPatchLevel@
509 GhcMajVersion = @GhcMajVersion@
510 GhcMinVersion = @GhcMinVersion@
511
512 # Canonicalised ghc version number, used for easy (integer) version
513 # comparisons. We must expand $(GhcMinVersion) to two digits by
514 # adding a leading zero if necessary:
515 ifneq "$(findstring $(GhcMinVersion), 0 1 2 3 4 5 6 7 8 9)" ""
516 GhcCanonVersion = $(GhcMajVersion)0$(GhcMinVersion)
517 else
518 GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion)
519 endif
520
521 GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
522
523 SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
524
525 #-----------------------------------------------------------------------------
526 # C compiler
527 #
528 # NB. Don't override $(CC) using build.mk, re-configure using
529 # the flag CC=<blah> instead. The reason is that the configure script
530 # needs to know which gcc you're using in order to perform its tests.
531
532 GccVersion = @GccVersion@
533 CrossCompilePrefix = @CrossCompilePrefix@
534 # TargetPlatformFull retains the string passed to configure so we have it in
535 # the necessary format to pass to libffi's configure.
536 TargetPlatformFull = @TargetPlatformFull@
537 GccLT34 = @GccLT34@
538 GccLT44 = @GccLT44@
539 GccLT46 = @GccLT46@
540 GccIsClang = @GccIsClang@
541
542 CC = @CC@
543 CC_STAGE0 = @CC_STAGE0@
544 CC_STAGE1 = $(CC)
545 CC_STAGE2 = $(CC)
546 CC_STAGE3 = $(CC)
547
548 AS = @CC@
549 AS_STAGE0 = @CC_STAGE0@
550 AS_STAGE1 = $(AS)
551 AS_STAGE2 = $(AS)
552 AS_STAGE3 = $(AS)
553
554 # why no LD=@LD@ ?
555 LD_STAGE0 = @LD_STAGE0@
556 LD_STAGE1 = $(LD)
557 LD_STAGE2 = $(LD)
558 LD_STAGE3 = $(LD)
559
560 # Cross-compiling options
561 # See Note [CrossCompiling vs Stage1Only]
562 CrossCompiling = @CrossCompiling@
563
564 # Change this to YES if you're building a cross-compiler and don't
565 # want to build stage 2.
566 # See Note [CrossCompiling vs Stage1Only]
567 # See Note [Stage1Only vs stage=1]
568 Stage1Only = NO
569
570 # Install stage 2 by default, or stage 1 in the cross compiler
571 # case. Can be changed to 3
572 INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2)
573
574 # Note [CrossCompiling vs Stage1Only]
575 #
576 # There are 4 possible settings:
577 #
578 # 1 CrossCompiling=NO Stage1Only=NO
579 # The default.
580 #
581 # 2 CrossCompiling=NO Stage1Only=YES
582 # Don't build ghc-stage2. See Note [Stage1Only vs stage=1].
583 #
584 # 3 CrossCompiling=YES Stage1Only=YES
585 # Building a cross-compiler (ghc-stage1). See [1] and
586 # Note [Stage1Only vs stage=1].
587 #
588 # 4 CrossCompiling=YES Stage1Only=NO
589 # Cross-compiling GHC itself. See [1].
590 #
591 # [1] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
592
593 # Note [Stage1Only vs stage=1]
594 #
595 # Stage1Only=YES means:
596 # - don't build ghc-stage2 (the executable)
597 # - don't build utils that rely on ghc-stage2
598 # See Note [No stage2 packages when CrossCompiling or Stage1Only] in
599 # ./ghc.mk.
600 # - install ghc-stage1 instead of ghc-stage2
601 # - install the ghc-pkg that was built with the stage0 compiler
602 # - (*do* still build compiler/stage2 (i.e. the ghc library))
603 # - (*do* still build all other libraries)
604 #
605 # stage=1 means:
606 # - don't build compiler/stage2 (i.e. the ghc library)
607 # - don't build ghc-stage2 (the executable)
608 # Note: these are the only two things it does. If you want to exclude more
609 # stuff, combine it with Stage1Only=YES, or run make in the ghc or compiler
610 # directory.
611 #
612 # running make in the ghc or compiler directory means:
613 # - don't build any packages in the libraries/ directory, except the ones
614 # listed in PACKAGES_STAGE0 (i.e. the boot libraries)
615 #
616 # You may wonder why Stage1Only=YES still builds compiler/stage2. Quoting
617 # simonmar in #7639:
618 #
619 # "strictly speaking building compiler/stage2 is correct, because it is
620 # the ghc package that can be used with [ghc-stage1]. If you don't
621 # want to build it, then setting stage=1 in your mk/build.mk should
622 # disable it."
623
624 # C compiler and linker flags from configure (e.g. -m<blah> to select
625 # correct C compiler backend). The stage number is the stage of GHC
626 # that is being used to compile with.
627 CONF_CC_OPTS_STAGE0 = @CONF_CC_OPTS_STAGE0@
628 CONF_CC_OPTS_STAGE1 = @CONF_CC_OPTS_STAGE1@
629 CONF_CC_OPTS_STAGE2 = @CONF_CC_OPTS_STAGE2@
630 CONF_GCC_LINKER_OPTS_STAGE0 = @CONF_GCC_LINKER_OPTS_STAGE0@
631 CONF_GCC_LINKER_OPTS_STAGE1 = @CONF_GCC_LINKER_OPTS_STAGE1@
632 CONF_GCC_LINKER_OPTS_STAGE2 = @CONF_GCC_LINKER_OPTS_STAGE2@
633 CONF_LD_LINKER_OPTS_STAGE0 = @CONF_LD_LINKER_OPTS_STAGE0@
634 CONF_LD_LINKER_OPTS_STAGE1 = @CONF_LD_LINKER_OPTS_STAGE1@
635 CONF_LD_LINKER_OPTS_STAGE2 = @CONF_LD_LINKER_OPTS_STAGE2@
636 CONF_CPP_OPTS_STAGE0 = @CONF_CPP_OPTS_STAGE0@
637 CONF_CPP_OPTS_STAGE1 = @CONF_CPP_OPTS_STAGE1@
638 CONF_CPP_OPTS_STAGE2 = @CONF_CPP_OPTS_STAGE2@
639 CONF_HC_OPTS_STAGE0 = @CONF_HC_OPTS_STAGE0@
640 CONF_HC_OPTS_STAGE1 = @CONF_HC_OPTS_STAGE1@
641 CONF_HC_OPTS_STAGE2 = @CONF_HC_OPTS_STAGE2@
642
643 # The .hsc files aren't currently safe for cross-compilation on Windows:
644 # libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:160
645 # directive "let" is not safe for cross-compilation
646 ifneq "$(Windows_Host)" "YES"
647 SRC_HSC2HS_OPTS += --cross-safe
648 endif
649 SRC_HSC2HS_OPTS += $(foreach d,$(GMP_INCLUDE_DIRS),-I$(d))
650
651 define set_stage_HSC2HS_OPTS
652 # $1 = stage
653 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(filter-out -O,$$(SRC_CC_OPTS) $$(CONF_CC_OPTS_STAGE$1)))
654 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(CONF_CPP_OPTS_STAGE$1))
655 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --lflag=,$$(CONF_GCC_LINKER_OPTS_STAGE$1))
656 endef
657 $(eval $(call set_stage_HSC2HS_OPTS,0))
658 $(eval $(call set_stage_HSC2HS_OPTS,1))
659 $(eval $(call set_stage_HSC2HS_OPTS,2))
660 ifeq "$(CrossCompiling)" "YES"
661 SRC_HSC2HS_OPTS_STAGE1 += --cross-compile
662 SRC_HSC2HS_OPTS_STAGE2 += --cross-compile
663 endif
664 SRC_HSC2HS_OPTS_STAGE0 += --cflag=-D$(HostArch_CPP)_HOST_ARCH --cflag=-D$(HostOS_CPP)_HOST_OS
665 SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(TargetOS_CPP)_HOST_OS
666 SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(TargetOS_CPP)_HOST_OS
667
668 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
669 WINDRES = $(INPLACE_MINGW)/bin/windres
670 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
671 WINDRES = $(INPLACE_MINGW)/bin/windres
672 endif
673
674 #-----------------------------------------------------------------------------
675 # Mingwex Library
676 #
677 HaveLibMingwEx = @HaveLibMingwEx@
678 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
679 DLLTOOL = inplace/mingw/bin/dlltool.exe
680 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
681 DLLTOOL = inplace/mingw/bin/dlltool.exe
682 endif
683
684 #-----------------------------------------------------------------------------
685 # Other standard (ha!) Unix utilities
686
687 AR = @ArCmd@
688 AR_OPTS = @ArArgs@
689 ArSupportsAtFile = @ArSupportsAtFile@
690
691 AR_STAGE0 = @AR_STAGE0@
692 AR_STAGE1 = $(AR)
693 AR_STAGE2 = $(AR)
694 AR_STAGE3 = $(AR)
695 AR_OPTS_STAGE0 = @AR_OPTS_STAGE0@
696 AR_OPTS_STAGE1 = $(AR_OPTS)
697 AR_OPTS_STAGE2 = $(AR_OPTS)
698 AR_OPTS_STAGE3 = $(AR_OPTS)
699 EXTRA_AR_ARGS_STAGE0 = $(EXTRA_AR_ARGS)
700 EXTRA_AR_ARGS_STAGE1 = $(EXTRA_AR_ARGS)
701 EXTRA_AR_ARGS_STAGE2 = $(EXTRA_AR_ARGS)
702 EXTRA_AR_ARGS_STAGE3 = $(EXTRA_AR_ARGS)
703 ArSupportsAtFile_STAGE0 = @ArSupportsAtFile_STAGE0@
704 ArSupportsAtFile_STAGE1 = $(ArSupportsAtFile)
705 ArSupportsAtFile_STAGE2 = $(ArSupportsAtFile)
706 ArSupportsAtFile_STAGE3 = $(ArSupportsAtFile)
707
708 CONTEXT_DIFF = @ContextDiffCmd@
709 CP = cp
710
711 # It's not easy to separate the CPP program from its flags, as
712 # AC_PROG_CPP defines CPP as "/usr/bin/gcc -E"
713 CPP = @CPP@ @CPPFLAGS@
714 HS_CPP = @HaskellCPPCmd@ @HaskellCPPArgs@
715
716 FIND = @FindCmd@
717
718 #
719 # Sigh - the autoconf macro for INSTALL will subst a relative path to the fallback
720 # install-sh script (if chosen). This not terribly useful to us, so we convert
721 # it into an abs. path.
722 #
723 INSTALL = @INSTALL@
724 INSTALL := $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
725
726 LN_S = @LN_S@
727 MV = mv
728 PERL = @PerlCmd@
729 PIC = pic
730 RANLIB_CMD = @RANLIB_CMD@
731 REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
732 SED = @SedCmd@
733 SHELL = @SHELL@
734
735 HaveDtrace = @HaveDtrace@
736 USE_DTRACE = $(HaveDtrace)
737 DTRACE = @DtraceCmd@
738
739 LD = @LdCmd@
740 NM = @NmCmd@
741 AR = @ArCmd@
742 OBJDUMP = @ObjdumpCmd@
743
744 LLC = @LlcCmd@
745 OPT = @OptCmd@
746
747 # GNU ld supports input via a linker script, which is useful to avoid
748 # overflowing command-line length limits.
749 LdIsGNULd = @LdIsGNULd@
750
751 # Set to YES if ld has the --build-id flag. Sometimes we need to
752 # disable it with --build-id=none.
753 LdHasBuildId = @LdHasBuildId@
754
755 # Set to YES if ld has the --no_compact_unwind flag. See #5019
756 # and compiler/main/DriverPipeline.hs.
757 LdHasNoCompactUnwind = @LdHasNoCompactUnwind@
758
759 # On MSYS, building with SplitObjs=YES fails with
760 # ar: Bad file number
761 # see #3201. We need to specify a smaller max command-line size
762 # to work around it. 32767 doesn't work; 30000 does, but says
763 # xargs: value for -s option should be < 28153
764 # so we now use 20000 to be comfortably below this bound
765 XARGS = xargs
766 ifeq "$(Windows_Host)" "YES"
767 XARGS_OPTS = -s 20000
768 endif
769
770 ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
771 STRIP_CMD = $(TOP)/inplace/mingw/bin/strip.exe
772 else ifeq "$(TARGETPLATFORM)" "arm-unknown-linux"
773 # The Cortex A8 hardware apparently has a bug which ld.gold will check for;
774 # however in order to do so it must have unstripped executables lest we
775 # see warnings of the form (see #10376, #10464),
776 #
777 # /usr/bin/ld.gold: warning: cannot scan executable section 1 of ... for
778 # Cortex-A8 erratum because it has no mapping symbols.
779 #
780 # Consequently we disabling stripping by default on this architecture.
781 # The hack of using `:` to disable stripping is implemented by ghc-cabal.
782 STRIP_CMD = :
783 else
784 STRIP_CMD = strip
785 endif
786 PATCH_CMD = @PatchCmd@
787 TAR_CMD = @TarCmd@
788 BZIP2_CMD = @Bzip2Cmd@
789 GZIP_CMD = @GzipCmd@
790 XZ_CMD = @XzCmd@
791
792 # xz is default compression
793 TAR_COMP ?= xz
794
795 # select compression command and .tar extension based on TAR_COMP value
796 ifeq "$(TAR_COMP)" "bzip2"
797 TAR_COMP_CMD = $(BZIP2_CMD)
798 TAR_COMP_EXT = bz2
799 else ifeq "$(TAR_COMP)" "gzip"
800 TAR_COMP_CMD = $(GZIP_CMD)
801 TAR_COMP_EXT = gz
802 else ifeq "$(TAR_COMP)" "xz"
803 TAR_COMP_CMD = $(XZ_CMD)
804 TAR_COMP_EXT = xz
805 else
806 $(error $$(TAR_COMP) set to unknown value "$(TAR_COMP)" (supported: "bzip2", "gzip", "xz"))
807 endif
808
809 ifeq "$(Windows_Host)" "YES"
810 TOUCH_CMD = $(utils/touchy_dist_INPLACE)
811 TOUCH_DEP = $(TOUCH_CMD)
812 else
813 TOUCH_CMD = touch
814 TOUCH_DEP =
815 endif
816
817 HSCOLOUR_CMD = @HSCOLOUR@
818
819 TIME_CMD = @TimeCmd@
820
821 #-----------------------------------------------------------------------------
822 # Sphinx stuff
823
824 SPHINXBUILD = @SPHINXBUILD@
825 BUILD_MAN = @BUILD_MAN@
826 BUILD_SPHINX_HTML = @BUILD_SPHINX_HTML@
827 BUILD_SPHINX_PDF = @BUILD_SPHINX_PDF@
828 SPHINXOPTS = -D latex_paper_size=letter
829 XELATEX = @XELATEX@
830
831 #-----------------------------------------------------------------------------
832 # FPtools support software
833
834 #
835 # ghc-pkg
836 #
837 GHC_PKG = @GhcPkgCmd@
838
839 #
840 # Happy
841 #
842 HAPPY = @HappyCmd@
843 HAPPY_VERSION = @HappyVersion@
844 #
845 # Options to pass to Happy when we're going to compile the output with GHC
846 #
847 SRC_HAPPY_OPTS = -agc --strict
848
849 #
850 # Alex
851 #
852 ALEX = @AlexCmd@
853 ALEX_VERSION = @AlexVersion@
854 Alex3 = @Alex3@
855 #
856 # Options to pass to Alex when we're going to compile the output with GHC
857 #
858 SRC_ALEX_OPTS = -g
859 ifeq "$(Alex3)" "YES"
860 # The compiler isn't using the Unicode support in Alex 3.0 yet, in fact we do our own
861 # Unicode handling, so diable Alex's.
862 compiler_ALEX_OPTS = --latin1
863 endif
864
865 # Should we build haddock docs?
866 HADDOCK_DOCS = YES
867 # And HsColour the sources?
868 ifeq "$(HSCOLOUR_CMD)" ""
869 HSCOLOUR_SRCS = NO
870 else
871 HSCOLOUR_SRCS = YES
872 endif
873
874 # Build and install DPH?
875 BUILD_DPH = NO
876 # Build and install the "extra" packages (see ./packages)?
877 BUILD_EXTRA_PKGS = NO
878
879 ################################################################################
880 #
881 # Library configure arguments
882 #
883 ################################################################################
884
885 CONFIGURE_ARGS = @CONFIGURE_ARGS@
886
887 ################################################################################
888 #
889 # To be passed to sub-builds
890 #
891 ################################################################################
892
893 ICONV_INCLUDE_DIRS = @ICONV_INCLUDE_DIRS@
894 ICONV_LIB_DIRS = @ICONV_LIB_DIRS@
895
896 GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
897 GMP_LIB_DIRS = @GMP_LIB_DIRS@
898
899 CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@
900 CURSES_LIB_DIRS = @CURSES_LIB_DIRS@