Pass -no-pie to GCC
[ghc.git] / distrib / configure.ac.in
index facba91..e733f64 100644 (file)
@@ -4,13 +4,7 @@ dnl
 #!/bin/sh
 #
 
-AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc])
-
-FP_BINDIST_GHC_PWD
-FP_FIND_ROOT
-
-BootingFromHc=NO
-AC_SUBST(BootingFromHc)
+AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
 
 dnl--------------------------------------------------------------------
 dnl * Deal with arguments telling us gmp is somewhere odd
@@ -18,9 +12,24 @@ dnl--------------------------------------------------------------------
 
 FP_GMP
 
-bootstrap_target=`ghc/stage2/build/tmp/ghc-stage2 +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
+bootstrap_target=@TargetPlatform@
 FPTOOLS_SET_PLATFORM_VARS
 
+# Requires FPTOOLS_SET_PLATFORM_VARS to be run first.
+FP_FIND_ROOT
+
+# ToDo: if Stage1Only=YES, should be YES
+CrossCompiling=NO
+CrossCompilePrefix=""
+TargetPlatformFull="${target}"
+
+AC_SUBST(CrossCompiling)
+AC_SUBST(CrossCompilePrefix)
+AC_SUBST(TargetPlatformFull)
+
+Unregisterised="@Unregisterised@"
+AC_SUBST(Unregisterised)
+
 #
 dnl ** Check Perl installation **
 #
@@ -30,7 +39,6 @@ if test -z "$PerlCmd"; then
    echo "Perhaps it is already installed, but not in your PATH?"
    exit 1
 fi
-FPTOOLS_SHEBANG_PERL
 
 #
 dnl ** figure out how to do a BSD-ish install **
@@ -47,22 +55,59 @@ dnl ** Find the path to sed **
 #
 AC_PATH_PROG(SedCmd,gsed sed,sed)
 
-#
-dnl ** How to invoke gcc/cpp **
-#
-FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc])
-export CC
-WhatGccIsCalled="$CC"
-AC_SUBST(WhatGccIsCalled)
+XCODE_VERSION()
+
+dnl ** Which gcc to use?
+dnl --------------------------------------------------------------
+AC_PROG_CC([gcc clang])
+
+# --with-hs-cpp/--with-hs-cpp-flags
+FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
+AC_SUBST([HaskellCPPCmd])
+AC_SUBST([HaskellCPPArgs])
+
+# Here is where we re-target which specific version of the LLVM
+# tools we are looking for. In the past, GHC supported a number of
+# versions of LLVM simultaneously, but that stopped working around
+# 3.5/3.6 release of LLVM.
+LlvmVersion=@LlvmVersion@
+
+dnl ** Which LLVM llc to use?
+dnl --------------------------------------------------------------
+FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
+LlcCmd="$LLC"
+AC_SUBST([LlcCmd])
+
+dnl ** Which LLVM opt to use?
+dnl --------------------------------------------------------------
+FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
+OptCmd="$OPT"
+AC_SUBST([OptCmd])
+
+dnl ** Which ld to use?
+dnl --------------------------------------------------------------
+FIND_LD([LdCmd])
+AC_SUBST([LdCmd])
 
 FP_GCC_VERSION
+FP_GCC_SUPPORTS_NO_PIE
 AC_PROG_CPP
 
+FP_PROG_LD_IS_GNU
+FP_PROG_LD_BUILD_ID
+FP_PROG_LD_NO_COMPACT_UNWIND
+FP_PROG_LD_FILELIST
+
 #
 dnl ** Check gcc version and flags we need to pass it **
 #
 FP_GCC_EXTRA_FLAGS
 
+FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS])
+dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
+FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
+FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
+
 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
@@ -82,13 +127,36 @@ AC_SUBST(CONF_CPP_OPTS_STAGE0)
 AC_SUBST(CONF_CPP_OPTS_STAGE1)
 AC_SUBST(CONF_CPP_OPTS_STAGE2)
 
-FP_SETTINGS
+dnl ** Set up the variables for the platform in the settings file.
+dnl May need to use gcc to find platform details.
+dnl --------------------------------------------------------------
+FPTOOLS_SET_HASKELL_PLATFORM_VARS
+
+dnl WordSize for settings.in
+AC_CHECK_SIZEOF(void *, 4)
+WordSize=$ac_cv_sizeof_void_p
+AC_SUBST(WordSize)
 
 #
 dnl ** how to invoke `ar' and `ranlib'
 #
+FP_PROG_AR_SUPPORTS_ATFILE
 FP_PROG_AR_NEEDS_RANLIB
 
+dnl ** Have libdw?
+dnl --------------------------------------------------------------
+dnl Check for a usable version of libdw/elfutils
+dnl Currently we need 0.158 or newer.
+BinDistNeedsLibdw=@UseLibdw@
+if test "x$BinDistNeedsLibdw" = "xYES" ; then
+  AC_CHECK_LIB(dw, dwfl_attach_state,
+    [UseLibdw=YES],
+    [AC_MSG_ERROR([Binary distribution was built with libdw support but target system doesn't have supported libdw version (needs at least 0.158)])]
+  )
+fi
+
+FP_SETTINGS
+
 #
 AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
 AC_OUTPUT