scripts/build/binutils/binutils.sh
changeset 3123 6a5946fbc728
parent 3119 1c56c03b7ed5
child 3290 bddc642fc8eb
     1.1 --- a/scripts/build/binutils/binutils.sh	Fri Nov 16 15:25:57 2012 +0100
     1.2 +++ b/scripts/build/binutils/binutils.sh	Mon Nov 19 11:21:31 2012 +0100
     1.3 @@ -12,6 +12,14 @@
     1.4                     {ftp,http}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils   \
     1.5                     ftp://gcc.gnu.org/pub/binutils/{releases,snapshots}
     1.6      fi
     1.7 +
     1.8 +    if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
     1.9 +        CT_GetCVS "elf2flt-${CT_ELF2FLT_VERSION}"               \
    1.10 +                  ":pserver:anonymous@cvs.uclinux.org:/var/cvs" \
    1.11 +                  "elf2flt"                                     \
    1.12 +                  ""                                            \
    1.13 +                  "elf2flt-${CT_ELF2FLT_VERSION}"
    1.14 +    fi
    1.15  }
    1.16  
    1.17  # Extract binutils
    1.18 @@ -24,6 +32,11 @@
    1.19  
    1.20      CT_Extract "binutils-${CT_BINUTILS_VERSION}"
    1.21      CT_Patch "binutils" "${CT_BINUTILS_VERSION}"
    1.22 +
    1.23 +    if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    1.24 +        CT_Extract "elf2flt-${CT_ELF2FLT_VERSION}"
    1.25 +        CT_Patch "elf2flt" "${CT_ELF2FLT_VERSION}"
    1.26 +    fi
    1.27  }
    1.28  
    1.29  # Build binutils for build -> target
    1.30 @@ -45,6 +58,19 @@
    1.31      do_binutils_backend "${binutils_opts[@]}"
    1.32  
    1.33      CT_Popd
    1.34 +
    1.35 +    if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    1.36 +        # We re-use binutils' options, plus our owns
    1.37 +        binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" )
    1.38 +        binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_BUILD}" )
    1.39 +
    1.40 +        CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}"
    1.41 +
    1.42 +        do_elf2flt_backend "${binutils_opts[@]}"
    1.43 +
    1.44 +        CT_Popd
    1.45 +    fi
    1.46 +
    1.47      CT_EndStep
    1.48  }
    1.49  
    1.50 @@ -65,6 +91,20 @@
    1.51  
    1.52      do_binutils_backend "${binutils_opts[@]}"
    1.53  
    1.54 +    CT_Popd
    1.55 +
    1.56 +    if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    1.57 +        # We re-use binutils' options, plus our owns
    1.58 +        binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" )
    1.59 +        binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" )
    1.60 +
    1.61 +        CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
    1.62 +
    1.63 +        do_elf2flt_backend "${binutils_opts[@]}"
    1.64 +
    1.65 +        CT_Popd
    1.66 +    fi
    1.67 +
    1.68      # Make those new tools available to the core C compilers to come.
    1.69      # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    1.70      # well. Create that.
    1.71 @@ -73,6 +113,9 @@
    1.72      case "${CT_TOOLCHAIN_TYPE}" in
    1.73          cross|native)
    1.74              binutils_tools=( ar as ld strip )
    1.75 +            if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
    1.76 +                binutils_tools+=( elf2flt flthdr )
    1.77 +            fi
    1.78              case "${CT_BINUTILS_LINKERS_LIST}" in
    1.79                  ld)         binutils_tools+=( ld.bfd ) ;;
    1.80                  gold)       binutils_tools+=( ld.gold ) ;;
    1.81 @@ -93,7 +136,6 @@
    1.82          *)  ;;
    1.83      esac
    1.84  
    1.85 -    CT_Popd
    1.86      CT_EndStep
    1.87  }
    1.88  
    1.89 @@ -218,6 +260,54 @@
    1.90      fi
    1.91  }
    1.92  
    1.93 +# Build elf2flt for X -> target
    1.94 +#     Parameter     : description               : type      : default
    1.95 +#     host          : machine to run on         : tuple     : (none)
    1.96 +#     prefix        : prefix to install into    : dir       : (none)
    1.97 +#     static_build  : build statcially          : bool      : no
    1.98 +#     cflags        : cflags to use             : string    : (empty)
    1.99 +#     ldflags       : ldflags to use            : string    : (empty)
   1.100 +#     binutils_src  : source dir of binutils    : dir       : (none)
   1.101 +#     binutils_bld  : build dir of binutils     : dir       : (none)
   1.102 +#     build_manuals : whether to build manuals  : bool      : no
   1.103 +do_elf2flt_backend() {
   1.104 +    local host
   1.105 +    local prefix
   1.106 +    local static_build
   1.107 +    local cflags
   1.108 +    local ldflags
   1.109 +    local binutils_bld
   1.110 +    local binutils_src
   1.111 +    local build_manuals
   1.112 +    local arg
   1.113 +
   1.114 +    for arg in "$@"; do
   1.115 +        eval "${arg// /\\ }"
   1.116 +    done
   1.117 +
   1.118 +    CT_DoLog EXTRA "Configuring elf2flt"
   1.119 +    CT_DoExecLog CFG                                            \
   1.120 +    CFLAGS="${cflags}"                                          \
   1.121 +    LDFLAGS="${ldflags}"                                        \
   1.122 +    "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure"     \
   1.123 +        --build=${CT_BUILD}                                     \
   1.124 +        --host=${host}                                          \
   1.125 +        --target=${CT_TARGET}                                   \
   1.126 +        --prefix=${prefix}                                      \
   1.127 +        --with-bfd-include-dir=${binutils_bld}/bfd              \
   1.128 +        --with-binutils-include-dir=${binutils_src}/include     \
   1.129 +        --with-libbfd=${binutils_bld}/bfd/libbfd.a              \
   1.130 +        --with-libiberty=${binutils_bld}/libiberty/libiberty.a  \
   1.131 +        ${elf2flt_opts}                                         \
   1.132 +        "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}"
   1.133 +
   1.134 +    CT_DoLog EXTRA "Building elf2flt"
   1.135 +    CT_DoExecLog ALL make ${JOBSFLAGS}
   1.136 +
   1.137 +    CT_DoLog EXTRA "Installing elf2flt"
   1.138 +    CT_DoExecLog ALL make install
   1.139 +}
   1.140 +
   1.141  # Now on for the target libraries
   1.142  do_binutils_for_target() {
   1.143      local -a extra_config