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