Merge remote-tracking branch 'remotes/Coacher/fwknop-2.6.8-bump'
[gentoo.git] / dev-libs / opencryptoki / opencryptoki-3.4.1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit autotools multilib flag-o-matic user
8
9 DESCRIPTION="PKCS#11 provider cryptographic hardware"
10 HOMEPAGE="http://sourceforge.net/projects/opencryptoki"
11 SRC_URI="mirror://sourceforge/opencryptoki/${PV}/${PN}-v${PV}.tgz"
12
13 # Upstream is looking into relicensing it into CPL-1.0 entirely; the CCA
14 # token sources are under CPL-1.0 already.
15 LICENSE="CPL-0.5"
16 SLOT="0"
17 KEYWORDS="~amd64 ~arm ~x86"
18
19 RDEPEND="tpm? ( app-crypt/trousers )
20                  dev-libs/openssl:*"
21 DEPEND="${RDEPEND}"
22
23 IUSE="+tpm debug"
24
25 S="${WORKDIR}/${PN}"
26
27 # tests right now basically don't exist; the only available thing would
28 # test against an installed copy and would kill a running pcscd, all
29 # things that we're not interested to.
30 RESTRICT=test
31
32 pkg_setup() {
33         enewgroup pkcs11
34 }
35
36 src_prepare() {
37         mv configure.in configure.ac || die
38         eautoreconf
39 }
40
41 src_configure() {
42         # package uses ${localstatedir}/lib as the default path, so if we
43         # leave it to econf, it'll create /var/lib/lib.
44
45         # Since upstream by default seem to enable any possible token, even
46         # when they don't seem to be used, we limit ourselves to the
47         # software emulation token (swtok) and if the user enabled the tpm
48         # USE flag, tpmtok.  The rest of the tokens seem to be hardware- or
49         # software-dependent even when they build fine without their
50         # requirements, but until somebody asks for those, I'd rather not
51         # enable them.
52
53         # We don't use --enable-debug because that tinkers with the CFLAGS
54         # and we don't want that. Instead we append -DDEBUG which enables
55         # debug information.
56         use debug && append-flags -DDEBUG
57
58         econf \
59                 --localstatedir=/var \
60                 --enable-fast-install \
61                 --disable-dependency-tracking \
62                 --disable-debug \
63                 --enable-daemon \
64                 --enable-library \
65                 --disable-icatok \
66                 --enable-swtok \
67                 $(use_enable tpm tpmtok) \
68                 --disable-ccatok
69 }
70
71 src_install() {
72         emake install DESTDIR="${ED}"
73
74         # Install libopencryptoki in the standard directory for libraries.
75         mv "${D}"/usr/$(get_libdir)/opencryptoki/libopencryptoki.so* "${D}"/usr/$(get_libdir) || die
76         rm "${D}"/usr/$(get_libdir)/pkcs11/libopencryptoki.so
77         dosym ../libopencryptoki.so /usr/$(get_libdir)/pkcs11/libopencryptoki.so
78
79         # Remove compatibility symlinks as we _never_ required those and
80         # they seem unused even upstream.
81         find "${D}" -name 'PKCS11_*' -delete
82
83         # doesn't use libltdl; only dlopen()-based interfaces
84         find "${D}" -name '*.la' -delete
85
86         # We replace their ld.so and init files (mostly designed for RedHat
87         # as far as I can tell) with our own replacements.
88         rm -rf "${D}"/etc/ld.so.conf.d "${D}"/etc/rc.d
89
90         # make sure that we don't modify the init script if the USE flags
91         # are enabled for the needed services.
92         cp "${FILESDIR}"/pkcsslotd.init.2 "${T}"/pkcsslotd.init
93         use tpm || sed -i -e '/use tcsd/d' "${T}"/pkcsslotd.init
94         newinitd "${T}/pkcsslotd.init" pkcsslotd
95
96         # We create /var dirs at runtime as needed, so don't bother installing
97         # our own.
98         rm -r "${D}"/var/{lib,lock} || die
99
100         dodoc README AUTHORS FAQ TODO doc/openCryptoki-HOWTO.pdf
101 }