2007-02-24 11:00:05 +00:00
|
|
|
# Copyright 2007 Yann E. MORIN
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package.
|
|
|
|
|
|
|
|
# This is the main entry point to crosstool
|
|
|
|
# This will:
|
|
|
|
# - download, extract and patch the toolchain components
|
|
|
|
# - build and install each components in turn
|
|
|
|
# - and eventually test the resulting toolchain
|
|
|
|
|
|
|
|
# What this file does is prepare the environment, based upon the user-choosen
|
|
|
|
# options. It also checks the existing environment for un-friendly variables,
|
2007-05-17 16:22:51 +00:00
|
|
|
# and builds the tools.
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
# Parse the common functions
|
2008-05-14 17:56:33 +00:00
|
|
|
# Note: some initialisation and sanitizing is done while parsing this file,
|
|
|
|
# most notably:
|
|
|
|
# - set trap handler on errors,
|
|
|
|
# - don't hash commands lookups,
|
2007-07-01 19:04:20 +00:00
|
|
|
. "${CT_LIB_DIR}/scripts/functions"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2016-12-14 06:18:50 +00:00
|
|
|
# Read the sample settings
|
|
|
|
CT_LoadConfig
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2017-01-25 23:45:37 +00:00
|
|
|
# Yes! We can do full logging from now on! Clean any old log file content.
|
|
|
|
CT_LogEnable clean=yes
|
2016-12-14 08:59:08 +00:00
|
|
|
|
2013-01-10 21:38:48 +00:00
|
|
|
# Check running as root
|
|
|
|
if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then
|
2013-01-10 22:09:38 +00:00
|
|
|
if [ $(id -u) -eq 0 ]; then
|
2013-01-10 21:38:48 +00:00
|
|
|
CT_DoLog ERROR "You must NOT be root to run crosstool-NG"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-10-06 21:48:07 +00:00
|
|
|
# If we want an interactive debug-shell, we must ensure these FDs
|
|
|
|
# are indeed connected to a terminal (and not redirected in any way).
|
|
|
|
if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then
|
|
|
|
CT_DoLog ERROR "Can't spawn interactive debug-shell,"
|
|
|
|
CT_DoLog ERROR "because stdout/stderr has been redirected."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-07-17 14:53:40 +00:00
|
|
|
# Override the locale early, in case we ever translate crosstool-NG messages
|
2017-01-28 07:19:36 +00:00
|
|
|
if [ -z "${CT_NO_OVERRIDE_LC_MESSAGES}" ]; then
|
2010-11-01 15:59:39 +00:00
|
|
|
export LC_ALL=C
|
|
|
|
export LANG=C
|
|
|
|
fi
|
2008-11-20 17:48:10 +00:00
|
|
|
|
2010-07-29 17:30:37 +00:00
|
|
|
# remove . from PATH since it can cause gcc build failures
|
|
|
|
CT_SanitizePath
|
|
|
|
|
2009-06-22 19:53:09 +00:00
|
|
|
# Some sanity checks in the environment and needed tools
|
|
|
|
CT_DoLog INFO "Performing some trivial sanity checks"
|
|
|
|
CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
|
2012-09-25 22:53:29 +00:00
|
|
|
CT_TestAndAbort "Don't set LIBRARY_PATH. It screws up the build." -n "${LIBRARY_PATH}"
|
|
|
|
CT_TestAndAbort "Don't set LPATH. It screws up the build." -n "${LPATH}"
|
2016-02-04 10:29:18 +00:00
|
|
|
CT_TestAndAbort "Don't set CPATH. It screws up the build." -n "${CPATH}"
|
|
|
|
CT_TestAndAbort "Don't set C_INCLUDE_PATH. It screws up the build." -n "${C_INCLUDE_PATH}"
|
|
|
|
CT_TestAndAbort "Don't set CPLUS_INCLUDE_PATH. It screws up the build." -n "${CPLUS_INCLUDE_PATH}"
|
|
|
|
CT_TestAndAbort "Don't set OBJC_INCLUDE_PATH. It screws up the build." -n "${OBJC_INCLUDE_PATH}"
|
2009-06-22 19:53:09 +00:00
|
|
|
CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
|
|
|
|
CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
|
2017-05-10 20:00:23 +00:00
|
|
|
CT_TestAndAbort "Don't set CC. It screws up the build." -n "${CC}"
|
2017-05-10 11:48:59 +00:00
|
|
|
CT_TestAndAbort "Don't set CXX. It screws up the build." -n "${CXX}"
|
2009-06-22 19:53:09 +00:00
|
|
|
CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
|
|
|
|
export GREP_OPTIONS=
|
2011-12-12 19:41:16 +00:00
|
|
|
# Workaround against openSUSE 12.1 that breaks ./configure for cross-compilation:
|
|
|
|
export CONFIG_SITE=
|
2009-06-22 19:53:09 +00:00
|
|
|
|
|
|
|
# Some sanity checks on paths content
|
|
|
|
for d in \
|
|
|
|
LOCAL_TARBALLS \
|
|
|
|
WORK \
|
|
|
|
PREFIX \
|
|
|
|
INSTALL \
|
|
|
|
; do
|
|
|
|
eval dir="\${CT_${d}_DIR}"
|
|
|
|
case "${dir}" in
|
|
|
|
*" "*)
|
|
|
|
CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things."
|
2012-11-21 00:59:17 +00:00
|
|
|
;;
|
|
|
|
*:*)
|
|
|
|
CT_Abort "'CT_${d}_DIR'='${dir}' contains a colon in it.\nDon't use colons in paths, it breaks things."
|
2009-06-22 19:53:09 +00:00
|
|
|
;;
|
2014-01-02 23:13:15 +00:00
|
|
|
*,*)
|
|
|
|
CT_Abort "'CT_${d}_DIR'='${dir}' contains a comma in it.\nDon't use commas in paths, it breaks things."
|
|
|
|
;;
|
2009-06-22 19:53:09 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2009-01-26 22:43:08 +00:00
|
|
|
# Where will we work?
|
2012-10-17 19:52:59 +00:00
|
|
|
CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}"
|
2017-06-15 04:20:28 +00:00
|
|
|
CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build"
|
2009-03-27 18:53:54 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}"
|
2012-10-14 23:46:15 +00:00
|
|
|
CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/backtrace"
|
2009-03-27 18:53:54 +00:00
|
|
|
|
|
|
|
# Check build file system case-sensitiveness
|
2009-03-29 21:05:13 +00:00
|
|
|
CT_DoExecLog DEBUG touch "${CT_WORK_DIR}/foo"
|
2009-03-27 18:53:54 +00:00
|
|
|
CT_TestAndAbort "Your file system in '${CT_WORK_DIR}' is *not* case-sensitive!" -f "${CT_WORK_DIR}/FOO"
|
2009-03-29 21:05:13 +00:00
|
|
|
CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/foo"
|
2009-01-26 22:43:08 +00:00
|
|
|
|
2009-08-02 21:43:15 +00:00
|
|
|
# Check the user is using an existing SHELL to be used by ./configure and Makefiles
|
2011-10-11 19:43:42 +00:00
|
|
|
CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CONFIG_SHELL}" -a -x "${CT_CONFIG_SHELL}"
|
2009-06-23 20:56:39 +00:00
|
|
|
|
2011-07-17 14:53:40 +00:00
|
|
|
# Create the bin-override early
|
2009-03-03 17:41:59 +00:00
|
|
|
# Contains symlinks to the tools found by ./configure
|
2009-01-26 22:43:08 +00:00
|
|
|
# Note: CT_DoLog and CT_DoExecLog do not use any of those tool, so
|
|
|
|
# they can be safely used
|
2017-01-28 07:19:36 +00:00
|
|
|
CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools"
|
|
|
|
CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'"
|
|
|
|
CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin"
|
2012-01-16 22:36:42 +00:00
|
|
|
cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do
|
2009-01-26 22:43:08 +00:00
|
|
|
tool="${line%%=*}"
|
2017-01-28 07:19:36 +00:00
|
|
|
# Suppress extra quoting
|
|
|
|
eval path=${line#*=}
|
|
|
|
if [ -r "${CT_LIB_DIR}/scripts/override/$tool" ]; then
|
|
|
|
tmpl="${CT_LIB_DIR}/scripts/override/$tool"
|
|
|
|
else
|
|
|
|
tmpl="${CT_LIB_DIR}/scripts/override/__default"
|
|
|
|
fi
|
|
|
|
CT_DoLog DEBUG "Creating script-override for '${tool}' -> '${path}' using '${tmpl}' template"
|
2017-01-28 08:11:08 +00:00
|
|
|
CT_DoExecLog ALL cp "${tmpl}" "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}"
|
2017-02-27 03:06:35 +00:00
|
|
|
CT_DoExecLog ALL ${sed} -i -r \
|
2017-01-28 08:11:08 +00:00
|
|
|
-e "s#@CONFIG_SHELL@#${CT_CONFIG_SHELL}#g" \
|
|
|
|
-e "s#@TOOL_PATH@#${path}#g" \
|
|
|
|
-e "s#@TOOLS_OVERRIDE_DIR@#${CT_TOOLS_OVERRIDE_DIR}#g" \
|
|
|
|
"${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}"
|
2017-01-28 07:19:36 +00:00
|
|
|
CT_DoExecLog ALL chmod 700 "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}"
|
2009-01-26 22:43:08 +00:00
|
|
|
done
|
2017-01-28 07:19:36 +00:00
|
|
|
export PATH="${CT_TOOLS_OVERRIDE_DIR}/bin:${PATH}"
|
2009-01-26 22:43:08 +00:00
|
|
|
|
2008-11-20 17:48:10 +00:00
|
|
|
# Start date. Can't be done until we know the locale
|
2009-06-22 19:53:09 +00:00
|
|
|
# Also requires the bin-override tools
|
2008-11-20 17:48:10 +00:00
|
|
|
CT_STAR_DATE=$(CT_DoDate +%s%N)
|
|
|
|
CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
|
|
|
|
|
2009-01-26 22:43:08 +00:00
|
|
|
# Log real begining of build, now
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
|
|
|
|
|
2008-10-01 18:10:40 +00:00
|
|
|
CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
|
2014-10-21 17:20:22 +00:00
|
|
|
CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_EndStep
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2007-07-23 19:49:35 +00:00
|
|
|
CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
|
|
|
|
unset MAKEFLAGS
|
|
|
|
export MAKEFLAGS
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_DoLog INFO "Building environment variables"
|
|
|
|
|
2009-12-19 11:44:21 +00:00
|
|
|
# Sanity check some directories
|
|
|
|
CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}"
|
|
|
|
|
2013-11-15 17:58:42 +00:00
|
|
|
# Avoid multiple '/' in the prefix dir, it breaks relocatability
|
2017-02-27 04:42:32 +00:00
|
|
|
CT_PREFIX_DIR="$( ${sed} -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )"
|
2013-11-15 17:58:42 +00:00
|
|
|
|
2007-09-16 17:59:18 +00:00
|
|
|
# Second kludge: merge user-supplied target CFLAGS with architecture-provided
|
2008-05-24 22:38:07 +00:00
|
|
|
# target CFLAGS. Do the same for LDFLAGS in case it happens in the future.
|
|
|
|
# Put user-supplied flags at the end, so that they take precedence.
|
2007-09-16 17:59:18 +00:00
|
|
|
CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
|
2008-05-24 22:38:07 +00:00
|
|
|
CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
|
2015-05-29 20:40:52 +00:00
|
|
|
CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
|
|
|
|
CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" )
|
2007-09-16 17:59:18 +00:00
|
|
|
|
2011-06-03 15:21:56 +00:00
|
|
|
# Compute the package version string
|
|
|
|
CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}"
|
|
|
|
|
2009-06-22 19:53:09 +00:00
|
|
|
# Compute the working directories names
|
2008-06-24 16:19:45 +00:00
|
|
|
CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
|
2017-06-26 05:54:29 +00:00
|
|
|
CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src"
|
|
|
|
CT_SRC_DIR="${CT_BUILD_DIR}/src"
|
2016-12-14 08:59:08 +00:00
|
|
|
CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools"
|
2009-03-27 23:40:07 +00:00
|
|
|
CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
|
2011-07-25 17:04:17 +00:00
|
|
|
# Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a
|
|
|
|
# sub-dir. So we won't have to save/restore it, not even create it.
|
|
|
|
# In case of cross or native, host-complibs are used for build-complibs;
|
|
|
|
# in case of canadian or cross-native, host-complibs are specific
|
2016-11-29 00:55:22 +00:00
|
|
|
# Note about BUILD_COMPTOOLS_DIR: if installing companion tools for "host" in
|
|
|
|
# a native or simple cross, we can can use the same binaries we built for
|
|
|
|
# "build". However, we need companion tools for "build" early - as other
|
|
|
|
# components may depend on them - so we may skip building for "host" rather
|
|
|
|
# than for "build" in that case.
|
2011-07-25 17:04:17 +00:00
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
|
|
|
native|cross)
|
|
|
|
CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
|
2016-11-29 00:55:22 +00:00
|
|
|
if [ -n "${CT_COMP_TOOLS_FOR_HOST}" ]; then
|
|
|
|
CT_BUILD_COMPTOOLS_DIR="${CT_PREFIX_DIR}"
|
|
|
|
else
|
|
|
|
CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
|
|
|
|
fi
|
2011-07-25 17:04:17 +00:00
|
|
|
;;
|
|
|
|
canadian|cross-native)
|
|
|
|
CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}/complibs-host"
|
2016-11-29 00:55:22 +00:00
|
|
|
CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
|
2011-07-25 17:04:17 +00:00
|
|
|
;;
|
|
|
|
esac
|
2009-03-27 23:40:07 +00:00
|
|
|
|
2010-05-19 15:53:04 +00:00
|
|
|
# Compute test suite install directory
|
2016-12-14 09:06:10 +00:00
|
|
|
CT_TEST_SUITE_DIR=${CT_PREFIX_DIR}/test-suite
|
2010-05-19 15:53:04 +00:00
|
|
|
|
2007-05-28 21:33:35 +00:00
|
|
|
# We must ensure that we can restart if asked for!
|
|
|
|
if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then
|
|
|
|
CT_DoLog ERROR "You asked to restart a non-restartable build"
|
|
|
|
CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
|
2007-06-02 15:50:45 +00:00
|
|
|
CT_DoLog ERROR "in the config options for the previous build, or the state"
|
2008-02-14 22:44:34 +00:00
|
|
|
CT_DoLog ERROR "directory for the previous build was deleted."
|
2007-05-28 21:33:35 +00:00
|
|
|
CT_Abort "I will stop here to avoid any carnage"
|
|
|
|
fi
|
|
|
|
|
2007-09-23 17:18:18 +00:00
|
|
|
# If the local tarball directory does not exist, say so, and don't try to save there!
|
2009-12-14 18:17:37 +00:00
|
|
|
if [ "${CT_SAVE_TARBALLS}" = "y" \
|
|
|
|
-a ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then
|
|
|
|
CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist."
|
|
|
|
CT_DoLog WARN "Will not save downloaded tarballs to local storage."
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_SAVE_TARBALLS=
|
2007-09-23 17:18:18 +00:00
|
|
|
fi
|
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Check now if we can write to the destination directory:
|
2016-12-14 09:06:10 +00:00
|
|
|
if [ -d "${CT_PREFIX_DIR}" ]; then
|
|
|
|
CT_TestAndAbort "Destination directory '${CT_PREFIX_DIR}' is not removable" ! -w $(dirname "${CT_PREFIX_DIR}")
|
2007-05-10 21:33:35 +00:00
|
|
|
fi
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# Good, now grab a bit of informations on the system we're being run on,
|
|
|
|
# just in case something goes awok, and it's not our fault:
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_SYS_USER=$(id -un)
|
|
|
|
CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true)
|
2007-05-17 16:22:51 +00:00
|
|
|
# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
|
|
|
|
CT_SYS_KERNEL=$(uname -s)
|
|
|
|
CT_SYS_REVISION=$(uname -r)
|
2010-05-19 16:17:39 +00:00
|
|
|
CT_SYS_OS=$(uname -s)
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_SYS_MACHINE=$(uname -m)
|
|
|
|
CT_SYS_PROCESSOR=$(uname -p)
|
2017-02-22 01:25:47 +00:00
|
|
|
CT_SYS_GCC=$(${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX} -dumpversion)
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_SYS_TARGET=$(CT_DoConfigGuess)
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
|
|
|
|
|
2017-03-27 06:32:27 +00:00
|
|
|
# Adjust the list of multilibs, if needed
|
|
|
|
CT_DoArchMultilibList
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_DoLog EXTRA "Preparing working directories"
|
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
# Ah! The build directory shall be eradicated, even if we restart!
|
2011-07-09 22:02:05 +00:00
|
|
|
# Ditto for the build tools install dir
|
|
|
|
CT_DoForceRmdir "${CT_BUILD_DIR}" "${CT_BUILDTOOLS_PREFIX_DIR}"
|
2007-05-10 21:33:35 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
# Don't eradicate directories if we need to restart
|
|
|
|
if [ -z "${CT_RESTART}" ]; then
|
2017-06-27 08:12:33 +00:00
|
|
|
# Per-target sources: eliminate
|
|
|
|
CT_DoForceRmdir "${CT_SRC_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
# Get rid of pre-existing installed toolchain and previous build directories.
|
|
|
|
if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
|
2009-01-12 21:35:23 +00:00
|
|
|
CT_DoForceRmdir "${CT_TARBALLS_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
2017-06-27 08:12:33 +00:00
|
|
|
if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_COMMON_SRC_DIR}" ]; then
|
|
|
|
CT_DoForceRmdir "${CT_COMMON_SRC_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
2016-12-14 09:06:10 +00:00
|
|
|
if [ -d "${CT_PREFIX_DIR}" -a "${CT_RM_RF_PREFIX_DIR}" = "y" ]; then
|
|
|
|
CT_DoForceRmdir "${CT_PREFIX_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
|
|
|
# In case we start anew, get rid of the previously saved state directory
|
|
|
|
if [ -d "${CT_STATE_DIR}" ]; then
|
2009-01-12 21:35:23 +00:00
|
|
|
CT_DoForceRmdir "${CT_STATE_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
|
|
|
fi
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
# Create the directories we'll use, even if restarting: it does no harm to
|
|
|
|
# create already existent directories, and CT_BUILD_DIR needs to be created
|
|
|
|
# anyway
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}"
|
2017-06-27 08:12:33 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_COMMON_SRC_DIR}"
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
|
2010-12-19 23:07:29 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
|
2011-07-25 17:04:17 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}"
|
2009-03-27 23:40:07 +00:00
|
|
|
|
|
|
|
# Only create the state dir if asked for a restartable build
|
|
|
|
[ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
|
2009-03-27 18:53:54 +00:00
|
|
|
# Check install file system case-sensitiveness
|
2009-03-29 21:05:13 +00:00
|
|
|
CT_DoExecLog DEBUG touch "${CT_PREFIX_DIR}/foo"
|
2009-03-27 18:53:54 +00:00
|
|
|
CT_TestAndAbort "Your file system in '${CT_PREFIX_DIR}' is *not* case-sensitive!" -f "${CT_PREFIX_DIR}/FOO"
|
2009-03-29 21:05:13 +00:00
|
|
|
CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo"
|
2009-03-27 18:53:54 +00:00
|
|
|
|
2016-12-14 09:06:10 +00:00
|
|
|
# Kludge: CT_PREFIX_DIR might have grown read-only if
|
2011-03-19 23:02:21 +00:00
|
|
|
# the previous build was successful.
|
2016-12-14 09:06:10 +00:00
|
|
|
CT_DoExecLog ALL chmod -R u+w "${CT_PREFIX_DIR}"
|
2007-05-10 21:33:35 +00:00
|
|
|
|
2007-09-16 17:59:18 +00:00
|
|
|
# Setting up the rest of the environment only if not restarting
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ -z "${CT_RESTART}" ]; then
|
2017-03-06 00:22:40 +00:00
|
|
|
# Having .. inside CT_PREFIX breaks relocatability.
|
|
|
|
CT_SanitizeVarDir CT_PREFIX_DIR
|
|
|
|
|
2011-01-25 19:31:16 +00:00
|
|
|
case "${CT_SYSROOT_NAME}" in
|
|
|
|
"") CT_SYSROOT_NAME="sysroot";;
|
|
|
|
.) CT_Abort "Sysroot name is set to '.' which is forbidden";;
|
|
|
|
*' '*) CT_Abort "Sysroot name contains forbidden space(s): '${CT_SYSROOT_NAME}'";;
|
|
|
|
*/*) CT_Abort "Sysroot name contains forbidden slash(es): '${CT_SYSROOT_NAME}'";;
|
|
|
|
esac
|
|
|
|
|
multilib: Determine which options may pass through.
On some arches (e.g. MIPS) the options like -mabi do not work if
specified more than once (see the comment in 100-gcc.sh). Therefore,
we need to determine which of the options produced by <arch>.sh can
be passed to multilib builds and which must be removed (i.e., which
options vary among the multilibs).
This presents a chicken-and-egg problem. GCC developers, in their
infinite wisdom, do not allow arbitrary multilib specification to be
supplied to GCC's configure. Instead, the target (and sometimes some
extra options) determine the set of multilibs - which may include
different CPUs, different ABIs, different endianness, different FPUs,
different floating-point ABIs, ... That is, we don't know which parts
vary until we build GCC and ask it.
So, the solution implemented here is:
- For multilib builds, start with empty CT_ARCH_TARGET_CFLAGS/LDFLAGS.
- For multilib builds, require core pass 1. Pass 1 does not build any
target binaries, so at that point, our target options have not been
used yet.
- Provide an API to modify the environment variables for the steps that
follow the current one.
- As a part of multilib-related housekeeping, determine the variable
part of multilibs and filter out these options; pass the rest into
CT_TARGET_CFLAGS/LDFLAGS.
This still does not handle extra dependencies between GCC options (like
-ma implying -mcpu=X -mtune=Y, etc.) but I feel that would complicate
matters too much. Let's leave this until there's a compelling case for
it.
Also, query GCC's sysroot suffix for targets that use it (SuperH,
for example) - the default multilib may not work if the command line
specifies the default option explicitly (%sysroot_suffix_spec is not
aware of multilib defaults).
Signed-off-by: Alexey Neyman <stilor@att.net>
2016-03-30 19:15:54 +00:00
|
|
|
# Arrange paths depending on whether we use sysroot or not.
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ "${CT_USE_SYSROOT}" = "y" ]; then
|
2017-03-06 00:22:40 +00:00
|
|
|
CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}"
|
2009-03-03 17:41:59 +00:00
|
|
|
CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root"
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
|
2017-03-06 00:22:40 +00:00
|
|
|
CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR
|
2007-05-22 20:46:07 +00:00
|
|
|
BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
|
|
|
|
CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
|
|
|
|
CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
|
|
|
|
# glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
|
|
|
|
# confused when $sysroot/usr/include is not present.
|
|
|
|
# Note: --prefix=/usr is magic!
|
|
|
|
# See http://www.gnu.org/software/libc/FAQ.html#s-2.2
|
|
|
|
else
|
|
|
|
# plain old way. All libraries in prefix/target/lib
|
|
|
|
CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
|
2009-06-23 20:52:13 +00:00
|
|
|
CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}"
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
|
2016-03-21 18:18:53 +00:00
|
|
|
CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR
|
2007-05-22 20:46:07 +00:00
|
|
|
# hack! Always use --with-sysroot for binutils.
|
|
|
|
# binutils 2.14 and later obey it, older binutils ignore it.
|
|
|
|
# Lets you build a working 32->64 bit cross gcc
|
|
|
|
BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
|
|
|
|
# Use --with-headers, else final gcc will define disable_glibc while
|
|
|
|
# building libgcc, and you'll have no profiling
|
|
|
|
CC_CORE_SYSROOT_ARG="--without-headers"
|
|
|
|
CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
|
|
|
|
fi
|
2009-03-03 17:41:59 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}"
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}"
|
2014-04-12 12:18:15 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_HEADERS_DIR}"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2014-04-12 12:18:15 +00:00
|
|
|
# Need the non-multilib directories: GCC's multi-os-directory is based off them, so
|
|
|
|
# even if the /lib is not used for any of the multilibs, it must be present so that
|
|
|
|
# the paths like 'lib/../lib64' still work.
|
2009-01-31 17:38:26 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib"
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib"
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
|
2008-07-27 16:35:37 +00:00
|
|
|
|
2008-11-13 18:22:23 +00:00
|
|
|
# Determine build system if not set by the user
|
2010-05-19 16:13:00 +00:00
|
|
|
if [ -z "${CT_BUILD}" ]; then
|
|
|
|
CT_BUILD=$(CT_DoConfigGuess)
|
|
|
|
fi
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2008-11-28 23:33:04 +00:00
|
|
|
# Prepare mangling patterns to later modify BUILD and HOST (see below)
|
2008-11-13 18:22:23 +00:00
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
|
|
|
cross)
|
2009-06-26 17:09:22 +00:00
|
|
|
# A cross-compiler runs on the same machine it is built on
|
2008-11-13 18:22:23 +00:00
|
|
|
CT_HOST="${CT_BUILD}"
|
|
|
|
build_mangle="build_"
|
|
|
|
host_mangle="build_"
|
2009-06-26 17:09:22 +00:00
|
|
|
target_mangle=""
|
2016-08-26 15:46:42 +00:00
|
|
|
install_build_tools_for="BUILD"
|
2008-11-13 18:22:23 +00:00
|
|
|
;;
|
2009-06-26 17:09:22 +00:00
|
|
|
canadian)
|
|
|
|
build_mangle="build_"
|
|
|
|
host_mangle="host_"
|
|
|
|
target_mangle=""
|
2012-01-03 21:57:25 +00:00
|
|
|
install_build_tools_for="BUILD HOST"
|
2009-06-26 17:09:22 +00:00
|
|
|
;;
|
2008-11-13 18:22:23 +00:00
|
|
|
*) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
|
|
|
|
;;
|
2007-05-17 16:22:51 +00:00
|
|
|
esac
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2008-11-13 18:22:23 +00:00
|
|
|
# Save the real tuples to generate shell-wrappers to the real tools
|
|
|
|
CT_REAL_BUILD="${CT_BUILD}"
|
|
|
|
CT_REAL_HOST="${CT_HOST}"
|
2009-06-26 17:09:22 +00:00
|
|
|
CT_REAL_TARGET="${CT_TARGET}"
|
2008-11-13 18:22:23 +00:00
|
|
|
|
2008-11-28 23:31:02 +00:00
|
|
|
# Canonicalise CT_BUILD and CT_HOST
|
|
|
|
# Not only will it give us full-qualified tuples, but it will also ensure
|
|
|
|
# that they are valid tuples (in case of typo with user-provided tuples)
|
|
|
|
# That's way better than trying to rewrite config.sub ourselves...
|
2009-06-26 17:09:22 +00:00
|
|
|
# CT_TARGET is already made canonical in CT_DoBuildTargetTuple
|
2008-12-03 22:35:52 +00:00
|
|
|
CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
|
|
|
|
CT_HOST=$(CT_DoConfigSub "${CT_HOST}")
|
2008-11-04 16:30:11 +00:00
|
|
|
|
2008-11-13 18:22:23 +00:00
|
|
|
# Modify BUILD and HOST so that gcc always generate a cross-compiler
|
|
|
|
# even if any of the build, host or target machines are the same.
|
|
|
|
# NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
|
|
|
|
# support canadain build, later...
|
|
|
|
CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
|
|
|
|
CT_HOST="${CT_HOST/-/-${host_mangle}}"
|
2009-06-26 17:09:22 +00:00
|
|
|
CT_TARGET="${CT_TARGET/-/-${target_mangle}}"
|
2008-11-13 18:22:23 +00:00
|
|
|
|
|
|
|
# Now we have mangled our BUILD and HOST tuples, we must fake the new
|
|
|
|
# cross-tools for those mangled tuples.
|
2007-06-17 14:51:37 +00:00
|
|
|
CT_DoLog DEBUG "Making build system tools available"
|
2009-06-26 17:09:22 +00:00
|
|
|
for m in ${install_build_tools_for}; do
|
2008-11-13 18:22:23 +00:00
|
|
|
r="CT_REAL_${m}"
|
|
|
|
v="CT_${m}"
|
|
|
|
p="CT_${m}_PREFIX"
|
|
|
|
s="CT_${m}_SUFFIX"
|
|
|
|
if [ -n "${!p}" ]; then
|
|
|
|
t="${!p}"
|
|
|
|
else
|
|
|
|
t="${!r}-"
|
|
|
|
fi
|
|
|
|
|
2009-01-06 22:10:17 +00:00
|
|
|
for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
|
2008-11-13 18:22:23 +00:00
|
|
|
# First try with prefix + suffix
|
|
|
|
# Then try with prefix only
|
|
|
|
# Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
|
|
|
|
# Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
|
|
|
|
# This is needed, because some tools have a prefix and
|
|
|
|
# a suffix (eg. gcc), while others may have only one,
|
|
|
|
# or even none (eg. binutils)
|
|
|
|
where=$(CT_Which "${t}${tool}${!s}")
|
|
|
|
[ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
|
|
|
|
if [ -z "${where}" \
|
|
|
|
-a \( "${m}" = "BUILD" \
|
|
|
|
-o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
|
|
|
|
where=$(CT_Which "${tool}${!s}")
|
|
|
|
fi
|
|
|
|
if [ -z "${where}" \
|
|
|
|
-a \( "${m}" = "BUILD" \
|
|
|
|
-o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
|
|
|
|
where=$(CT_Which "${tool}")
|
|
|
|
fi
|
|
|
|
|
2012-11-21 00:59:17 +00:00
|
|
|
# Not all tools are available for all platforms, but some are required.
|
2008-11-13 18:22:23 +00:00
|
|
|
if [ -n "${where}" ]; then
|
|
|
|
CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'"
|
2011-11-30 11:07:59 +00:00
|
|
|
printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}"
|
2010-12-19 23:07:29 +00:00
|
|
|
CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}"
|
2008-11-13 18:22:23 +00:00
|
|
|
else
|
|
|
|
case "${tool}" in
|
2009-01-29 22:09:55 +00:00
|
|
|
# We'll at least need some of them...
|
2010-04-19 21:42:31 +00:00
|
|
|
ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
|
2008-11-13 18:22:23 +00:00
|
|
|
CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
|
|
|
|
;;
|
2009-01-29 22:09:55 +00:00
|
|
|
# Some are conditionnally required
|
|
|
|
# Add them in alphabetical (C locale) ordering
|
2010-04-19 21:42:31 +00:00
|
|
|
g++)
|
|
|
|
# g++ (needed for companion lib), only needed for HOST
|
|
|
|
CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${m}" = "HOST"
|
|
|
|
;;
|
2009-01-29 22:09:55 +00:00
|
|
|
gcj)
|
|
|
|
CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_CC_LANG_JAVA}" = "y"
|
|
|
|
;;
|
2010-05-27 21:18:19 +00:00
|
|
|
strip)
|
2015-11-10 09:59:02 +00:00
|
|
|
CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y"
|
2010-05-27 21:18:19 +00:00
|
|
|
;;
|
2009-01-29 22:09:55 +00:00
|
|
|
# If any other is missing, only warn at low level
|
2008-11-13 18:22:23 +00:00
|
|
|
*)
|
|
|
|
# It does not deserve a WARN level.
|
|
|
|
CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
2007-05-22 20:46:07 +00:00
|
|
|
done
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2011-01-22 22:20:18 +00:00
|
|
|
# Some makeinfo versions are a pain in [put your most sensible body part here].
|
|
|
|
# Go ahead with those, by creating a wrapper that keeps partial files, and that
|
|
|
|
# never fails:
|
|
|
|
CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'"
|
2011-11-30 11:07:59 +00:00
|
|
|
printf "#${BANG}${CT_CONFIG_SHELL}\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo"
|
2010-12-19 23:07:29 +00:00
|
|
|
CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo"
|
2011-01-22 22:20:18 +00:00
|
|
|
|
2008-11-13 18:22:23 +00:00
|
|
|
# Carefully add paths in the order we want them:
|
|
|
|
# - first try in ${CT_PREFIX_DIR}/bin
|
2012-01-01 16:49:44 +00:00
|
|
|
# - then try the buildtools dir
|
2008-11-13 18:22:23 +00:00
|
|
|
# - fall back to searching user's PATH
|
|
|
|
# Of course, neither cross-native nor canadian can run on BUILD,
|
|
|
|
# so don't add those PATHs in this case...
|
2016-12-19 18:28:15 +00:00
|
|
|
# For native and simple cross, build==host, combine the extra CFLAGS/LDFLAGS
|
|
|
|
# supplied for both (so that it doesn't matter where the user supplied them).
|
2008-11-13 18:22:23 +00:00
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
2016-12-19 18:28:15 +00:00
|
|
|
cross|native)
|
|
|
|
export PATH="${CT_PREFIX_DIR}/bin:${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}"
|
|
|
|
bh_cflags="${CT_EXTRA_CFLAGS_FOR_BUILD} ${CT_EXTRA_CFLAGS_FOR_HOST}"
|
|
|
|
bh_ldflags="${CT_EXTRA_LDFLAGS_FOR_BUILD} ${CT_EXTRA_LDFLAGS_FOR_HOST}"
|
|
|
|
CT_EXTRA_CFLAGS_FOR_BUILD="${bh_cflags}"
|
|
|
|
CT_EXTRA_CFLAGS_FOR_HOST="${bh_cflags}"
|
|
|
|
CT_EXTRA_LDFLAGS_FOR_BUILD="${bh_ldflags}"
|
|
|
|
CT_EXTRA_LDFLAGS_FOR_HOST="${bh_ldflags}"
|
|
|
|
;;
|
|
|
|
canadian|cross-native)
|
|
|
|
export PATH="${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}"
|
|
|
|
# build!=host in this case
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
2008-11-13 18:22:23 +00:00
|
|
|
esac
|
|
|
|
|
2012-11-16 14:25:57 +00:00
|
|
|
# Help build gcc
|
|
|
|
# Explicitly optimise, else the lines below will overide the
|
|
|
|
# package's default optimisation flags
|
2016-12-16 23:56:32 +00:00
|
|
|
CT_CFLAGS_FOR_BUILD="-O2 -g -I${CT_BUILDTOOLS_PREFIX_DIR}/include"
|
2012-11-16 14:25:57 +00:00
|
|
|
CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}"
|
2016-12-16 23:56:32 +00:00
|
|
|
CT_LDFLAGS_FOR_BUILD="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib"
|
2012-11-16 14:25:57 +00:00
|
|
|
CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}"
|
2017-01-08 08:32:10 +00:00
|
|
|
|
|
|
|
case "${CT_BUILD}" in
|
|
|
|
*darwin*)
|
|
|
|
# Two issues while building on MacOS. Really, we should be checking for
|
|
|
|
# clang instead.
|
|
|
|
# - gettext static library fails to link unless CoreFoundation framework
|
|
|
|
# is included
|
|
|
|
# - ranlib on MacOS does not include common symbols into the symbol index
|
|
|
|
# for a static library, and hence linker fails to pull in the right
|
|
|
|
# archive members; hence, avoid common symbols. Alternative is to
|
|
|
|
# have ranlib wrapper in buildtools/bin supply -c option.
|
|
|
|
CT_CFLAGS_FOR_BUILD+=" -fno-common"
|
|
|
|
CT_LDFLAGS_FOR_BUILD+=" -framework CoreFoundation"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-12-16 23:56:32 +00:00
|
|
|
CT_DoLog DEBUG "CFLAGS for build compiler: '${CT_CFLAGS_FOR_BUILD}'"
|
|
|
|
CT_DoLog DEBUG "LDFLAGS for build compiler: '${CT_LDFLAGS_FOR_BUILD}'"
|
2016-08-26 15:46:42 +00:00
|
|
|
|
2012-11-16 14:25:57 +00:00
|
|
|
# Help host gcc
|
2012-11-13 15:06:18 +00:00
|
|
|
# Explicitly optimise, else the lines below will overide the
|
|
|
|
# package's default optimisation flags
|
|
|
|
CT_CFLAGS_FOR_HOST="-O2 -g"
|
2011-10-05 01:19:51 +00:00
|
|
|
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
|
2016-12-16 23:56:32 +00:00
|
|
|
CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include"
|
2012-11-16 14:25:57 +00:00
|
|
|
CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
|
2016-12-16 23:56:32 +00:00
|
|
|
CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib"
|
2012-11-16 14:25:57 +00:00
|
|
|
CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
|
2017-01-08 08:32:10 +00:00
|
|
|
case "${CT_HOST}" in
|
|
|
|
*darwin*)
|
|
|
|
# Same as above, for host
|
|
|
|
CT_CFLAGS_FOR_HOST+=" -fno-common"
|
|
|
|
CT_LDFLAGS_FOR_HOST+=" -framework CoreFoundation"
|
|
|
|
;;
|
|
|
|
esac
|
2012-11-21 00:59:17 +00:00
|
|
|
CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'"
|
|
|
|
CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'"
|
2007-05-22 20:46:07 +00:00
|
|
|
|
2008-11-04 16:30:11 +00:00
|
|
|
# Set the shell to be used by ./configure scripts and by Makefiles (those
|
|
|
|
# that support it!).
|
2011-10-11 19:43:42 +00:00
|
|
|
export CONFIG_SHELL="${CT_CONFIG_SHELL}" # for ./configure
|
|
|
|
export SHELL="${CT_CONFIG_SHELL}" # for Makefiles
|
2008-08-25 19:44:39 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
# And help make go faster
|
2011-01-22 21:35:43 +00:00
|
|
|
JOBSFLAGS=
|
2011-10-16 11:26:26 +00:00
|
|
|
# Override the configured jobs with what's been given on the command line
|
2015-10-30 20:53:53 +00:00
|
|
|
if [ -n "${CT_JOBS}" ]; then
|
2015-11-17 10:48:09 +00:00
|
|
|
if [ ! -z "`echo "${CT_JOBS}" | ${sed} 's/[0-9]//g'`" ]; then
|
2015-10-30 20:53:53 +00:00
|
|
|
CT_Abort "Number of parallel jobs must be integer."
|
|
|
|
fi
|
|
|
|
CT_PARALLEL_JOBS="${CT_JOBS}"
|
|
|
|
fi
|
2011-09-28 23:40:42 +00:00
|
|
|
# Use the number of processors+1 when automatically setting the number of
|
|
|
|
# parallel jobs. Fall back to 1 if the host doesn't use GLIBC.
|
2017-03-02 04:22:13 +00:00
|
|
|
AUTO_JOBS=$((`@@CT_cpucount@@ 2>/dev/null || echo 0` + 1))
|
2011-10-16 11:26:26 +00:00
|
|
|
[ ${CT_PARALLEL_JOBS} -eq 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}"
|
2011-09-28 23:40:42 +00:00
|
|
|
[ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
|
2013-01-27 16:54:19 +00:00
|
|
|
JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
|
2007-05-22 20:46:07 +00:00
|
|
|
|
2015-10-30 08:04:39 +00:00
|
|
|
# Override 'download only' option
|
|
|
|
[ -n "${CT_SOURCE}" ] && CT_ONLY_DOWNLOAD=y
|
|
|
|
|
2012-11-21 00:59:17 +00:00
|
|
|
# Now that we've set up $PATH and $CT_CFLAGS_FOR_HOST, sanity test that gcc
|
|
|
|
# is runnable so that the user can troubleshoot problems if not.
|
|
|
|
CT_DoStep DEBUG "Checking that we can run gcc -v"
|
|
|
|
CT_DoExecLog DEBUG "${CT_HOST}-gcc" -v
|
|
|
|
CT_EndStep
|
|
|
|
|
|
|
|
# Create a simple C program for testing.
|
|
|
|
testc="${CT_BUILD_DIR}/test.c"
|
|
|
|
printf "int main() { return 0; }\n" >"${testc}"
|
|
|
|
gccout="${CT_BUILD_DIR}/.gccout"
|
|
|
|
|
|
|
|
CT_DoStep DEBUG "Checking that gcc can compile a trivial program"
|
|
|
|
CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -o "${gccout}"
|
|
|
|
rm -f "${gccout}"
|
|
|
|
CT_EndStep
|
|
|
|
|
2017-03-30 01:23:44 +00:00
|
|
|
# These tests are only enabled if we need static linking on the *build*
|
2012-11-21 00:59:17 +00:00
|
|
|
if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then
|
|
|
|
CT_DoStep DEBUG "Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)"
|
|
|
|
CT_DoLog DEBUG "You may need to ensure that static libraries such as libc.a are installed on your system"
|
2017-03-30 01:23:44 +00:00
|
|
|
CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -o "${gccout}"
|
2012-11-21 00:59:17 +00:00
|
|
|
rm -f "${gccout}"
|
|
|
|
CT_EndStep
|
|
|
|
fi
|
2017-03-30 01:23:44 +00:00
|
|
|
if [ "${CT_WANTS_STATIC_LINK_CXX}" = "y" ]; then
|
|
|
|
CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_WANTS_STATIC_LINK_CXX)"
|
2012-11-21 00:59:17 +00:00
|
|
|
CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system"
|
2017-03-30 01:23:44 +00:00
|
|
|
CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -lstdc++ -o "${gccout}"
|
2012-11-21 00:59:17 +00:00
|
|
|
rm -f "${gccout}"
|
|
|
|
CT_EndStep
|
|
|
|
fi
|
|
|
|
rm -f "${testc}"
|
|
|
|
|
2008-10-01 18:10:40 +00:00
|
|
|
CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
|
2009-06-26 17:09:22 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
|
2015-11-17 10:48:09 +00:00
|
|
|
CT_DoExecLog DEBUG ${install} -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
|
2015-05-10 03:09:05 +00:00
|
|
|
CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
|
2008-10-06 21:23:31 +00:00
|
|
|
bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
|
2008-10-01 18:10:40 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
|
|
|
|
CT_DoLog EXTRA "Building a toolchain for:"
|
2008-11-13 18:22:23 +00:00
|
|
|
CT_DoLog EXTRA " build = ${CT_REAL_BUILD}"
|
|
|
|
CT_DoLog EXTRA " host = ${CT_REAL_HOST}"
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_DoLog EXTRA " target = ${CT_TARGET}"
|
2014-08-26 22:52:18 +00:00
|
|
|
set |${grep} -E '^CT_.+=' |sort |CT_DoLog DEBUG
|
2010-02-17 23:04:48 +00:00
|
|
|
CT_DoLog DEBUG "Other environment:"
|
2014-08-26 22:52:18 +00:00
|
|
|
printenv |${grep} -v -E '^CT_.+=' |CT_DoLog DEBUG
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_EndStep
|
|
|
|
fi
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ -z "${CT_RESTART}" ]; then
|
2011-08-02 21:10:37 +00:00
|
|
|
CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
|
|
|
|
do_companion_tools_get
|
|
|
|
do_kernel_get
|
2012-11-16 13:59:27 +00:00
|
|
|
do_companion_libs_get
|
2011-08-02 21:10:37 +00:00
|
|
|
do_binutils_get
|
|
|
|
do_cc_get
|
|
|
|
do_libc_get
|
|
|
|
do_debug_get
|
|
|
|
do_test_suite_get
|
|
|
|
CT_EndStep
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
|
|
|
|
if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
|
2009-01-12 21:35:23 +00:00
|
|
|
CT_DoForceRmdir "${CT_SRC_DIR}"
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
|
2007-05-10 21:33:35 +00:00
|
|
|
fi
|
2010-01-12 20:09:30 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_DoStep INFO "Extracting and patching toolchain components"
|
2016-11-23 02:10:23 +00:00
|
|
|
do_companion_tools_extract
|
2007-05-22 20:46:07 +00:00
|
|
|
do_kernel_extract
|
2012-11-16 13:59:27 +00:00
|
|
|
do_companion_libs_extract
|
2007-05-22 20:46:07 +00:00
|
|
|
do_binutils_extract
|
|
|
|
do_cc_extract
|
2007-08-15 10:14:43 +00:00
|
|
|
do_libc_extract
|
2007-05-22 20:46:07 +00:00
|
|
|
do_debug_extract
|
2010-05-19 15:53:04 +00:00
|
|
|
do_test_suite_extract
|
2007-05-22 20:46:07 +00:00
|
|
|
CT_EndStep
|
|
|
|
fi
|
|
|
|
fi
|
2007-05-10 21:33:35 +00:00
|
|
|
|
2007-05-22 20:46:07 +00:00
|
|
|
# Now for the job by itself. Go have a coffee!
|
|
|
|
if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
|
|
|
|
# Because of CT_RESTART, this becomes quite complex
|
2007-05-28 21:33:35 +00:00
|
|
|
do_stop=0
|
|
|
|
prev_step=
|
2007-05-22 20:46:07 +00:00
|
|
|
[ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
|
2008-04-30 10:43:41 +00:00
|
|
|
# Aha! CT_STEPS comes from steps.mk!
|
2008-04-28 07:38:36 +00:00
|
|
|
for step in ${CT_STEPS}; do
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ ${do_it} -eq 0 ]; then
|
|
|
|
if [ "${CT_RESTART}" = "${step}" ]; then
|
|
|
|
CT_DoLoadState "${step}"
|
|
|
|
do_it=1
|
2007-05-28 21:33:35 +00:00
|
|
|
do_stop=0
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
CT_DoSaveState ${step}
|
2007-05-28 21:33:35 +00:00
|
|
|
if [ ${do_stop} -eq 1 ]; then
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested."
|
2007-05-28 21:33:35 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2007-05-10 21:33:35 +00:00
|
|
|
fi
|
2007-05-22 20:46:07 +00:00
|
|
|
if [ ${do_it} -eq 1 ]; then
|
2011-10-09 17:19:04 +00:00
|
|
|
( do_${step} )
|
2012-05-08 16:31:10 +00:00
|
|
|
# POSIX 1003.1-2008 does not say if "set -e" should catch a
|
|
|
|
# sub-shell ending with !0. bash-3 does not, while bash-4 does,
|
|
|
|
# so the following line is for bash-3; bash-4 would choke above.
|
2012-05-08 21:29:38 +00:00
|
|
|
[ $? -eq 0 ]
|
multilib: Determine which options may pass through.
On some arches (e.g. MIPS) the options like -mabi do not work if
specified more than once (see the comment in 100-gcc.sh). Therefore,
we need to determine which of the options produced by <arch>.sh can
be passed to multilib builds and which must be removed (i.e., which
options vary among the multilibs).
This presents a chicken-and-egg problem. GCC developers, in their
infinite wisdom, do not allow arbitrary multilib specification to be
supplied to GCC's configure. Instead, the target (and sometimes some
extra options) determine the set of multilibs - which may include
different CPUs, different ABIs, different endianness, different FPUs,
different floating-point ABIs, ... That is, we don't know which parts
vary until we build GCC and ask it.
So, the solution implemented here is:
- For multilib builds, start with empty CT_ARCH_TARGET_CFLAGS/LDFLAGS.
- For multilib builds, require core pass 1. Pass 1 does not build any
target binaries, so at that point, our target options have not been
used yet.
- Provide an API to modify the environment variables for the steps that
follow the current one.
- As a part of multilib-related housekeeping, determine the variable
part of multilibs and filter out these options; pass the rest into
CT_TARGET_CFLAGS/LDFLAGS.
This still does not handle extra dependencies between GCC options (like
-ma implying -mcpu=X -mtune=Y, etc.) but I feel that would complicate
matters too much. Let's leave this until there's a compelling case for
it.
Also, query GCC's sysroot suffix for targets that use it (SuperH,
for example) - the default multilib may not work if the command line
specifies the default option explicitly (%sysroot_suffix_spec is not
aware of multilib defaults).
Signed-off-by: Alexey Neyman <stilor@att.net>
2016-03-30 19:15:54 +00:00
|
|
|
# Pick up environment changes.
|
|
|
|
if [ -r "${CT_BUILD_DIR}/env.modify.sh" ]; then
|
|
|
|
CT_DoLog DEBUG "Step '${step}' modified the environment:"
|
|
|
|
CT_DoExecLog DEBUG cat "${CT_BUILD_DIR}/env.modify.sh"
|
|
|
|
. "${CT_BUILD_DIR}/env.modify.sh"
|
|
|
|
CT_DoExecLog DEBUG rm -f "${CT_BUILD_DIR}/env.modify.sh"
|
|
|
|
|
|
|
|
fi
|
2007-05-25 19:30:42 +00:00
|
|
|
if [ "${CT_STOP}" = "${step}" ]; then
|
2007-05-28 21:33:35 +00:00
|
|
|
do_stop=1
|
2007-05-25 19:30:42 +00:00
|
|
|
fi
|
2008-07-25 22:57:35 +00:00
|
|
|
if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then
|
2008-05-20 21:32:39 +00:00
|
|
|
CT_DoPause "Step '${step}' finished"
|
2007-05-22 20:46:07 +00:00
|
|
|
fi
|
|
|
|
fi
|
2007-05-28 21:33:35 +00:00
|
|
|
prev_step="${step}"
|
2007-05-22 20:46:07 +00:00
|
|
|
done
|
2007-03-07 19:00:10 +00:00
|
|
|
fi
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_DoEnd INFO
|
|
|
|
|
2009-01-12 18:57:45 +00:00
|
|
|
# From now-on, it can become impossible to log any time, because
|
|
|
|
# either we're compressing the log file, or it can become RO any
|
2016-12-14 06:18:50 +00:00
|
|
|
# moment...
|
2009-01-12 18:57:45 +00:00
|
|
|
CT_DoLog INFO "Finishing installation (may take a few seconds)..."
|
2016-12-14 06:18:50 +00:00
|
|
|
CT_LogDisable
|
2011-07-12 21:52:24 +00:00
|
|
|
rm -f ${CT_PREFIX_DIR}/build.log.bz2
|
2011-03-19 23:02:21 +00:00
|
|
|
if [ "${CT_LOG_TO_FILE}" = "y" ]; then
|
2016-12-14 06:18:50 +00:00
|
|
|
cp "${CT_BUILD_LOG}" "${CT_PREFIX_DIR}/build.log"
|
2011-03-19 23:02:21 +00:00
|
|
|
if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then
|
|
|
|
bzip2 -9 "${CT_PREFIX_DIR}/build.log"
|
|
|
|
fi
|
|
|
|
fi
|
2016-12-14 09:06:10 +00:00
|
|
|
if [ "${CT_PREFIX_DIR_RO}" = "y" ]; then
|
|
|
|
chmod -R a-w "${CT_PREFIX_DIR}"
|
2013-01-28 20:53:18 +00:00
|
|
|
fi
|
|
|
|
# CT_TEST_SUITE_DIR may not exist if only downloading or extracting
|
|
|
|
if [ "${CT_TEST_SUITE}" = "y" -a -d "${CT_TEST_SUITE_DIR}" ]; then
|
|
|
|
chmod -R u+w "${CT_TEST_SUITE_DIR}"
|
|
|
|
fi
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
trap - EXIT
|