scripts/build/companion_libs/libelf.sh
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Mon Apr 16 15:25:36 2012 +0200 (2012-04-16)
changeset 2941 13e40098fffc
parent 2929 22e495b7bee8
permissions -rw-r--r--
cc/gcc: update Linaro GCC revisions to 2012.04

Update Linaro GCC with the latest available revisions.

The 4.7 revision is also released, but the infrastructure is not yet ready for
it in CT-NG.

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
     1 # Build script for libelf
     2 
     3 do_libelf_get() { :; }
     4 do_libelf_extract() { :; }
     5 do_libelf_for_build() { :; }
     6 do_libelf_for_host() { :; }
     7 do_libelf_for_target() { :; }
     8 
     9 if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then
    10 
    11 do_libelf_get() {
    12     # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
    13     # error code if we try to download a file that does not exists there.
    14     # So we have to request the file with an explicit extension.
    15     CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
    16 }
    17 
    18 do_libelf_extract() {
    19     CT_Extract "libelf-${CT_LIBELF_VERSION}"
    20     CT_Patch "libelf" "${CT_LIBELF_VERSION}"
    21 }
    22 
    23 if [ "${CT_LIBELF}" = "y" ]; then
    24 
    25 # Build libelf for running on build
    26 # - always build statically
    27 # - we do not have build-specific CFLAGS
    28 # - install in build-tools prefix
    29 do_libelf_for_build() {
    30     local -a libelf_opts
    31 
    32     case "${CT_TOOLCHAIN_TYPE}" in
    33         native|cross)   return 0;;
    34     esac
    35 
    36     CT_DoStep INFO "Installing libelf for build"
    37     CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-build-${CT_BUILD}"
    38 
    39     libelf_opts+=( "host=${CT_BUILD}" )
    40     libelf_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    41     do_libelf_backend "${libelf_opts[@]}"
    42 
    43     CT_Popd
    44     CT_EndStep
    45 }
    46 
    47 # Build libelf for running on host
    48 do_libelf_for_host() {
    49     local -a libelf_opts
    50 
    51     CT_DoStep INFO "Installing libelf for host"
    52     CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-host-${CT_HOST}"
    53 
    54     libelf_opts+=( "host=${CT_HOST}" )
    55     libelf_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    56     libelf_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    57     do_libelf_backend "${libelf_opts[@]}"
    58 
    59     CT_Popd
    60     CT_EndStep
    61 }
    62 
    63 fi # CT_LIBELF
    64 
    65 if [ "${CT_LIBELF_TARGET}" = "y" ]; then
    66 
    67 do_libelf_for_target() {
    68     local -a libelf_opts
    69 
    70     CT_DoStep INFO "Installing libelf for the target"
    71     CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-target-${CT_TARGET}"
    72 
    73     libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" )
    74     libelf_opts+=( "host=${CT_TARGET}" )
    75     libelf_opts+=( "prefix=/usr" )
    76     libelf_opts+=( "shared=y" )
    77     do_libelf_backend "${libelf_opts[@]}"
    78 
    79     CT_Popd
    80     CT_EndStep
    81 }
    82 
    83 fi # CT_LIBELF_TARGET
    84 
    85 # Build libelf
    86 #     Parameter     : description               : type      : default
    87 #     destdir       : out-of-tree install dir   : string    : /
    88 #     host          : machine to run on         : tuple     : (none)
    89 #     prefix        : prefix to install into    : dir       : (none)
    90 #     cflags        : host cflags to use        : string    : (empty)
    91 #     shared        : also buils shared lib     : bool      : n
    92 do_libelf_backend() {
    93     local destdir="/"
    94     local host
    95     local prefix
    96     local cflags
    97     local shared
    98     local -a extra_config
    99     local arg
   100 
   101     for arg in "$@"; do
   102         eval "${arg// /\\ }"
   103     done
   104 
   105     CT_DoLog EXTRA "Configuring libelf"
   106 
   107     if [ "${shared}" = "y" ]; then
   108         extra_config+=( --enable-shared )
   109     else
   110         extra_config+=( --disable-shared )
   111     fi
   112 
   113     CT_DoExecLog CFG                                        \
   114     CC="${host}-gcc"                                        \
   115     RANLIB="${host}-ranlib"                                 \
   116     CFLAGS="${cflags} -fPIC"                                \
   117     "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
   118         --build=${CT_BUILD}                                 \
   119         --host=${host}                                      \
   120         --target=${CT_TARGET}                               \
   121         --prefix="${prefix}"                                \
   122         --enable-compat                                     \
   123         --enable-elf64                                      \
   124         --enable-extended-format                            \
   125         --enable-static                                     \
   126         "${extra_config[@]}"
   127 
   128     CT_DoLog EXTRA "Building libelf"
   129     CT_DoExecLog ALL make
   130 
   131     CT_DoLog EXTRA "Installing libelf"
   132     CT_DoExecLog ALL make instroot="${destdir}" install
   133 }
   134 
   135 fi # CT_LIBELF || CT_LIBELF_TARGET