1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/build/companion_libs/140-mpc.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 MPC library
1.5 +# Copyright 2009 Yann E. MORIN
1.6 +# Licensed under the GPL v2. See COPYING in the root of this package
1.7 +
1.8 +do_mpc_get() { :; }
1.9 +do_mpc_extract() { :; }
1.10 +do_mpc_for_build() { :; }
1.11 +do_mpc_for_host() { :; }
1.12 +
1.13 +# Overide functions depending on configuration
1.14 +if [ "${CT_MPC}" = "y" ]; then
1.15 +
1.16 +# Download MPC
1.17 +do_mpc_get() {
1.18 + CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz \
1.19 + http://www.multiprecision.org/mpc/download
1.20 +}
1.21 +
1.22 +# Extract MPC
1.23 +do_mpc_extract() {
1.24 + CT_Extract "mpc-${CT_MPC_VERSION}"
1.25 + CT_Patch "mpc" "${CT_MPC_VERSION}"
1.26 +}
1.27 +
1.28 +# Build MPC for running on build
1.29 +# - always build statically
1.30 +# - we do not have build-specific CFLAGS
1.31 +# - install in build-tools prefix
1.32 +do_mpc_for_build() {
1.33 + local -a mpc_opts
1.34 +
1.35 + case "${CT_TOOLCHAIN_TYPE}" in
1.36 + native|cross) return 0;;
1.37 + esac
1.38 +
1.39 + CT_DoStep INFO "Installing MPC for build"
1.40 + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-build-${CT_BUILD}"
1.41 +
1.42 + mpc_opts+=( "host=${CT_BUILD}" )
1.43 + mpc_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
1.44 + do_mpc_backend "${mpc_opts[@]}"
1.45 +
1.46 + CT_Popd
1.47 + CT_EndStep
1.48 +}
1.49 +
1.50 +# Build MPC for running on host
1.51 +do_mpc_for_host() {
1.52 + local -a mpc_opts
1.53 +
1.54 + CT_DoStep INFO "Installing MPC for host"
1.55 + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-host-${CT_HOST}"
1.56 +
1.57 + mpc_opts+=( "host=${CT_HOST}" )
1.58 + mpc_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
1.59 + mpc_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
1.60 + do_mpc_backend "${mpc_opts[@]}"
1.61 +
1.62 + CT_Popd
1.63 + CT_EndStep
1.64 +}
1.65 +
1.66 +# Build MPC
1.67 +# Parameter : description : type : default
1.68 +# host : machine to run on : tuple : (none)
1.69 +# prefix : prefix to install into : dir : (none)
1.70 +# cflags : host cflags to use : string : (empty)
1.71 +do_mpc_backend() {
1.72 + local host
1.73 + local prefix
1.74 + local cflags
1.75 + local arg
1.76 +
1.77 + for arg in "$@"; do
1.78 + eval "${arg// /\\ }"
1.79 + done
1.80 +
1.81 + CT_DoLog EXTRA "Configuring MPC"
1.82 +
1.83 + CT_DoExecLog CFG \
1.84 + CFLAGS="${cflags}" \
1.85 + "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
1.86 + --build=${CT_BUILD} \
1.87 + --host=${host} \
1.88 + --prefix="${prefix}" \
1.89 + --with-gmp="${prefix}" \
1.90 + --with-mpfr="${prefix}" \
1.91 + --disable-shared \
1.92 + --enable-static
1.93 +
1.94 + CT_DoLog EXTRA "Building MPC"
1.95 + CT_DoExecLog ALL make ${JOBSFLAGS}
1.96 +
1.97 + if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
1.98 + CT_DoLog EXTRA "Checking MPC"
1.99 + CT_DoExecLog ALL make ${JOBSFLAGS} -s check
1.100 + fi
1.101 +
1.102 + CT_DoLog EXTRA "Installing MPC"
1.103 + CT_DoExecLog ALL make install
1.104 +}
1.105 +
1.106 +fi # CT_MPC