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