1 # Copyright 1999-2018 Gentoo Foundation
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 ~amd64-fbsd ~x86-fbsd"
16 IUSE="cpu_flags_x86_sse2 doc havege libressl programs test threads zlib"
20 !libressl? ( dev-libs/openssl:0= )
21 libressl? ( dev-libs/libressl:0= )
23 zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
25 doc? ( app-doc/doxygen media-gfx/graphviz )
26 test? ( dev-lang/perl )"
28 enable_mbedtls_option() {
30 # check that config.h syntax is the same at version bump
32 -e "s://#define ${myopt}:#define ${myopt}:" \
33 include/mbedtls/config.h || die
37 use cpu_flags_x86_sse2 && enable_mbedtls_option MBEDTLS_HAVE_SSE2
38 use zlib && enable_mbedtls_option MBEDTLS_ZLIB_SUPPORT
39 use havege && enable_mbedtls_option MBEDTLS_HAVEGE_C
40 use threads && enable_mbedtls_option MBEDTLS_THREADING_C
41 use threads && enable_mbedtls_option MBEDTLS_THREADING_PTHREAD
43 cmake-utils_src_prepare
46 multilib_src_configure() {
48 -DENABLE_PROGRAMS=$(multilib_native_usex programs)
49 -DENABLE_ZLIB_SUPPORT=$(usex zlib)
50 -DUSE_STATIC_MBEDTLS_LIBRARY=OFF
51 -DENABLE_TESTING=$(usex test)
52 -DUSE_SHARED_MBEDTLS_LIBRARY=ON
53 -DINSTALL_MBEDTLS_HEADERS=ON
54 -DLIB_INSTALL_DIR="/usr/$(get_libdir)"
57 cmake-utils_src_configure
60 multilib_src_compile() {
61 cmake-utils_src_compile
62 use doc && multilib_is_native_abi && emake apidoc
66 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BUILD_DIR}/library" \
70 multilib_src_install() {
71 cmake-utils_src_install
74 multilib_src_install_all() {
75 use doc && HTML_DOCS=( apidoc )
79 if use programs ; then
80 # avoid file collisions with sys-apps/coreutils
82 for p in "${ED%/}"/usr/bin/* ; do
83 if [[ -x "${p}" && ! -d "${p}" ]] ; then
84 mv "${p}" "${ED%/}"/usr/bin/mbedtls_${p##*/} || die
87 for e in aes hash pkey ssl test ; do
89 dodoc programs/"${e}"/*.c
90 dodoc programs/"${e}"/*.txt