1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils multilib cmake-utils multilib-minimal
9 DESCRIPTION="Cryptographic library for embedded systems"
10 HOMEPAGE="https://tls.mbed.org/"
11 SRC_URI="https://github.com/ARMmbed/mbedtls/archive/mbedtls-${PV}.tar.gz"
14 SLOT="0/10" # slot for libmbedtls.so
15 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 ~s390 ~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 )
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 S=${WORKDIR}/${PN}-${P}
30 enable_mbedtls_option() {
32 # check that config.h syntax is the same at version bump
34 -e "s://#define ${myopt}:#define ${myopt}:" \
35 include/mbedtls/config.h || die
39 use cpu_flags_x86_sse2 && enable_mbedtls_option MBEDTLS_HAVE_SSE2
40 use zlib && enable_mbedtls_option MBEDTLS_ZLIB_SUPPORT
41 use havege && enable_mbedtls_option MBEDTLS_HAVEGE_C
42 use threads && enable_mbedtls_option MBEDTLS_THREADING_C
43 use threads && enable_mbedtls_option MBEDTLS_THREADING_PTHREAD
46 multilib_src_configure() {
48 $(multilib_is_native_abi && cmake-utils_use_enable programs PROGRAMS \
49 || echo -DENABLE_PROGRAMS=OFF)
50 $(cmake-utils_use_enable zlib ZLIB_SUPPORT)
51 -DUSE_STATIC_MBEDTLS_LIBRARY=OFF
52 $(cmake-utils_use_enable test TESTING)
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() {
78 use doc && dohtml -r 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