scripts/build/companion_libs/mpfr.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 30 00:57:40 2009 +0200 (2009-08-30)
changeset 1495 2542421e3321
parent 1422 ff866c9faad2
child 1797 42c618ca576e
child 1922 78dded99f609
permissions -rw-r--r--
tools wrapper: introduce the silent WRAPPER_NEEDED config option

Add the WRAPPER_NEEDED silent config option, that can be selected by
components that require it (companion libs so far).
Rely on this config option when deciding to install the wrapper,
instead of checking GMP/MPFR or PPL/CLoog/MPC.
     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         *mingw*)    mpfr_opt="--disable-thread-safe";;
    78         *)          mpfr_opt="--enable-thread-safe";;
    79     esac
    80 
    81     CT_DoLog EXTRA "Configuring MPFR"
    82     CC="${CT_HOST}-gcc"                                 \
    83     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    84     CT_DoExecLog ALL                                    \
    85     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    86         --build=${CT_BUILD}                             \
    87         --host=${CT_HOST}                               \
    88         --prefix="${CT_PREFIX_DIR}"                     \
    89         ${mpfr_opt}                                     \
    90         --enable-shared                                 \
    91         --disable-static                                \
    92         --with-gmp="${CT_PREFIX_DIR}"
    93 
    94     CT_DoLog EXTRA "Building MPFR"
    95     CT_DoExecLog ALL make ${PARALLELMFLAGS}
    96 
    97     if [ "${CT_COMP_LIBS_CHECK}" = "y" ]; then
    98         CT_DoLog EXTRA "Checking MPFR"
    99         CT_DoExecLog ALL make ${PARALLELMFLAGS} -s check
   100     fi
   101 
   102     CT_DoLog EXTRA "Installing MPFR"
   103     CT_DoExecLog ALL make install
   104 
   105     CT_EndStep
   106 }
   107 
   108 if [ "${CT_COMP_LIBS_TARGET}" = "y" ]; then
   109 
   110 do_mpfr_target() {
   111     mkdir -p "${CT_BUILD_DIR}/build-mpfr-target"
   112     cd "${CT_BUILD_DIR}/build-mpfr-target"
   113 
   114     CT_DoStep INFO "Installing MPFR for the target"
   115 
   116     mpfr_opt=
   117     # Under Cygwin, we can't build a thread-safe library
   118     case "${CT_TARGET}" in
   119         *-cygwin)   mpfr_opt="--disable-thread-safe";;
   120         *)          mpfr_opt="--enable-thread-safe";;
   121     esac
   122 
   123     CT_DoLog EXTRA "Configuring MPFR"
   124     CC="${CT_TARGET}-gcc"                               \
   125     CFLAGS="${CT_CFLAGS_FOR_TARGET}"                    \
   126     CT_DoExecLog ALL                                    \
   127     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
   128         --build=${CT_BUILD}                             \
   129         --host=${CT_TARGET}                             \
   130         --prefix=/usr                                   \
   131         ${mpfr_opt}                                     \
   132         --disable-shared                                \
   133         --enable-static                                 \
   134         --with-gmp="${CT_SYSROOT_DIR}/usr"
   135 
   136     CT_DoLog EXTRA "Building MPFR"
   137     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   138 
   139     # Not possible to check MPFR while X-compiling
   140 
   141     CT_DoLog EXTRA "Installing MPFR"
   142     CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   143 
   144     CT_EndStep
   145 }
   146 
   147 fi # CT_GMP_MPFR_TARGET == y
   148 
   149 fi # CT_GMP_MPFR == y