scripts/build/companion_libs/110-mpfr.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Thu Dec 27 12:53:32 2012 +0100 (2012-12-27)
changeset 3153 f6740f9e42de
parent 3115 1c68438f44f7
permissions -rw-r--r--
scripts/addToolsVersion: handle elf2flt

The one was missing from the list.

It is very improbable that we ever need it, as elf2flt does no release,
and we always get it from CVS head. But for the sake of consistency, we
just add it.

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