scripts/build/binutils/binutils.sh
changeset 1345 27fec561af53
child 1483 094f442a9d5e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/build/binutils/binutils.sh	Wed May 20 20:13:13 2009 +0000
     1.3 @@ -0,0 +1,116 @@
     1.4 +# This file adds functions to build binutils
     1.5 +# Copyright 2007 Yann E. MORIN
     1.6 +# Licensed under the GPL v2. See COPYING in the root of this package
     1.7 +
     1.8 +# Download binutils
     1.9 +do_binutils_get() {
    1.10 +    CT_GetFile "binutils-${CT_BINUTILS_VERSION}"                                        \
    1.11 +               {ftp,http}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils   \
    1.12 +               ftp://gcc.gnu.org/pub/binutils/{releases,snapshots}
    1.13 +}
    1.14 +
    1.15 +# Extract binutils
    1.16 +do_binutils_extract() {
    1.17 +    CT_Extract "binutils-${CT_BINUTILS_VERSION}"
    1.18 +    CT_Patch "binutils-${CT_BINUTILS_VERSION}"
    1.19 +}
    1.20 +
    1.21 +# Build binutils
    1.22 +do_binutils() {
    1.23 +    mkdir -p "${CT_BUILD_DIR}/build-binutils"
    1.24 +    cd "${CT_BUILD_DIR}/build-binutils"
    1.25 +
    1.26 +    CT_DoStep INFO "Installing binutils"
    1.27 +
    1.28 +    binutils_opts=
    1.29 +    # If GMP and MPFR were configured, then use that,
    1.30 +    # otherwise let binutils find the system-wide libraries, if they exist.
    1.31 +    if [ "${CT_GMP_MPFR}" = "y" ]; then
    1.32 +        binutils_opts="--with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
    1.33 +    fi
    1.34 +
    1.35 +    CT_DoLog EXTRA "Configuring binutils"
    1.36 +    CFLAGS="${CT_CFLAGS_FOR_HOST}"                              \
    1.37 +    CT_DoExecLog ALL                                            \
    1.38 +    "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
    1.39 +        --build=${CT_BUILD}                                     \
    1.40 +        --host=${CT_HOST}                                       \
    1.41 +        --target=${CT_TARGET}                                   \
    1.42 +        --prefix=${CT_PREFIX_DIR}                               \
    1.43 +        --disable-nls                                           \
    1.44 +        --disable-multilib                                      \
    1.45 +        --disable-werror                                        \
    1.46 +        ${binutils_opts}                                        \
    1.47 +        ${CT_ARCH_WITH_FLOAT}                                   \
    1.48 +        ${CT_BINUTILS_EXTRA_CONFIG}                             \
    1.49 +        ${BINUTILS_SYSROOT_ARG}
    1.50 +
    1.51 +    CT_DoLog EXTRA "Building binutils"
    1.52 +    CT_DoExecLog ALL make ${PARALLELMFLAGS}
    1.53 +
    1.54 +    CT_DoLog EXTRA "Installing binutils"
    1.55 +    CT_DoExecLog ALL make install
    1.56 +
    1.57 +    # Make those new tools available to the core C compilers to come.
    1.58 +    # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    1.59 +    # well. Create that.
    1.60 +    mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin"
    1.61 +    mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
    1.62 +    mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
    1.63 +    mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
    1.64 +    for t in ar as ld strip; do
    1.65 +        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    1.66 +        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    1.67 +        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    1.68 +        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    1.69 +    done 2>&1 |CT_DoLog ALL
    1.70 +
    1.71 +    CT_EndStep
    1.72 +}
    1.73 +
    1.74 +# Now on for the target libraries
    1.75 +do_binutils_target() {
    1.76 +    targets=
    1.77 +    [ "${CT_BINUTILS_FOR_TARGET_IBERTY}" = "y" ] && targets="${targets} libiberty"
    1.78 +    [ "${CT_BINUTILS_FOR_TARGET_BFD}"    = "y" ] && targets="${targets} bfd"
    1.79 +    targets="${targets# }"
    1.80 +
    1.81 +    binutils_opts=
    1.82 +    # If GMP and MPFR were configured, then use that
    1.83 +    if [ "${CT_GMP_MPFR_TARGET}" = "y" ]; then
    1.84 +        binutils_opts="--with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
    1.85 +    fi
    1.86 +
    1.87 +    if [ -n "${targets}" ]; then
    1.88 +        CT_DoStep INFO "Installing binutils for target"
    1.89 +        mkdir -p "${CT_BUILD_DIR}/build-binutils-for-target"
    1.90 +        CT_Pushd "${CT_BUILD_DIR}/build-binutils-for-target"
    1.91 +
    1.92 +        CT_DoLog EXTRA "Configuring binutils for target"
    1.93 +        CT_DoExecLog ALL                                            \
    1.94 +        "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
    1.95 +            --build=${CT_BUILD}                                     \
    1.96 +            --host=${CT_TARGET}                                     \
    1.97 +            --target=${CT_TARGET}                                   \
    1.98 +            --prefix=/usr                                           \
    1.99 +            --disable-werror                                        \
   1.100 +            --enable-shared                                         \
   1.101 +            --enable-static                                         \
   1.102 +            --disable-nls                                           \
   1.103 +            --disable-multilib                                      \
   1.104 +            ${binutils_opts}                                        \
   1.105 +            ${CT_ARCH_WITH_FLOAT}                                   \
   1.106 +            ${CT_BINUTILS_EXTRA_CONFIG}
   1.107 +
   1.108 +        build_targets=$(echo "${targets}" |sed -r -e 's/(^| +)/\1all-/g;')
   1.109 +        install_targets=$(echo "${targets}" |sed -r -e 's/(^| +)/\1install-/g;')
   1.110 +
   1.111 +        CT_DoLog EXTRA "Building binutils' libraries (${targets}) for target"
   1.112 +        CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_targets}
   1.113 +        CT_DoLog EXTRA "Installing binutils' libraries (${targets}) for target"
   1.114 +        CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" ${install_targets}
   1.115 +
   1.116 +        CT_Popd
   1.117 +        CT_EndStep
   1.118 +    fi
   1.119 +}