1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/build/companion_libs/100-gmp.sh Fri Nov 16 14:59:27 2012 +0100
1.3 @@ -0,0 +1,103 @@
1.4 +# This file adds the functions to build the GMP library
1.5 +# Copyright 2008 Yann E. MORIN
1.6 +# Licensed under the GPL v2. See COPYING in the root of this package
1.7 +
1.8 +do_gmp_get() { :; }
1.9 +do_gmp_extract() { :; }
1.10 +do_gmp_for_build() { :; }
1.11 +do_gmp_for_host() { :; }
1.12 +
1.13 +# Overide functions depending on configuration
1.14 +if [ "${CT_GMP}" = "y" ]; then
1.15 +
1.16 +# Download GMP
1.17 +do_gmp_get() {
1.18 + CT_GetFile "gmp-${CT_GMP_VERSION}" {ftp,http}://{ftp.sunet.se/pub,ftp.gnu.org}/gnu/gmp
1.19 +}
1.20 +
1.21 +# Extract GMP
1.22 +do_gmp_extract() {
1.23 + CT_Extract "gmp-${CT_GMP_VERSION}"
1.24 + CT_Patch "gmp" "${CT_GMP_VERSION}"
1.25 +}
1.26 +
1.27 +# Build GMP for running on build
1.28 +# - always build statically
1.29 +# - we do not have build-specific CFLAGS
1.30 +# - install in build-tools prefix
1.31 +do_gmp_for_build() {
1.32 + local -a gmp_opts
1.33 +
1.34 + case "${CT_TOOLCHAIN_TYPE}" in
1.35 + native|cross) return 0;;
1.36 + esac
1.37 +
1.38 + CT_DoStep INFO "Installing GMP for build"
1.39 + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-build-${CT_BUILD}"
1.40 +
1.41 + gmp_opts+=( "host=${CT_BUILD}" )
1.42 + gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
1.43 + do_gmp_backend "${gmp_opts[@]}"
1.44 +
1.45 + CT_Popd
1.46 + CT_EndStep
1.47 +}
1.48 +
1.49 +# Build GMP for running on host
1.50 +do_gmp_for_host() {
1.51 + local -a gmp_opts
1.52 +
1.53 + CT_DoStep INFO "Installing GMP for host"
1.54 + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-host-${CT_HOST}"
1.55 +
1.56 + gmp_opts+=( "host=${CT_HOST}" )
1.57 + gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
1.58 + gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
1.59 + do_gmp_backend "${gmp_opts[@]}"
1.60 +
1.61 + CT_Popd
1.62 + CT_EndStep
1.63 +}
1.64 +
1.65 +# Build GMP
1.66 +# Parameter : description : type : default
1.67 +# host : machine to run on : tuple : (none)
1.68 +# prefix : prefix to install into : dir : (none)
1.69 +# cflags : host cflags to use : string : (empty)
1.70 +do_gmp_backend() {
1.71 + local host
1.72 + local prefix
1.73 + local cflags
1.74 + local arg
1.75 +
1.76 + for arg in "$@"; do
1.77 + eval "${arg// /\\ }"
1.78 + done
1.79 +
1.80 + CT_DoLog EXTRA "Configuring GMP"
1.81 +
1.82 + CT_DoExecLog CFG \
1.83 + CFLAGS="${cflags} -fexceptions" \
1.84 + "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
1.85 + --build=${CT_BUILD} \
1.86 + --host=${host} \
1.87 + --prefix="${prefix}" \
1.88 + --enable-fft \
1.89 + --enable-mpbsd \
1.90 + --enable-cxx \
1.91 + --disable-shared \
1.92 + --enable-static
1.93 +
1.94 + CT_DoLog EXTRA "Building GMP"
1.95 + CT_DoExecLog ALL make ${JOBSFLAGS}
1.96 +
1.97 + if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
1.98 + CT_DoLog EXTRA "Checking GMP"
1.99 + CT_DoExecLog ALL make ${JOBSFLAGS} -s check
1.100 + fi
1.101 +
1.102 + CT_DoLog EXTRA "Installing GMP"
1.103 + CT_DoExecLog ALL make install
1.104 +}
1.105 +
1.106 +fi # CT_GMP