scripts/build/companion_libs/100-gmp.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@466
     1
# This file adds the functions to build the GMP library
yann@466
     2
# Copyright 2008 Yann E. MORIN
yann@466
     3
# Licensed under the GPL v2. See COPYING in the root of this package
yann@466
     4
yann@602
     5
do_gmp_get() { :; }
yann@602
     6
do_gmp_extract() { :; }
yann@2929
     7
do_gmp_for_build() { :; }
yann@2927
     8
do_gmp_for_host() { :; }
yann@602
     9
yann@602
    10
# Overide functions depending on configuration
yann@2099
    11
if [ "${CT_GMP}" = "y" ]; then
yann@468
    12
yann@466
    13
# Download GMP
yann@466
    14
do_gmp_get() {
yann@1119
    15
    CT_GetFile "gmp-${CT_GMP_VERSION}" {ftp,http}://{ftp.sunet.se/pub,ftp.gnu.org}/gnu/gmp
yann@466
    16
}
yann@466
    17
yann@466
    18
# Extract GMP
yann@466
    19
do_gmp_extract() {
yann@1126
    20
    CT_Extract "gmp-${CT_GMP_VERSION}"
yann@1901
    21
    CT_Patch "gmp" "${CT_GMP_VERSION}"
yann@466
    22
}
yann@466
    23
yann@2929
    24
# Build GMP for running on build
yann@2929
    25
# - always build statically
yann@2929
    26
# - we do not have build-specific CFLAGS
yann@2929
    27
# - install in build-tools prefix
yann@2929
    28
do_gmp_for_build() {
yann@2929
    29
    local -a gmp_opts
yann@2929
    30
yann@2929
    31
    case "${CT_TOOLCHAIN_TYPE}" in
yann@2929
    32
        native|cross)   return 0;;
yann@2929
    33
    esac
yann@2929
    34
yann@2929
    35
    CT_DoStep INFO "Installing GMP for build"
yann@2929
    36
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-build-${CT_BUILD}"
yann@2929
    37
yann@2929
    38
    gmp_opts+=( "host=${CT_BUILD}" )
yann@2929
    39
    gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
diorcet@3119
    40
    gmp_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
diorcet@3119
    41
    gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
yann@2929
    42
    do_gmp_backend "${gmp_opts[@]}"
yann@2929
    43
yann@2929
    44
    CT_Popd
yann@2929
    45
    CT_EndStep
yann@2929
    46
}
yann@2929
    47
yann@2927
    48
# Build GMP for running on host
yann@2927
    49
do_gmp_for_host() {
yann@2927
    50
    local -a gmp_opts
yann@466
    51
yann@2927
    52
    CT_DoStep INFO "Installing GMP for host"
yann@2927
    53
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-host-${CT_HOST}"
yann@2927
    54
yann@2927
    55
    gmp_opts+=( "host=${CT_HOST}" )
yann@2931
    56
    gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
yann@2927
    57
    gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
diorcet@3119
    58
    gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
yann@2927
    59
    do_gmp_backend "${gmp_opts[@]}"
yann@2927
    60
yann@2927
    61
    CT_Popd
yann@2927
    62
    CT_EndStep
yann@2927
    63
}
yann@2927
    64
yann@2927
    65
# Build GMP
yann@2927
    66
#     Parameter     : description               : type      : default
yann@2927
    67
#     host          : machine to run on         : tuple     : (none)
yann@2927
    68
#     prefix        : prefix to install into    : dir       : (none)
diorcet@3119
    69
#     cflags        : cflags to use             : string    : (empty)
diorcet@3119
    70
#     ldflags       : ldflags to use            : string    : (empty)
yann@2927
    71
do_gmp_backend() {
yann@2927
    72
    local host
yann@2927
    73
    local prefix
yann@2927
    74
    local cflags
diorcet@3119
    75
    local ldflags
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@466
    81
yann@466
    82
    CT_DoLog EXTRA "Configuring GMP"
yann@1324
    83
yann@2346
    84
    CT_DoExecLog CFG                                \
yann@2927
    85
    CFLAGS="${cflags} -fexceptions"                 \
diorcet@3119
    86
    LDFLAGS="${ldflags}"                            \
yann@1119
    87
    "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
yann@1119
    88
        --build=${CT_BUILD}                         \
yann@2927
    89
        --host=${host}                              \
yann@2927
    90
        --prefix="${prefix}"                        \
yann@1324
    91
        --enable-fft                                \
yann@1324
    92
        --enable-mpbsd                              \
yann@1892
    93
        --enable-cxx                                \
yann@2381
    94
        --disable-shared                            \
yann@2381
    95
        --enable-static
yann@466
    96
yann@466
    97
    CT_DoLog EXTRA "Building GMP"
yann@2275
    98
    CT_DoExecLog ALL make ${JOBSFLAGS}
yann@466
    99
yann@1890
   100
    if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
yann@466
   101
        CT_DoLog EXTRA "Checking GMP"
yann@2275
   102
        CT_DoExecLog ALL make ${JOBSFLAGS} -s check
yann@466
   103
    fi
yann@466
   104
yann@466
   105
    CT_DoLog EXTRA "Installing GMP"
yann@655
   106
    CT_DoExecLog ALL make install
yann@466
   107
}
yann@468
   108
yann@1810
   109
fi # CT_GMP