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