2007-02-24 11:00:05 +00:00
|
|
|
# This file adds functions to build binutils
|
|
|
|
# Copyright 2007 Yann E. MORIN
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Download binutils
|
|
|
|
do_binutils_get() {
|
2009-01-04 14:21:00 +00:00
|
|
|
CT_GetFile "binutils-${CT_BINUTILS_VERSION}" \
|
2008-10-15 07:29:07 +00:00
|
|
|
{ftp,http}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils \
|
|
|
|
ftp://gcc.gnu.org/pub/binutils/{releases,snapshots}
|
2007-05-07 09:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Extract binutils
|
|
|
|
do_binutils_extract() {
|
2009-01-05 23:02:43 +00:00
|
|
|
CT_Extract "binutils-${CT_BINUTILS_VERSION}"
|
2010-04-11 21:18:10 +00:00
|
|
|
CT_Patch "binutils" "${CT_BINUTILS_VERSION}"
|
2007-05-07 09:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build binutils
|
2007-02-24 11:00:05 +00:00
|
|
|
do_binutils() {
|
2009-08-19 17:44:44 +00:00
|
|
|
local -a extra_config
|
2010-12-09 17:55:33 +00:00
|
|
|
local -a extra_make_flags
|
2010-12-29 17:19:40 +00:00
|
|
|
local -a binutils_tools
|
2009-08-19 17:44:44 +00:00
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-binutils"
|
|
|
|
cd "${CT_BUILD_DIR}/build-binutils"
|
|
|
|
|
|
|
|
CT_DoStep INFO "Installing binutils"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring binutils"
|
2010-12-27 23:11:33 +00:00
|
|
|
|
2010-12-29 17:19:40 +00:00
|
|
|
binutils_tools=( ar as ld strip )
|
2010-12-27 23:11:33 +00:00
|
|
|
if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then
|
|
|
|
case "${CT_BINUTILS_LINKERS_LIST}" in
|
|
|
|
ld)
|
|
|
|
extra_config+=( --enable-ld=yes --enable-gold=no )
|
2010-12-29 17:19:40 +00:00
|
|
|
binutils_tools+=( ld.bfd )
|
2010-12-27 23:11:33 +00:00
|
|
|
;;
|
|
|
|
gold)
|
|
|
|
extra_config+=( --enable-ld=no --enable-gold=yes )
|
2010-12-29 17:19:40 +00:00
|
|
|
binutils_tools+=( ld.gold )
|
2010-12-27 23:11:33 +00:00
|
|
|
;;
|
|
|
|
ld,gold)
|
|
|
|
extra_config+=( --enable-ld=default --enable-gold=yes )
|
2010-12-29 17:19:40 +00:00
|
|
|
binutils_tools+=( ld.bfd ld.gold )
|
2010-12-27 23:11:33 +00:00
|
|
|
;;
|
|
|
|
gold,ld)
|
|
|
|
extra_config+=( --enable-ld=yes --enable-gold=default )
|
2010-12-29 17:19:40 +00:00
|
|
|
binutils_tools+=( ld.bfd ld.gold )
|
2010-12-27 23:11:33 +00:00
|
|
|
;;
|
|
|
|
esac
|
2011-01-02 12:52:16 +00:00
|
|
|
if [ "${CT_BINUTILS_GOLD_THREADED}" = "y" ]; then
|
|
|
|
extra_config+=( --enable-threads )
|
|
|
|
fi
|
2010-12-27 23:11:33 +00:00
|
|
|
fi
|
2011-01-02 12:56:05 +00:00
|
|
|
if [ "${CT_BINUTILS_PLUGINS}" = "y" ]; then
|
|
|
|
extra_config+=( --enable-plugins )
|
|
|
|
fi
|
2011-05-31 18:39:42 +00:00
|
|
|
if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then
|
2011-06-03 15:21:56 +00:00
|
|
|
extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
|
|
|
|
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
|
2011-05-31 18:39:42 +00:00
|
|
|
fi
|
2010-12-27 23:11:33 +00:00
|
|
|
|
|
|
|
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
|
|
|
|
|
2010-10-22 20:02:57 +00:00
|
|
|
CT_DoExecLog CFG \
|
2011-03-19 23:45:05 +00:00
|
|
|
CFLAGS="${CT_CFLAGS_FOR_HOST}" \
|
2009-01-04 14:21:00 +00:00
|
|
|
"${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
|
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${CT_HOST} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--prefix=${CT_PREFIX_DIR} \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-multilib \
|
|
|
|
--disable-werror \
|
2009-08-19 17:44:44 +00:00
|
|
|
"${extra_config[@]}" \
|
2009-01-04 14:21:00 +00:00
|
|
|
${CT_ARCH_WITH_FLOAT} \
|
2011-05-15 16:51:40 +00:00
|
|
|
${BINUTILS_SYSROOT_ARG} \
|
2011-05-18 21:00:46 +00:00
|
|
|
"${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2010-12-09 17:55:33 +00:00
|
|
|
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
|
|
|
|
extra_make_flags+=("LDFLAGS=-all-static")
|
|
|
|
CT_DoLog EXTRA "Prepare binutils for static build"
|
|
|
|
CT_DoExecLog ALL make configure-host
|
|
|
|
fi
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_DoLog EXTRA "Building binutils"
|
2011-01-22 21:35:43 +00:00
|
|
|
CT_DoExecLog ALL make "${extra_make_flags[@]}" ${JOBSFLAGS}
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing binutils"
|
2008-07-14 15:27:20 +00:00
|
|
|
CT_DoExecLog ALL make install
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2010-12-29 17:19:40 +00:00
|
|
|
# Install the wrapper if needed
|
|
|
|
if [ "${CT_BINUTILS_LD_WRAPPER}" = "y" ]; then
|
|
|
|
CT_DoLog EXTRA "Installing ld wrapper"
|
|
|
|
rm -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
2011-04-05 21:34:16 +00:00
|
|
|
rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/bin/ld"
|
2010-12-29 17:19:40 +00:00
|
|
|
sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \
|
|
|
|
"${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \
|
|
|
|
>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
|
|
|
chmod +x "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
|
2011-04-05 21:34:16 +00:00
|
|
|
cp -a "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld" \
|
|
|
|
"${CT_PREFIX_DIR}/${CT_TARGET}/bin/ld"
|
2011-04-04 23:02:28 +00:00
|
|
|
|
|
|
|
# If needed, force using ld.bfd during the toolchain build
|
|
|
|
if [ "${CT_BINUTILS_FORCE_LD_BFD}" = "y" ]; then
|
|
|
|
export CTNG_LD_IS=bfd
|
|
|
|
fi
|
2010-12-29 17:19:40 +00:00
|
|
|
fi
|
|
|
|
|
2007-08-15 10:14:43 +00:00
|
|
|
# Make those new tools available to the core C compilers to come.
|
2007-02-24 11:00:05 +00:00
|
|
|
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
|
2007-07-30 20:02:13 +00:00
|
|
|
# well. Create that.
|
2007-05-27 20:22:06 +00:00
|
|
|
mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin"
|
|
|
|
mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
|
|
|
|
mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
|
|
|
|
mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
|
2010-12-29 17:19:40 +00:00
|
|
|
for t in "${binutils_tools[@]}"; do
|
2007-05-27 20:22:06 +00:00
|
|
|
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
|
|
|
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
|
|
|
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
|
|
|
|
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
|
2008-07-14 15:27:20 +00:00
|
|
|
done 2>&1 |CT_DoLog ALL
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2008-04-28 07:38:36 +00:00
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now on for the target libraries
|
|
|
|
do_binutils_target() {
|
2009-08-19 17:44:44 +00:00
|
|
|
local -a extra_config
|
|
|
|
local -a targets
|
|
|
|
local -a build_targets
|
|
|
|
local -a install_targets
|
|
|
|
local t
|
|
|
|
|
|
|
|
[ "${CT_BINUTILS_FOR_TARGET_IBERTY}" = "y" ] && targets+=("libiberty")
|
|
|
|
[ "${CT_BINUTILS_FOR_TARGET_BFD}" = "y" ] && targets+=("bfd")
|
|
|
|
for t in "${targets[@]}"; do
|
|
|
|
build_targets+=("all-${t}")
|
|
|
|
install_targets+=("install-${t}")
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "${#targets[@]}" -ne 0 ]; then
|
2008-04-27 15:08:15 +00:00
|
|
|
CT_DoStep INFO "Installing binutils for target"
|
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-binutils-for-target"
|
|
|
|
CT_Pushd "${CT_BUILD_DIR}/build-binutils-for-target"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring binutils for target"
|
2011-05-31 18:39:42 +00:00
|
|
|
|
|
|
|
if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then
|
2011-06-03 15:21:56 +00:00
|
|
|
extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
|
|
|
|
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
|
2011-05-31 18:39:42 +00:00
|
|
|
fi
|
|
|
|
|
2011-03-03 22:29:07 +00:00
|
|
|
CT_DoExecLog CFG \
|
2009-01-04 14:21:00 +00:00
|
|
|
"${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
|
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${CT_TARGET} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--prefix=/usr \
|
|
|
|
--disable-werror \
|
|
|
|
--enable-shared \
|
|
|
|
--enable-static \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-multilib \
|
2009-08-19 17:44:44 +00:00
|
|
|
"${extra_config[@]}" \
|
2009-01-04 14:21:00 +00:00
|
|
|
${CT_ARCH_WITH_FLOAT} \
|
2011-05-15 16:51:40 +00:00
|
|
|
"${CT_BINUTILS_EXTRA_CONFIG[@]}"
|
2008-04-27 15:08:15 +00:00
|
|
|
|
2009-08-19 17:44:44 +00:00
|
|
|
CT_DoLog EXTRA "Building binutils' libraries (${targets[*]}) for target"
|
2011-01-22 21:35:43 +00:00
|
|
|
CT_DoExecLog ALL make ${JOBSFLAGS} "${build_targets[@]}"
|
2009-08-19 17:44:44 +00:00
|
|
|
CT_DoLog EXTRA "Installing binutils' libraries (${targets[*]}) for target"
|
|
|
|
CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" "${install_targets[@]}"
|
2008-04-27 15:08:15 +00:00
|
|
|
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
fi
|
2007-02-24 11:00:05 +00:00
|
|
|
}
|