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