2008-04-30 10:43:41 +00:00
|
|
|
# This file adds the functions to build the GMP library
|
|
|
|
# Copyright 2008 Yann E. MORIN
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
2008-06-20 15:16:43 +00:00
|
|
|
do_gmp_get() { :; }
|
|
|
|
do_gmp_extract() { :; }
|
2011-07-24 21:53:14 +00:00
|
|
|
do_gmp_for_build() { :; }
|
2011-07-17 16:56:30 +00:00
|
|
|
do_gmp_for_host() { :; }
|
2015-11-05 23:49:19 +00:00
|
|
|
do_gmp_for_target() { :; }
|
2008-06-20 15:16:43 +00:00
|
|
|
|
|
|
|
# Overide functions depending on configuration
|
2021-09-16 09:30:46 +00:00
|
|
|
if [ "${CT_GMP_TARGET}" = "y" -o "${CT_GMP}" = "y" ]; then
|
2008-04-30 16:38:06 +00:00
|
|
|
|
2008-04-30 10:43:41 +00:00
|
|
|
# Download GMP
|
|
|
|
do_gmp_get() {
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_Fetch GMP
|
2008-04-30 10:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Extract GMP
|
|
|
|
do_gmp_extract() {
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_ExtractPatch GMP
|
2008-04-30 10:43:41 +00:00
|
|
|
}
|
|
|
|
|
2011-07-24 21:53:14 +00:00
|
|
|
# Build GMP for running on build
|
|
|
|
# - always build statically
|
|
|
|
# - install in build-tools prefix
|
|
|
|
do_gmp_for_build() {
|
|
|
|
local -a gmp_opts
|
|
|
|
|
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
|
|
|
native|cross) return 0;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
CT_DoStep INFO "Installing GMP for build"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-build-${CT_BUILD}"
|
|
|
|
|
|
|
|
gmp_opts+=( "host=${CT_BUILD}" )
|
|
|
|
gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
|
2012-11-16 14:25:57 +00:00
|
|
|
gmp_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
|
|
|
|
gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
|
2011-07-24 21:53:14 +00:00
|
|
|
do_gmp_backend "${gmp_opts[@]}"
|
|
|
|
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2011-07-17 16:56:30 +00:00
|
|
|
# Build GMP for running on host
|
|
|
|
do_gmp_for_host() {
|
|
|
|
local -a gmp_opts
|
2008-04-30 10:43:41 +00:00
|
|
|
|
2011-07-17 16:56:30 +00:00
|
|
|
CT_DoStep INFO "Installing GMP for host"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-host-${CT_HOST}"
|
|
|
|
|
|
|
|
gmp_opts+=( "host=${CT_HOST}" )
|
2011-07-25 17:04:17 +00:00
|
|
|
gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
|
2011-07-17 16:56:30 +00:00
|
|
|
gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
|
2012-11-16 14:25:57 +00:00
|
|
|
gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
|
2011-07-17 16:56:30 +00:00
|
|
|
do_gmp_backend "${gmp_opts[@]}"
|
|
|
|
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2021-09-16 09:30:46 +00:00
|
|
|
if [ "${CT_GMP_TARGET}" = "y" ]; then
|
|
|
|
do_gmp_for_target() {
|
|
|
|
local -a gmp_opts
|
|
|
|
|
|
|
|
CT_DoStep INFO "Installing GMP for target"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-target-${CT_HOST}"
|
|
|
|
|
|
|
|
gmp_opts+=( "host=${CT_TARGET}" )
|
|
|
|
case "${CT_TARGET}" in
|
|
|
|
*-*-mingw*)
|
|
|
|
prefix="/mingw"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
prefix="/usr"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
gmp_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" )
|
|
|
|
gmp_opts+=( "prefix=${prefix}" )
|
|
|
|
gmp_opts+=( "destdir=${CT_SYSROOT_DIR}" )
|
|
|
|
gmp_opts+=( "shared=${CT_SHARED_LIBS}" )
|
|
|
|
do_gmp_backend "${gmp_opts[@]}"
|
|
|
|
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2011-07-17 16:56:30 +00:00
|
|
|
# Build GMP
|
|
|
|
# Parameter : description : type : default
|
|
|
|
# host : machine to run on : tuple : (none)
|
|
|
|
# prefix : prefix to install into : dir : (none)
|
2012-11-16 14:25:57 +00:00
|
|
|
# cflags : cflags to use : string : (empty)
|
|
|
|
# ldflags : ldflags to use : string : (empty)
|
2021-09-16 09:30:46 +00:00
|
|
|
# destdir : install destination : dir : (none)
|
2011-07-17 16:56:30 +00:00
|
|
|
do_gmp_backend() {
|
|
|
|
local host
|
|
|
|
local prefix
|
|
|
|
local cflags
|
2012-11-16 14:25:57 +00:00
|
|
|
local ldflags
|
2011-07-17 16:56:30 +00:00
|
|
|
local arg
|
2014-12-23 21:28:26 +00:00
|
|
|
local -a extra_config
|
2011-07-17 16:56:30 +00:00
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
done
|
2008-04-30 10:43:41 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring GMP"
|
2009-05-05 22:04:20 +00:00
|
|
|
|
2022-12-13 20:16:22 +00:00
|
|
|
# To avoid “illegal text-relocation” linking error against
|
2020-07-10 20:38:09 +00:00
|
|
|
# the static library, see:
|
|
|
|
# https://github.com/Homebrew/homebrew-core/pull/25470
|
|
|
|
case "${host}" in
|
|
|
|
*darwin*)
|
|
|
|
extra_config+=("--with-pic")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-12-13 20:16:22 +00:00
|
|
|
if [ "${CT_CC_LANG_JIT}" = "y" ]; then
|
|
|
|
extra_config+=("--with-pic")
|
|
|
|
fi
|
|
|
|
|
2022-05-30 07:35:12 +00:00
|
|
|
# GMP's configure script doesn't respect the host parameter
|
|
|
|
# when not cross-compiling, ie when build == host so set
|
|
|
|
# CC_FOR_BUILD and CPP_FOR_BUILD.
|
2010-10-22 20:02:57 +00:00
|
|
|
CT_DoExecLog CFG \
|
2022-05-30 07:35:12 +00:00
|
|
|
CC_FOR_BUILD="${CT_BUILD}-gcc" \
|
|
|
|
CPP_FOR_BUILD="{CT_BUILD}-cpp" \
|
2017-02-22 01:25:26 +00:00
|
|
|
CC="${host}-gcc" \
|
2011-07-17 16:56:30 +00:00
|
|
|
CFLAGS="${cflags} -fexceptions" \
|
2012-11-16 14:25:57 +00:00
|
|
|
LDFLAGS="${ldflags}" \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/gmp/configure" \
|
2009-01-04 14:25:58 +00:00
|
|
|
--build=${CT_BUILD} \
|
2011-07-17 16:56:30 +00:00
|
|
|
--host=${host} \
|
|
|
|
--prefix="${prefix}" \
|
2009-05-05 22:04:20 +00:00
|
|
|
--enable-fft \
|
2010-04-10 22:47:23 +00:00
|
|
|
--enable-cxx \
|
2011-04-06 20:30:57 +00:00
|
|
|
--disable-shared \
|
2014-12-23 21:28:26 +00:00
|
|
|
--enable-static \
|
2017-02-04 01:49:45 +00:00
|
|
|
"${extra_config[@]}"
|
2008-04-30 10:43:41 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building GMP"
|
2019-04-04 23:47:50 +00:00
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS}
|
2008-04-30 10:43:41 +00:00
|
|
|
|
2010-04-10 21:42:28 +00:00
|
|
|
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
|
2017-02-11 20:49:48 +00:00
|
|
|
if [ "${host}" = "${CT_BUILD}" ]; then
|
|
|
|
CT_DoLog EXTRA "Checking GMP"
|
2019-04-04 23:47:50 +00:00
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
|
2017-02-11 20:49:48 +00:00
|
|
|
else
|
|
|
|
# Cannot run host binaries on build in a canadian cross
|
|
|
|
CT_DoLog EXTRA "Skipping check for GMP on the host"
|
|
|
|
fi
|
2008-04-30 10:43:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing GMP"
|
2021-09-16 09:30:46 +00:00
|
|
|
CT_DoExecLog ALL make install DESTDIR="${destdir}"
|
2008-04-30 10:43:41 +00:00
|
|
|
}
|
2008-04-30 16:38:06 +00:00
|
|
|
|
2010-02-17 22:50:49 +00:00
|
|
|
fi # CT_GMP
|