scripts/build/binutils/elf2flt.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 17 18:29:35 2011 +0200 (2011-07-17)
changeset 2926 d304c8a7bfa8
parent 2924 0eab838768b1
child 2928 3f70dd642d34
permissions -rw-r--r--
binutils: split binutils to backend/frontend, a-la cc_core

Move the actual binutils code to a backend function that builds the
required combo of build/host/target as requested by a frontend.

This split is currently a no-op, but is required for the upcoming
canadian-cross rework, where we'll be needing to build two binutils,
one for build/build/target, and one for build/host/target.

This applies to the three binutils:
- GNU binutils
- elf2flt
- sstrip

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 # This file adds functions to build elf2flt
     2 # Copyright 2009 John Williams
     3 # Copyright 2007 Yann E. MORIN
     4 # Licensed under the GPL v2. See COPYING in the root of this package
     5 
     6 # Default: do nothing
     7 do_elf2flt_get()        { :; }
     8 do_elf2flt_extract()    { :; }
     9 do_elf2flt_for_host()   { :; }
    10 
    11 if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    12 
    13 # Download elf2flt
    14 do_elf2flt_get() {
    15     CT_GetCVS "elf2flt-cvs-${CT_ELF2FLT_VERSION}"           \
    16               ":pserver:anonymous@cvs.uclinux.org:/var/cvs" \
    17               "elf2flt"                                     \
    18               "" \
    19               "elf2flt-cvs-${CT_ELF2FLT_VERSION}"
    20 }
    21 
    22 # Extract elf2flt
    23 do_elf2flt_extract() {
    24     CT_Extract "elf2flt-cvs-${CT_ELF2FLT_VERSION}"
    25     CT_Patch "elf2flt-cvs" "${CT_ELF2FLT_VERSION}"
    26 }
    27 
    28 # Build elf2flt for host -> target
    29 do_elf2flt_for_host() {
    30     local -a elf2flt_opts
    31 
    32     CT_DoStep INFO "Installing elf2flt for host"
    33     CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
    34 
    35     elf2flt_opts+=( "host=${CT_HOST}" )
    36     elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
    37     elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
    38     elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    39 
    40     do_elf2flt_backend "${elf2flt_opts[@]}"
    41 
    42     # Make those new tools available to the core C compilers to come.
    43     # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    44     # well. Create that.
    45     # Don't do it for canadian or cross-native, because the binutils
    46     # are not executable on the build machine.
    47     case "${CT_TOOLCHAIN_TYPE}" in
    48         cross|native)
    49             mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
    50             mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
    51             for t in elf2flt flthdr; do
    52                 CT_DoExecLog ALL ln -sv                                         \
    53                                     "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    54                                     "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    55                 CT_DoExecLog ALL ln -sv                                         \
    56                                     "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    57                                     "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    58             done
    59             ;;
    60         *)  ;;
    61     esac
    62 
    63     CT_Popd
    64     CT_EndStep
    65 }
    66 
    67 # Build elf2flt for X -> target
    68 #     Parameter     : description               : type      : default
    69 #     host          : machine to run on         : tuple     : (none)
    70 #     prefix        : prefix to install into    : dir       : (none)
    71 #     static_build  : build statcially          : bool      : no
    72 #     cflags        : host cflags to use        : string    : (empty)
    73 do_elf2flt_backend() {
    74     local host
    75     local prefix
    76     local static_build
    77     local cflags
    78     local arg
    79 
    80     for arg in "$@"; do
    81         eval "${arg// /\\ }"
    82     done
    83 
    84     elf2flt_opts=
    85     binutils_bld="${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}"
    86     binutils_src="${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}"
    87 
    88     CT_DoLog EXTRA "Configuring elf2flt"
    89     CT_DoExecLog CFG                                            \
    90     CFLAGS="${host_cflags}"                                     \
    91     "${CT_SRC_DIR}/elf2flt-cvs-${CT_ELF2FLT_VERSION}/configure" \
    92         --build=${CT_BUILD}                                     \
    93         --host=${host}                                          \
    94         --target=${CT_TARGET}                                   \
    95         --prefix=${prefix}                                      \
    96         --with-bfd-include-dir=${binutils_bld}/bfd              \
    97         --with-binutils-include-dir=${binutils_src}/include     \
    98         --with-libbfd=${binutils_bld}/bfd/libbfd.a              \
    99         --with-libiberty=${binutils_bld}/libiberty/libiberty.a  \
   100         ${elf2flt_opts}                                         \
   101         "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}"
   102 
   103     CT_DoLog EXTRA "Building elf2flt"
   104     CT_DoExecLog ALL make ${JOBSFLAGS}
   105 
   106     CT_DoLog EXTRA "Installing elf2flt"
   107     CT_DoExecLog ALL make install
   108 }
   109 
   110 fi # CT_ARCH_BINFMT_FLAT