scripts/build/companion_libs/libelf.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Dec 29 02:34:18 2010 +0100 (2010-12-29)
branch1.9
changeset 2256 004b41d847f8
parent 2216 81b4c0efa46f
child 2332 cc0587459152
permissions -rw-r--r--
complibs/libelf: build with -fPIC

libelf is used by gcc to build the lto-plugin used
by binutils' gold to perform LTO.

This requires that files in libelf be compiled with
-fPIC to generate a proper .so.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
(transplanted from c48aba92cbeb7b7dce956a63ec65d3296735cc16)
     1 # Build script for libelf
     2 
     3 do_libelf_get() { :; }
     4 do_libelf_extract() { :; }
     5 do_libelf() { :; }
     6 do_libelf_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 do_libelf() {
    25     local -a libelf_opts
    26 
    27     CT_DoStep INFO "Installing libelf"
    28     mkdir -p "${CT_BUILD_DIR}/build-libelf"
    29     CT_Pushd "${CT_BUILD_DIR}/build-libelf"
    30 
    31     CT_DoLog EXTRA "Configuring libelf"
    32 
    33     if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    34         libelf_opts+=( --enable-shared --disable-static )
    35     else
    36         libelf_opts+=( --disable-shared --enable-static )
    37     fi
    38 
    39     CC="${CT_HOST}-gcc"                                     \
    40     CFLAGS="-fPIC"                                          \
    41     CT_DoExecLog CFG                                        \
    42     "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    43         --build=${CT_BUILD}                                 \
    44         --host=${CT_HOST}                                   \
    45         --target=${CT_TARGET}                               \
    46         --prefix="${CT_COMPLIBS_DIR}"                       \
    47         --enable-compat                                     \
    48         --enable-elf64                                      \
    49         --enable-extended-format                            \
    50         "${libelf_opts[@]}"
    51 
    52     CT_DoLog EXTRA "Building libelf"
    53     CT_DoExecLog ALL make
    54 
    55     CT_DoLog EXTRA "Installing libelf"
    56     CT_DoExecLog ALL make install
    57 
    58     CT_Popd
    59     CT_EndStep
    60 }
    61 
    62 fi # CT_LIBELF
    63 
    64 if [ "${CT_LIBELF_TARGET}" = "y" ]; then
    65 
    66 do_libelf_target() {
    67     CT_DoStep INFO "Installing libelf for the target"
    68     mkdir -p "${CT_BUILD_DIR}/build-libelf-for-target"
    69     CT_Pushd "${CT_BUILD_DIR}/build-libelf-for-target"
    70 
    71     CT_DoLog EXTRA "Configuring libelf"
    72     CC="${CT_TARGET}-gcc"                                   \
    73     CFLAGS="-fPIC"                                          \
    74     CT_DoExecLog ALL                                        \
    75     "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    76         --build=${CT_BUILD}                                 \
    77         --host=${CT_TARGET}                                 \
    78         --target=${CT_TARGET}                               \
    79         --prefix=/usr                                       \
    80         --enable-compat                                     \
    81         --enable-elf64                                      \
    82         --enable-shared                                     \
    83         --enable-extended-format                            \
    84         --enable-static
    85 
    86     CT_DoLog EXTRA "Building libelf"
    87     CT_DoExecLog ALL make
    88 
    89     CT_DoLog EXTRA "Installing libelf"
    90     CT_DoExecLog ALL make instroot="${CT_SYSROOT_DIR}" install
    91 
    92     CT_Popd
    93     CT_EndStep
    94 }
    95 
    96 fi # CT_LIBELF_TARGET
    97 
    98 fi # CT_LIBELF || CT_LIBELF_TARGET