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