b21a0040628f9d622a5763b76d7b38bda3d2ec2b
[gentoo.git] / dev-libs / crypto++ / crypto++-5.6.4-r2.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6
7 inherit flag-o-matic toolchain-funcs
8
9 DESCRIPTION="C++ class library of cryptographic schemes"
10 HOMEPAGE="http://cryptopp.com"
11 SRC_URI="mirror://sourceforge/cryptopp/cryptopp${PV//.}.zip"
12
13 LICENSE="Boost-1.0"
14 SLOT="0/5.6" # subslot is so version
15 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86 ~x64-macos"
16 IUSE="static-libs"
17
18 DEPEND="app-arch/unzip"
19
20 S="${WORKDIR}"
21
22 PATCHES=(
23         "${FILESDIR}/${P}-nonative.patch"
24 )
25
26 pkg_setup() {
27         export CXX="$(tc-getCXX)"
28         export LIBDIR="${EPREFIX}/usr/$(get_libdir)"
29         export PREFIX="${EPREFIX}/usr"
30 }
31
32 src_configure() {
33         default
34         cp config.recommend config.h || die
35 }
36
37 src_compile() {
38         # higher optimizations cause problems
39         replace-flags -O3 -O2
40         # ASM isn't Darwin/Mach-O ready, #479554, buildsys doesn't grok CPPFLAGS
41         [[ ${CHOST} == *-darwin* ]] && append-flags -DCRYPTOPP_DISABLE_X86ASM
42
43         emake -f GNUmakefile all shared
44 }
45
46 src_test() {
47         # ensure that all test vectors have Unix line endings
48         local file
49         for file in TestVectors/* ; do
50                 edos2unix "${file}"
51         done
52
53         if ! emake test; then
54                 eerror "Crypto++ self-tests failed."
55                 eerror "Try to remove some optimization flags and reemerge Crypto++."
56                 die "emake test failed"
57         fi
58 }
59
60 src_install() {
61         default
62
63         # remove leftovers as build system sucks
64         rm -fr "${ED}"/usr/bin "${ED}"/usr/share/cryptopp
65         use static-libs || rm -f "${ED}${EPREFIX}"/usr/$(get_libdir)/*.a
66
67         # compatibility
68         dosym cryptopp "${EPREFIX}"/usr/include/crypto++
69         for f in "${ED}${EPREFIX}"/usr/$(get_libdir)/*; do
70                 ln -s "$(basename "${f}")" "$(echo "${f}" | sed 's/cryptopp/crypto++/')" || die
71         done
72 }
73
74 pkg_preinst() {
75         # we switched directory to symlink
76         # make sure portage digests that
77         rm -fr "${EROOT}/usr/include/crypto++"
78         rm -fr "${EROOT}/usr/include/cryptopp"
79 }