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