scripts/build/binutils/binutils.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Feb 09 22:50:53 2010 +0100 (2010-02-09)
changeset 1807 4201b5881a7e
parent 1483 094f442a9d5e
child 1808 a1370757e6a1
permissions -rw-r--r--
binutils/binutils: fix using GMP and MPFR
     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     # If GMP and MPFR were configured, then use that
    89     if [ "${CT_BINUTILS_TARGET_USE_GMP_MPFR}" = "y" ]; then
    90         extra_config+=("--with-gmp=${CT_SYSROOT_DIR}/usr")
    91         extra_config+=("--with-mpfr=${CT_SYSROOT_DIR}/usr")
    92     fi
    93 
    94     if [ "${#targets[@]}" -ne 0 ]; then
    95         CT_DoStep INFO "Installing binutils for target"
    96         mkdir -p "${CT_BUILD_DIR}/build-binutils-for-target"
    97         CT_Pushd "${CT_BUILD_DIR}/build-binutils-for-target"
    98 
    99         CT_DoLog EXTRA "Configuring binutils for target"
   100         CT_DoExecLog ALL                                            \
   101         "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
   102             --build=${CT_BUILD}                                     \
   103             --host=${CT_TARGET}                                     \
   104             --target=${CT_TARGET}                                   \
   105             --prefix=/usr                                           \
   106             --disable-werror                                        \
   107             --enable-shared                                         \
   108             --enable-static                                         \
   109             --disable-nls                                           \
   110             --disable-multilib                                      \
   111             "${extra_config[@]}"                                    \
   112             ${CT_ARCH_WITH_FLOAT}                                   \
   113             ${CT_BINUTILS_EXTRA_CONFIG}
   114 
   115         CT_DoLog EXTRA "Building binutils' libraries (${targets[*]}) for target"
   116         CT_DoExecLog ALL make ${PARALLELMFLAGS} "${build_targets[@]}"
   117         CT_DoLog EXTRA "Installing binutils' libraries (${targets[*]}) for target"
   118         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" "${install_targets[@]}"
   119 
   120         CT_Popd
   121         CT_EndStep
   122     fi
   123 }