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