Allow different customizations per cross target
[ghc.git] / mk / config.mk.in
index 2482da8..0fc3a1d 100644 (file)
@@ -27,6 +27,9 @@ TOP           = @hardtop@
 
 include $(TOP)/mk/project.mk
 
+# By default, be verbose
+V = 1
+
 ################################################################################
 #
 #              Global configuration options
@@ -119,7 +122,7 @@ SharedLibsPlatformList =                        \
     i386-unknown-freebsd x86_64-unknown-freebsd \
     i386-unknown-openbsd x86_64-unknown-openbsd \
     i386-unknown-netbsd  x86_64-unknown-netbsd  \
-    i386-unknown-mingw32                        \
+    i386-unknown-mingw32 x86_64-unknown-mingw32 \
     i386-apple-darwin    x86_64-apple-darwin    powerpc-apple-darwin
 
 ifeq "$(SOLARIS_BROKEN_SHLD)" "NO"
@@ -129,6 +132,26 @@ endif
 PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
        $(SharedLibsPlatformList)),YES,NO)
 
+# DYNAMIC_BY_DEFAULT says whether this compiler will default to
+# building dynamic executables, i.e. -dynamic is on.  We do this for
+# most platforms because it lets us use the system dynamic linker
+# instead of our own linker for GHCi.
+#
+# Currently this isn't possible on Windows, and we have not yet enabled
+# it on i386 while we consider the performance implications.
+#
+ifeq "$(TargetOS_CPP)" "mingw32"
+DYNAMIC_BY_DEFAULT = NO
+else ifeq "$(TargetArch_CPP)" "i386"
+DYNAMIC_BY_DEFAULT = NO
+else
+DYNAMIC_BY_DEFAULT = YES
+endif
+
+# 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
+
 # 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,
@@ -139,11 +162,7 @@ PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
 # the compiler you build with is generating registerised binaries), but
 # the stage2 compiler will be an unregisterised binary.
 #
-ifneq "$(findstring $(TargetArch_CPP), i386 x86_64 powerpc arm)" ""
-GhcUnregisterised=NO
-else
-GhcUnregisterised=YES
-endif
+GhcUnregisterised=@Unregisterised@
 
 # Build a compiler with a native code generator backend
 # (as well as a C backend)
@@ -154,8 +173,7 @@ endif
 ArchSupportsNCG=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc sparc)))
 OsSupportsNCG=$(strip $(patsubst $(TargetOS_CPP), YES, $(patsubst aix,,$(TargetOS_CPP))))
 
-# lazy test, because $(GhcUnregisterised) might be set in build.mk later.
-GhcWithNativeCodeGen=$(strip\
+GhcWithNativeCodeGen := $(strip\
     $(if $(filter YESYESNO,\
                  $(OsSupportsNCG)$(ArchSupportsNCG)$(GhcUnregisterised)),YES,NO))
 
@@ -165,19 +183,18 @@ HaveLibDL = @HaveLibDL@
 # includes/stg/SMP.h
 ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc arm)))
 
-# lazy test, because $(GhcUnregisterised) might be set in build.mk later.
-GhcWithSMP=$(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
+GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
 
 # Whether to include GHCi in the compiler.  Depends on whether the RTS linker
 # has support for this OS/ARCH combination.
 
 OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 cygwin32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
-ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc sparc sparc64)))
+ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc sparc sparc64 arm)))
 
 ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
 GhcWithInterpreter=YES
 else 
-GhcWithInterpreter=NO
+GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_BY_DEFAULT)),YES,NO)
 endif
 
 # GhcEnableTablesNextToCode tells us whether the target architecture
@@ -216,6 +233,8 @@ include $(TOP)/mk/install.mk
 # portable as possible.
 BeConservative = NO
 
+ExtraMakefileSanityChecks = NO
+
 #
 # Building various ways?
 # (right now, empty if not).
@@ -267,7 +286,7 @@ endif
 # (see GhcWithSMP).
 GhcRTSWays += thr thr_debug thr_l
 GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p,)
-GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn,)
+GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,)
 
 # We can only build GHCi threaded if we have a threaded RTS:
 GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
@@ -304,8 +323,7 @@ ArchSupportsSplitObjs=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 powerp
 OsSupportsSplitObjs=$(strip $(if $(filter $(TargetOS_CPP),mingw32 cygwin32 linux darwin solaris2 freebsd dragonfly netbsd openbsd),YES,NO))
 SplitObjsBroken = @SplitObjsBroken@
 
-# lazy test, so that $(GhcUnregisterised) can be set in build.mk
-SupportsSplitObjs=$(strip \
+SupportsSplitObjs := $(strip \
                     $(if $(and $(filter YES,$(ArchSupportsSplitObjs)),\
                                $(filter YES,$(OsSupportsSplitObjs)),\
                                $(filter NO,$(SplitObjsBroken)),\
@@ -348,10 +366,12 @@ LAX_DEPENDENCIES = NO
 # ----------------------------------------------------------------------------
 # Options for GHC's RTS
 
-# For an optimised RTS (you probably don't want to change these; we build
-# a debugging RTS by default now.  Use -debug to get it).
-GhcRtsHcOpts=-optc-O2
-GhcRtsCcOpts=-fomit-frame-pointer
+# 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.
+GhcRtsHcOpts=-O2
+GhcRtsCcOpts=-O2 -fomit-frame-pointer
 
 # Include the front panel code?  Needs GTK+.
 GhcRtsWithFrontPanel = NO
@@ -362,6 +382,13 @@ GhcRtsWithPapi = NO
 PapiLibDir=
 PapiIncludeDir=
 
+# Configuration for libffi
+UseSystemLibFFI=@UseSystemLibFFI@
+# Flags to go into package.conf for rts
+FFILibDir=@FFILibDir@
+FFIIncludeDir=@FFIIncludeDir@
+
+
 ################################################################################
 #
 #              Paths (see paths.mk)
@@ -393,7 +420,7 @@ BIN_DIST_PREP_TAR_BZ2 = $(BIN_DIST_PREP_TAR).bz2
 BIN_DIST_TAR_BZ2      = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.bz2
 BIN_DIST_LIST         = bindist-list
 
-WINDOWS_INSTALLER_BASE = ghc-$(ProjectVersion)-i386-windows
+WINDOWS_INSTALLER_BASE = ghc-$(ProjectVersion)-$(TargetArch_CPP)-windows
 WINDOWS_INSTALLER = $(WINDOWS_INSTALLER_BASE)$(exeext)
 
 # -----------------------------------------------------------------------------
@@ -533,15 +560,7 @@ else
 GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion)
 endif
 
-# Work around #5453, which causes the stage1 compiler to segfault when
-# built with 7.2.1.
-ifeq "$(GhcVersion)" "7.2.1"
-CONF_HC_OPTS_STAGE0 += -fno-full-laziness
-compiler/cmm/Bitmap_HC_OPTS += -ffull-laziness
-# urgh.  Compiling cmm/Bitmap.hs with -fno-full-laziness results in 
-#   "gmp: overflow in mpz type"
-# for some unknown reason, so turn full-laziness back on for this module.
-endif
+GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
 
 #-----------------------------------------------------------------------------
 # C compiler
@@ -552,7 +571,7 @@ endif
 
 WhatGccIsCalled       = @WhatGccIsCalled@
 GccVersion            = @GccVersion@
-AlienScript           = @AlienScript@
+GlobalCrossCompilePrefix = @CrossCompilePrefix@
 ifeq "$(phase)" "0"
 CrossCompilePrefix    =
 else
@@ -563,32 +582,37 @@ endif
 TargetPlatformFull    = @TargetPlatformFull@
 GccLT34         = @GccLT34@
 GccLT46         = @GccLT46@
+
 CC              = $(WhatGccIsCalled)
 CC_STAGE0       = @CC_STAGE0@
 CC_STAGE1       = $(CC)
 CC_STAGE2       = $(CC)
 CC_STAGE3       = $(CC)
+
 AS              = $(WhatGccIsCalled)
 AS_STAGE0       = @CC_STAGE0@
 AS_STAGE1       = $(AS)
 AS_STAGE2       = $(AS)
 AS_STAGE3       = $(AS)
 
+# 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)
+
 # Cross-compiling options
 #
-# The 'toolchain' case: Cross-compiler to run locally:
-BuildingCrossCompiler = @BuildingCrossCompiler@
-# The 'port' case: Porting to a foreign architecture:
-PortingCompiler       = @PortingCompiler@
-# BuildingCrossCompiler OR PortingCompiler
 CrossCompiling        = @CrossCompiling@
 
-# Install stage 2 by default, or stage 1 in the cross compiler case. Can be changed to 3
-ifeq "$(BuildingCrossCompiler)" "YES"
-INSTALL_GHC_STAGE=1
-else
-INSTALL_GHC_STAGE=2
-endif
+# Change this to YES if you're building a cross-compiler and don't
+# want to build stage 2.
+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)
 
 # C compiler and linker flags from configure (e.g. -m<blah> to select
 # correct C compiler backend). The stage number is the stage of GHC
@@ -625,14 +649,18 @@ endif
 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
 WINDRES = $(INPLACE_MINGW)/bin/windres
 else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
-WINDRES = $(INPLACE_MINGW)/bin/x86_64-w64-mingw32-windres
+WINDRES = $(INPLACE_MINGW)/bin/windres
 endif
 
 #-----------------------------------------------------------------------------
 # Mingwex Library
 #
 HaveLibMingwEx = @HaveLibMingwEx@
+ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
 DLLTOOL                        = inplace/mingw/bin/dlltool.exe
+else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
+DLLTOOL                        = inplace/mingw/bin/dlltool.exe
+endif
 
 #-----------------------------------------------------------------------------
 # Flex (currently unused, could be moved to glafp-utils)
@@ -678,7 +706,6 @@ CTAGS                       = $(ETAGS)
 #
 RAWCPP_FLAGS            = -undef -traditional
 FIND                   = @FindCmd@
-SORT                   = @SortCmd@
 
 #
 # Sigh - the autoconf macro for INSTALL will subst a relative path to the fallback
@@ -695,7 +722,6 @@ LN_S                        = @LN_S@
 MV                     = mv
 NROFF                  = nroff
 PERL                   = @PerlCmd@
-PYTHON                 = @PythonCmd@
 PIC                    = pic
 RANLIB                 = @RANLIB@
 SED                    = @SedCmd@
@@ -708,15 +734,11 @@ DTRACE                    = @DtraceCmd@
 
 LD = @LdCmd@
 NM = @NmCmd@
+OBJDUMP = @ObjdumpCmd@
 
 LLC = @LlcCmd@
 OPT = @OptCmd@
 
-# Some ld's support the -x flag and some don't, so the configure
-# script detects which we have and sets LdXFlag to "-x" or ""
-# respectively.
-LD_X                   = @LdXFlag@
-
 # GNU ld supports input via a linker script, which is useful to avoid
 # overflowing command-line length limits.
 LdIsGNULd              = @LdIsGNULd@
@@ -764,7 +786,11 @@ endif
 #
 REAL_SHELL     = $(SHELL)
 
+ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
+STRIP_CMD      = $(TOP)/inplace/mingw/bin/strip.exe
+else
 STRIP_CMD      = strip
+endif
 PATCH_CMD      = @PatchCmd@
 TAR_CMD        = @TarCmd@
 BZIP2_CMD      = bzip2
@@ -796,6 +822,8 @@ BUILD_DOCBOOK_HTML       = @BUILD_DOCBOOK_HTML@
 BUILD_DOCBOOK_PS         = @BUILD_DOCBOOK_PS@
 BUILD_DOCBOOK_PDF        = @BUILD_DOCBOOK_PDF@
 DBLATEX                  = @DblatexCmd@
+# filename.as.url=0 is needed with dblatex 0.3.4 (#7486)
+DBLATEX_OPTS             = -P 'filename.as.url=0'
 XSLTPROC                 = @XsltprocCmd@
 XMLLINT                  = @XmllintCmd@
 HAVE_DOCBOOK_XSL        = @HAVE_DOCBOOK_XSL@