SUMMARY="A free C++ class library of cryptographic schemes"
DESCRIPTION="Crypto++ is a C++ Class Library of Cryptographic Schemes \
The library contains the following algorithms:
* Authenticated encryption schemes: (GCM, CCM, EAX)
* High speed stream ciphers: ChaCha (ChaCha8/12/20), Panama
* AES and AES candidates: AES (Rijndael), RC6, MARS, Twofish, Serpent
* Other block ciphers: IDEA, DES, Camellia, SEED, RC5, Blowfish,
* Block cipher modes of operation: ECB, CBC, CBC (CTS), CFB, OFB
* Message authentication codes: VMAC, HMAC, GMAC, CMAC, CBC-MAC, DMAC
* Hash functions: BLAKE2 (BLAKE2b, BLAKE2s), SHA-1, SHA-2, SHA-3
* Public-key cryptography: RSA, DSA, ElGamal, Nyberg-Rueppel (NR)
* Padding schemes for public-key systems: PKCS#1 v2.0, OAEP, PSS,
* Key agreement schemes: Diffie-Hellman (DH), Unified Diffie-Hellman (DH2),
* Elliptic curve cryptography: ECDSA, ECNR, ECIES, ECDH, ECMQV
* Insecure or obsolescent algorithms: MD2, MD4, MD5
* And many more other algorithms."
HOMEPAGE="https://cryptopp.com/"
COPYRIGHT="2015-2019 Wei Dai"
LICENSE="Boost v1.0"
REVISION="1"
SOURCE_URI="https://github.com/weidai11/cryptopp/archive/CRYPTOPP_${portVersion//./_}.tar.gz"
CHECKSUM_SHA256="9304625f4767a13e0a5f26d0f019d78cf9375604a33e5391c3bf2e81399dfeb8"
PATCHES="crypto++-$portVersion.patchset"
SOURCE_DIR="cryptopp-CRYPTOPP_${portVersion//./_}"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion=$portVersion
libVersionCompat="$libVersion compat >= ${libVersion%.*}"

PROVIDES="
	crypto++$secondaryArchSuffix = $portVersion
	lib:libcryptopp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	crypto++${secondaryArchSuffix}_devel = $portVersion
	devel:libcryptopp$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	crypto++$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld
	cmd:make
	cmd:nasm
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage crypto++$secondaryArchSuffix \
	$libDir/libcryptopp.so.$libVersion

BUILD()
{
	make $jobArgs dynamic cryptest.exe libcryptopp.pc
}

INSTALL()
{
	make \
		LDCONF=true \
		BINDIR=$binDir \
		LIBDIR=$libDir \
		DATADIR=$dataDir \
		INCLUDEDIR=$includeDir \
		install

	rm -f $libDir/lib*.a

	prepareInstalledDevelLib libcryptopp
	fixPkgconfig

	packageEntries devel $developDir

	rm -rf "$binDir" "$dataDir/cryptopp"
}

TEST()
{
	make test
}
