net-libs/serf: marked ~x64-solaris
[gentoo.git] / net-libs / mbedtls / mbedtls-2.2.0.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit eutils multilib cmake-utils multilib-minimal
8
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"
12
13 LICENSE="Apache-2.0"
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"
17
18 RDEPEND="
19         programs? (
20                 !libressl? ( dev-libs/openssl:0 )
21                 libressl? ( dev-libs/libressl )
22         )
23         zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
24 DEPEND="${RDEPEND}
25         doc? ( app-doc/doxygen media-gfx/graphviz )
26         test? ( dev-lang/perl )"
27
28 S=${WORKDIR}/${PN}-${P}
29
30 enable_mbedtls_option() {
31         local myopt="$@"
32         # check that config.h syntax is the same at version bump
33         sed -i \
34                 -e "s://#define ${myopt}:#define ${myopt}:" \
35                 include/mbedtls/config.h || die
36 }
37
38 src_prepare() {
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
44 }
45
46 multilib_src_configure() {
47         local mycmakeargs=(
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)"
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         einstalldocs
77
78         use doc && dohtml -r apidoc
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 }