summaryrefslogtreecommitdiff
path: root/sci-libs/symengine/symengine-0.13.0.ebuild
blob: 589a31fdb9afc2fd16715cc5fbb09690498256f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LLVM_COMPAT=( {18..20} )
LLVM_OPTIONAL=1

inherit cmake llvm-r2 toolchain-funcs

DESCRIPTION="Fast symbolic manipulation library, written in C++"
HOMEPAGE="https://github.com/symengine/symengine/"
SRC_URI="
	https://github.com/symengine/${PN}/archive/v${PV}.tar.gz
		-> ${P}.gh.tar.gz
"

LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86"
IUSE="
	boost debug ecm +flint llvm +mpc +mpfr openmp primesieve tcmalloc
	test
"
REQUIRED_USE="
	boost? ( !flint !mpc !mpfr )
	llvm? ( ${LLVM_REQUIRED_USE} )
	mpc? ( mpfr )
"
RESTRICT="!test? ( test )"

RDEPEND="
	boost? ( dev-libs/boost:= )
	!boost? ( dev-libs/gmp:= )
	debug? ( sys-libs/binutils-libs:= )
	ecm? ( sci-mathematics/gmp-ecm:= )
	flint? ( sci-mathematics/flint:= )
	mpc? ( dev-libs/mpc:= )
	mpfr? ( dev-libs/mpfr:= )
	llvm? ( $(llvm_gen_dep 'llvm-core/llvm:${LLVM_SLOT}=') )
	primesieve? ( sci-mathematics/primesieve:= )
	tcmalloc? ( dev-util/google-perftools )
"
DEPEND="
	${RDEPEND}
	dev-libs/cereal
"

PATCHES=(
	# TODO: upstream
	"${FILESDIR}"/${PN}-0.7.0-cmake-build-type.patch
	# TODO: make a proper patch for upstream
	"${FILESDIR}"/${PN}-0.8.1-fix_llvm.patch
)

pkg_pretend() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

pkg_setup() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

src_configure() {
	local int_class

	if use flint; then
		int_class=flint
	elif use mpfr; then
		int_class=gmpxx
	elif use boost; then
		int_class=boostmp
	else
		int_class=gmp
	fi

	einfo "Building with integer class: ${int_class}"

	local mycmakeargs=(
		-DINSTALL_CMAKE_DIR="${EPREFIX}/usr/$(get_libdir)/cmake/symengine"
		-DINTEGER_CLASS=${int_class}
		# not installed
		-DBUILD_BENCHMARKS=OFF
		# broken with out-of-tree builds
		-DBUILD_DOXYGEN=OFF
		-DBUILD_TESTS=$(usex test)
		# -DWITH_ARB provided by flint >= 2
		-DWITH_BFD=$(usex debug)
		-DWITH_ECM=$(usex ecm)
		-DWITH_FLINT=$(usex flint)
		-DWITH_LLVM=$(usex llvm)
		-DWITH_MPC=$(usex mpc)
		-DWITH_MPFR=$(usex mpfr)
		-DWITH_OPENMP=$(usex openmp)
		-DWITH_PRIMESIEVE=$(usex primesieve)
		-DWITH_PTHREAD=ON
		-DWITH_SYMENGINE_ASSERT=$(usex debug)
		-DWITH_SYMENGINE_THREAD_SAFE=ON
		-DWITH_SYSTEM_CEREAL=ON
		# TODO: package it
		# -DWITH_SYSTEM_FASTFLOAT=ON
		-DWITH_TCMALLOC=$(usex tcmalloc)
	)
	if use llvm; then
		mycmakeargs+=(
			-DLLVM_ROOT="$(get_llvm_prefix -d)"
		)
	fi

	cmake_src_configure
}