scripts/build/companion_libs/mpfr.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 2381 0ca0f85a4b2a
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@466
     1
# This file adds the functions to build the MPFR 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_mpfr_get() { :; }
yann@602
     6
do_mpfr_extract() { :; }
yann@2927
     7
do_mpfr_for_host() { :; }
yann@602
     8
yann@602
     9
# Overide function depending on configuration
yann@2099
    10
if [ "${CT_MPFR}" = "y" ]; then
yann@468
    11
yann@466
    12
# Download MPFR
yann@466
    13
do_mpfr_get() {
yann@1119
    14
    CT_GetFile "mpfr-${CT_MPFR_VERSION}" http://www.mpfr.org/mpfr-current/  \
yann@522
    15
                                 http://www.mpfr.org/mpfr-${CT_MPFR_VERSION}/
yann@466
    16
}
yann@466
    17
yann@466
    18
# Extract MPFR
yann@466
    19
do_mpfr_extract() {
yann@1126
    20
    CT_Extract "mpfr-${CT_MPFR_VERSION}"
yann@1901
    21
    CT_Patch "mpfr" "${CT_MPFR_VERSION}"
yann@466
    22
yann@584
    23
    # OK, Gentoo have a sanity check that libtool.m4 and ltmain.sh have the
yann@584
    24
    # same version number. Unfortunately, some tarballs of MPFR are not
yann@584
    25
    # built sanely, and thus ./configure fails on Gentoo.
yann@584
    26
    # See: http://sourceware.org/ml/crossgcc/2008-05/msg00080.html
yann@584
    27
    # and: http://sourceware.org/ml/crossgcc/2008-06/msg00005.html
yann@598
    28
    # This hack is not bad per se, but the MPFR guys would be better not to
yann@584
    29
    # do that in the future...
yann@1251
    30
    # It seems that MPFR >= 2.4.0 do not need this...
yann@1251
    31
    case "${CT_MPFR_VERSION}" in
yann@1889
    32
        2.4.*)
oron@1449
    33
            CT_Pushd "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}"
oron@1449
    34
            if [ ! -f .autoreconf.ct-ng ]; then
oron@1449
    35
                CT_DoLog DEBUG "Running autoreconf"
yann@1904
    36
                CT_DoExecLog ALL autoreconf
oron@1449
    37
                touch .autoreconf.ct-ng
oron@1449
    38
            fi
oron@1449
    39
            CT_Popd
oron@1449
    40
            ;;
yann@1251
    41
        1.*|2.0.*|2.1.*|2.2.*|2.3.*)
yann@1251
    42
            CT_Pushd "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}"
yann@1251
    43
            if [ ! -f .autotools.ct-ng ]; then
yann@1251
    44
                CT_DoLog DEBUG "Re-building autotools files"
yann@1251
    45
                CT_DoExecLog ALL autoreconf -fi
yann@1251
    46
                # Starting with libtool-1.9f, config.{guess,sub} are no longer
yann@1251
    47
                # installed without -i, but starting with libtool-2.2.6, they
yann@1251
    48
                # are no longer removed without -i. Sight... Just use -i with
yann@1251
    49
                # libtool >=2
yann@1251
    50
                # See: http://sourceware.org/ml/crossgcc/2008-11/msg00046.html
yann@1251
    51
                # and: http://sourceware.org/ml/crossgcc/2008-11/msg00048.html
yann@1251
    52
                libtoolize_opt=
yann@1299
    53
                case "$(libtoolize --version |head -n 1 |awk '{ print $(NF); }')" in
yann@1251
    54
                    0.*)    ;;
yann@1251
    55
                    1.*)    ;;
yann@1251
    56
                    *)      libtoolize_opt=-i;;
yann@1251
    57
                esac
yann@1251
    58
                CT_DoExecLog ALL libtoolize -f ${libtoolize_opt}
yann@1251
    59
                touch .autotools.ct-ng
yann@1251
    60
            fi
yann@1251
    61
            CT_Popd
yann@1251
    62
            ;;
yann@1251
    63
    esac
yann@595
    64
}
yann@595
    65
yann@2927
    66
# Build MPFR for running on host
yann@2927
    67
do_mpfr_for_host() {
yann@2927
    68
    local -a mpfr_opts
yann@595
    69
yann@2927
    70
    CT_DoStep INFO "Installing MPFR for host"
yann@2927
    71
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpfr-host-${CT_HOST}"
yann@2927
    72
yann@2927
    73
    mpfr_opts+=( "host=${CT_HOST}" )
yann@2927
    74
    mpfr_opts+=( "prefix=${CT_COMPLIBS_DIR}" )
yann@2927
    75
    mpfr_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
yann@2927
    76
    do_mpfr_backend "${mpfr_opts[@]}"
yann@2927
    77
yann@2927
    78
    CT_Popd
yann@2927
    79
    CT_EndStep
yann@2927
    80
}
yann@2927
    81
yann@2927
    82
# Build MPFR
yann@2927
    83
#     Parameter     : description               : type      : default
yann@2927
    84
#     host          : machine to run on         : tuple     : (none)
yann@2927
    85
#     prefix        : prefix to install into    : dir       : (none)
yann@2927
    86
#     cflags        : host cflags to use        : string    : (empty)
yann@2927
    87
do_mpfr_backend() {
yann@2927
    88
    local host
yann@2927
    89
    local prefix
yann@2927
    90
    local cflags
yann@2927
    91
    local arg
yann@2927
    92
yann@2927
    93
    for arg in "$@"; do
yann@2927
    94
        eval "${arg// /\\ }"
yann@2927
    95
    done
yann@584
    96
yann@1251
    97
    # Under Cygwin, we can't build a thread-safe library
yann@1205
    98
    case "${CT_HOST}" in
yann@1892
    99
        *cygwin*)   mpfr_opts+=( --disable-thread-safe );;
yann@1892
   100
        *mingw*)    mpfr_opts+=( --disable-thread-safe );;
yann@1892
   101
        *darwin*)   mpfr_opts+=( --disable-thread-safe );;
yann@1892
   102
        *)          mpfr_opts+=( --enable-thread-safe  );;
yann@1205
   103
    esac
yann@1205
   104
yann@466
   105
    CT_DoLog EXTRA "Configuring MPFR"
yann@2347
   106
    CT_DoExecLog CFG                                    \
yann@2927
   107
    CC="${host}-gcc"                                    \
yann@1119
   108
    CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
yann@1119
   109
    "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
yann@1119
   110
        --build=${CT_BUILD}                             \
yann@2927
   111
        --host=${host}                                  \
yann@2927
   112
        --prefix="${prefix}"                            \
yann@2927
   113
        --with-gmp="${prefix}"                          \
yann@2381
   114
        --disable-shared                                \
yann@2381
   115
        --enable-static
yann@466
   116
yann@466
   117
    CT_DoLog EXTRA "Building MPFR"
yann@2275
   118
    CT_DoExecLog ALL make ${JOBSFLAGS}
yann@466
   119
yann@1890
   120
    if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
yann@466
   121
        CT_DoLog EXTRA "Checking MPFR"
yann@2275
   122
        CT_DoExecLog ALL make ${JOBSFLAGS} -s check
yann@466
   123
    fi
yann@466
   124
yann@466
   125
    CT_DoLog EXTRA "Installing MPFR"
yann@656
   126
    CT_DoExecLog ALL make install
yann@466
   127
}
yann@468
   128
yann@1810
   129
fi # CT_MPFR