scripts/build/binutils/binutils.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Feb 18 20:43:31 2010 +0100 (2010-02-18)
changeset 1809 b488b4815f9b
parent 1808 a1370757e6a1
child 1901 bdb3a98e064b
permissions -rw-r--r--
complibs: simplify config file

Although currently the wrapper is directly dependent on
companion libraries, let's still decorelate those two.
yann@1345
     1
# This file adds functions to build binutils
yann@1345
     2
# Copyright 2007 Yann E. MORIN
yann@1345
     3
# Licensed under the GPL v2. See COPYING in the root of this package
yann@1345
     4
yann@1345
     5
# Download binutils
yann@1345
     6
do_binutils_get() {
yann@1345
     7
    CT_GetFile "binutils-${CT_BINUTILS_VERSION}"                                        \
yann@1345
     8
               {ftp,http}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils   \
yann@1345
     9
               ftp://gcc.gnu.org/pub/binutils/{releases,snapshots}
yann@1345
    10
}
yann@1345
    11
yann@1345
    12
# Extract binutils
yann@1345
    13
do_binutils_extract() {
yann@1345
    14
    CT_Extract "binutils-${CT_BINUTILS_VERSION}"
yann@1345
    15
    CT_Patch "binutils-${CT_BINUTILS_VERSION}"
yann@1345
    16
}
yann@1345
    17
yann@1345
    18
# Build binutils
yann@1345
    19
do_binutils() {
yann@1483
    20
    local -a extra_config
yann@1483
    21
yann@1345
    22
    mkdir -p "${CT_BUILD_DIR}/build-binutils"
yann@1345
    23
    cd "${CT_BUILD_DIR}/build-binutils"
yann@1345
    24
yann@1345
    25
    CT_DoStep INFO "Installing binutils"
yann@1345
    26
yann@1345
    27
    # If GMP and MPFR were configured, then use that,
yann@1345
    28
    # otherwise let binutils find the system-wide libraries, if they exist.
yann@1808
    29
    [ -z "${CT_GMP}"    ] || extra_config+=("--with-gmp=${CT_PREFIX_DIR}")
yann@1808
    30
    [ -z "${CT_MPFR}"   ] || extra_config+=("--with-mpfr=${CT_PREFIX_DIR}")
yann@1345
    31
yann@1345
    32
    CT_DoLog EXTRA "Configuring binutils"
yann@1345
    33
    CFLAGS="${CT_CFLAGS_FOR_HOST}"                              \
yann@1345
    34
    CT_DoExecLog ALL                                            \
yann@1345
    35
    "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
yann@1345
    36
        --build=${CT_BUILD}                                     \
yann@1345
    37
        --host=${CT_HOST}                                       \
yann@1345
    38
        --target=${CT_TARGET}                                   \
yann@1345
    39
        --prefix=${CT_PREFIX_DIR}                               \
yann@1345
    40
        --disable-nls                                           \
yann@1345
    41
        --disable-multilib                                      \
yann@1345
    42
        --disable-werror                                        \
yann@1483
    43
        "${extra_config[@]}"                                    \
yann@1345
    44
        ${CT_ARCH_WITH_FLOAT}                                   \
yann@1345
    45
        ${CT_BINUTILS_EXTRA_CONFIG}                             \
yann@1345
    46
        ${BINUTILS_SYSROOT_ARG}
yann@1345
    47
yann@1345
    48
    CT_DoLog EXTRA "Building binutils"
yann@1345
    49
    CT_DoExecLog ALL make ${PARALLELMFLAGS}
yann@1345
    50
yann@1345
    51
    CT_DoLog EXTRA "Installing binutils"
yann@1345
    52
    CT_DoExecLog ALL make install
yann@1345
    53
yann@1345
    54
    # Make those new tools available to the core C compilers to come.
yann@1345
    55
    # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
yann@1345
    56
    # well. Create that.
yann@1345
    57
    mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin"
yann@1345
    58
    mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
yann@1345
    59
    mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
yann@1345
    60
    mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
yann@1345
    61
    for t in ar as ld strip; do
yann@1345
    62
        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
yann@1345
    63
        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
yann@1345
    64
        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
yann@1345
    65
        ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
yann@1345
    66
    done 2>&1 |CT_DoLog ALL
yann@1345
    67
yann@1345
    68
    CT_EndStep
yann@1345
    69
}
yann@1345
    70
yann@1345
    71
# Now on for the target libraries
yann@1345
    72
do_binutils_target() {
yann@1483
    73
    local -a extra_config
yann@1483
    74
    local -a targets
yann@1483
    75
    local -a build_targets
yann@1483
    76
    local -a install_targets
yann@1483
    77
    local t
yann@1345
    78
yann@1483
    79
    [ "${CT_BINUTILS_FOR_TARGET_IBERTY}" = "y" ] && targets+=("libiberty")
yann@1483
    80
    [ "${CT_BINUTILS_FOR_TARGET_BFD}"    = "y" ] && targets+=("bfd")
yann@1483
    81
    for t in "${targets[@]}"; do
yann@1483
    82
        build_targets+=("all-${t}")
yann@1483
    83
        install_targets+=("install-${t}")
yann@1483
    84
    done
yann@1483
    85
yann@1345
    86
    # If GMP and MPFR were configured, then use that
yann@1809
    87
    if [ "${CT_BINUTILS_TARGET_USE_GMP_MPFR}" = "y" ]; then
yann@1483
    88
        extra_config+=("--with-gmp=${CT_SYSROOT_DIR}/usr")
yann@1483
    89
        extra_config+=("--with-mpfr=${CT_SYSROOT_DIR}/usr")
yann@1345
    90
    fi
yann@1345
    91
yann@1483
    92
    if [ "${#targets[@]}" -ne 0 ]; then
yann@1345
    93
        CT_DoStep INFO "Installing binutils for target"
yann@1345
    94
        mkdir -p "${CT_BUILD_DIR}/build-binutils-for-target"
yann@1345
    95
        CT_Pushd "${CT_BUILD_DIR}/build-binutils-for-target"
yann@1345
    96
yann@1345
    97
        CT_DoLog EXTRA "Configuring binutils for target"
yann@1345
    98
        CT_DoExecLog ALL                                            \
yann@1345
    99
        "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
yann@1345
   100
            --build=${CT_BUILD}                                     \
yann@1345
   101
            --host=${CT_TARGET}                                     \
yann@1345
   102
            --target=${CT_TARGET}                                   \
yann@1345
   103
            --prefix=/usr                                           \
yann@1345
   104
            --disable-werror                                        \
yann@1345
   105
            --enable-shared                                         \
yann@1345
   106
            --enable-static                                         \
yann@1345
   107
            --disable-nls                                           \
yann@1345
   108
            --disable-multilib                                      \
yann@1483
   109
            "${extra_config[@]}"                                    \
yann@1345
   110
            ${CT_ARCH_WITH_FLOAT}                                   \
yann@1345
   111
            ${CT_BINUTILS_EXTRA_CONFIG}
yann@1345
   112
yann@1483
   113
        CT_DoLog EXTRA "Building binutils' libraries (${targets[*]}) for target"
yann@1483
   114
        CT_DoExecLog ALL make ${PARALLELMFLAGS} "${build_targets[@]}"
yann@1483
   115
        CT_DoLog EXTRA "Installing binutils' libraries (${targets[*]}) for target"
yann@1483
   116
        CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" "${install_targets[@]}"
yann@1345
   117
yann@1345
   118
        CT_Popd
yann@1345
   119
        CT_EndStep
yann@1345
   120
    fi
yann@1345
   121
}