scripts/build/companion_libs/libelf.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jul 25 19:04:17 2011 +0200 (2011-07-25)
changeset 2931 8a72662f0815
parent 2929 22e495b7bee8
permissions -rw-r--r--
complibs: fixup the host complibs install dir

It's easier to have as much as possible stuff in the same place to
ease backup/restore, and make things easier to follow.

Move the host companion libraries install dir as a sub-dir of the
build-tools install dir (but not directly in it, it would break
for canadian or cross-native).

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