config.mk.in 28.5 KB
Newer Older
chak's avatar
chak committed
1
#								 -*-makefile-*-
2 3
# @configure_input@
#
4
################################################################################
5
#
6
# config.mk.in
7
#
8 9 10
# This file supplies defaults for many tweakable build configuration
# options.  Some of the defaults are filled in by the autoconf-generated
# 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 19 20 21 22
#	  definitions in build.mk.  See build.mk.sample for a good
#	  starting point for a build.mk file.
#
#	  If you don't have a build.mk file then you get defaults for everything.
#	  The defaults should provide a reasonable vanilla build.
23

Ian Lynagh's avatar
Ian Lynagh committed
24 25 26
# TOP: the top of the fptools hierarchy, absolute path.
# On Windows this is a c:/foo/bar style path.
TOP		= @hardtop@
sof's avatar
sof committed
27

Ian Lynagh's avatar
Ian Lynagh committed
28
include $(TOP)/mk/project.mk
sof's avatar
sof committed
29

30 31 32
# By default, be verbose
V = 1

33 34 35 36 37 38
################################################################################
#
#		Global configuration options
#
################################################################################

Ian Lynagh's avatar
Ian Lynagh committed
39 40 41
NO_INCLUDE_DEPS = NO
NO_INCLUDE_PKGDATA = NO

42
################################################################################
43 44
#
# Variables that control how the compiler itself is built
sof's avatar
sof committed
45
#
46
################################################################################
47

48 49
# The compiler used to build GHC is $(GHC).  To change the actual compiler
# used, re-configure with --with-ghc=<path-to-ghc>.
sof's avatar
sof committed
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:
sof's avatar
sof committed
54
#
55 56 57
#	-DDEBUG		include debugging code and assertions (will make the
#			compiler slower and produce debugging output, but useful
#			for development)
sof's avatar
sof committed
58 59
#
#	-dcore-lint	check the types after every pass of the compiler;
60 61 62 63
#			a pretty strong internal check of the compiler being
#			used to compile GHC.  Useful when bootstrapping.
GhcHcOpts=-Rghc-timing

64 65 66
# Extra options added to specific stages of the compiler bootstrap.
# These are placed later on the command line, and may therefore
# override options from $(GhcHcOpts).
67 68
#
# See Note [Stage number in build variables].
69
GhcStage1HcOpts=
70 71
GhcStage2HcOpts=-O2
GhcStage3HcOpts=-O2
72

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
# Disable -O2 optimization. Otherwise amount of generated C code
# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
# and sometimes not compile at all (powerpc64 overflows something
# on 'compiler/hsSyn/HsExpr.lhs').
ifeq "$(GhcUnregisterised)" "YES"
GhcStage1HcOpts=
GhcStage2HcOpts=
GhcStage3HcOpts=
endif

# Note [Stage number in build variables].
#
# There are (unfortunately) two different naming schemes for build variables
# specific to a certain stage.
#
# * GhcStage1HcOpts/GhcStage2HcOpts/GhcStage3HcOpts:
#
#   The stage number refers to the compiler stage being built (ghc library
#   and executable).
#
# * SRC_HC_OPTS_STAGE$4 and SRC_HC_WARNING_OPTS_STAGE$4:
#
#   The stage number refers to the compiler stage the options are passed to.

97
GhcDebugged=NO
98
GhcDynamic=NO
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
99 100 101

# GhcProfiled=YES means compile a profiled stage-2 compiler
GhcProfiled=NO
102

103 104 105 106 107 108 109
ifeq "$(findstring $(TargetOS_CPP),linux freebsd dragonfly openbsd netbsd solaris2 kfreebsdgnu haiku linux-android)" ""
TargetElf = NO
else
TargetElf = YES
endif

# Some platforms don't support shared libraries
110
NoSharedLibsPlatformList = \
111
	x86_64-unknown-mingw32 \
112
	i386-unknown-mingw32
113 114 115

ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
NoSharedLibsPlatformList += i386-unknown-solaris2
116 117 118
endif

PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
119
    $(NoSharedLibsPlatformList)),NO,YES)
120

121
# DYNAMIC_BY_DEFAULT says whether this compiler will default to
122
# building dynamic executables, i.e. -dynamic is on.  We do this for
123
# most platforms because it lets us use the system dynamic linker
124 125
# instead of our own linker for GHCi.
#
126 127
# Currently this isn't possible on Windows, and we have not yet enabled
# it on i386 while we consider the performance implications.
128
#
129 130 131 132 133 134 135
ifeq "$(TargetOS_CPP)" "mingw32"
DYNAMIC_BY_DEFAULT = NO
else ifeq "$(TargetArch_CPP)" "i386"
DYNAMIC_BY_DEFAULT = NO
else
DYNAMIC_BY_DEFAULT = YES
endif
136

137 138 139 140
# For now, we unconditionally disable dynamic-by-default, as the
# cabal-install's that are in the wild don't handle it properly.
DYNAMIC_BY_DEFAULT = NO

141 142
# If building both v and dyn ways, then use -dynamic-too to build them.
# This makes the build faster.
143
DYNAMIC_TOO = YES
144

145 146 147
# Use the dynamic way when building programs in the GHC tree. In
# particular, this means that GHCi will use DLLs rather than loading
# object files directly.
148 149 150
ifeq "$(TargetOS_CPP)" "mingw32"
# This doesn't work on Windows yet
DYNAMIC_GHC_PROGRAMS = NO
Austin Seipp's avatar
Austin Seipp committed
151
DYNAMIC_TOO=NO
152 153
else ifeq "$(PlatformSupportsSharedLibs)" "NO"
DYNAMIC_GHC_PROGRAMS = NO
154
else
155
DYNAMIC_GHC_PROGRAMS = YES
156
endif
157

158 159 160 161 162 163
# Build a compiler that will build *unregisterised* libraries and
# binaries by default.  Unregisterised code is supposed to compile and
# run without any support for architecture-specific assembly mangling,
# register assignment or tail-calls, and is therefore a good way to get
# started when porting GHC to new architectures.
#
164 165 166
# NOTE: the stage1 compiler will be a registerised binary (assuming
# the compiler you build with is generating registerised binaries), but
# the stage2 compiler will be an unregisterised binary.
167
#
168
GhcUnregisterised=@Unregisterised@
169

170 171 172 173
# Build a compiler with a native code generator backend
# (as well as a C backend)
#
# Target platforms supported:
174
#   i386, powerpc, powerpc64, sparc
175
#   IOS and AIX are not supported
176
ArchSupportsNCG=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc)))
177
OsSupportsNCG=$(strip $(patsubst $(TargetOS_CPP), YES, $(patsubst ios,,$(patsubst aix,,$(TargetOS_CPP)))))
178

179
GhcWithNativeCodeGen := $(strip\
180 181
    $(if $(filter YESYESNO,\
		  $(OsSupportsNCG)$(ArchSupportsNCG)$(GhcUnregisterised)),YES,NO))
182

183 184
HaveLibDL = @HaveLibDL@

185
# ArchSupportsSMP should be set iff there is support for that arch in
Simon Marlow's avatar
Simon Marlow committed
186
# includes/stg/SMP.h
187
ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le arm aarch64)))
188

189
GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
190

191 192
# Whether to include GHCi in the compiler.  Depends on whether the RTS linker
# has support for this OS/ARCH combination.
193

194
OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
195
ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc sparc64 arm aarch64)))
196 197

ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
198
GhcWithInterpreter=YES
199
else
200
GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_GHC_PROGRAMS)),YES,NO)
201
endif
202

203 204 205 206 207
# GhcEnableTablesNextToCode tells us whether the target architecture
# supports placing info tables directly before the entry code
# (see TABLES_NEXT_TO_CODE in the RTS).  Whether we actually compile for
# TABLES_NEXT_TO_CODE depends on whether we're building unregisterised
# code or not, which may be decided by options to the compiler later.
208
ifneq "$(findstring $(TargetArch_CPP)X, ia64X powerpc64X powerpc64leX)" ""
209
GhcEnableTablesNextToCode=NO
210
else
211
GhcEnableTablesNextToCode=YES
212 213
endif

214 215 216
# Whether to use libffi for adjustors (foreign import "wrapper") or
# not.  If we have built-in support (rts/Adjustor.c) then we use that,
# otherwise we fall back on libffi, which is slightly slower.
217
ArchHasAdjustorSupport = $(if $(findstring $(TargetArch_CPP),i386 x86_64),YES,NO)
218 219 220 221 222 223
ifeq "$(ArchHasAdjustorSupport)" "YES"
UseLibFFIForAdjustors=NO
else
UseLibFFIForAdjustors=YES
endif

Ian Lynagh's avatar
Ian Lynagh committed
224 225
# On Windows we normally want to make a relocatable bindist, to we
# ignore flags like libdir
226
ifeq "$(Windows_Host)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
227 228 229 230 231
RelocatableBuild = YES
else
RelocatableBuild = NO
endif

Simon Marlow's avatar
Simon Marlow committed
232 233 234
# needs to be after $(RelocatableBuild) is set above
include $(TOP)/mk/install.mk

235 236 237 238
# When building bindists we set this to yes so that the binaries are as
# portable as possible.
BeConservative = NO

239 240
ExtraMakefileSanityChecks = NO

241
#------------------------------------------------------------------------------
242
# Options for Libraries
243

244
# Which directory (in libraries/) contains the integer library?
245
INTEGER_LIBRARY=integer-gmp
246

Ian Lynagh's avatar
Ian Lynagh committed
247
# We build the libraries at least the "vanilla" way (way "v")
248 249
# Technically we don't need the v way if DYNAMIC_GHC_PROGRAMS is YES,
# but with -dynamic-too it's cheap, and makes life easier.
Ian Lynagh's avatar
Ian Lynagh committed
250 251
GhcLibWays = v

252
# In addition to the normal sequential way, the default is to also build
253
# profiled prelude libraries
254 255 256 257 258 259 260 261
# $(if $(filter ...)) allows controlling this expression from build.mk.
GhcLibWays += $(if $(filter $(BUILD_PROF_LIBS),NO),,p)

# Backward compatibility: although it would be cleaner to test for
# PlatformSupportsSharedLibs, or perhaps a new variable BUILD_SHARED_LIBS,
# some users currently expect that DYNAMIC_GHC_PROGRAMS=NO in build.mk implies
# that dyn is not added to GhcLibWays.
GhcLibWays += $(if $(filter $(DYNAMIC_GHC_PROGRAMS),NO),,dyn)
262

263 264 265
# Handy way to test whether we're building shared libs or not.
BuildSharedLibs=$(strip $(if $(findstring dyn,$(GhcLibWays)),YES,NO))

266 267
# In addition, the RTS is built in some further variations.  Ways that
# make sense here:
268
#
269 270 271 272
#   thr         : threaded
#   thr_p       : threaded profiled
#   debug       : debugging (compile with -g for the C compiler, and -DDEBUG)
#   debug_p     : debugging profiled
273 274
#   thr_debug   : debugging threaded
#   thr_debug_p : debugging threaded profiled
Simon Marlow's avatar
Simon Marlow committed
275 276
#   l           : event logging
#   thr_l       : threaded and event logging
277
#
Simon Marlow's avatar
Simon Marlow committed
278
GhcRTSWays=l
279 280

# Usually want the debug version
281
GhcRTSWays += debug
282

283 284 285 286
# We always have the threaded versions, but note that SMP support may be disabled
# (see GhcWithSMP).
GhcRTSWays += thr thr_debug thr_l
GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p,)
287
GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,)
288

289
# We can only build GHCi threaded if we have a threaded RTS:
290
GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
291

292 293 294 295
# Option flags to pass to GHC when it's compiling modules in
# fptools/libraries.  Typically these are things like -O or
# -dcore-lint or -H32m.  The ones that are *essential* are wired into
# the build system.
sof's avatar
sof committed
296
#
297
# 	-O(2) is pretty desirable, otherwise no inlining of prelude
sof's avatar
sof committed
298 299
#		things (incl "+") happens when compiling with this compiler

300
GhcLibHcOpts=-O2
rrt's avatar
rrt committed
301

302 303 304 305 306 307 308 309 310 311 312 313 314 315
# Strip local symbols from libraries?  This can make the libraries smaller,
# but makes debugging somewhat more difficult.  Doesn't work with all ld's.
#
StripLibraries=NO

# ----------------------------------------------------------------------------
# Object-file splitting
#
# 	Set SplitObjs=YES or NO in your build.mk
#
#	Don't use -split-objs in in GhcLibHcOpts, because the build
#		system needs to do other special magic if you are
#		doing object-file splitting

316
ArchSupportsSplitObjs=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 powerpc sparc),YES,NO))
317
OsSupportsSplitObjs=$(strip $(if $(filter $(TargetOS_CPP),mingw32 linux darwin solaris2 freebsd dragonfly netbsd openbsd),YES,NO))
318
SplitObjsBroken = @SplitObjsBroken@
319

320
SupportsSplitObjs := $(strip \
321 322
                    $(if $(and $(filter YES,$(ArchSupportsSplitObjs)),\
                               $(filter YES,$(OsSupportsSplitObjs)),\
323
                               $(filter NO,$(SplitObjsBroken)),\
324 325
                               $(filter NO,$(GhcUnregisterised))),\
                          YES,NO))
326 327 328

# By default, enable SplitObjs for the libraries if this build supports it
SplitObjs=$(SupportsSplitObjs)
329

330 331 332 333 334 335 336 337 338 339 340
# ----------------------------------------------------------------------------
# Section splitting
#
# Similar to -ffunction-sections -fdata-sections in GCC. Provides space saving
# like SplitObjs, but doesn't require post-processing and splitting of object
# files.
#
# Set SplitSections=YES in your build.mk to enable.

SplitSections=NO

341 342
# ----------------------------------------------------------------------------

343 344
# There are a number of things which technically depend on GHC (e.g. if
# ghc changes then Haskell files may be compiled differently, or Cabal
345 346 347 348 349 350 351 352 353
# packages may be configured differently). By default we therefore
# have dependencies on the compiler executable.

# However, in practice, having a dependency on GHC is just a pain: We
# normally don't want to spend time recompiling other things while
# we're working on the compiler, and even if we did, GHC will normally
# decide compilation isn't needed anyway. So by setting LAX_DEPENDENCIES
# to YES you can turn these dependencies into order-only dependencies,
# i.e. GHC must exist, but if it's newer than other targets then
354
# rebuilding is not necessary.
355 356

LAX_DEPENDENCIES = NO
357

358 359
# ----------------------------------------------------------------------------
# Options for GHC's RTS
360

361 362 363 364
# Build an optimised RTS.  Remember that we need to turn on
# optimisation both for C code (-optc-O2) and .cmm code (-O2).  For
# the debugging RTS flavour, rts/ghc.mk overrides these to turn off
# optimisation.
365
GhcRtsHcOpts=-O2
366
GhcRtsCcOpts=-O2 -fomit-frame-pointer -g
367

368 369 370 371 372 373 374
# Configuration for libffi
UseSystemLibFFI=@UseSystemLibFFI@
# Flags to go into package.conf for rts
FFILibDir=@FFILibDir@
FFIIncludeDir=@FFIIncludeDir@


375 376 377
# Include support for DWARF unwinding
GhcRtsWithLibdw = @HaveLibdw@

378
################################################################################
379 380 381
#
#		Paths (see paths.mk)
#
382
################################################################################
383

384
# Directory used by GHC (and possibly other tools) for storing
rrt's avatar
rrt committed
385
# temporary files.  If your TMPDIR isn't big enough, either override
386 387 388
# this in build.mk or set your environment variable "TMPDIR" to point
# to somewhere with more space.  (TMPDIR=. is a good choice).

389
# DEFAULT_TMPDIR isn't called TMPDIR because GNU make tends to
390 391 392
# override an environment variable with the value of the make variable
# of the same name (if it exists) when executing sub-processes, so
# setting the TMPDIR env var would have no effect in the build tree.
393 394

DEFAULT_TMPDIR		= /tmp
rrt's avatar
rrt committed
395
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
396
DEFAULT_TMPDIR		= /C/TEMP
rrt's avatar
rrt committed
397
endif
398

Ian Lynagh's avatar
Ian Lynagh committed
399 400 401
BIN_DIST_NAME         = ghc-$(ProjectVersion)
BIN_DIST_PREP_DIR     = bindistprep/$(BIN_DIST_NAME)
BIN_DIST_PREP_TAR     = bindistprep/$(BIN_DIST_NAME)-$(TARGETPLATFORM).tar
Herbert Valerio Riedel's avatar
Herbert Valerio Riedel committed
402 403
BIN_DIST_PREP_TAR_COMP = $(BIN_DIST_PREP_TAR).$(TAR_COMP_EXT)
BIN_DIST_TAR_COMP     = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT)
404

405
# -----------------------------------------------------------------------------
406
# Utilities programs: flags
407 408 409 410 411 412 413

# If you want to give any standard flags to pretty much any utility
# (see utils.mk for a complete list), by adding a line here
#
# 	SRC_P_OPTS += ...
#
# where P is the utility. For example, to add -O to all Haskell
414
# compilations,
415 416 417
#
#	SRC_HC_OPTS += -O

Simon Marlow's avatar
Simon Marlow committed
418 419 420 421

# SRC_HC_OPTS includes flags to be added to *every* Haskell
# compilation.  Setting SRC_HC_OPTS is a good way to set the default
# optimisation level (-O) and heap size (-H<size>).
422
#
Simon Marlow's avatar
Simon Marlow committed
423 424 425 426 427 428 429 430 431 432 433 434
# SRC_HC_OPTS is *not* for adding flags that are required to make your
# build work.  Examples:
#
#  - instead of using -pgmc/-pgma-/-pgml, use the --with-gcc option to configure
#
#  - if you need -optc, -opta, or -optl flags, the CONF_CC_* and CONF_LD_*
#    variables are more appropriate (set via configure)
#
# Note that SRC_HC_OPTS are added to every Haskell compilation,
# including when using the bootstrapping compiler (stage 0), So don't
# put options here that are only supported by very recent GHCs.
#
435
SRC_HC_OPTS += -H32m -O
436

437 438 439 440 441 442 443 444 445 446 447 448 449 450

# See Note [Stage number in build variables].
SRC_HC_OPTS_STAGE0 =
SRC_HC_OPTS_STAGE1 =
SRC_HC_OPTS_STAGE2 =

# Warning supression flags. See mk/warnings.mk.
SRC_CC_WARNING_OPTS =
SRC_HC_WARNING_OPTS =

# See Note [Stage number in build variables].
SRC_HC_WARNING_OPTS_STAGE0 =
SRC_HC_WARNING_OPTS_STAGE1 =
SRC_HC_WARNING_OPTS_STAGE2 =
451

452 453
# -----------------------------------------------------------------------------
# Names of programs in the GHC tree
Ian Lynagh's avatar
Ian Lynagh committed
454

455
MKDIRHIER           = $(INPLACE_BIN)/mkdirhier
Ian Lynagh's avatar
Ian Lynagh committed
456

457
GENERATED_FILE  = chmod a-w
Ian Lynagh's avatar
Ian Lynagh committed
458
EXECUTABLE_FILE = chmod +x
459

460
#-----------------------------------------------------------------------------
461
# Installed GHC
462

463
# $(GHC) points to installed version of the compiler.
464 465 466
#
# NOTE: Don't override $(GHC) in build.mk, use configure --with-ghc instead
# (because the version numbers have to be calculated).
467

Ian Lynagh's avatar
Ian Lynagh committed
468 469 470 471 472 473 474 475 476
GHC := @WithGhc@
# If we have a make dependency on c:/ghc/ghc, and the file is actually
# called c:/ghc/ghc.exe, then make will think that ghc doesn't exist
# and that it doesn't know how to create it.
ifneq "$(wildcard $(GHC).exe)" ""
GHC := $(GHC).exe
endif

GHC_STAGE0  = $(GHC)
477 478 479
GHC_STAGE1  = $(ghc-stage1_INPLACE)
GHC_STAGE2  = $(ghc-stage2_INPLACE)
GHC_STAGE3  = $(ghc-stage3_INPLACE)
480

Ian Lynagh's avatar
Ian Lynagh committed
481
BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
482

483
INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
484 485 486 487 488 489 490 491 492 493 494 495 496

GhcVersion	= @GhcVersion@
GhcPatchLevel	= @GhcPatchLevel@
GhcMajVersion	= @GhcMajVersion@
GhcMinVersion	= @GhcMinVersion@

# Canonicalised ghc version number, used for easy (integer) version
# comparisons.  We must expand $(GhcMinVersion) to two digits by
# adding a leading zero if necessary:
ifneq "$(findstring $(GhcMinVersion), 0 1 2 3 4 5 6 7 8 9)" ""
GhcCanonVersion = $(GhcMajVersion)0$(GhcMinVersion)
else
GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion)
497
endif
498

499 500
GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@

501 502
CMM_SINK_BOOTSTRAP_IS_NEEDED = @CMM_SINK_BOOTSTRAP_IS_NEEDED@

503
SUPPORTS_COMPONENT_ID = @SUPPORTS_COMPONENT_ID@
504

505 506 507
#-----------------------------------------------------------------------------
# C compiler
#
508 509 510 511
# NB. Don't override $(WhatGccIsCalled) using build.mk,  re-configure using
# the flag --with-gcc=<blah> instead.  The reason is that the configure script
# needs to know which gcc you're using in order to perform its tests.

512 513 514 515 516 517 518 519 520 521
WhatGccIsCalled       = @WhatGccIsCalled@
GccVersion            = @GccVersion@
ifeq "$(phase)" "0"
CrossCompilePrefix    =
else
CrossCompilePrefix    = @CrossCompilePrefix@
endif
# TargetPlatformFull retains the string passed to configure so we have it in
# the necessary format to pass to libffi's configure.
TargetPlatformFull    = @TargetPlatformFull@
Ian Lynagh's avatar
Ian Lynagh committed
522
GccLT34         = @GccLT34@
Ian Lynagh's avatar
Ian Lynagh committed
523
GccLT46         = @GccLT46@
524
GccIsClang      = @GccIsClang@
Simon Marlow's avatar
Simon Marlow committed
525

Ian Lynagh's avatar
Ian Lynagh committed
526
CC              = $(WhatGccIsCalled)
527
CC_STAGE0       = @CC_STAGE0@
Ian Lynagh's avatar
Ian Lynagh committed
528 529 530
CC_STAGE1       = $(CC)
CC_STAGE2       = $(CC)
CC_STAGE3       = $(CC)
Simon Marlow's avatar
Simon Marlow committed
531

532 533 534 535 536
AS              = $(WhatGccIsCalled)
AS_STAGE0       = @CC_STAGE0@
AS_STAGE1       = $(AS)
AS_STAGE2       = $(AS)
AS_STAGE3       = $(AS)
537

Simon Marlow's avatar
Simon Marlow committed
538 539 540 541 542 543 544
# We don't have an LD_STAGE0.  CC_STAGE0 is determined by asking "ghc
# --info", and it doesn't report an LD.
LD_STAGE0       = error-no-ld-stage0
LD_STAGE1       = $(LD)
LD_STAGE2       = $(LD)
LD_STAGE3       = $(LD)

545
# Cross-compiling options
546
# See Note [CrossCompiling vs Stage1Only]
547 548
CrossCompiling        = @CrossCompiling@

Simon Marlow's avatar
Simon Marlow committed
549 550
# Change this to YES if you're building a cross-compiler and don't
# want to build stage 2.
551 552
# See Note [CrossCompiling vs Stage1Only]
# See Note [Stage1Only vs stage=1]
Simon Marlow's avatar
Simon Marlow committed
553 554 555 556 557
Stage1Only = NO

# Install stage 2 by default, or stage 1 in the cross compiler
# case. Can be changed to 3
INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2)
558

559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
# Note [CrossCompiling vs Stage1Only]
#
# There are 4 possible settings:
#
# 1 CrossCompiling=NO Stage1Only=NO
#   The default.
#
# 2 CrossCompiling=NO Stage1Only=YES
#   Don't build ghc-stage2. See Note [Stage1Only vs stage=1].
#
# 3 CrossCompiling=YES Stage1Only=YES
#   Building a cross-compiler (ghc-stage1). See [1] and
#   Note [Stage1Only vs stage=1].
#
# 4 CrossCompiling=YES Stage1Only=NO
#   Cross-compiling GHC itself. See [1].
#
# [1] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling

# Note [Stage1Only vs stage=1]
#
# Stage1Only=YES means:
#   - don't build ghc-stage2 (the executable)
#   - don't build utils that rely on ghc-stage2
#     See Note [No stage2 packages when CrossCompiling or Stage1Only] in
#     ./ghc.mk.
#   - install ghc-stage1 instead of ghc-stage2
#   - install the ghc-pkg that was built with the stage0 compiler
#   - (*do* still build compiler/stage2 (i.e. the ghc library))
#   - (*do* still build all other libraries)
#
# stage=1 means:
#   - don't build compiler/stage2 (i.e. the ghc library)
#   - don't build ghc-stage2 (the executable)
#   Note: these are the only two things it does. If you want to exclude more
#   stuff, combine it with Stage1Only=YES, or run make in the ghc or compiler
#   directory.
#
# running make in the ghc or compiler directory means:
#   - don't build any packages in the libraries/ directory, except the ones
#     listed in PACKAGES_STAGE0 (i.e. the boot libraries)
#
# You may wonder why Stage1Only=YES still builds compiler/stage2. Quoting
# simonmar in #7639:
#
#     "strictly speaking building compiler/stage2 is correct, because it is
#     the ghc package that can be used with [ghc-stage1]. If you don't
#     want to build it, then setting stage=1 in your mk/build.mk should
#     disable it."

609
# C compiler and linker flags from configure (e.g. -m<blah> to select
610 611
# correct C compiler backend). The stage number is the stage of GHC
# that is being used to compile with.
612 613 614
CONF_CC_OPTS_STAGE0 = @CONF_CC_OPTS_STAGE0@
CONF_CC_OPTS_STAGE1 = @CONF_CC_OPTS_STAGE1@
CONF_CC_OPTS_STAGE2 = @CONF_CC_OPTS_STAGE2@
615 616 617 618 619 620
CONF_GCC_LINKER_OPTS_STAGE0 = @CONF_GCC_LINKER_OPTS_STAGE0@
CONF_GCC_LINKER_OPTS_STAGE1 = @CONF_GCC_LINKER_OPTS_STAGE1@
CONF_GCC_LINKER_OPTS_STAGE2 = @CONF_GCC_LINKER_OPTS_STAGE2@
CONF_LD_LINKER_OPTS_STAGE0 = @CONF_LD_LINKER_OPTS_STAGE0@
CONF_LD_LINKER_OPTS_STAGE1 = @CONF_LD_LINKER_OPTS_STAGE1@
CONF_LD_LINKER_OPTS_STAGE2 = @CONF_LD_LINKER_OPTS_STAGE2@
621 622 623
CONF_CPP_OPTS_STAGE0 = @CONF_CPP_OPTS_STAGE0@
CONF_CPP_OPTS_STAGE1 = @CONF_CPP_OPTS_STAGE1@
CONF_CPP_OPTS_STAGE2 = @CONF_CPP_OPTS_STAGE2@
624

625
ifeq "$(TARGETPLATFORM)" "ia64-unknown-linux"
626
CONF_CC_OPTS += -G0
627 628
endif

629 630 631
# The .hsc files aren't currently safe for cross-compilation on Windows:
#     libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:160
#     directive "let" is not safe for cross-compilation
632
ifneq "$(Windows_Host)" "YES"
633
SRC_HSC2HS_OPTS += --cross-safe
634
endif
635
SRC_HSC2HS_OPTS += $(foreach d,$(GMP_INCLUDE_DIRS),-I$(d))
636 637 638 639 640

define set_stage_HSC2HS_OPTS
# $1 = stage
SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(filter-out -O,$$(SRC_CC_OPTS) $$(CONF_CC_OPTS_STAGE$1)))
SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(CONF_CPP_OPTS_STAGE$1))
641
SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --lflag=,$$(CONF_GCC_LINKER_OPTS_STAGE$1))
642 643 644 645
endef
$(eval $(call set_stage_HSC2HS_OPTS,0))
$(eval $(call set_stage_HSC2HS_OPTS,1))
$(eval $(call set_stage_HSC2HS_OPTS,2))
646
ifeq "$(CrossCompiling)" "YES"
647 648
SRC_HSC2HS_OPTS_STAGE1 += --cross-compile
SRC_HSC2HS_OPTS_STAGE2 += --cross-compile
649
endif
650 651 652
SRC_HSC2HS_OPTS_STAGE0 += --cflag=-D$(HostArch_CPP)_HOST_ARCH=1 --cflag=-D$(HostOS_CPP)_HOST_OS=1
SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(TargetOS_CPP)_HOST_OS=1
SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(TargetOS_CPP)_HOST_OS=1
Ian Lynagh's avatar
Ian Lynagh committed
653

Ian Lynagh's avatar
Ian Lynagh committed
654 655 656
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
WINDRES = $(INPLACE_MINGW)/bin/windres
else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
657
WINDRES = $(INPLACE_MINGW)/bin/windres
Ian Lynagh's avatar
Ian Lynagh committed
658 659
endif

660
#-----------------------------------------------------------------------------
661
# Mingwex Library
662
#
663
HaveLibMingwEx	= @HaveLibMingwEx@
664
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
665
DLLTOOL			= inplace/mingw/bin/dlltool.exe
666
else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
667
DLLTOOL			= inplace/mingw/bin/dlltool.exe
668
endif
669

670 671 672 673
#-----------------------------------------------------------------------------
# Other standard (ha!) Unix utilities

AR			= @ArCmd@
674
AR_OPTS			= @ArArgs@
675
ArSupportsAtFile = @ArSupportsAtFile@
676

677
AR_STAGE0 = @AR_STAGE0@
678 679 680
AR_STAGE1 = $(AR)
AR_STAGE2 = $(AR)
AR_STAGE3 = $(AR)
681
AR_OPTS_STAGE0 = @AR_OPTS_STAGE0@
682 683 684 685 686 687 688
AR_OPTS_STAGE1 = $(AR_OPTS)
AR_OPTS_STAGE2 = $(AR_OPTS)
AR_OPTS_STAGE3 = $(AR_OPTS)
EXTRA_AR_ARGS_STAGE0 = $(EXTRA_AR_ARGS)
EXTRA_AR_ARGS_STAGE1 = $(EXTRA_AR_ARGS)
EXTRA_AR_ARGS_STAGE2 = $(EXTRA_AR_ARGS)
EXTRA_AR_ARGS_STAGE3 = $(EXTRA_AR_ARGS)
689
ArSupportsAtFile_STAGE0 = @ArSupportsAtFile_STAGE0@
690 691 692
ArSupportsAtFile_STAGE1 = $(ArSupportsAtFile)
ArSupportsAtFile_STAGE2 = $(ArSupportsAtFile)
ArSupportsAtFile_STAGE3 = $(ArSupportsAtFile)
693

694 695
CONTEXT_DIFF		= @ContextDiffCmd@
CP			= cp
thomie's avatar
thomie committed
696

697 698
# It's not easy to separate the CPP program from its flags, as
# AC_PROG_CPP defines CPP as "/usr/bin/gcc -E"
sof's avatar
sof committed
699
CPP			= @CPP@ @CPPFLAGS@
thomie's avatar
thomie committed
700
HS_CPP			= @HaskellCPPCmd@ @HaskellCPPArgs@
701

rrt's avatar
rrt committed
702
FIND			= @FindCmd@
703

sof's avatar
sof committed
704 705 706 707
#
# Sigh - the autoconf macro for INSTALL will subst a relative path to the fallback
# install-sh script (if chosen). This not terribly useful to us, so we convert
# it into an abs. path.
708
#
709
INSTALL			= @INSTALL@
Ian Lynagh's avatar
Ian Lynagh committed
710
INSTALL			:= $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
711

712 713 714 715
LN_S			= @LN_S@
MV			= mv
PERL 			= @PerlCmd@
PIC			= pic
716 717
RANLIB_CMD = @RANLIB_CMD@
REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
718
SED			= @SedCmd@
719
SHELL			= @SHELL@
720

721
HaveDtrace		= @HaveDtrace@
722
USE_DTRACE = $(HaveDtrace)
723 724
DTRACE			= @DtraceCmd@

725 726
LD = @LdCmd@
NM = @NmCmd@
727
AR = @ArCmd@
728
OBJDUMP = @ObjdumpCmd@
729

730 731 732
LLC = @LlcCmd@
OPT = @OptCmd@

733 734 735 736
# GNU ld supports input via a linker script, which is useful to avoid
# overflowing command-line length limits.
LdIsGNULd		= @LdIsGNULd@

737 738 739 740
# Set to YES if ld has the --build-id flag.  Sometimes we need to
# disable it with --build-id=none.
LdHasBuildId	        = @LdHasBuildId@

741 742 743 744
# Set to YES if ld has the --no_compact_unwind flag. See #5019
# and compiler/main/DriverPipeline.hs.
LdHasNoCompactUnwind	= @LdHasNoCompactUnwind@

745
# On MSYS, building with SplitObjs=YES fails with
746 747
#   ar: Bad file number
# see #3201.  We need to specify a smaller max command-line size
748 749 750
# to work around it.  32767 doesn't work; 30000 does, but says
#     xargs: value for -s option should be < 28153
# so we now use 20000 to be comfortably below this bound
751
XARGS = xargs
752
ifeq "$(Windows_Host)" "YES"
753
XARGS_OPTS = -s 20000
754 755
endif

Ian Lynagh's avatar
Ian Lynagh committed
756
ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
757
STRIP_CMD      = $(TOP)/inplace/mingw/bin/strip.exe
Ian Lynagh's avatar
Ian Lynagh committed
758
else
759
STRIP_CMD      = strip
Ian Lynagh's avatar
Ian Lynagh committed
760
endif
761 762 763 764
PATCH_CMD      = @PatchCmd@
TAR_CMD        = @TarCmd@
BZIP2_CMD      = bzip2
GZIP_CMD       = gzip
765
XZ_CMD         = xz -9e
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782

# bzip2 is default compression
TAR_COMP      = bzip2

# select compression command and .tar extension based on TAR_COMP value
ifeq "$(TAR_COMP)" "bzip2"
TAR_COMP_CMD  = $(BZIP2_CMD)
TAR_COMP_EXT  = bz2
else ifeq "$(TAR_COMP)" "gzip"
TAR_COMP_CMD  = $(GZIP_CMD)
TAR_COMP_EXT  = gz
else ifeq "$(TAR_COMP)" "xz"
TAR_COMP_CMD  = $(XZ_CMD)
TAR_COMP_EXT  = xz
else
$(error $$(TAR_COMP) set to unknown value "$(TAR_COMP)" (supported: "bzip2", "gzip", "xz"))
endif
sof's avatar
sof committed
783

784
ifeq "$(Windows_Host)" "YES"
785 786 787 788 789 790 791
TOUCH_CMD      = $(utils/touchy_dist_INPLACE)
TOUCH_DEP      = $(TOUCH_CMD)
else
TOUCH_CMD      = touch
TOUCH_DEP      =
endif

792
HSCOLOUR_CMD   = @HSCOLOUR@
793

794
TIME_CMD       = @TimeCmd@
795

796
#-----------------------------------------------------------------------------
797 798 799 800 801 802 803 804
# Sphinx stuff

SPHINXBUILD              = @SPHINXBUILD@
BUILD_MAN                = @BUILD_MAN@
BUILD_SPHINX_HTML        = @BUILD_SPHINX_HTML@
BUILD_SPHINX_PDF         = @BUILD_SPHINX_PDF@
SPHINXOPTS               = -D latex_paper_size=letter
XELATEX                  = @XELATEX@
805

806 807 808
#-----------------------------------------------------------------------------
# 		FPtools support software

reid's avatar
reid committed
809 810 811 812 813
#
# ghc-pkg
#
GHC_PKG		        = @GhcPkgCmd@

814 815 816 817
#
# Happy
#
HAPPY			= @HappyCmd@
818
HAPPY_VERSION		= @HappyVersion@
819 820 821
#
# Options to pass to Happy when we're going to compile the output with GHC
#
Ian Lynagh's avatar
Ian Lynagh committed
822
SRC_HAPPY_OPTS		= -agc --strict
823

824 825 826 827
#
# Alex
#
ALEX			= @AlexCmd@
828
ALEX_VERSION		= @AlexVersion@
829
Alex3			= @Alex3@
830
#
831
# Options to pass to Alex when we're going to compile the output with GHC
832
#
833
SRC_ALEX_OPTS = -g
834
ifeq "$(Alex3)" "YES"
835
# The compiler isn't using the Unicode support in Alex 3.0 yet, in fact we do our own
836
# Unicode handling, so diable Alex's.
837
compiler_ALEX_OPTS = --latin1
838
endif
839

840
# Should we build haddock docs?
Ian Lynagh's avatar
Ian Lynagh committed
841
HADDOCK_DOCS = YES
842
# And HsColour the sources?
843
ifeq "$(HSCOLOUR_CMD)" ""
844 845 846 847 848
HSCOLOUR_SRCS = NO
else
HSCOLOUR_SRCS = YES
endif

849
# Build and install DPH?
850
BUILD_DPH = NO
851
# Build and install the "extra" packages (see ./packages)?
852
BUILD_EXTRA_PKGS = NO
853

854 855 856 857 858 859 860 861
################################################################################
#
#    Library configure arguments
#
################################################################################

CONFIGURE_ARGS = @CONFIGURE_ARGS@

862 863 864 865 866 867 868 869 870
################################################################################
#
#    To be passed to sub-builds
#
################################################################################

ICONV_INCLUDE_DIRS = @ICONV_INCLUDE_DIRS@
ICONV_LIB_DIRS = @ICONV_LIB_DIRS@

871 872
GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
GMP_LIB_DIRS = @GMP_LIB_DIRS@
873 874 875

CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@
CURSES_LIB_DIRS = @CURSES_LIB_DIRS@