scripts/build/binutils/elf2flt.sh
changeset 2926 d304c8a7bfa8
parent 2924 0eab838768b1
child 2928 3f70dd642d34
     1.1 --- a/scripts/build/binutils/elf2flt.sh	Sun Jan 01 17:49:44 2012 +0100
     1.2 +++ b/scripts/build/binutils/elf2flt.sh	Sun Jul 17 18:29:35 2011 +0200
     1.3 @@ -4,9 +4,9 @@
     1.4  # Licensed under the GPL v2. See COPYING in the root of this package
     1.5  
     1.6  # Default: do nothing
     1.7 -do_elf2flt_get()     { :; }
     1.8 -do_elf2flt_extract() { :; }
     1.9 -do_elf2flt()         { :; }
    1.10 +do_elf2flt_get()        { :; }
    1.11 +do_elf2flt_extract()    { :; }
    1.12 +do_elf2flt_for_host()   { :; }
    1.13  
    1.14  if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    1.15  
    1.16 @@ -25,25 +25,74 @@
    1.17      CT_Patch "elf2flt-cvs" "${CT_ELF2FLT_VERSION}"
    1.18  }
    1.19  
    1.20 -# Build elf2flt
    1.21 -do_elf2flt() {
    1.22 -    mkdir -p "${CT_BUILD_DIR}/build-elf2flt"
    1.23 -    cd "${CT_BUILD_DIR}/build-elf2flt"
    1.24 +# Build elf2flt for host -> target
    1.25 +do_elf2flt_for_host() {
    1.26 +    local -a elf2flt_opts
    1.27  
    1.28 -    CT_DoStep INFO "Installing elf2flt"
    1.29 +    CT_DoStep INFO "Installing elf2flt for host"
    1.30 +    CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
    1.31 +
    1.32 +    elf2flt_opts+=( "host=${CT_HOST}" )
    1.33 +    elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
    1.34 +    elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
    1.35 +    elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    1.36 +
    1.37 +    do_elf2flt_backend "${elf2flt_opts[@]}"
    1.38 +
    1.39 +    # Make those new tools available to the core C compilers to come.
    1.40 +    # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    1.41 +    # well. Create that.
    1.42 +    # Don't do it for canadian or cross-native, because the binutils
    1.43 +    # are not executable on the build machine.
    1.44 +    case "${CT_TOOLCHAIN_TYPE}" in
    1.45 +        cross|native)
    1.46 +            mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
    1.47 +            mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
    1.48 +            for t in elf2flt flthdr; do
    1.49 +                CT_DoExecLog ALL ln -sv                                         \
    1.50 +                                    "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    1.51 +                                    "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    1.52 +                CT_DoExecLog ALL ln -sv                                         \
    1.53 +                                    "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}"    \
    1.54 +                                    "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    1.55 +            done
    1.56 +            ;;
    1.57 +        *)  ;;
    1.58 +    esac
    1.59 +
    1.60 +    CT_Popd
    1.61 +    CT_EndStep
    1.62 +}
    1.63 +
    1.64 +# Build elf2flt for X -> target
    1.65 +#     Parameter     : description               : type      : default
    1.66 +#     host          : machine to run on         : tuple     : (none)
    1.67 +#     prefix        : prefix to install into    : dir       : (none)
    1.68 +#     static_build  : build statcially          : bool      : no
    1.69 +#     cflags        : host cflags to use        : string    : (empty)
    1.70 +do_elf2flt_backend() {
    1.71 +    local host
    1.72 +    local prefix
    1.73 +    local static_build
    1.74 +    local cflags
    1.75 +    local arg
    1.76 +
    1.77 +    for arg in "$@"; do
    1.78 +        eval "${arg// /\\ }"
    1.79 +    done
    1.80  
    1.81      elf2flt_opts=
    1.82 -    binutils_bld=${CT_BUILD_DIR}/build-binutils
    1.83 -    binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}
    1.84 +    binutils_bld="${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}"
    1.85 +    binutils_src="${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}"
    1.86  
    1.87      CT_DoLog EXTRA "Configuring elf2flt"
    1.88      CT_DoExecLog CFG                                            \
    1.89 -    CFLAGS="${CT_CFLAGS_FOR_HOST}"                              \
    1.90 +    CFLAGS="${host_cflags}"                                     \
    1.91      "${CT_SRC_DIR}/elf2flt-cvs-${CT_ELF2FLT_VERSION}/configure" \
    1.92          --build=${CT_BUILD}                                     \
    1.93 -        --host=${CT_HOST}                                       \
    1.94 +        --host=${host}                                          \
    1.95          --target=${CT_TARGET}                                   \
    1.96 -        --prefix=${CT_PREFIX_DIR}                               \
    1.97 +        --prefix=${prefix}                                      \
    1.98          --with-bfd-include-dir=${binutils_bld}/bfd              \
    1.99          --with-binutils-include-dir=${binutils_src}/include     \
   1.100          --with-libbfd=${binutils_bld}/bfd/libbfd.a              \
   1.101 @@ -56,25 +105,6 @@
   1.102  
   1.103      CT_DoLog EXTRA "Installing elf2flt"
   1.104      CT_DoExecLog ALL make install
   1.105 -
   1.106 -    # Make those new tools available to the core C compilers to come.
   1.107 -    # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
   1.108 -    # well. Create that.
   1.109 -    # Don't do it for canadian or cross-native, because the binutils
   1.110 -    # are not executable on the build machine.
   1.111 -    case "${CT_TOOLCHAIN_TYPE}" in
   1.112 -        cross|native)
   1.113 -            mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
   1.114 -            mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
   1.115 -            for t in elf2flt flthdr; do
   1.116 -                ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
   1.117 -                ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
   1.118 -            done 2>&1 |CT_DoLog ALL
   1.119 -            ;;
   1.120 -        *)  ;;
   1.121 -    esac
   1.122 -
   1.123 -    CT_EndStep
   1.124  }
   1.125  
   1.126  fi # CT_ARCH_BINFMT_FLAT