scripts/build/companion_libs/mpfr.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jun 23 22:57:12 2009 +0200 (2009-06-23)
changeset 1422 ff866c9faad2
parent 1386 7995942261f2
child 1449 8ad2773e7ae3
permissions -rw-r--r--
Fix MPFR build to recognise the Mingw32 case.

Once we have canadian in place, Mingw32 can be a legitimate host,
so we have to recognise that along with Cygwin.

Also fix recognising Cygwin hosts.

Signed-off-by: Bart van der Meulen <bartvdrmeulen@gmail.com>
     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_GMP_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         1.*|2.0.*|2.1.*|2.2.*|2.3.*)
    34             CT_Pushd "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}"
    35             if [ ! -f .autotools.ct-ng ]; then
    36                 CT_DoLog DEBUG "Re-building autotools files"
    37                 CT_DoExecLog ALL autoreconf -fi
    38                 # Starting with libtool-1.9f, config.{guess,sub} are no longer
    39                 # installed without -i, but starting with libtool-2.2.6, they
    40                 # are no longer removed without -i. Sight... Just use -i with
    41                 # libtool >=2
    42                 # See: http://sourceware.org/ml/crossgcc/2008-11/msg00046.html
    43                 # and: http://sourceware.org/ml/crossgcc/2008-11/msg00048.html
    44                 libtoolize_opt=
    45                 case "$(libtoolize --version |head -n 1 |awk '{ print $(NF); }')" in
    46                     0.*)    ;;
    47                     1.*)    ;;
    48                     *)      libtoolize_opt=-i;;
    49                 esac
    50                 CT_DoExecLog ALL libtoolize -f ${libtoolize_opt}
    51                 touch .autotools.ct-ng
    52             fi
    53             CT_Popd
    54             ;;
    55     esac
    56 }
    57 
    58 do_mpfr() {
    59     mkdir -p "${CT_BUILD_DIR}/build-mpfr"
    60     cd "${CT_BUILD_DIR}/build-mpfr"
    61 
    62     CT_DoStep INFO "Installing MPFR"
    63 
    64     mpfr_opt=
    65     # Under Cygwin, we can't build a thread-safe library
    66     case "${CT_HOST}" in
    67         *cygwin*)   mpfr_opt="--disable-thread-safe";;
    68         *mingw*)    mpfr_opt="--disable-thread-safe";;
    69         *)          mpfr_opt="--enable-thread-safe";;
    70     esac
    71 
    72     CT_DoLog EXTRA "Configuring MPFR"
    73     CC="${CT_HOST}-gcc"                                 \
    74     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    75     CT_DoExecLog ALL                                    \
    76     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    77         --build=${CT_BUILD}                             \
    78         --host=${CT_HOST}                               \
    79         --prefix="${CT_PREFIX_DIR}"                     \
    80         ${mpfr_opt}                                     \
    81         --enable-shared                                 \
    82         --disable-static                                \
    83         --with-gmp="${CT_PREFIX_DIR}"
    84 
    85     CT_DoLog EXTRA "Building MPFR"
    86     CT_DoExecLog ALL make ${PARALLELMFLAGS}
    87 
    88     if [ "${CT_COMP_LIBS_CHECK}" = "y" ]; then
    89         CT_DoLog EXTRA "Checking MPFR"
    90         CT_DoExecLog ALL make ${PARALLELMFLAGS} -s check
    91     fi
    92 
    93     CT_DoLog EXTRA "Installing MPFR"
    94     CT_DoExecLog ALL make install
    95 
    96     CT_EndStep
    97 }
    98 
    99 if [ "${CT_COMP_LIBS_TARGET}" = "y" ]; then
   100 
   101 do_mpfr_target() {
   102     mkdir -p "${CT_BUILD_DIR}/build-mpfr-target"
   103     cd "${CT_BUILD_DIR}/build-mpfr-target"
   104 
   105     CT_DoStep INFO "Installing MPFR for the target"
   106 
   107     mpfr_opt=
   108     # Under Cygwin, we can't build a thread-safe library
   109     case "${CT_TARGET}" in
   110         *-cygwin)   mpfr_opt="--disable-thread-safe";;
   111         *)          mpfr_opt="--enable-thread-safe";;
   112     esac
   113 
   114     CT_DoLog EXTRA "Configuring MPFR"
   115     CC="${CT_TARGET}-gcc"                               \
   116     CFLAGS="${CT_CFLAGS_FOR_TARGET}"                    \
   117     CT_DoExecLog ALL                                    \
   118     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
   119         --build=${CT_BUILD}                             \
   120         --host=${CT_TARGET}                             \
   121         --prefix=/usr                                   \
   122         ${mpfr_opt}                                     \
   123         --disable-shared                                \
   124         --enable-static                                 \
   125         --with-gmp="${CT_SYSROOT_DIR}/usr"
   126 
   127     CT_DoLog EXTRA "Building MPFR"
   128     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   129 
   130     # Not possible to check MPFR while X-compiling
   131 
   132     CT_DoLog EXTRA "Installing MPFR"
   133     CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   134 
   135     CT_EndStep
   136 }
   137 
   138 fi # CT_GMP_MPFR_TARGET == y
   139 
   140 fi # CT_GMP_MPFR == y