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