scripts/build/companion_libs/140-mpc.sh
author Daniel Price <daniel.price@gmail.com>
Tue Nov 20 16:59:17 2012 -0800 (2012-11-20)
changeset 3126 333d3e40cbd1
parent 3115 1c68438f44f7
permissions -rw-r--r--
scripts: refine static linking check to better guide the user

The current mechanism to check if static linking is possible, and the mesage
displayed on failure, can be puzzling to the unsuspecting user.

Also, the current implementation is not using the existing infrastructure,
and is thus difficult to enhance with new tests.

So, switch to using the standard CT_DoExecLog infra, and use four tests to
check for the host compiler:
- check we can run it
- check it can build a trivial program
- check it can statically link that program
- check if it statically link with libstdc++

That should cover most of the problems. Hopefully.

(At the same time, fix a typo in a comment)

Signed-off-by: Daniel Price <daniel.price@gmail.com>
[yann.morin.1998@free.fr: split original patch for self-contained changes]
[yann.morin.1998@free.fr: use steps to better see gcc's output]
[yann.morin.1998@free.fr: commit log]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <163f86b5216fc08c672a.1353459722@nipigon.dssd.com>
Patchwork-Id: 200536
yann@1384
     1
# This file adds the functions to build the MPC library
yann@1384
     2
# Copyright 2009 Yann E. MORIN
yann@1384
     3
# Licensed under the GPL v2. See COPYING in the root of this package
yann@1384
     4
yann@1384
     5
do_mpc_get() { :; }
yann@1384
     6
do_mpc_extract() { :; }
yann@2929
     7
do_mpc_for_build() { :; }
yann@2927
     8
do_mpc_for_host() { :; }
yann@1384
     9
yann@1384
    10
# Overide functions depending on configuration
yann@1808
    11
if [ "${CT_MPC}" = "y" ]; then
yann@1384
    12
yann@1384
    13
# Download MPC
yann@1384
    14
do_mpc_get() {
yann@1384
    15
    CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz      \
yann@1384
    16
        http://www.multiprecision.org/mpc/download
yann@1384
    17
}
yann@1384
    18
yann@1384
    19
# Extract MPC
yann@1384
    20
do_mpc_extract() {
yann@1384
    21
    CT_Extract "mpc-${CT_MPC_VERSION}"
yann@1901
    22
    CT_Patch "mpc" "${CT_MPC_VERSION}"
yann@1384
    23
}
yann@1384
    24
yann@2929
    25
# Build MPC 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_mpc_for_build() {
yann@2929
    30
    local -a mpc_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 MPC for build"
yann@2929
    37
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-build-${CT_BUILD}"
yann@2929
    38
yann@2929
    39
    mpc_opts+=( "host=${CT_BUILD}" )
yann@2929
    40
    mpc_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
diorcet@3119
    41
    mpc_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
diorcet@3119
    42
    mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
yann@2929
    43
    do_mpc_backend "${mpc_opts[@]}"
yann@2929
    44
yann@2929
    45
    CT_Popd
yann@2929
    46
    CT_EndStep
yann@2929
    47
}
yann@2929
    48
yann@2927
    49
# Build MPC for running on host
yann@2927
    50
do_mpc_for_host() {
yann@2927
    51
    local -a mpc_opts
yann@1384
    52
yann@2927
    53
    CT_DoStep INFO "Installing MPC for host"
yann@2927
    54
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-host-${CT_HOST}"
yann@2927
    55
yann@2927
    56
    mpc_opts+=( "host=${CT_HOST}" )
yann@2931
    57
    mpc_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
yann@2927
    58
    mpc_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
diorcet@3119
    59
    mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
yann@2927
    60
    do_mpc_backend "${mpc_opts[@]}"
yann@2927
    61
yann@2927
    62
    CT_Popd
yann@2927
    63
    CT_EndStep
yann@2927
    64
}
yann@2927
    65
yann@2927
    66
# Build MPC
yann@2927
    67
#     Parameter     : description               : type      : default
yann@2927
    68
#     host          : machine to run on         : tuple     : (none)
yann@2927
    69
#     prefix        : prefix to install into    : dir       : (none)
diorcet@3119
    70
#     cflags        : cflags to use             : string    : (empty)
diorcet@3119
    71
#     ldflags       : ldflags to use            : string    : (empty)
yann@2927
    72
do_mpc_backend() {
yann@2927
    73
    local host
yann@2927
    74
    local prefix
yann@2927
    75
    local cflags
diorcet@3119
    76
    local ldflags
yann@2927
    77
    local arg
yann@2927
    78
yann@2927
    79
    for arg in "$@"; do
yann@2927
    80
        eval "${arg// /\\ }"
yann@2927
    81
    done
yann@1384
    82
yann@1384
    83
    CT_DoLog EXTRA "Configuring MPC"
yann@1892
    84
yann@2350
    85
    CT_DoExecLog CFG                                \
yann@2927
    86
    CFLAGS="${cflags}"                              \
diorcet@3119
    87
    LDFLAGS="${ldflags}"                            \
yann@1384
    88
    "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
yann@1384
    89
        --build=${CT_BUILD}                         \
yann@2927
    90
        --host=${host}                              \
yann@2927
    91
        --prefix="${prefix}"                        \
yann@2927
    92
        --with-gmp="${prefix}"                      \
yann@2927
    93
        --with-mpfr="${prefix}"                     \
yann@2381
    94
        --disable-shared                            \
yann@2381
    95
        --enable-static
yann@1384
    96
yann@1384
    97
    CT_DoLog EXTRA "Building MPC"
yann@2275
    98
    CT_DoExecLog ALL make ${JOBSFLAGS}
yann@1384
    99
yann@1890
   100
    if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
yann@1384
   101
        CT_DoLog EXTRA "Checking MPC"
yann@2275
   102
        CT_DoExecLog ALL make ${JOBSFLAGS} -s check
yann@1384
   103
    fi
yann@1384
   104
yann@1384
   105
    CT_DoLog EXTRA "Installing MPC"
yann@1384
   106
    CT_DoExecLog ALL make install
yann@1384
   107
}
yann@1384
   108
yann@1808
   109
fi # CT_MPC