1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit cmake-utils multilib-minimal
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}
14 SLOT="0/10" # 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 test threads zlib"
17 RESTRICT="!test? ( test )"
21 !libressl? ( dev-libs/openssl:0= )
22 libressl? ( dev-libs/libressl:0= )
24 zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
26 doc? ( app-doc/doxygen media-gfx/graphviz )
27 test? ( dev-lang/perl )"
29 enable_mbedtls_option() {
31 # check that config.h syntax is the same at version bump
33 -e "s://#define ${myopt}:#define ${myopt}:" \
34 include/mbedtls/config.h || die
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
44 cmake-utils_src_prepare
47 multilib_src_configure() {
49 -DENABLE_PROGRAMS=$(multilib_native_usex programs)
50 -DENABLE_ZLIB_SUPPORT=$(usex zlib)
51 -DUSE_STATIC_MBEDTLS_LIBRARY=OFF
52 -DENABLE_TESTING=$(usex test)
53 -DUSE_SHARED_MBEDTLS_LIBRARY=ON
54 -DINSTALL_MBEDTLS_HEADERS=ON
55 -DLIB_INSTALL_DIR="/usr/$(get_libdir)"
58 cmake-utils_src_configure
61 multilib_src_compile() {
62 cmake-utils_src_compile
63 use doc && multilib_is_native_abi && emake apidoc
67 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BUILD_DIR}/library" \
71 multilib_src_install() {
72 cmake-utils_src_install
75 multilib_src_install_all() {
76 use doc && HTML_DOCS=( apidoc )
80 if use programs ; then
81 # avoid file collisions with sys-apps/coreutils
83 for p in "${ED}"/usr/bin/* ; do
84 if [[ -x "${p}" && ! -d "${p}" ]] ; then
85 mv "${p}" "${ED}"/usr/bin/mbedtls_${p##*/} || die
88 for e in aes hash pkey ssl test ; do
90 dodoc programs/"${e}"/*.c
91 dodoc programs/"${e}"/*.txt