Add flag allowing convenient disabling of terminfo support
[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 "$(Windows_Target)" "NO"
107 WITH_TERMINFO=YES
108 else
109 WITH_TERMINFO=NO
110 endif
111
112 ifeq "$(findstring $(TargetOS_CPP),linux freebsd dragonfly openbsd netbsd solaris2 kfreebsdgnu haiku linux-android)" ""
113 TargetElf = NO
114 else
115 TargetElf = YES
116 endif
117
118 # Some platforms don't support shared libraries
119 NoSharedLibsPlatformList = \
120 powerpc-ibm-aix \
121 x86_64-unknown-mingw32 \
122 i386-unknown-mingw32
123
124 ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
125 NoSharedLibsPlatformList += i386-unknown-solaris2
126 endif
127
128 PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
129 $(NoSharedLibsPlatformList)),NO,YES)
130
131 # DYNAMIC_BY_DEFAULT says whether this compiler will default to
132 # building dynamic executables, i.e. -dynamic is on. We do this for
133 # most platforms because it lets us use the system dynamic linker
134 # instead of our own linker for GHCi.
135 #
136 # Currently this isn't possible on Windows, and we have not yet enabled
137 # it on i386 while we consider the performance implications.
138 #
139 ifeq "$(TargetOS_CPP)" "mingw32"
140 DYNAMIC_BY_DEFAULT = NO
141 else ifeq "$(TargetArch_CPP)" "i386"
142 DYNAMIC_BY_DEFAULT = NO
143 else
144 DYNAMIC_BY_DEFAULT = YES
145 endif
146
147 # For now, we unconditionally disable dynamic-by-default, as the
148 # cabal-install's that are in the wild don't handle it properly.
149 DYNAMIC_BY_DEFAULT = NO
150
151 # If building both v and dyn ways, then use -dynamic-too to build them.
152 # This makes the build faster.
153 DYNAMIC_TOO = YES
154
155 # Use the dynamic way when building programs in the GHC tree. In
156 # particular, this means that GHCi will use DLLs rather than loading
157 # object files directly.
158 ifeq "$(TargetOS_CPP)" "mingw32"
159 # This doesn't work on Windows yet
160 DYNAMIC_GHC_PROGRAMS = NO
161 DYNAMIC_TOO=NO
162 else ifeq "$(PlatformSupportsSharedLibs)" "NO"
163 DYNAMIC_GHC_PROGRAMS = NO
164 else
165 DYNAMIC_GHC_PROGRAMS = YES
166 endif
167
168 # Build a compiler that will build *unregisterised* libraries and
169 # binaries by default. Unregisterised code is supposed to compile and
170 # run without any support for architecture-specific assembly mangling,
171 # register assignment or tail-calls, and is therefore a good way to get
172 # started when porting GHC to new architectures.
173 #
174 # NOTE: the stage1 compiler will be a registerised binary (assuming
175 # the compiler you build with is generating registerised binaries), but
176 # the stage2 compiler will be an unregisterised binary.
177 #
178 GhcUnregisterised=@Unregisterised@
179
180 # Build a compiler with a native code generator backend
181 # (as well as a C backend)
182 #
183 # Target platforms supported:
184 # i386, powerpc, powerpc64, sparc
185 # IOS is not supported
186 ArchSupportsNCG=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc)))
187 OsSupportsNCG=$(strip $(patsubst $(TargetOS_CPP), YES, $(patsubst ios,,$(TargetOS_CPP))))
188
189 GhcWithNativeCodeGen := $(strip\
190 $(if $(filter YESYESNO,\
191 $(OsSupportsNCG)$(ArchSupportsNCG)$(GhcUnregisterised)),YES,NO))
192
193 HaveLibDL = @HaveLibDL@
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 BIN_DIST_NAME = ghc-$(ProjectVersion)
419 BIN_DIST_PREP_DIR = bindistprep/$(BIN_DIST_NAME)
420 BIN_DIST_PREP_TAR = bindistprep/$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
421 BIN_DIST_PREP_TAR_COMP = $(BIN_DIST_PREP_TAR).$(TAR_COMP_EXT)
422 BIN_DIST_TAR_COMP = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT)
423
424 # -----------------------------------------------------------------------------
425 # Utilities programs: flags
426
427 # If you want to give any standard flags to pretty much any utility
428 # (see utils.mk for a complete list), by adding a line here
429 #
430 # SRC_P_OPTS += ...
431 #
432 # where P is the utility. For example, to add -O to all Haskell
433 # compilations,
434 #
435 # SRC_HC_OPTS += -O
436
437
438 # SRC_HC_OPTS includes flags to be added to *every* Haskell
439 # compilation. Setting SRC_HC_OPTS is a good way to set the default
440 # optimisation level (-O) and heap size (-H<size>).
441 #
442 # SRC_HC_OPTS is *not* for adding flags that are required to make your
443 # build work. Examples:
444 #
445 # - instead of using -pgmc/-pgma-/-pgml, use the --with-gcc option to configure
446 #
447 # - if you need -optc, -opta, or -optl flags, the CONF_CC_* and CONF_LD_*
448 # variables are more appropriate (set via configure)
449 #
450 # Note that SRC_HC_OPTS are added to every Haskell compilation,
451 # including when using the bootstrapping compiler (stage 0), So don't
452 # put options here that are only supported by very recent GHCs.
453 #
454 SRC_HC_OPTS += -H32m -O
455
456
457 # See Note [Stage number in build variables].
458 SRC_HC_OPTS_STAGE0 =
459 SRC_HC_OPTS_STAGE1 =
460 SRC_HC_OPTS_STAGE2 =
461
462 # Warning suppression flags. See mk/warnings.mk.
463 SRC_CC_WARNING_OPTS =
464 SRC_HC_WARNING_OPTS =
465
466 # See Note [Stage number in build variables].
467 SRC_HC_WARNING_OPTS_STAGE0 =
468 SRC_HC_WARNING_OPTS_STAGE1 =
469 SRC_HC_WARNING_OPTS_STAGE2 =
470
471 # -----------------------------------------------------------------------------
472 # Names of programs in the GHC tree
473
474 MKDIRHIER = $(INPLACE_BIN)/mkdirhier
475
476 GENERATED_FILE = chmod a-w
477 EXECUTABLE_FILE = chmod +x
478
479 #-----------------------------------------------------------------------------
480 # Installed GHC
481
482 # $(GHC) points to installed version of the compiler.
483 #
484 # NOTE: Don't override $(GHC) in build.mk, use configure --with-ghc instead
485 # (because the version numbers have to be calculated).
486
487 GHC := @WithGhc@
488 # If we have a make dependency on c:/ghc/ghc, and the file is actually
489 # called c:/ghc/ghc.exe, then make will think that ghc doesn't exist
490 # and that it doesn't know how to create it.
491 ifneq "$(wildcard $(GHC).exe)" ""
492 GHC := $(GHC).exe
493 endif
494
495 GHC_STAGE0 = $(GHC)
496 GHC_STAGE1 = $(ghc-stage1_INPLACE)
497 GHC_STAGE2 = $(ghc-stage2_INPLACE)
498 GHC_STAGE3 = $(ghc-stage3_INPLACE)
499
500 BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
501
502 INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
503
504 GhcVersion = @GhcVersion@
505 GhcPatchLevel = @GhcPatchLevel@
506 GhcMajVersion = @GhcMajVersion@
507 GhcMinVersion = @GhcMinVersion@
508
509 # Canonicalised ghc version number, used for easy (integer) version
510 # comparisons. We must expand $(GhcMinVersion) to two digits by
511 # adding a leading zero if necessary:
512 ifneq "$(findstring $(GhcMinVersion), 0 1 2 3 4 5 6 7 8 9)" ""
513 GhcCanonVersion = $(GhcMajVersion)0$(GhcMinVersion)
514 else
515 GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion)
516 endif
517
518 GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
519
520 SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
521
522 #-----------------------------------------------------------------------------
523 # C compiler
524 #
525 # NB. Don't override $(CC) using build.mk, re-configure using
526 # the flag CC=<blah> instead. The reason is that the configure script
527 # needs to know which gcc you're using in order to perform its tests.
528
529 GccVersion = @GccVersion@
530 ifeq "$(phase)" "0"
531 CrossCompilePrefix =
532 else
533 CrossCompilePrefix = @CrossCompilePrefix@
534 endif
535 # TargetPlatformFull retains the string passed to configure so we have it in
536 # the necessary format to pass to libffi's configure.
537 TargetPlatformFull = @TargetPlatformFull@
538 GccLT34 = @GccLT34@
539 GccLT44 = @GccLT44@
540 GccLT46 = @GccLT46@
541 GccIsClang = @GccIsClang@
542
543 CC = @CC@
544 CC_STAGE0 = @CC_STAGE0@
545 CC_STAGE1 = $(CC)
546 CC_STAGE2 = $(CC)
547 CC_STAGE3 = $(CC)
548
549 AS = @CC@
550 AS_STAGE0 = @CC_STAGE0@
551 AS_STAGE1 = $(AS)
552 AS_STAGE2 = $(AS)
553 AS_STAGE3 = $(AS)
554
555 # why no LD=@LD@ ?
556 LD_STAGE0 = @LD_STAGE0@
557 LD_STAGE1 = $(LD)
558 LD_STAGE2 = $(LD)
559 LD_STAGE3 = $(LD)
560
561 # Cross-compiling options
562 # See Note [CrossCompiling vs Stage1Only]
563 CrossCompiling = @CrossCompiling@
564
565 # Change this to YES if you're building a cross-compiler and don't
566 # want to build stage 2.
567 # See Note [CrossCompiling vs Stage1Only]
568 # See Note [Stage1Only vs stage=1]
569 Stage1Only = NO
570
571 # Install stage 2 by default, or stage 1 in the cross compiler
572 # case. Can be changed to 3
573 INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2)
574
575 # Note [CrossCompiling vs Stage1Only]
576 #
577 # There are 4 possible settings:
578 #
579 # 1 CrossCompiling=NO Stage1Only=NO
580 # The default.
581 #
582 # 2 CrossCompiling=NO Stage1Only=YES
583 # Don't build ghc-stage2. See Note [Stage1Only vs stage=1].
584 #
585 # 3 CrossCompiling=YES Stage1Only=YES
586 # Building a cross-compiler (ghc-stage1). See [1] and
587 # Note [Stage1Only vs stage=1].
588 #
589 # 4 CrossCompiling=YES Stage1Only=NO
590 # Cross-compiling GHC itself. See [1].
591 #
592 # [1] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
593
594 # Note [Stage1Only vs stage=1]
595 #
596 # Stage1Only=YES means:
597 # - don't build ghc-stage2 (the executable)
598 # - don't build utils that rely on ghc-stage2
599 # See Note [No stage2 packages when CrossCompiling or Stage1Only] in
600 # ./ghc.mk.
601 # - install ghc-stage1 instead of ghc-stage2
602 # - install the ghc-pkg that was built with the stage0 compiler
603 # - (*do* still build compiler/stage2 (i.e. the ghc library))
604 # - (*do* still build all other libraries)
605 #
606 # stage=1 means:
607 # - don't build compiler/stage2 (i.e. the ghc library)
608 # - don't build ghc-stage2 (the executable)
609 # Note: these are the only two things it does. If you want to exclude more
610 # stuff, combine it with Stage1Only=YES, or run make in the ghc or compiler
611 # directory.
612 #
613 # running make in the ghc or compiler directory means:
614 # - don't build any packages in the libraries/ directory, except the ones
615 # listed in PACKAGES_STAGE0 (i.e. the boot libraries)
616 #
617 # You may wonder why Stage1Only=YES still builds compiler/stage2. Quoting
618 # simonmar in #7639:
619 #
620 # "strictly speaking building compiler/stage2 is correct, because it is
621 # the ghc package that can be used with [ghc-stage1]. If you don't
622 # want to build it, then setting stage=1 in your mk/build.mk should
623 # disable it."
624
625 # C compiler and linker flags from configure (e.g. -m<blah> to select
626 # correct C compiler backend). The stage number is the stage of GHC
627 # that is being used to compile with.
628 CONF_CC_OPTS_STAGE0 = @CONF_CC_OPTS_STAGE0@
629 CONF_CC_OPTS_STAGE1 = @CONF_CC_OPTS_STAGE1@
630 CONF_CC_OPTS_STAGE2 = @CONF_CC_OPTS_STAGE2@
631 CONF_GCC_LINKER_OPTS_STAGE0 = @CONF_GCC_LINKER_OPTS_STAGE0@
632 CONF_GCC_LINKER_OPTS_STAGE1 = @CONF_GCC_LINKER_OPTS_STAGE1@
633 CONF_GCC_LINKER_OPTS_STAGE2 = @CONF_GCC_LINKER_OPTS_STAGE2@
634 CONF_LD_LINKER_OPTS_STAGE0 = @CONF_LD_LINKER_OPTS_STAGE0@
635 CONF_LD_LINKER_OPTS_STAGE1 = @CONF_LD_LINKER_OPTS_STAGE1@
636 CONF_LD_LINKER_OPTS_STAGE2 = @CONF_LD_LINKER_OPTS_STAGE2@
637 CONF_CPP_OPTS_STAGE0 = @CONF_CPP_OPTS_STAGE0@
638 CONF_CPP_OPTS_STAGE1 = @CONF_CPP_OPTS_STAGE1@
639 CONF_CPP_OPTS_STAGE2 = @CONF_CPP_OPTS_STAGE2@
640 CONF_HC_OPTS_STAGE0 = @CONF_HC_OPTS_STAGE0@
641 CONF_HC_OPTS_STAGE1 = @CONF_HC_OPTS_STAGE1@
642 CONF_HC_OPTS_STAGE2 = @CONF_HC_OPTS_STAGE2@
643
644 # The .hsc files aren't currently safe for cross-compilation on Windows:
645 # libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:160
646 # directive "let" is not safe for cross-compilation
647 ifneq "$(Windows_Host)" "YES"
648 SRC_HSC2HS_OPTS += --cross-safe
649 endif
650 SRC_HSC2HS_OPTS += $(foreach d,$(GMP_INCLUDE_DIRS),-I$(d))
651
652 define set_stage_HSC2HS_OPTS
653 # $1 = stage
654 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(filter-out -O,$$(SRC_CC_OPTS) $$(CONF_CC_OPTS_STAGE$1)))
655 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(CONF_CPP_OPTS_STAGE$1))
656 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --lflag=,$$(CONF_GCC_LINKER_OPTS_STAGE$1))
657 endef
658 $(eval $(call set_stage_HSC2HS_OPTS,0))
659 $(eval $(call set_stage_HSC2HS_OPTS,1))
660 $(eval $(call set_stage_HSC2HS_OPTS,2))
661 ifeq "$(CrossCompiling)" "YES"
662 SRC_HSC2HS_OPTS_STAGE1 += --cross-compile
663 SRC_HSC2HS_OPTS_STAGE2 += --cross-compile
664 endif
665 SRC_HSC2HS_OPTS_STAGE0 += --cflag=-D$(HostArch_CPP)_HOST_ARCH --cflag=-D$(HostOS_CPP)_HOST_OS
666 SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(TargetOS_CPP)_HOST_OS
667 SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(TargetOS_CPP)_HOST_OS
668
669 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
670 WINDRES = $(INPLACE_MINGW)/bin/windres
671 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
672 WINDRES = $(INPLACE_MINGW)/bin/windres
673 endif
674
675 #-----------------------------------------------------------------------------
676 # Mingwex Library
677 #
678 HaveLibMingwEx = @HaveLibMingwEx@
679 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
680 DLLTOOL = inplace/mingw/bin/dlltool.exe
681 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
682 DLLTOOL = inplace/mingw/bin/dlltool.exe
683 endif
684
685 #-----------------------------------------------------------------------------
686 # Other standard (ha!) Unix utilities
687
688 AR = @ArCmd@
689 AR_OPTS = @ArArgs@
690 ArSupportsAtFile = @ArSupportsAtFile@
691
692 AR_STAGE0 = @AR_STAGE0@
693 AR_STAGE1 = $(AR)
694 AR_STAGE2 = $(AR)
695 AR_STAGE3 = $(AR)
696 AR_OPTS_STAGE0 = @AR_OPTS_STAGE0@
697 AR_OPTS_STAGE1 = $(AR_OPTS)
698 AR_OPTS_STAGE2 = $(AR_OPTS)
699 AR_OPTS_STAGE3 = $(AR_OPTS)
700 EXTRA_AR_ARGS_STAGE0 = $(EXTRA_AR_ARGS)
701 EXTRA_AR_ARGS_STAGE1 = $(EXTRA_AR_ARGS)
702 EXTRA_AR_ARGS_STAGE2 = $(EXTRA_AR_ARGS)
703 EXTRA_AR_ARGS_STAGE3 = $(EXTRA_AR_ARGS)
704 ArSupportsAtFile_STAGE0 = @ArSupportsAtFile_STAGE0@
705 ArSupportsAtFile_STAGE1 = $(ArSupportsAtFile)
706 ArSupportsAtFile_STAGE2 = $(ArSupportsAtFile)
707 ArSupportsAtFile_STAGE3 = $(ArSupportsAtFile)
708
709 CONTEXT_DIFF = @ContextDiffCmd@
710 CP = cp
711
712 # It's not easy to separate the CPP program from its flags, as
713 # AC_PROG_CPP defines CPP as "/usr/bin/gcc -E"
714 CPP = @CPP@ @CPPFLAGS@
715 HS_CPP = @HaskellCPPCmd@ @HaskellCPPArgs@
716
717 FIND = @FindCmd@
718
719 #
720 # Sigh - the autoconf macro for INSTALL will subst a relative path to the fallback
721 # install-sh script (if chosen). This not terribly useful to us, so we convert
722 # it into an abs. path.
723 #
724 INSTALL = @INSTALL@
725 INSTALL := $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
726
727 LN_S = @LN_S@
728 MV = mv
729 PERL = @PerlCmd@
730 PIC = pic
731 RANLIB_CMD = @RANLIB_CMD@
732 REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
733 SED = @SedCmd@
734 SHELL = @SHELL@
735
736 HaveDtrace = @HaveDtrace@
737 USE_DTRACE = $(HaveDtrace)
738 DTRACE = @DtraceCmd@
739
740 LD = @LdCmd@
741 NM = @NmCmd@
742 AR = @ArCmd@
743 OBJDUMP = @ObjdumpCmd@
744
745 LLC = @LlcCmd@
746 OPT = @OptCmd@
747
748 # GNU ld supports input via a linker script, which is useful to avoid
749 # overflowing command-line length limits.
750 LdIsGNULd = @LdIsGNULd@
751
752 # Set to YES if ld has the --build-id flag. Sometimes we need to
753 # disable it with --build-id=none.
754 LdHasBuildId = @LdHasBuildId@
755
756 # Set to YES if ld has the --no_compact_unwind flag. See #5019
757 # and compiler/main/DriverPipeline.hs.
758 LdHasNoCompactUnwind = @LdHasNoCompactUnwind@
759
760 # On MSYS, building with SplitObjs=YES fails with
761 # ar: Bad file number
762 # see #3201. We need to specify a smaller max command-line size
763 # to work around it. 32767 doesn't work; 30000 does, but says
764 # xargs: value for -s option should be < 28153
765 # so we now use 20000 to be comfortably below this bound
766 XARGS = xargs
767 ifeq "$(Windows_Host)" "YES"
768 XARGS_OPTS = -s 20000
769 endif
770
771 ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
772 STRIP_CMD = $(TOP)/inplace/mingw/bin/strip.exe
773 else ifeq "$(TARGETPLATFORM)" "arm-unknown-linux"
774 # The Cortex A8 hardware apparently has a bug which ld.gold will check for;
775 # however in order to do so it must have unstripped executables lest we
776 # see warnings of the form (see #10376, #10464),
777 #
778 # /usr/bin/ld.gold: warning: cannot scan executable section 1 of ... for
779 # Cortex-A8 erratum because it has no mapping symbols.
780 #
781 # Consequently we disabling stripping by default on this architecture.
782 # The hack of using `:` to disable stripping is implemented by ghc-cabal.
783 STRIP_CMD = :
784 else
785 STRIP_CMD = strip
786 endif
787 PATCH_CMD = @PatchCmd@
788 TAR_CMD = @TarCmd@
789 BZIP2_CMD = bzip2
790 GZIP_CMD = gzip
791 XZ_CMD = xz
792
793 # xz is default compression
794 TAR_COMP ?= xz
795
796 # select compression command and .tar extension based on TAR_COMP value
797 ifeq "$(TAR_COMP)" "bzip2"
798 TAR_COMP_CMD = $(BZIP2_CMD)
799 TAR_COMP_EXT = bz2
800 else ifeq "$(TAR_COMP)" "gzip"
801 TAR_COMP_CMD = $(GZIP_CMD)
802 TAR_COMP_EXT = gz
803 else ifeq "$(TAR_COMP)" "xz"
804 TAR_COMP_CMD = $(XZ_CMD)
805 TAR_COMP_EXT = xz
806 else
807 $(error $$(TAR_COMP) set to unknown value "$(TAR_COMP)" (supported: "bzip2", "gzip", "xz"))
808 endif
809
810 ifeq "$(Windows_Host)" "YES"
811 TOUCH_CMD = $(utils/touchy_dist_INPLACE)
812 TOUCH_DEP = $(TOUCH_CMD)
813 else
814 TOUCH_CMD = touch
815 TOUCH_DEP =
816 endif
817
818 HSCOLOUR_CMD = @HSCOLOUR@
819
820 TIME_CMD = @TimeCmd@
821
822 #-----------------------------------------------------------------------------
823 # Sphinx stuff
824
825 SPHINXBUILD = @SPHINXBUILD@
826 BUILD_MAN = @BUILD_MAN@
827 BUILD_SPHINX_HTML = @BUILD_SPHINX_HTML@
828 BUILD_SPHINX_PDF = @BUILD_SPHINX_PDF@
829 SPHINXOPTS = -D latex_paper_size=letter
830 XELATEX = @XELATEX@
831
832 #-----------------------------------------------------------------------------
833 # FPtools support software
834
835 #
836 # ghc-pkg
837 #
838 GHC_PKG = @GhcPkgCmd@
839
840 #
841 # Happy
842 #
843 HAPPY = @HappyCmd@
844 HAPPY_VERSION = @HappyVersion@
845 #
846 # Options to pass to Happy when we're going to compile the output with GHC
847 #
848 SRC_HAPPY_OPTS = -agc --strict
849
850 #
851 # Alex
852 #
853 ALEX = @AlexCmd@
854 ALEX_VERSION = @AlexVersion@
855 Alex3 = @Alex3@
856 #
857 # Options to pass to Alex when we're going to compile the output with GHC
858 #
859 SRC_ALEX_OPTS = -g
860 ifeq "$(Alex3)" "YES"
861 # The compiler isn't using the Unicode support in Alex 3.0 yet, in fact we do our own
862 # Unicode handling, so diable Alex's.
863 compiler_ALEX_OPTS = --latin1
864 endif
865
866 # Should we build haddock docs?
867 HADDOCK_DOCS = YES
868 # And HsColour the sources?
869 ifeq "$(HSCOLOUR_CMD)" ""
870 HSCOLOUR_SRCS = NO
871 else
872 HSCOLOUR_SRCS = YES
873 endif
874
875 # Build and install DPH?
876 BUILD_DPH = NO
877 # Build and install the "extra" packages (see ./packages)?
878 BUILD_EXTRA_PKGS = NO
879
880 ################################################################################
881 #
882 # Library configure arguments
883 #
884 ################################################################################
885
886 CONFIGURE_ARGS = @CONFIGURE_ARGS@
887
888 ################################################################################
889 #
890 # To be passed to sub-builds
891 #
892 ################################################################################
893
894 ICONV_INCLUDE_DIRS = @ICONV_INCLUDE_DIRS@
895 ICONV_LIB_DIRS = @ICONV_LIB_DIRS@
896
897 GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
898 GMP_LIB_DIRS = @GMP_LIB_DIRS@
899
900 CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@
901 CURSES_LIB_DIRS = @CURSES_LIB_DIRS@