scripts/build/binutils/elf2flt.sh
author David Holsgrove <david.holsgrove@xilinx.com>
Thu Oct 11 14:39:42 2012 +1000 (2012-10-11)
changeset 3090 a221c86d9b33
parent 2928 3f70dd642d34
child 3119 1c56c03b7ed5
permissions -rw-r--r--
binutils/elf2flt: Add CUSTOM version, CUSTOM_LOCATION config options, GetCustom

CUSTOM_LOCATION config options only presented in menuconfig if component
CUSTOM version selected.

Change elf2flt CT_ELF2FLT_VERSION from 'head' to 'cvs' if cvs selected in config

Also remove hardcoded 'cvs-' from elf2flt component name, used in CT_Extract,
CT_Patch and as the CT_SRC_DIR location for the configure stage.

Signed-off-by: "David Holsgrove" <david.holsgrove@xilinx.com>
[yann.morin.1998@free.fr: fix indentation, don't patch custom dir location]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <288db3721a37844defa5.1349931196@localhost.localdomain>
PatchWork-Id: 190789
     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_build()  { :; }
    10 do_elf2flt_for_host()   { :; }
    11 
    12 if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    13 
    14 # Download elf2flt
    15 do_elf2flt_get() {
    16     if [ "${CT_ELF2FLT_CUSTOM}" = "y" ]; then
    17         CT_GetCustom "elf2flt" "${ELF2FLT_VERSION}" \
    18                      "${CT_ELF2FLT_CUSTOM_LOCATION}"
    19     else
    20         CT_GetCVS "elf2flt-${CT_ELF2FLT_VERSION}"               \
    21                   ":pserver:anonymous@cvs.uclinux.org:/var/cvs" \
    22                   "elf2flt"                                     \
    23                   "" \
    24                   "elf2flt-${CT_ELF2FLT_VERSION}"
    25     fi
    26 }
    27 
    28 # Extract elf2flt
    29 do_elf2flt_extract() {
    30     # If using custom directory location, nothing to do
    31     if [    "${CT_ELF2FLT_CUSTOM}" = "y" \
    32          -a -d "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}" ]; then
    33         return 0
    34     fi
    35     CT_Extract "elf2flt-${CT_ELF2FLT_VERSION}"
    36     CT_Patch "elf2flt" "${CT_ELF2FLT_VERSION}"
    37 }
    38 
    39 # Build elf2flt for build -> target
    40 do_elf2flt_for_build() {
    41     local -a elf2flt_opts
    42 
    43     case "${CT_TOOLCHAIN_TYPE}" in
    44         native|cross)   return 0;;
    45     esac
    46 
    47     CT_DoStep INFO "Installing elf2flt for build"
    48     CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}"
    49 
    50     elf2flt_opts+=( "host=${CT_BUILD}" )
    51     elf2flt_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    52     elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_HOST}" )
    53 
    54     do_elf2flt_backend "${elf2flt_opts[@]}"
    55 
    56     CT_Popd
    57     CT_EndStep
    58 }
    59 
    60 # Build elf2flt for host -> target
    61 do_elf2flt_for_host() {
    62     local -a elf2flt_opts
    63 
    64     CT_DoStep INFO "Installing elf2flt for host"
    65     CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
    66 
    67     elf2flt_opts+=( "host=${CT_HOST}" )
    68     elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
    69     elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
    70     elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    71     elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" )
    72 
    73     do_elf2flt_backend "${elf2flt_opts[@]}"
    74 
    75     # Make those new tools available to the core C compilers to come.
    76     # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    77     # well. Create that.
    78     # Don't do it for canadian or cross-native, because the binutils
    79     # are not executable on the build machine.
    80     case "${CT_TOOLCHAIN_TYPE}" in
    81         cross|native)
    82             mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
    83             mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
    84             for t in elf2flt flthdr; do
    85                 CT_DoExecLog ALL ln -sv                                         \
    86                                     "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    87                                     "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    88                 CT_DoExecLog ALL ln -sv                                         \
    89                                     "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    90                                     "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    91             done
    92             ;;
    93         *)  ;;
    94     esac
    95 
    96     CT_Popd
    97     CT_EndStep
    98 }
    99 
   100 # Build elf2flt for X -> target
   101 #     Parameter     : description               : type      : default
   102 #     host          : machine to run on         : tuple     : (none)
   103 #     prefix        : prefix to install into    : dir       : (none)
   104 #     static_build  : build statcially          : bool      : no
   105 #     cflags        : host cflags to use        : string    : (empty)
   106 do_elf2flt_backend() {
   107     local host
   108     local prefix
   109     local static_build
   110     local cflags
   111     local binutils_bld
   112     local binutils_src
   113     local arg
   114 
   115     for arg in "$@"; do
   116         eval "${arg// /\\ }"
   117     done
   118 
   119     binutils_src="${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}"
   120 
   121     CT_DoLog EXTRA "Configuring elf2flt"
   122     CT_DoExecLog CFG                                            \
   123     CFLAGS="${host_cflags}"                                     \
   124     "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure"     \
   125         --build=${CT_BUILD}                                     \
   126         --host=${host}                                          \
   127         --target=${CT_TARGET}                                   \
   128         --prefix=${prefix}                                      \
   129         --with-bfd-include-dir=${binutils_bld}/bfd              \
   130         --with-binutils-include-dir=${binutils_src}/include     \
   131         --with-libbfd=${binutils_bld}/bfd/libbfd.a              \
   132         --with-libiberty=${binutils_bld}/libiberty/libiberty.a  \
   133         ${elf2flt_opts}                                         \
   134         "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}"
   135 
   136     CT_DoLog EXTRA "Building elf2flt"
   137     CT_DoExecLog ALL make ${JOBSFLAGS}
   138 
   139     CT_DoLog EXTRA "Installing elf2flt"
   140     CT_DoExecLog ALL make install
   141 }
   142 
   143 fi # CT_ARCH_BINFMT_FLAT