scripts/build/companion_libs/libelf.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 17 18:56:30 2011 +0200 (2011-07-17)
changeset 2927 ddaae597fd7c
parent 2905 286b2937c101
child 2929 22e495b7bee8
permissions -rw-r--r--
complibs: split companion libraries to backend/frontend, a-la cc_core

Move the actual complibs codes to backend functions that builds the
required combo of build/host/target as requested by a frontend.

This split is currently a no-op, but is required for the upcoming
canadian-cross rework, where we'll be needing to build the complibs
twice, one for build/build, and one for build/host.

This applies to the six companion libraries:
- GMP
- MPFR
- PPL
- Cloog/PPL
- MPC
- libelf

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