scripts/build/mpfr.sh
author Oron Peled <oron@actcom.co.il>
Mon Aug 03 00:49:25 2009 +0200 (2009-08-03)
branch1.4
changeset 1456 94fc77c37418
parent 1299 3448ac3f1a5d
permissions -rw-r--r--
[complib:mpfr] Fix building MPFR in some weird cases

The tmul test uses a compiled-in input file in $(srcdir).
The problem is that the Makefile passes it unquoted. The C code
tries to stringify it using clever macros, which may *usually* work.

In my case the source directory was named:
.../toolchain-powerpc-e500v2-linux-gnuspe-1.0-2.fc10/.../tests
And guess what? During testing I found out the program fails because
it tries to open:
.../toolchain-powerpc-e500v2-1-gnuspe-1.0-2.fc10/.../tests

Yes, CPP tokenized the macro before stringifying it and not surprisingly
the 'linux' part was converted to 1.
[on Fedora-10: cpp (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)]

So the attached patch simplify the macros and pass the path as string
from the Makefile.

Manually backported from 1449:8ad2773e7ae3
     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         2.4.1)
    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 do_mpfr() {
    68     mkdir -p "${CT_BUILD_DIR}/build-mpfr"
    69     cd "${CT_BUILD_DIR}/build-mpfr"
    70 
    71     CT_DoStep INFO "Installing MPFR"
    72 
    73     mpfr_opt=
    74     # Under Cygwin, we can't build a thread-safe library
    75     case "${CT_HOST}" in
    76         *-cygwin)   mpfr_opt="--disable-thread-safe";;
    77         *)          mpfr_opt="--enable-thread-safe";;
    78     esac
    79 
    80     CT_DoLog EXTRA "Configuring MPFR"
    81     CC="${CT_HOST}-gcc"                                 \
    82     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    83     CT_DoExecLog ALL                                    \
    84     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    85         --build=${CT_BUILD}                             \
    86         --host=${CT_HOST}                               \
    87         --prefix="${CT_PREFIX_DIR}"                     \
    88         ${mpfr_opt}                                     \
    89         --disable-shared                                \
    90         --enable-static                                 \
    91         --with-gmp="${CT_PREFIX_DIR}"
    92 
    93     CT_DoLog EXTRA "Building MPFR"
    94     CT_DoExecLog ALL make ${PARALLELMFLAGS}
    95 
    96     if [ "${CT_MPFR_CHECK}" = "y" ]; then
    97         CT_DoLog EXTRA "Checking MPFR"
    98         CT_DoExecLog ALL make ${PARALLELMFLAGS} -s check
    99     fi
   100 
   101     CT_DoLog EXTRA "Installing MPFR"
   102     CT_DoExecLog ALL make install
   103 
   104     CT_EndStep
   105 }
   106 
   107 if [ "${CT_GMP_MPFR_TARGET}" = "y" ]; then
   108 
   109 do_mpfr_target() {
   110     mkdir -p "${CT_BUILD_DIR}/build-mpfr-target"
   111     cd "${CT_BUILD_DIR}/build-mpfr-target"
   112 
   113     CT_DoStep INFO "Installing MPFR for the target"
   114 
   115     mpfr_opt=
   116     # Under Cygwin, we can't build a thread-safe library
   117     case "${CT_TARGET}" in
   118         *-cygwin)   mpfr_opt="--disable-thread-safe";;
   119         *)          mpfr_opt="--enable-thread-safe";;
   120     esac
   121 
   122     CT_DoLog EXTRA "Configuring MPFR"
   123     CC="${CT_TARGET}-gcc"                               \
   124     CFLAGS="${CT_CFLAGS_FOR_TARGET}"                    \
   125     CT_DoExecLog ALL                                    \
   126     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
   127         --build=${CT_BUILD}                             \
   128         --host=${CT_TARGET}                             \
   129         --prefix=/usr                                   \
   130         ${mpfr_opt}                                     \
   131         --disable-shared                                \
   132         --enable-static                                 \
   133         --with-gmp="${CT_SYSROOT_DIR}/usr"
   134 
   135     CT_DoLog EXTRA "Building MPFR"
   136     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   137 
   138     # Not possible to check MPFR while X-compiling
   139 
   140     CT_DoLog EXTRA "Installing MPFR"
   141     CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   142 
   143     CT_EndStep
   144 }
   145 
   146 fi # CT_GMP_MPFR_TARGET == y
   147 
   148 fi # CT_GMP_MPFR == y