net-libs/mbedtls: version bump to 2.16.4
[gentoo.git] / net-libs / mbedtls / mbedtls-2.16.3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit cmake-utils multilib-minimal
7
8 DESCRIPTION="Cryptographic library for embedded systems"
9 HOMEPAGE="https://tls.mbed.org/"
10 SRC_URI="https://github.com/ARMmbed/mbedtls/archive/${P}.tar.gz"
11 S=${WORKDIR}/${PN}-${P}
12
13 LICENSE="Apache-2.0"
14 SLOT="0/12" # slot for libmbedtls.so
15 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
16 IUSE="cpu_flags_x86_sse2 doc havege libressl programs -static-libs test threads zlib"
17 RESTRICT="!test? ( test )"
18
19 RDEPEND="
20         programs? (
21                 !libressl? ( dev-libs/openssl:0= )
22                 libressl? ( dev-libs/libressl:0= )
23         )
24         zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
25 DEPEND="${RDEPEND}
26         doc? ( app-doc/doxygen media-gfx/graphviz )
27         test? ( dev-lang/perl )"
28
29 enable_mbedtls_option() {
30         local myopt="$@"
31         # check that config.h syntax is the same at version bump
32         sed -i \
33                 -e "s://#define ${myopt}:#define ${myopt}:" \
34                 include/mbedtls/config.h || die
35 }
36
37 src_prepare() {
38         use cpu_flags_x86_sse2 && enable_mbedtls_option MBEDTLS_HAVE_SSE2
39         use zlib && enable_mbedtls_option MBEDTLS_ZLIB_SUPPORT
40         use havege && enable_mbedtls_option MBEDTLS_HAVEGE_C
41         use threads && enable_mbedtls_option MBEDTLS_THREADING_C
42         use threads && enable_mbedtls_option MBEDTLS_THREADING_PTHREAD
43
44         cmake-utils_src_prepare
45 }
46
47 multilib_src_configure() {
48         local mycmakeargs=(
49                 -DENABLE_PROGRAMS=$(multilib_native_usex programs)
50                 -DENABLE_ZLIB_SUPPORT=$(usex zlib)
51                 -DUSE_STATIC_MBEDTLS_LIBRARY=$(usex static-libs)
52                 -DENABLE_TESTING=$(usex test)
53                 -DUSE_SHARED_MBEDTLS_LIBRARY=ON
54                 -DINSTALL_MBEDTLS_HEADERS=ON
55                 -DLIB_INSTALL_DIR="/usr/$(get_libdir)"
56         )
57
58         cmake-utils_src_configure
59 }
60
61 multilib_src_compile() {
62         cmake-utils_src_compile
63         use doc && multilib_is_native_abi && emake apidoc
64 }
65
66 multilib_src_test() {
67         LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BUILD_DIR}/library" \
68                 cmake-utils_src_test
69 }
70
71 multilib_src_install() {
72         cmake-utils_src_install
73 }
74
75 multilib_src_install_all() {
76         use doc && HTML_DOCS=( apidoc )
77
78         einstalldocs
79
80         if use programs ; then
81                 # avoid file collisions with sys-apps/coreutils
82                 local p e
83                 for p in "${ED}"/usr/bin/* ; do
84                         if [[ -x "${p}" && ! -d "${p}" ]] ; then
85                                 mv "${p}" "${ED}"/usr/bin/mbedtls_${p##*/} || die
86                         fi
87                 done
88                 for e in aes hash pkey ssl test ; do
89                         docinto "${e}"
90                         dodoc programs/"${e}"/*.c
91                         dodoc programs/"${e}"/*.txt
92                 done
93         fi
94 }