scripts/build/companion_libs/mpfr.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Apr 11 23:18:10 2010 +0200 (2010-04-11)
changeset 1901 bdb3a98e064b
parent 1895 3ea4e6f7b85f
child 1905 f819ad7335e2
permissions -rw-r--r--
scripts/functions: make CT_Patch dumber

It is the responsibility of the caller to split the package name from
its version. It already knows that.
     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() { :; }
     8 do_mpfr_target() { :; }
     9 
    10 # Overide function depending on configuration
    11 if [ "${CT_MPFR}" = "y" -o "${CT_MPFR_TARGET}" = "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 -fi
    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 if [ "${CT_MPFR}" = "y" ]; then
    68 
    69 do_mpfr() {
    70     local -a mpfr_opts
    71 
    72     mkdir -p "${CT_BUILD_DIR}/build-mpfr"
    73     cd "${CT_BUILD_DIR}/build-mpfr"
    74 
    75     CT_DoStep INFO "Installing MPFR"
    76 
    77     # Under Cygwin, we can't build a thread-safe library
    78     case "${CT_HOST}" in
    79         *cygwin*)   mpfr_opts+=( --disable-thread-safe );;
    80         *mingw*)    mpfr_opts+=( --disable-thread-safe );;
    81         *darwin*)   mpfr_opts+=( --disable-thread-safe );;
    82         *)          mpfr_opts+=( --enable-thread-safe  );;
    83     esac
    84 
    85     if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    86         mpfr_opts+=( --enable-shared --disable-static )
    87     else
    88         mpfr_opts+=( --disable-shared --enable-static )
    89     fi
    90 
    91     CT_DoLog EXTRA "Configuring MPFR"
    92     CC="${CT_HOST}-gcc"                                 \
    93     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    94     CT_DoExecLog ALL                                    \
    95     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    96         --build=${CT_BUILD}                             \
    97         --host=${CT_HOST}                               \
    98         --prefix="${CT_COMPLIBS_DIR}"                   \
    99         --with-gmp="${CT_COMPLIBS_DIR}"                 \
   100         "${mpfr_opts[@]}"
   101 
   102     CT_DoLog EXTRA "Building MPFR"
   103     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   104 
   105     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   106         CT_DoLog EXTRA "Checking MPFR"
   107         CT_DoExecLog ALL make ${PARALLELMFLAGS} -s check
   108     fi
   109 
   110     CT_DoLog EXTRA "Installing MPFR"
   111     CT_DoExecLog ALL make install
   112 
   113     CT_EndStep
   114 }
   115 
   116 fi # CT_MPFR
   117 
   118 if [ "${CT_MPFR_TARGET}" = "y" ]; then
   119 
   120 do_mpfr_target() {
   121     mkdir -p "${CT_BUILD_DIR}/build-mpfr-target"
   122     cd "${CT_BUILD_DIR}/build-mpfr-target"
   123 
   124     CT_DoStep INFO "Installing MPFR for the target"
   125 
   126     mpfr_opt=
   127     # Under Cygwin, we can't build a thread-safe library
   128     case "${CT_TARGET}" in
   129         *-cygwin)   mpfr_opt="--disable-thread-safe";;
   130         *)          mpfr_opt="--enable-thread-safe";;
   131     esac
   132 
   133     CT_DoLog EXTRA "Configuring MPFR"
   134     CC="${CT_TARGET}-gcc"                               \
   135     CFLAGS="${CT_CFLAGS_FOR_TARGET}"                    \
   136     CT_DoExecLog ALL                                    \
   137     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
   138         --build=${CT_BUILD}                             \
   139         --host=${CT_TARGET}                             \
   140         --prefix=/usr                                   \
   141         ${mpfr_opt}                                     \
   142         --disable-shared                                \
   143         --enable-static                                 \
   144         --with-gmp="${CT_SYSROOT_DIR}/usr"
   145 
   146     CT_DoLog EXTRA "Building MPFR"
   147     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   148 
   149     # Not possible to check MPFR while X-compiling
   150 
   151     CT_DoLog EXTRA "Installing MPFR"
   152     CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   153 
   154     CT_EndStep
   155 }
   156 
   157 fi # CT_MPFR_TARGET
   158 
   159 fi # CT_MPFR || CT_MPFR_TARGET