Implement function-sections for Haskell code, #8405
[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 # Section splitting
306 #
307 # Similar to -ffunction-sections -fdata-sections in GCC. Provides space saving
308 # like SplitObjs, but doesn't require post-processing and splitting of object
309 # files.
310 #
311 # Set SplitSections=YES in your build.mk to enable.
312
313 SplitSections=NO
314
315 # ----------------------------------------------------------------------------
316
317 # There are a number of things which technically depend on GHC (e.g. if
318 # ghc changes then Haskell files may be compiled differently, or Cabal
319 # packages may be configured differently). By default we therefore
320 # have dependencies on the compiler executable.
321
322 # However, in practice, having a dependency on GHC is just a pain: We
323 # normally don't want to spend time recompiling other things while
324 # we're working on the compiler, and even if we did, GHC will normally
325 # decide compilation isn't needed anyway. So by setting LAX_DEPENDENCIES
326 # to YES you can turn these dependencies into order-only dependencies,
327 # i.e. GHC must exist, but if it's newer than other targets then
328 # rebuilding is not necessary.
329
330 LAX_DEPENDENCIES = NO
331
332 # ----------------------------------------------------------------------------
333 # Options for GHC's RTS
334
335 # Build an optimised RTS. Remember that we need to turn on
336 # optimisation both for C code (-optc-O2) and .cmm code (-O2). For
337 # the debugging RTS flavour, rts/ghc.mk overrides these to turn off
338 # optimisation.
339 GhcRtsHcOpts=-O2
340 GhcRtsCcOpts=-O2 -fomit-frame-pointer -g
341
342 # Include support for CPU performance counters via the PAPI library in the RTS?
343 # (PAPI: http://icl.cs.utk.edu/papi/)
344 GhcRtsWithPapi = NO
345 PapiLibDir=
346 PapiIncludeDir=
347
348 # Configuration for libffi
349 UseSystemLibFFI=@UseSystemLibFFI@
350 # Flags to go into package.conf for rts
351 FFILibDir=@FFILibDir@
352 FFIIncludeDir=@FFIIncludeDir@
353
354
355 # Include support for DWARF unwinding
356 GhcRtsWithLibdw = @HaveLibdw@
357
358 ################################################################################
359 #
360 # Paths (see paths.mk)
361 #
362 ################################################################################
363
364 # Directory used by GHC (and possibly other tools) for storing
365 # temporary files. If your TMPDIR isn't big enough, either override
366 # this in build.mk or set your environment variable "TMPDIR" to point
367 # to somewhere with more space. (TMPDIR=. is a good choice).
368
369 # DEFAULT_TMPDIR isn't called TMPDIR because GNU make tends to
370 # override an environment variable with the value of the make variable
371 # of the same name (if it exists) when executing sub-processes, so
372 # setting the TMPDIR env var would have no effect in the build tree.
373
374 DEFAULT_TMPDIR = /tmp
375 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
376 DEFAULT_TMPDIR = /C/TEMP
377 endif
378
379 BIN_DIST_NAME = ghc-$(ProjectVersion)
380 BIN_DIST_PREP_DIR = bindistprep/$(BIN_DIST_NAME)
381 BIN_DIST_PREP_TAR = bindistprep/$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
382 BIN_DIST_PREP_TAR_COMP = $(BIN_DIST_PREP_TAR).$(TAR_COMP_EXT)
383 BIN_DIST_TAR_COMP = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT)
384
385 # -----------------------------------------------------------------------------
386 # Utilities programs: flags
387
388 # If you want to give any standard flags to pretty much any utility
389 # (see utils.mk for a complete list), by adding a line here
390 #
391 # SRC_P_OPTS += ...
392 #
393 # where P is the utility. For example, to add -O to all Haskell
394 # compilations,
395 #
396 # SRC_HC_OPTS += -O
397
398
399 # SRC_HC_OPTS includes flags to be added to *every* Haskell
400 # compilation. Setting SRC_HC_OPTS is a good way to set the default
401 # optimisation level (-O) and heap size (-H<size>).
402 #
403 # SRC_HC_OPTS is *not* for adding flags that are required to make your
404 # build work. Examples:
405 #
406 # - instead of using -pgmc/-pgma-/-pgml, use the --with-gcc option to configure
407 #
408 # - if you need -optc, -opta, or -optl flags, the CONF_CC_* and CONF_LD_*
409 # variables are more appropriate (set via configure)
410 #
411 # Note that SRC_HC_OPTS are added to every Haskell compilation,
412 # including when using the bootstrapping compiler (stage 0), So don't
413 # put options here that are only supported by very recent GHCs.
414 #
415 SRC_HC_OPTS += -H32m -O
416
417 # Disable -O2 optimization. Otherwise amount of generated C code
418 # makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
419 # and sometimes not compile at all (powerpc64 overflows something
420 # on 'compiler/hsSyn/HsExpr.lhs').
421 ifeq "$(GhcUnregisterised)" "YES"
422 GhcStage1HcOpts=
423 GhcStage2HcOpts=
424 GhcStage3HcOpts=
425 endif
426
427 # -----------------------------------------------------------------------------
428 # Names of programs in the GHC tree
429
430 MKDIRHIER = $(INPLACE_BIN)/mkdirhier
431
432 GENERATED_FILE = chmod a-w
433 EXECUTABLE_FILE = chmod +x
434
435 #-----------------------------------------------------------------------------
436 # Installed GHC
437
438 # $(GHC) points to installed version of the compiler.
439 #
440 # NOTE: Don't override $(GHC) in build.mk, use configure --with-ghc instead
441 # (because the version numbers have to be calculated).
442
443 GHC := @WithGhc@
444 # If we have a make dependency on c:/ghc/ghc, and the file is actually
445 # called c:/ghc/ghc.exe, then make will think that ghc doesn't exist
446 # and that it doesn't know how to create it.
447 ifneq "$(wildcard $(GHC).exe)" ""
448 GHC := $(GHC).exe
449 endif
450
451 GHC_STAGE0 = $(GHC)
452 GHC_STAGE1 = $(ghc-stage1_INPLACE)
453 GHC_STAGE2 = $(ghc-stage2_INPLACE)
454 GHC_STAGE3 = $(ghc-stage3_INPLACE)
455
456 BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
457
458 INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
459
460 GhcVersion = @GhcVersion@
461 GhcPatchLevel = @GhcPatchLevel@
462 GhcMajVersion = @GhcMajVersion@
463 GhcMinVersion = @GhcMinVersion@
464
465 # Canonicalised ghc version number, used for easy (integer) version
466 # comparisons. We must expand $(GhcMinVersion) to two digits by
467 # adding a leading zero if necessary:
468 ifneq "$(findstring $(GhcMinVersion), 0 1 2 3 4 5 6 7 8 9)" ""
469 GhcCanonVersion = $(GhcMajVersion)0$(GhcMinVersion)
470 else
471 GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion)
472 endif
473
474 GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
475
476 CMM_SINK_BOOTSTRAP_IS_NEEDED = @CMM_SINK_BOOTSTRAP_IS_NEEDED@
477
478 SUPPORTS_COMPONENT_ID = @SUPPORTS_COMPONENT_ID@
479
480 #-----------------------------------------------------------------------------
481 # C compiler
482 #
483 # NB. Don't override $(WhatGccIsCalled) using build.mk, re-configure using
484 # the flag --with-gcc=<blah> instead. The reason is that the configure script
485 # needs to know which gcc you're using in order to perform its tests.
486
487 WhatGccIsCalled = @WhatGccIsCalled@
488 GccVersion = @GccVersion@
489 ifeq "$(phase)" "0"
490 CrossCompilePrefix =
491 else
492 CrossCompilePrefix = @CrossCompilePrefix@
493 endif
494 # TargetPlatformFull retains the string passed to configure so we have it in
495 # the necessary format to pass to libffi's configure.
496 TargetPlatformFull = @TargetPlatformFull@
497 GccLT34 = @GccLT34@
498 GccLT46 = @GccLT46@
499 GccIsClang = @GccIsClang@
500
501 CC = $(WhatGccIsCalled)
502 CC_STAGE0 = @CC_STAGE0@
503 CC_STAGE1 = $(CC)
504 CC_STAGE2 = $(CC)
505 CC_STAGE3 = $(CC)
506
507 AS = $(WhatGccIsCalled)
508 AS_STAGE0 = @CC_STAGE0@
509 AS_STAGE1 = $(AS)
510 AS_STAGE2 = $(AS)
511 AS_STAGE3 = $(AS)
512
513 # We don't have an LD_STAGE0. CC_STAGE0 is determined by asking "ghc
514 # --info", and it doesn't report an LD.
515 LD_STAGE0 = error-no-ld-stage0
516 LD_STAGE1 = $(LD)
517 LD_STAGE2 = $(LD)
518 LD_STAGE3 = $(LD)
519
520 # Cross-compiling options
521 # See Note [CrossCompiling vs Stage1Only]
522 CrossCompiling = @CrossCompiling@
523
524 # Change this to YES if you're building a cross-compiler and don't
525 # want to build stage 2.
526 # See Note [CrossCompiling vs Stage1Only]
527 # See Note [Stage1Only vs stage=1]
528 Stage1Only = NO
529
530 # Install stage 2 by default, or stage 1 in the cross compiler
531 # case. Can be changed to 3
532 INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2)
533
534 # Note [CrossCompiling vs Stage1Only]
535 #
536 # There are 4 possible settings:
537 #
538 # 1 CrossCompiling=NO Stage1Only=NO
539 # The default.
540 #
541 # 2 CrossCompiling=NO Stage1Only=YES
542 # Don't build ghc-stage2. See Note [Stage1Only vs stage=1].
543 #
544 # 3 CrossCompiling=YES Stage1Only=YES
545 # Building a cross-compiler (ghc-stage1). See [1] and
546 # Note [Stage1Only vs stage=1].
547 #
548 # 4 CrossCompiling=YES Stage1Only=NO
549 # Cross-compiling GHC itself. See [1].
550 #
551 # [1] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
552
553 # Note [Stage1Only vs stage=1]
554 #
555 # Stage1Only=YES means:
556 # - don't build ghc-stage2 (the executable)
557 # - don't build utils that rely on ghc-stage2
558 # See Note [No stage2 packages when CrossCompiling or Stage1Only] in
559 # ./ghc.mk.
560 # - install ghc-stage1 instead of ghc-stage2
561 # - install the ghc-pkg that was built with the stage0 compiler
562 # - (*do* still build compiler/stage2 (i.e. the ghc library))
563 # - (*do* still build all other libraries)
564 #
565 # stage=1 means:
566 # - don't build compiler/stage2 (i.e. the ghc library)
567 # - don't build ghc-stage2 (the executable)
568 # Note: these are the only two things it does. If you want to exclude more
569 # stuff, combine it with Stage1Only=YES, or run make in the ghc or compiler
570 # directory.
571 #
572 # running make in the ghc or compiler directory means:
573 # - don't build any packages in the libraries/ directory, except the ones
574 # listed in PACKAGES_STAGE0 (i.e. the boot libraries)
575 #
576 # You may wonder why Stage1Only=YES still builds compiler/stage2. Quoting
577 # simonmar in #7639:
578 #
579 # "strictly speaking building compiler/stage2 is correct, because it is
580 # the ghc package that can be used with [ghc-stage1]. If you don't
581 # want to build it, then setting stage=1 in your mk/build.mk should
582 # disable it."
583
584 # C compiler and linker flags from configure (e.g. -m<blah> to select
585 # correct C compiler backend). The stage number is the stage of GHC
586 # that is being used to compile with.
587 CONF_CC_OPTS_STAGE0 = @CONF_CC_OPTS_STAGE0@
588 CONF_CC_OPTS_STAGE1 = @CONF_CC_OPTS_STAGE1@
589 CONF_CC_OPTS_STAGE2 = @CONF_CC_OPTS_STAGE2@
590 CONF_GCC_LINKER_OPTS_STAGE0 = @CONF_GCC_LINKER_OPTS_STAGE0@
591 CONF_GCC_LINKER_OPTS_STAGE1 = @CONF_GCC_LINKER_OPTS_STAGE1@
592 CONF_GCC_LINKER_OPTS_STAGE2 = @CONF_GCC_LINKER_OPTS_STAGE2@
593 CONF_LD_LINKER_OPTS_STAGE0 = @CONF_LD_LINKER_OPTS_STAGE0@
594 CONF_LD_LINKER_OPTS_STAGE1 = @CONF_LD_LINKER_OPTS_STAGE1@
595 CONF_LD_LINKER_OPTS_STAGE2 = @CONF_LD_LINKER_OPTS_STAGE2@
596 CONF_CPP_OPTS_STAGE0 = @CONF_CPP_OPTS_STAGE0@
597 CONF_CPP_OPTS_STAGE1 = @CONF_CPP_OPTS_STAGE1@
598 CONF_CPP_OPTS_STAGE2 = @CONF_CPP_OPTS_STAGE2@
599
600 ifeq "$(TARGETPLATFORM)" "ia64-unknown-linux"
601 CONF_CC_OPTS += -G0
602 endif
603
604 # The .hsc files aren't currently safe for cross-compilation on Windows:
605 # libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:160
606 # directive "let" is not safe for cross-compilation
607 ifneq "$(Windows_Host)" "YES"
608 SRC_HSC2HS_OPTS += --cross-safe
609 endif
610 SRC_HSC2HS_OPTS += $(foreach d,$(GMP_INCLUDE_DIRS),-I$(d))
611
612 define set_stage_HSC2HS_OPTS
613 # $1 = stage
614 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(filter-out -O,$$(SRC_CC_OPTS) $$(CONF_CC_OPTS_STAGE$1)))
615 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(CONF_CPP_OPTS_STAGE$1))
616 SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --lflag=,$$(CONF_GCC_LINKER_OPTS_STAGE$1))
617 endef
618 $(eval $(call set_stage_HSC2HS_OPTS,0))
619 $(eval $(call set_stage_HSC2HS_OPTS,1))
620 $(eval $(call set_stage_HSC2HS_OPTS,2))
621 ifeq "$(CrossCompiling)" "YES"
622 SRC_HSC2HS_OPTS_STAGE1 += --cross-compile
623 SRC_HSC2HS_OPTS_STAGE2 += --cross-compile
624 endif
625 SRC_HSC2HS_OPTS_STAGE0 += --cflag=-D$(HostArch_CPP)_HOST_ARCH=1 --cflag=-D$(HostOS_CPP)_HOST_OS=1
626 SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(TargetOS_CPP)_HOST_OS=1
627 SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(TargetOS_CPP)_HOST_OS=1
628
629 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
630 WINDRES = $(INPLACE_MINGW)/bin/windres
631 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
632 WINDRES = $(INPLACE_MINGW)/bin/windres
633 endif
634
635 #-----------------------------------------------------------------------------
636 # Mingwex Library
637 #
638 HaveLibMingwEx = @HaveLibMingwEx@
639 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
640 DLLTOOL = inplace/mingw/bin/dlltool.exe
641 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
642 DLLTOOL = inplace/mingw/bin/dlltool.exe
643 endif
644
645 #-----------------------------------------------------------------------------
646 # Other standard (ha!) Unix utilities
647
648 AR = @ArCmd@
649 AR_OPTS = @ArArgs@
650 ArSupportsAtFile = @ArSupportsAtFile@
651
652 AR_STAGE0 = @AR_STAGE0@
653 AR_STAGE1 = $(AR)
654 AR_STAGE2 = $(AR)
655 AR_STAGE3 = $(AR)
656 AR_OPTS_STAGE0 = @AR_OPTS_STAGE0@
657 AR_OPTS_STAGE1 = $(AR_OPTS)
658 AR_OPTS_STAGE2 = $(AR_OPTS)
659 AR_OPTS_STAGE3 = $(AR_OPTS)
660 EXTRA_AR_ARGS_STAGE0 = $(EXTRA_AR_ARGS)
661 EXTRA_AR_ARGS_STAGE1 = $(EXTRA_AR_ARGS)
662 EXTRA_AR_ARGS_STAGE2 = $(EXTRA_AR_ARGS)
663 EXTRA_AR_ARGS_STAGE3 = $(EXTRA_AR_ARGS)
664 ArSupportsAtFile_STAGE0 = @ArSupportsAtFile_STAGE0@
665 ArSupportsAtFile_STAGE1 = $(ArSupportsAtFile)
666 ArSupportsAtFile_STAGE2 = $(ArSupportsAtFile)
667 ArSupportsAtFile_STAGE3 = $(ArSupportsAtFile)
668
669 CONTEXT_DIFF = @ContextDiffCmd@
670 CP = cp
671
672 # It's not easy to separate the CPP program from its flags, as
673 # AC_PROG_CPP defines CPP as "/usr/bin/gcc -E"
674 CPP = @CPP@ @CPPFLAGS@
675 HS_CPP = @HaskellCPPCmd@ @HaskellCPPArgs@
676
677 FIND = @FindCmd@
678
679 #
680 # Sigh - the autoconf macro for INSTALL will subst a relative path to the fallback
681 # install-sh script (if chosen). This not terribly useful to us, so we convert
682 # it into an abs. path.
683 #
684 INSTALL = @INSTALL@
685 INSTALL := $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
686
687 LN_S = @LN_S@
688 MV = mv
689 PERL = @PerlCmd@
690 PIC = pic
691 RANLIB_CMD = @RANLIB_CMD@
692 REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
693 SED = @SedCmd@
694 SHELL = @SHELL@
695
696 HaveDtrace = @HaveDtrace@
697 USE_DTRACE = $(HaveDtrace)
698 DTRACE = @DtraceCmd@
699
700 LD = @LdCmd@
701 NM = @NmCmd@
702 AR = @ArCmd@
703 OBJDUMP = @ObjdumpCmd@
704
705 LLC = @LlcCmd@
706 OPT = @OptCmd@
707
708 # GNU ld supports input via a linker script, which is useful to avoid
709 # overflowing command-line length limits.
710 LdIsGNULd = @LdIsGNULd@
711
712 # Set to YES if ld has the --build-id flag. Sometimes we need to
713 # disable it with --build-id=none.
714 LdHasBuildId = @LdHasBuildId@
715
716 # Set to YES if ld has the --no_compact_unwind flag. See #5019
717 # and compiler/main/DriverPipeline.hs.
718 LdHasNoCompactUnwind = @LdHasNoCompactUnwind@
719
720 # On MSYS, building with SplitObjs=YES fails with
721 # ar: Bad file number
722 # see #3201. We need to specify a smaller max command-line size
723 # to work around it. 32767 doesn't work; 30000 does, but says
724 # xargs: value for -s option should be < 28153
725 # so we now use 20000 to be comfortably below this bound
726 XARGS = xargs
727 ifeq "$(Windows_Host)" "YES"
728 XARGS_OPTS = -s 20000
729 endif
730
731 ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
732 STRIP_CMD = $(TOP)/inplace/mingw/bin/strip.exe
733 else
734 STRIP_CMD = strip
735 endif
736 PATCH_CMD = @PatchCmd@
737 TAR_CMD = @TarCmd@
738 BZIP2_CMD = bzip2
739 GZIP_CMD = gzip
740 XZ_CMD = xz -9e
741
742 # bzip2 is default compression
743 TAR_COMP = bzip2
744
745 # select compression command and .tar extension based on TAR_COMP value
746 ifeq "$(TAR_COMP)" "bzip2"
747 TAR_COMP_CMD = $(BZIP2_CMD)
748 TAR_COMP_EXT = bz2
749 else ifeq "$(TAR_COMP)" "gzip"
750 TAR_COMP_CMD = $(GZIP_CMD)
751 TAR_COMP_EXT = gz
752 else ifeq "$(TAR_COMP)" "xz"
753 TAR_COMP_CMD = $(XZ_CMD)
754 TAR_COMP_EXT = xz
755 else
756 $(error $$(TAR_COMP) set to unknown value "$(TAR_COMP)" (supported: "bzip2", "gzip", "xz"))
757 endif
758
759 ifeq "$(Windows_Host)" "YES"
760 TOUCH_CMD = $(utils/touchy_dist_INPLACE)
761 TOUCH_DEP = $(TOUCH_CMD)
762 else
763 TOUCH_CMD = touch
764 TOUCH_DEP =
765 endif
766
767 HSCOLOUR_CMD = @HSCOLOUR@
768
769 TIME_CMD = @TimeCmd@
770
771 #-----------------------------------------------------------------------------
772 # Sphinx stuff
773
774 SPHINXBUILD = @SPHINXBUILD@
775 BUILD_MAN = @BUILD_MAN@
776 BUILD_SPHINX_HTML = @BUILD_SPHINX_HTML@
777 BUILD_SPHINX_PDF = @BUILD_SPHINX_PDF@
778 SPHINXOPTS = -D latex_paper_size=letter
779 XELATEX = @XELATEX@
780
781 #-----------------------------------------------------------------------------
782 # FPtools support software
783
784 #
785 # ghc-pkg
786 #
787 GHC_PKG = @GhcPkgCmd@
788
789 #
790 # Happy
791 #
792 HAPPY = @HappyCmd@
793 HAPPY_VERSION = @HappyVersion@
794 #
795 # Options to pass to Happy when we're going to compile the output with GHC
796 #
797 SRC_HAPPY_OPTS = -agc --strict
798
799 #
800 # Alex
801 #
802 ALEX = @AlexCmd@
803 ALEX_VERSION = @AlexVersion@
804 Alex3 = @Alex3@
805 #
806 # Options to pass to Alex when we're going to compile the output with GHC
807 #
808 SRC_ALEX_OPTS = -g
809 ifeq "$(Alex3)" "YES"
810 # The compiler isn't using the Unicode support in Alex 3.0 yet, in fact we do our own
811 # Unicode handling, so diable Alex's.
812 compiler_ALEX_OPTS = --latin1
813 endif
814
815 # Should we build haddock docs?
816 HADDOCK_DOCS = YES
817 # And HsColour the sources?
818 ifeq "$(HSCOLOUR_CMD)" ""
819 HSCOLOUR_SRCS = NO
820 else
821 HSCOLOUR_SRCS = YES
822 endif
823
824 # Build and install DPH?
825 BUILD_DPH = NO
826 # Build and install the "extra" packages (see ./packages)?
827 BUILD_EXTRA_PKGS = NO
828
829 ################################################################################
830 #
831 # Library configure arguments
832 #
833 ################################################################################
834
835 CONFIGURE_ARGS = @CONFIGURE_ARGS@
836
837 ################################################################################
838 #
839 # To be passed to sub-builds
840 #
841 ################################################################################
842
843 ICONV_INCLUDE_DIRS = @ICONV_INCLUDE_DIRS@
844 ICONV_LIB_DIRS = @ICONV_LIB_DIRS@
845
846 GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
847 GMP_LIB_DIRS = @GMP_LIB_DIRS@
848
849 CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@
850 CURSES_LIB_DIRS = @CURSES_LIB_DIRS@