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