2007-02-24 11:00:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# 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
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# CT_TOP_DIR is set by the makefile. If we don't have it, something's gone horribly wrong...
|
2007-02-24 11:00:05 +00:00
|
|
|
if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then
|
|
|
|
# We don't have the functions right now, because we don't have CT_TOP_DIR.
|
|
|
|
# Do the print stuff by hand:
|
2007-05-17 16:22:51 +00:00
|
|
|
echo "CT_TOP_DIR not set, or not a directory. Something's gone horribly wrong."
|
|
|
|
echo "Please send a bug report (see README)"
|
2007-02-24 11:00:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Parse the common functions
|
|
|
|
. "${CT_TOP_DIR}/scripts/functions"
|
|
|
|
|
|
|
|
CT_STAR_DATE=`CT_DoDate +%s%N`
|
|
|
|
CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
|
|
|
|
|
2007-05-20 13:48:26 +00:00
|
|
|
# Log policy:
|
|
|
|
# - what goes to the log file goes to fd #1 (stdout)
|
|
|
|
# - what goes to the screen goes to fd #6
|
|
|
|
tmp_log_file="${CT_TOP_DIR}/$$.log"
|
|
|
|
exec 6>&1
|
|
|
|
exec >>"${tmp_log_file}"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# Are we configured? We'll need that later...
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
|
2007-05-17 16:22:51 +00:00
|
|
|
|
|
|
|
# Parse the configuration file
|
|
|
|
# It has some info about the logging facility, so include it early
|
2007-02-24 11:00:05 +00:00
|
|
|
. "${CT_TOP_DIR}/.config"
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# renice oursleves
|
|
|
|
renice ${CT_NICE} $$ |CT_DoLog DEBUG
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
# Yes! We can do full logging from now on!
|
|
|
|
CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_DoStep DEBUG "Dumping crosstool-NG configuration"
|
|
|
|
cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
|
|
|
|
CT_EndStep
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
# Some sanity checks in the environment and needed tools
|
|
|
|
CT_DoLog INFO "Checking environment sanity"
|
|
|
|
|
|
|
|
# Enable known ordering of files in directory listings:
|
|
|
|
CT_Test "Crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
|
|
|
|
case "${LC_COLLATE},${LC_ALL}" in
|
|
|
|
# These four combinations are known to sort files in the correct order:
|
|
|
|
fr_FR*,) ;;
|
|
|
|
en_US*,) ;;
|
|
|
|
*,fr_FR*) ;;
|
|
|
|
*,en_US*) ;;
|
|
|
|
# Anything else is destined to be borked if not gracefuly handled:
|
|
|
|
*) CT_DoLog WARN "Either LC_COLLATE=\"${LC_COLLATE}\" or LC_ALL=\"${LC_ALL}\" is not supported."
|
|
|
|
export LC_ALL=`locale -a |egrep "^(fr_FR|en_US)" |head -n 1`
|
|
|
|
CT_TestOrAbort "Neither en_US* nor fr_FR* locales found on your system." -n "${LC_ALL}"
|
|
|
|
CT_DoLog WARN "Forcing to known working LC_ALL=\"${LC_ALL}\"."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Other environment sanity checks
|
|
|
|
CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
|
|
|
|
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}"
|
|
|
|
CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
|
|
|
|
GREP_OPTIONS=
|
|
|
|
CT_HasOrAbort awk
|
|
|
|
CT_HasOrAbort sed
|
|
|
|
CT_HasOrAbort bison
|
|
|
|
CT_HasOrAbort flex
|
|
|
|
|
|
|
|
CT_DoLog INFO "Building environment variables"
|
|
|
|
|
|
|
|
# Target triplet: CT_TARGET needs a little love:
|
2007-05-07 09:04:02 +00:00
|
|
|
CT_DoBuildTargetTriplet
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# Kludge: If any of the configured options needs CT_TARGET,
|
|
|
|
# then rescan the options file now:
|
|
|
|
. "${CT_TOP_DIR}/.config"
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
# Now, build up the variables from the user-configured options.
|
|
|
|
CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
|
|
|
|
CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}"
|
|
|
|
if [ "${CT_CC_USE_CORE}" != "y" ]; then
|
|
|
|
CT_CC_CORE="${CT_CC}"
|
|
|
|
CT_CC_CORE_VERSION="${CT_CC_VERSION}"
|
|
|
|
CT_CC_CORE_EXTRA_CONFIG="${CT_CC_EXTRA_CONFIG}"
|
|
|
|
fi
|
|
|
|
CT_CC_CORE_FILE="${CT_CC_CORE}-${CT_CC_CORE_VERSION}"
|
|
|
|
CT_CC_FILE="${CT_CC}-${CT_CC_VERSION}"
|
|
|
|
CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}"
|
2007-05-19 13:10:11 +00:00
|
|
|
CT_LIBFLOAT_FILE="libfloat-${CT_LIBFLOAT_VERSION}"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Where will we work?
|
|
|
|
CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
|
|
|
|
CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
|
|
|
|
CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
|
2007-05-10 21:33:35 +00:00
|
|
|
|
|
|
|
# Make all path absolute, it so much easier!
|
|
|
|
CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Some more sanity checks now that we have all paths set up
|
|
|
|
case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
|
|
|
|
*" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
|
|
|
|
esac
|
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Check now if we can write to the destination directory:
|
|
|
|
if [ -d "${CT_INSTALL_DIR}" ]; then
|
|
|
|
CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
|
|
|
|
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:
|
|
|
|
CT_SYS_USER="`id -un`"
|
|
|
|
CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
|
|
|
|
# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
|
|
|
|
CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
|
|
|
|
CT_SYS_KERNEL=`uname -s`
|
|
|
|
CT_SYS_REVISION=`uname -r`
|
|
|
|
# MacOS X lacks '-o' :
|
|
|
|
CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
|
|
|
|
CT_SYS_MACHINE=`uname -m`
|
|
|
|
CT_SYS_PROCESSOR=`uname -p`
|
|
|
|
CT_SYS_GCC=`gcc -dumpversion`
|
|
|
|
CT_SYS_TARGET=`${CT_TOP_DIR}/tools/config.guess`
|
|
|
|
CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Preparing working directories"
|
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Get rid of pre-existing installed toolchain and previous build directories.
|
|
|
|
# We need to do that _before_ we can safely log, because the log file will
|
|
|
|
# most probably be in the toolchain directory.
|
|
|
|
if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
|
|
|
|
mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
|
2007-05-17 16:22:51 +00:00
|
|
|
chmod -R u+w "${CT_TARBALLS_DIR}.$$"
|
2007-05-10 21:33:35 +00:00
|
|
|
nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
|
|
|
|
fi
|
|
|
|
if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
|
|
|
|
mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
|
2007-05-17 16:22:51 +00:00
|
|
|
chmod -R u+w "${CT_SRC_DIR}.$$"
|
2007-05-10 21:33:35 +00:00
|
|
|
nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
|
|
|
|
fi
|
|
|
|
if [ -d "${CT_BUILD_DIR}" ]; then
|
|
|
|
mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
|
2007-05-17 16:22:51 +00:00
|
|
|
chmod -R u+w "${CT_BUILD_DIR}.$$"
|
2007-05-10 21:33:35 +00:00
|
|
|
nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
|
|
|
|
fi
|
|
|
|
if [ -d "${CT_INSTALL_DIR}" ]; then
|
|
|
|
mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
|
2007-05-17 16:22:51 +00:00
|
|
|
chmod -R u+w "${CT_INSTALL_DIR}.$$"
|
2007-05-10 21:33:35 +00:00
|
|
|
nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
|
|
|
|
fi
|
2007-05-17 16:22:51 +00:00
|
|
|
if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
|
|
|
|
mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
|
|
|
|
chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
|
|
|
|
nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
|
|
|
|
fi
|
2007-05-10 21:33:35 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Note: we'll always install the core compiler in its own directory, so as to
|
|
|
|
# not mix the two builds: core and final. Anyway, its generic, wether we use
|
|
|
|
# a different compiler as core, or not.
|
|
|
|
CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
|
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Create the directories we'll use
|
|
|
|
mkdir -p "${CT_TARBALLS_DIR}"
|
|
|
|
mkdir -p "${CT_SRC_DIR}"
|
|
|
|
mkdir -p "${CT_BUILD_DIR}"
|
|
|
|
mkdir -p "${CT_INSTALL_DIR}"
|
2007-05-17 16:22:51 +00:00
|
|
|
mkdir -p "${CT_DEBUG_INSTALL_DIR}"
|
2007-05-10 21:33:35 +00:00
|
|
|
mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
# Redirect log to the actual log file now we can
|
2007-05-07 09:04:02 +00:00
|
|
|
# It's quite understandable that the log file will be installed in the install
|
|
|
|
# directory, so we must first ensure it exists and is writeable (above) before
|
|
|
|
# we can log there
|
2007-05-20 13:48:26 +00:00
|
|
|
exec >/dev/null
|
2007-02-24 11:00:05 +00:00
|
|
|
case "${CT_LOG_TO_FILE},${CT_LOG_FILE}" in
|
2007-05-20 13:48:26 +00:00
|
|
|
,*) rm -f "${tmp_log_file}"
|
2007-02-24 11:00:05 +00:00
|
|
|
;;
|
|
|
|
y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
|
2007-05-20 13:48:26 +00:00
|
|
|
mv "${tmp_log_file}" "${CT_LOG_FILE}"
|
|
|
|
exec >>"${CT_LOG_FILE}"
|
2007-02-24 11:00:05 +00:00
|
|
|
;;
|
|
|
|
y,*) mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
|
2007-05-20 13:48:26 +00:00
|
|
|
mv "${tmp_log_file}" "`pwd`/${CT_LOG_FILE}"
|
|
|
|
exec >>"${CT_LOG_FILE}"
|
2007-02-24 11:00:05 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Determine build system if not set by the user
|
2007-05-20 13:48:26 +00:00
|
|
|
CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
|
2007-05-07 09:04:02 +00:00
|
|
|
CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
|
|
|
|
|
|
|
|
# Arrange paths depending on wether we use sys-root or not.
|
|
|
|
if [ "${CT_USE_SYSROOT}" = "y" ]; then
|
|
|
|
CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
|
|
|
|
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
|
|
|
|
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}"
|
|
|
|
LIBC_SYSROOT_ARG=""
|
|
|
|
# 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}"
|
|
|
|
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
|
|
|
|
# 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}"
|
|
|
|
LIBC_SYSROOT_ARG="prefix="
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
|
|
|
|
# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
|
|
|
|
# "ld: cannot open crti.o: No such file or directory"
|
|
|
|
mkdir -p "${CT_SYSROOT_DIR}/lib"
|
|
|
|
mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
|
|
|
|
|
|
|
|
# Canadian-cross are really picky on the way they are built. Tweak the values.
|
|
|
|
if [ "${CT_CANADIAN}" = "y" ]; then
|
|
|
|
# Arrange so that gcc never, ever think that build system == host system
|
|
|
|
CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
|
|
|
|
# We shall have a compiler for this target!
|
|
|
|
# Do test here...
|
|
|
|
else
|
|
|
|
CT_HOST="${CT_BUILD}"
|
|
|
|
CT_CANADIAN_OPT=
|
|
|
|
# Add the target toolchain in the path so that we can build the C library
|
|
|
|
export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Modify GCC_HOST to never be equal to $BUILD or $TARGET
|
|
|
|
# This strange operation causes gcc to always generate a cross-compiler
|
|
|
|
# even if the build machine is the same kind as the host.
|
|
|
|
# This is why CC has to be set when doing a canadian cross; you can't find a
|
|
|
|
# host compiler by appending -gcc to our whacky $GCC_HOST
|
|
|
|
# Kludge: it is reported that the above causes canadian crosses with cygwin
|
|
|
|
# hosts to fail, so avoid it just in that one case. It would be cleaner to
|
|
|
|
# just move this into the non-canadian case above, but I'm afraid that might
|
|
|
|
# cause some configure script somewhere to decide that since build==host, they
|
|
|
|
# could run host binaries.
|
|
|
|
# (Copied almost as-is from original crosstool):
|
|
|
|
case "${CT_KERNEL},${CT_CANADIAN}" in
|
|
|
|
cygwin,y) ;;
|
|
|
|
*) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
|
2007-02-24 11:00:05 +00:00
|
|
|
esac
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Ah! Recent versions of binutils need some of the build and/or host system
|
|
|
|
# (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
|
|
|
|
# Do that:
|
|
|
|
CT_DoLog EXTRA "Making build system tools available"
|
|
|
|
mkdir -p "${CT_PREFIX_DIR}/bin"
|
2007-05-17 16:22:51 +00:00
|
|
|
for tool in ar gcc; do
|
2007-05-07 09:04:02 +00:00
|
|
|
ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
|
2007-05-17 16:22:51 +00:00
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
|
|
|
cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
|
|
|
|
esac
|
2007-05-07 09:04:02 +00:00
|
|
|
done
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Ha. cygwin host have an .exe suffix (extension) for executables.
|
|
|
|
[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Transform the ARCH into a kernel-understandable ARCH
|
|
|
|
case "${CT_ARCH}" in
|
|
|
|
x86) CT_KERNEL_ARCH=i386;;
|
|
|
|
ppc) CT_KERNEL_ARCH=powerpc;;
|
|
|
|
*) CT_KERNEL_ARCH="${CT_ARCH}";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Build up the TARGET_CFLAGS from user-provided options
|
|
|
|
# Override with user-specified CFLAGS
|
|
|
|
[ -n "${CT_ARCH_CPU}" ] && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
|
|
|
|
[ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
|
|
|
|
[ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
|
|
|
|
[ -n "${CT_ARCH_FPU}" ] && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
|
|
|
|
|
|
|
|
# Help gcc
|
|
|
|
CT_CFLAGS_FOR_HOST=
|
|
|
|
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
|
|
|
|
|
|
|
|
# And help make go faster
|
|
|
|
PARALLELMFLAGS=
|
|
|
|
[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
|
|
|
|
[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
|
|
|
|
|
|
|
|
CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
|
|
|
|
CT_DoLog EXTRA "Building a toolchain for:"
|
|
|
|
CT_DoLog EXTRA " build = ${CT_BUILD}"
|
|
|
|
CT_DoLog EXTRA " host = ${CT_HOST}"
|
|
|
|
CT_DoLog EXTRA " target = ${CT_TARGET}"
|
|
|
|
set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
|
|
|
|
CT_EndStep
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
# Include sub-scripts instead of calling them: that way, we do not have to
|
|
|
|
# export any variable, nor re-parse the configuration and functions files.
|
2007-05-07 09:04:02 +00:00
|
|
|
. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
|
|
|
|
. "${CT_TOP_DIR}/scripts/build/binutils.sh"
|
2007-05-09 18:55:35 +00:00
|
|
|
. "${CT_TOP_DIR}/scripts/build/libfloat.sh"
|
2007-05-07 09:04:02 +00:00
|
|
|
. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
|
|
|
|
. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
|
|
|
|
. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
|
2007-05-17 16:22:51 +00:00
|
|
|
. "${CT_TOP_DIR}/scripts/build/debug.sh"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
|
|
|
# Now for the job by itself. Go have a coffee!
|
2007-05-10 21:33:35 +00:00
|
|
|
CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
|
|
|
|
do_kernel_get
|
|
|
|
do_binutils_get
|
|
|
|
do_cc_core_get
|
|
|
|
do_libfloat_get
|
|
|
|
do_libc_get
|
|
|
|
do_cc_get
|
2007-05-17 16:22:51 +00:00
|
|
|
do_debug_get
|
2007-05-10 21:33:35 +00:00
|
|
|
CT_EndStep
|
2007-05-07 09:04:02 +00:00
|
|
|
|
|
|
|
if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
|
|
|
|
if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
|
|
|
|
mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
|
|
|
|
nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
CT_DoStep INFO "Extracting and patching toolchain components"
|
|
|
|
do_kernel_extract
|
|
|
|
do_binutils_extract
|
|
|
|
do_cc_core_extract
|
2007-05-17 16:22:51 +00:00
|
|
|
do_libfloat_extract
|
|
|
|
do_libc_extract
|
2007-05-07 09:04:02 +00:00
|
|
|
do_cc_extract
|
2007-05-17 16:22:51 +00:00
|
|
|
do_debug_extract
|
2007-05-07 09:04:02 +00:00
|
|
|
CT_EndStep
|
|
|
|
|
|
|
|
if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
|
|
|
|
do_libc_check_config
|
|
|
|
do_kernel_check_config
|
|
|
|
do_kernel_headers
|
|
|
|
do_binutils
|
|
|
|
do_libc_headers
|
|
|
|
do_cc_core
|
|
|
|
do_libfloat
|
|
|
|
do_libc
|
|
|
|
do_cc
|
|
|
|
do_libc_finish
|
2007-05-17 16:22:51 +00:00
|
|
|
do_debug
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-10 21:33:35 +00:00
|
|
|
# Create the aliases to the target tools
|
|
|
|
if [ -n "${CT_TARGET_ALIAS}" ]; then
|
|
|
|
CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
|
|
|
|
CT_Pushd "${CT_PREFIX_DIR}/bin"
|
|
|
|
for t in "${CT_TARGET}-"*; do
|
|
|
|
_t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
|
|
|
|
CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
|
|
|
|
ln -s "${t}" "${_t}"
|
|
|
|
done
|
|
|
|
CT_Popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove the generated documentation files
|
|
|
|
if [ "${CT_REMOVE_DOCS}" = "y" ]; then
|
|
|
|
CT_DoLog INFO "Removing installed documentation"
|
2007-05-18 15:48:11 +00:00
|
|
|
rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
|
|
|
|
rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
|
|
|
|
rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
|
2007-05-10 21:33:35 +00:00
|
|
|
fi
|
|
|
|
fi
|
2007-03-07 19:00:10 +00:00
|
|
|
fi
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# OK, now we're done, set the toolchain read-only
|
|
|
|
# Don't log, the log file may become read-only any moment...
|
|
|
|
chmod -R a-w "${CT_INSTALL_DIR}"
|
|
|
|
|
|
|
|
# We stil have some small bits to log
|
|
|
|
chmod u+w "${CT_LOG_FILE}"
|
|
|
|
|
|
|
|
CT_DoEnd INFO
|
|
|
|
|
|
|
|
# All files should now be read-only, log-file included
|
|
|
|
chmod a-w "${CT_LOG_FILE}"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
# Restore a 'normal' color setting
|
|
|
|
echo -en "${CT_NORMAL_COLOR}"
|
|
|
|
|
|
|
|
trap - EXIT
|