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