summaryrefslogtreecommitdiff
blob: b81af078bf30f18759c709f190d628c33859a84e (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit toolchain-funcs

DESCRIPTION="C++ class library of cryptographic schemes"
HOMEPAGE="https://cryptopp.com"
SRC_URI="https://www.cryptopp.com/cryptopp${PV//.}.zip"

LICENSE="Boost-1.0"
SLOT="0/8" # subslot is so version
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~sparc ~x86 ~x64-macos"
IUSE="+asm cpu_flags_x86_aes cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_x86_pclmul cpu_flags_x86_sha cpu_flags_x86_sse2 cpu_flags_x86_sse4_2 cpu_flags_x86_ssse3 static-libs"

BDEPEND="app-arch/unzip"

S="${WORKDIR}"

PATCHES=(
	"${FILESDIR}/${P}-build.patch"
)

config_add() {
	sed -i -e "/Important Settings/a#define $1 1" config.h || die
}

pkg_setup() {
	export CXX="$(tc-getCXX)"
	export LIBDIR="${EPREFIX}/usr/$(get_libdir)"
	export PREFIX="${EPREFIX}/usr"
}

src_prepare() {
	default

	use asm || config_add CRYPTOPP_DISABLE_ASM
	use cpu_flags_x86_aes || config_add CRYPTOPP_DISABLE_AESNI
	use cpu_flags_x86_avx || config_add CRYPTOPP_DISABLE_AVX
	use cpu_flags_x86_avx2 || config_add CRYPTOPP_DISABLE_AVX2
	use cpu_flags_x86_pclmul || config_add CRYPTOPP_DISABLE_CLMUL
	use cpu_flags_x86_sha || config_add CRYPTOPP_DISABLE_SHANI
	use cpu_flags_x86_sse2 || config_add CRYPTOPP_DISABLE_SSE2
	use cpu_flags_x86_sse4_2 || config_add CRYPTOPP_DISABLE_SSE4
	use cpu_flags_x86_ssse3 || config_add CRYPTOPP_DISABLE_SSSE3

	# ASM isn't Darwin/Mach-O ready, #479554, buildsys doesn't grok CPPFLAGS
	[[ ${CHOST} == *-darwin* ]] && config_add CRYPTOPP_DISABLE_ASM
}

src_compile() {
	emake -f GNUmakefile all shared libcryptopp.pc
}

src_install() {
	default

	use static-libs || rm -f "${ED}"/usr/$(get_libdir)/*.a
}