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