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