summaryrefslogtreecommitdiff
path: root/sci-libs/mpir/mpir-3.0.0-r1.ebuild
blob: 1c8e843d6950945a89ed05c59de266df72054a76 (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit autotools toolchain-funcs

DESCRIPTION="Library for arbitrary precision integer arithmetic (fork of gmp)"
HOMEPAGE="https://www.mpir.org/"
SRC_URI="https://www.mpir.org/${P}.tar.bz2"

LICENSE="LGPL-3"
SLOT="0/23"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~ppc ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
IUSE="+cxx cpudetection"

BDEPEND="
	x86? ( dev-lang/yasm )
	amd64? ( dev-lang/yasm )
"

PATCHES=(
	"${FILESDIR}"/${PN}-2.7.2-ABI-multilib.patch
)

src_prepare() {
	tc-export CC

	default

	# In the same way there was QA regarding executable stacks
	# with GMP we have some here as well. We cannot apply the
	# GMP solution as yasm is used, at least on x86/amd64.
	# Furthermore we are able to patch config.ac.
	einfo "Patching assembler files to remove executable sections"
	local i
	for i in $(find . -type f -name '*.asm') ; do
		cat >> $i <<-EOF || die

			#if defined(__linux__) && defined(__ELF__)
			.section .note.GNU-stack,"",%progbits
			#endif
		EOF
	done

	for i in $(find . -type f -name '*.as') ; do
		cat >> $i <<-EOF || die

			%ifidn __OUTPUT_FORMAT__,elf
			section .note.GNU-stack noalloc noexec nowrite progbits
			%endif
		EOF
	done

	eautoreconf
}

src_configure() {
	# beware that cpudetection aka fat binaries is x86/amd64 only.
	# Place mpir in profiles/arch/$arch/package.use.mask
	# when making it available on $arch.
	local myeconfargs=(
		$(use_enable cxx)
		$(use_enable cpudetection fat)
		--disable-static
	)
	# https://bugs.gentoo.org/661430
	if ! use amd64 && ! use x86; then
		myeconfargs+=( --with-yasm="${BROOT}"/bin/false )
	fi
	econf "${myeconfargs[@]}"
}

src_install() {
	default
	find "${ED}" -name '*.la' -delete || die
}