Allow different customizations per cross target
[ghc.git] / mk / config.mk.in
index 7e24ead..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 $(HostArch_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)
@@ -151,11 +170,10 @@ endif
 # Target platforms supported:
 #   i386, powerpc
 #   AIX is not supported 
-ArchSupportsNCG=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 powerpc sparc)))
-OsSupportsNCG=$(strip $(patsubst $(HostOS_CPP), YES, $(patsubst aix,,$(HostOS_CPP))))
+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))
 
@@ -163,21 +181,20 @@ HaveLibDL = @HaveLibDL@
 
 # ArchSupportsSMP should be set iff there is support for that arch in
 # includes/stg/SMP.h
-ArchSupportsSMP=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 sparc powerpc arm)))
+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 $(HostOS_CPP), YES, $(findstring $(HostOS_CPP), mingw32 cygwin32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
-ArchSupportsGHCi=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 powerpc sparc sparc64)))
+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 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
@@ -194,7 +211,7 @@ endif
 # 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.
-ArchHasAdjustorSupport = $(if $(findstring $(HostArch_CPP),i386 x86_64),YES,NO)
+ArchHasAdjustorSupport = $(if $(findstring $(TargetArch_CPP),i386 x86_64),YES,NO)
 ifeq "$(ArchHasAdjustorSupport)" "YES"
 UseLibFFIForAdjustors=NO
 else
@@ -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)
 
 # -----------------------------------------------------------------------------
@@ -515,9 +542,6 @@ GHC_STAGE1  = $(INPLACE_BIN)/ghc-stage1$(exeext)
 GHC_STAGE2  = $(INPLACE_BIN)/ghc-stage2$(exeext)
 GHC_STAGE3  = $(INPLACE_BIN)/ghc-stage3$(exeext)
 
-# Install stage 2 by default, can be changed to 3
-INSTALL_GHC_STAGE=2
-
 BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
 
 INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
@@ -536,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
@@ -553,21 +569,51 @@ endif
 # 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.
 
-WhatGccIsCalled = @WhatGccIsCalled@
-GccVersion      = @GccVersion@
+WhatGccIsCalled       = @WhatGccIsCalled@
+GccVersion            = @GccVersion@
+GlobalCrossCompilePrefix = @CrossCompilePrefix@
+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@
 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
+#
+CrossCompiling        = @CrossCompiling@
+
+# 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
 # that is being used to compile with.
@@ -596,12 +642,25 @@ SRC_HSC2HS_OPTS += --cross-safe
 endif
 SRC_HSC2HS_OPTS += $(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)))
 SRC_HSC2HS_OPTS += $(foreach d,$(GMP_INCLUDE_DIRS),-I$(d))
+ifeq "$(CrossCompiling)" "YES"
+SRC_HSC2HS_OPTS += --cross-compile
+endif
+
+ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+WINDRES = $(INPLACE_MINGW)/bin/windres
+else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
+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)
@@ -647,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
@@ -664,7 +722,6 @@ LN_S                        = @LN_S@
 MV                     = mv
 NROFF                  = nroff
 PERL                   = @PerlCmd@
-PYTHON                 = @PythonCmd@
 PIC                    = pic
 RANLIB                 = @RANLIB@
 SED                    = @SedCmd@
@@ -677,11 +734,10 @@ DTRACE                    = @DtraceCmd@
 
 LD = @LdCmd@
 NM = @NmCmd@
+OBJDUMP = @ObjdumpCmd@
 
-# 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@
+LLC = @LlcCmd@
+OPT = @OptCmd@
 
 # GNU ld supports input via a linker script, which is useful to avoid
 # overflowing command-line length limits.
@@ -730,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
@@ -762,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@