scripts/build/companion_libs/120-ppl.sh
author Yann Diorcet <diorcet.yann@gmail.com>
Fri Nov 16 15:25:57 2012 +0100 (2012-11-16)
changeset 3119 1c56c03b7ed5
parent 3115 1c68438f44f7
child 3135 3829050af02a
permissions -rw-r--r--
scripts: add BUILD/HOST extra cflags/ldflags

On some hosts, and for certain toolchains (eg. toolchain targetting
the upcoming Darwin), it may be necessary to pass arbitrary CFLAGS
and/or LDFLAGS when building the components.

And necessary infrastructure:
- EXTRA_{CFLAGS,LDFLAGS}_FOR_{BUILD,HOST} as config options
- pass those extra flags to components

Fix-up a slight typo in elf2flt at the same time (misnamed cflags).

Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com>
Message-Id: <d24043276c9243a35421.1353077450@macbook-smorlat.local>
Patchwork-Id: 199645
yann@1324
     1
# This file adds the functions to build the PPL library
yann@1324
     2
# Copyright 2009 Yann E. MORIN
yann@1324
     3
# Licensed under the GPL v2. See COPYING in the root of this package
yann@1324
     4
yann@1324
     5
do_ppl_get() { :; }
yann@1324
     6
do_ppl_extract() { :; }
yann@2929
     7
do_ppl_for_build() { :; }
yann@2927
     8
do_ppl_for_host() { :; }
yann@1324
     9
yann@1324
    10
# Overide functions depending on configuration
yann@1808
    11
if [ "${CT_PPL}" = "y" ]; then
yann@1324
    12
yann@1324
    13
# Download PPL
yann@1324
    14
do_ppl_get() {
yann@1324
    15
    CT_GetFile "ppl-${CT_PPL_VERSION}"                                      \
yann@1324
    16
        http://www.cs.unipr.it/ppl/Download/ftp/releases/${CT_PPL_VERSION}  \
yann@1369
    17
        ftp://ftp.cs.unipr.it/pub/ppl/releases/${CT_PPL_VERSION}            \
yann@1369
    18
        ftp://gcc.gnu.org/pub/gcc/infrastructure
yann@1324
    19
}
yann@1324
    20
yann@1324
    21
# Extract PPL
yann@1324
    22
do_ppl_extract() {
yann@1324
    23
    CT_Extract "ppl-${CT_PPL_VERSION}"
yann@1901
    24
    CT_Patch "ppl" "${CT_PPL_VERSION}"
yann@1324
    25
}
yann@1324
    26
yann@2929
    27
# Build PPL for running on build
yann@2929
    28
# - always build statically
yann@2929
    29
# - we do not have build-specific CFLAGS
yann@2929
    30
# - install in build-tools prefix
yann@2929
    31
do_ppl_for_build() {
yann@2929
    32
    local -a ppl_opts
yann@2929
    33
yann@2929
    34
    case "${CT_TOOLCHAIN_TYPE}" in
yann@2929
    35
        native|cross)   return 0;;
yann@2929
    36
    esac
yann@2929
    37
yann@2929
    38
    CT_DoStep INFO "Installing PPL for build"
yann@2929
    39
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-build-${CT_BUILD}"
yann@2929
    40
yann@2929
    41
    ppl_opts+=( "host=${CT_BUILD}" )
yann@2929
    42
    ppl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
diorcet@3119
    43
    ppl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
diorcet@3119
    44
    ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
yann@2929
    45
    do_ppl_backend "${ppl_opts[@]}"
yann@2929
    46
yann@2929
    47
    CT_Popd
yann@2929
    48
    CT_EndStep
yann@2929
    49
}
yann@2929
    50
yann@2927
    51
# Build PPL for running on host
yann@2927
    52
do_ppl_for_host() {
yann@2927
    53
    local -a ppl_opts
yann@1324
    54
yann@2927
    55
    CT_DoStep INFO "Installing PPL for host"
yann@2927
    56
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-host-${CT_HOST}"
yann@2927
    57
yann@2927
    58
    ppl_opts+=( "host=${CT_HOST}" )
yann@2931
    59
    ppl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
yann@2927
    60
    ppl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
diorcet@3119
    61
    ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
yann@2927
    62
    do_ppl_backend "${ppl_opts[@]}"
yann@2927
    63
yann@2927
    64
    CT_Popd
yann@2927
    65
    CT_EndStep
yann@2927
    66
}
yann@2927
    67
yann@2927
    68
# Build PPL
yann@2927
    69
#     Parameter     : description               : type      : default
yann@2927
    70
#     host          : machine to run on         : tuple     : (none)
yann@2927
    71
#     prefix        : prefix to install into    : dir       : (none)
diorcet@3119
    72
#     cflags        : cflags to use             : string    : (empty)
diorcet@3119
    73
#     ldflags       : ldflags to use            : string    : (empty)
yann@2927
    74
do_ppl_backend() {
yann@2927
    75
    local host
yann@2927
    76
    local prefix
yann@2927
    77
    local cflags
diorcet@3119
    78
    local ldflags
yann@2927
    79
    local arg
yann@2927
    80
yann@2927
    81
    for arg in "$@"; do
yann@2927
    82
        eval "${arg// /\\ }"
yann@2927
    83
    done
yann@1324
    84
yann@1324
    85
    CT_DoLog EXTRA "Configuring PPL"
yann@1892
    86
yann@2348
    87
    CT_DoExecLog CFG                                \
yann@2927
    88
    CFLAGS="${cflags}"                              \
yann@2927
    89
    CXXFLAGS="${cflags}"                            \
diorcet@3119
    90
    LDFLAGS="${ldflags}"                            \
yann@1324
    91
    "${CT_SRC_DIR}/ppl-${CT_PPL_VERSION}/configure" \
yann@1324
    92
        --build=${CT_BUILD}                         \
yann@2927
    93
        --host=${host}                              \
yann@2927
    94
        --prefix="${prefix}"                        \
yann@2927
    95
        --with-libgmp-prefix="${prefix}"            \
yann@2927
    96
        --with-libgmpxx-prefix="${prefix}"          \
yann@2927
    97
        --with-gmp-prefix="${prefix}"               \
yann@2364
    98
        --enable-watchdog                           \
yann@1324
    99
        --disable-debugging                         \
yann@1324
   100
        --disable-assertions                        \
yann@1324
   101
        --disable-ppl_lcdd                          \
yann@1892
   102
        --disable-ppl_lpsol                         \
yann@2381
   103
        --disable-shared                            \
anthony@2461
   104
        --enable-interfaces='c c++'                 \
yann@2381
   105
        --enable-static
yann@1324
   106
yann@1324
   107
    # Maybe-options:
yann@1324
   108
    # --enable-optimization=speed  or sspeed (yes, with 2 's')
yann@1324
   109
yann@1324
   110
    CT_DoLog EXTRA "Building PPL"
yann@2275
   111
    CT_DoExecLog ALL make ${JOBSFLAGS}
yann@1324
   112
yann@1890
   113
    if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
yann@1324
   114
        CT_DoLog EXTRA "Checking PPL"
yann@2275
   115
        CT_DoExecLog ALL make ${JOBSFLAGS} -s check
yann@1324
   116
    fi
yann@1324
   117
yann@1324
   118
    CT_DoLog EXTRA "Installing PPL"
yann@1324
   119
    CT_DoExecLog ALL make install
yann@1324
   120
yann@1397
   121
    # Remove spuriously installed file
yann@2927
   122
    CT_DoExecLog ALL rm -f "${prefix}/bin/ppl-config"
yann@1324
   123
}
yann@1324
   124
yann@1808
   125
fi # CT_PPL