scripts/build/binutils/elf2flt.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 17 22:43:07 2011 +0200 (2011-07-17)
changeset 2893 a8a65758664f
parent 2466 b7df125a1c78
child 2923 60f5ceb1b413
permissions -rw-r--r--
cc/gcc: do not use the core pass-2 to build the baremetal compiler

In case we build a baremetal compiler, use the standard passes:
- core_cc is used to build the C library;
- as such, it is meant to run on build, not host;
- the final compiler is meant to run on host;

As the current final compiler step can not build a baremetal compiler,
call the core backend from the final step.

NB: Currently, newlib is built during the start_files pass, so we have
to have a core compiler by then... Once we can build the baremetal
compiler from the final cc step, then we can move the newlib build to
the proper step, and then get rid of the core pass-1 static compiler...

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()         { :; }
    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
    29 do_elf2flt() {
    30     mkdir -p "${CT_BUILD_DIR}/build-elf2flt"
    31     cd "${CT_BUILD_DIR}/build-elf2flt"
    32 
    33     CT_DoStep INFO "Installing elf2flt"
    34 
    35     elf2flt_opts=
    36     binutils_bld=${CT_BUILD_DIR}/build-binutils
    37     binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}
    38 
    39     CT_DoLog EXTRA "Configuring elf2flt"
    40     CT_DoExecLog CFG                                            \
    41     CFLAGS="${CT_CFLAGS_FOR_HOST}"                              \
    42     "${CT_SRC_DIR}/elf2flt-cvs-${CT_ELF2FLT_VERSION}/configure" \
    43         --build=${CT_BUILD}                                     \
    44         --host=${CT_HOST}                                       \
    45         --target=${CT_TARGET}                                   \
    46         --prefix=${CT_PREFIX_DIR}                               \
    47         --with-bfd-include-dir=${binutils_bld}/bfd              \
    48         --with-binutils-include-dir=${binutils_src}/include     \
    49         --with-libbfd=${binutils_bld}/bfd/libbfd.a              \
    50         --with-libiberty=${binutils_bld}/libiberty/libiberty.a  \
    51         ${elf2flt_opts}                                         \
    52         "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}"
    53 
    54     CT_DoLog EXTRA "Building elf2flt"
    55     CT_DoExecLog ALL make ${JOBSFLAGS}
    56 
    57     CT_DoLog EXTRA "Installing elf2flt"
    58     CT_DoExecLog ALL make install
    59 
    60     # Make those new tools available to the core C compilers to come.
    61     # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
    62     # well. Create that.
    63     mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin"
    64     mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
    65     mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
    66     mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
    67     for t in elf2flt flthdr; do
    68         ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    69         ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    70         ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
    71         ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
    72     done 2>&1 |CT_DoLog ALL
    73 
    74     CT_EndStep
    75 }
    76 
    77 fi # CT_ARCH_BINFMT_FLAT