scripts/build/companion_libs/mpfr.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Feb 17 23:50:49 2010 +0100 (2010-02-17)
changeset 1810 e44f67656c5f
parent 1809 b488b4815f9b
child 1889 b376baa43a50
permissions -rw-r--r--
complibs: hide companion libraries for target entry

The companion libraries on the target are required only for internal use by
binutils and gdb. The user should not have to know about this, so hide the
option.
     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.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 if [ "${CT_MPFR}" = "y" ]; then
    68 
    69 do_mpfr() {
    70     mkdir -p "${CT_BUILD_DIR}/build-mpfr"
    71     cd "${CT_BUILD_DIR}/build-mpfr"
    72 
    73     CT_DoStep INFO "Installing MPFR"
    74 
    75     mpfr_opt=
    76     # Under Cygwin, we can't build a thread-safe library
    77     case "${CT_HOST}" in
    78         *cygwin*)   mpfr_opt="--disable-thread-safe";;
    79         *mingw*)    mpfr_opt="--disable-thread-safe";;
    80         *darwin*)   mpfr_opt="--disable-thread-safe";;
    81         *)          mpfr_opt="--enable-thread-safe";;
    82     esac
    83 
    84     CT_DoLog EXTRA "Configuring MPFR"
    85     CC="${CT_HOST}-gcc"                                 \
    86     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    87     CT_DoExecLog ALL                                    \
    88     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    89         --build=${CT_BUILD}                             \
    90         --host=${CT_HOST}                               \
    91         --prefix="${CT_PREFIX_DIR}"                     \
    92         ${mpfr_opt}                                     \
    93         --enable-shared                                 \
    94         --disable-static                                \
    95         --with-gmp="${CT_PREFIX_DIR}"
    96 
    97     CT_DoLog EXTRA "Building MPFR"
    98     CT_DoExecLog ALL make ${PARALLELMFLAGS}
    99 
   100     if [ "${CT_COMP_LIBS_CHECK}" = "y" ]; then
   101         CT_DoLog EXTRA "Checking MPFR"
   102         CT_DoExecLog ALL make ${PARALLELMFLAGS} -s check
   103     fi
   104 
   105     CT_DoLog EXTRA "Installing MPFR"
   106     CT_DoExecLog ALL make install
   107 
   108     CT_EndStep
   109 }
   110 
   111 fi # CT_MPFR
   112 
   113 if [ "${CT_MPFR_TARGET}" = "y" ]; then
   114 
   115 do_mpfr_target() {
   116     mkdir -p "${CT_BUILD_DIR}/build-mpfr-target"
   117     cd "${CT_BUILD_DIR}/build-mpfr-target"
   118 
   119     CT_DoStep INFO "Installing MPFR for the target"
   120 
   121     mpfr_opt=
   122     # Under Cygwin, we can't build a thread-safe library
   123     case "${CT_TARGET}" in
   124         *-cygwin)   mpfr_opt="--disable-thread-safe";;
   125         *)          mpfr_opt="--enable-thread-safe";;
   126     esac
   127 
   128     CT_DoLog EXTRA "Configuring MPFR"
   129     CC="${CT_TARGET}-gcc"                               \
   130     CFLAGS="${CT_CFLAGS_FOR_TARGET}"                    \
   131     CT_DoExecLog ALL                                    \
   132     "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
   133         --build=${CT_BUILD}                             \
   134         --host=${CT_TARGET}                             \
   135         --prefix=/usr                                   \
   136         ${mpfr_opt}                                     \
   137         --disable-shared                                \
   138         --enable-static                                 \
   139         --with-gmp="${CT_SYSROOT_DIR}/usr"
   140 
   141     CT_DoLog EXTRA "Building MPFR"
   142     CT_DoExecLog ALL make ${PARALLELMFLAGS}
   143 
   144     # Not possible to check MPFR while X-compiling
   145 
   146     CT_DoLog EXTRA "Installing MPFR"
   147     CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   148 
   149     CT_EndStep
   150 }
   151 
   152 fi # CT_MPFR_TARGET
   153 
   154 fi # CT_MPFR || CT_MPFR_TARGET