net-libs/libasyncns: keyword ~arm64
[gentoo.git] / net-libs / axtls / axtls-2.1.1.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils multilib multilib-minimal savedconfig toolchain-funcs user
7
8 ################################################################################
9 # axtls CONFIG MINI-HOWTO
10 #
11 # Note: axtls is highly configurable and uses mconf, like the linux kernel.
12 # You can configure it in a couple of ways:
13 #
14 # 1) USE="-savedconfig" and set/unset the remaining flags to obtain the features
15 # you want, and possibly a lot more.
16 #
17 # 2) You can create your own configuration file by doing
18 #
19 #       FEATURES="keepwork" USE="savedconfig -*" emerge axtls
20 #       cd /var/tmp/portage/net-libs/axtls*/work/axTLS
21 #       make menuconfig
22 #
23 # Now configure axtls as you want.  Finally save your config file:
24 #
25 #       cp config/.config /etc/portage/savedconfig/net-libs/axtls-${PV}
26 #
27 # where ${PV} is the current version.  You can then run emerge again with
28 # your configuration by doing
29 #
30 #       USE="savedconfig" emerge axtls
31 #
32 ################################################################################
33
34 MY_PN=${PN/tls/TLS}
35
36 DESCRIPTION="Embedded client/server TLSv1 SSL library and small HTTP(S) server"
37 HOMEPAGE="http://axtls.sourceforge.net/"
38 SRC_URI="mirror://sourceforge/axtls/${MY_PN}-${PV}.tar.gz"
39 S="${WORKDIR}/${PN}-code"
40
41 LICENSE="BSD GPL-2"
42 SLOT="0/1"
43 KEYWORDS="~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 ~s390 ~x86"
44
45 IUSE="httpd cgi-lua cgi-php static static-libs doc"
46
47 # TODO: add ipv6, and c#, java, lua, perl bindings
48 # Currently these all have some issue
49 DEPEND="doc? ( app-doc/doxygen )"
50 RDEPEND="
51         httpd? (
52                 cgi-lua? ( dev-lang/lua )
53                 cgi-php? ( dev-lang/php[cgi] )
54         )"
55
56 #Note1: static, cgi-* makes no sense if httpd is not given
57 REQUIRED_USE="
58         static? ( httpd )
59         cgi-lua? ( httpd )
60         cgi-php? ( httpd )"
61
62 AXTLS_GROUP="axtls"
63 AXTLS_USER="axtls"
64
65 pkg_setup() {
66         use httpd && {
67                 ebegin "Creating axtls user and group"
68                 enewgroup ${AXTLS_GROUP}
69                 enewuser ${AXTLS_USER} -1 -1 -1 ${AXTLS_GROUP}
70         }
71 }
72
73 src_prepare() {
74         tc-export AR CC
75
76         epatch "${FILESDIR}/explicit-libdir-r1.patch"
77
78         #We want CONFIG_DEBUG to avoid stripping
79         #but not for debugging info
80         sed -i -e 's: -g::' config/Rules.mak || die
81         sed -i -e 's: -g::' config/makefile.conf || die
82
83         multilib_copy_sources
84 }
85
86 use_flag_config() {
87         cp "${FILESDIR}"/config config/.config || die
88
89         #Respect CFLAGS/LDFLAGS
90         sed -i -e "s:^CONFIG_EXTRA_CFLAGS_OPTIONS.*$:CONFIG_EXTRA_CFLAGS_OPTIONS=\"${CFLAGS}\":" \
91                 config/.config || die
92         sed -i -e "s:^CONFIG_EXTRA_LDFLAGS_OPTIONS.*$:CONFIG_EXTRA_LDFLAGS_OPTIONS=\"${LDLAGS}\":" \
93                 config/.config || die
94
95         #The logic is that the default config file enables everything and we disable
96         #here with sed unless a USE flags says to keep it
97         if use httpd; then
98                 if ! use static; then
99                         sed -i -e 's:^CONFIG_HTTP_STATIC_BUILD:# CONFIG_HTTP_STATIC_BUILD:' \
100                                 config/.config || die
101                 fi
102                 if ! use cgi-php && ! use cgi-lua; then
103                         sed -i -e 's:^CONFIG_HTTP_HAS_CGI:# CONFIG_HTTP_HAS_CGI:' \
104                                 config/.config || die
105                 fi
106                 if ! use cgi-php; then
107                         sed -i -e 's:,.php::' config/.config || die
108                 fi
109                 if ! use cgi-lua; then
110                         sed -i -e 's:\.lua,::' \
111                                 -e 's:lua:php:' \
112                                 -e 's:^CONFIG_HTTP_ENABLE_LUA:# CONFIG_HTTP_ENABLE_LUA:' \
113                                 config/.config || die
114                 fi
115         else
116                 sed -i -e 's:^CONFIG_AXHTTPD:# CONFIG_AXHTTPD:' \
117                         config/.config || die
118         fi
119
120         yes "n" | emake -j1 oldconfig > /dev/null || die
121 }
122
123 multilib_src_configure() {
124         #Per-ABI substitutions.
125         sed -i -e 's:^LIBDIR.*/lib:LIBDIR = $(PREFIX)/'"$(get_libdir):" \
126                 Makefile || die
127
128         #Use CC as the host compiler for mconf
129         sed -i -e "s:^HOSTCC.*:HOSTCC=${CC}:" \
130                 config/Rules.mak || die
131
132         if use savedconfig; then
133                 restore_config config/.config
134                 if [[ -f config/.config ]]; then
135                         ewarn "Using saved config, all other USE flags ignored"
136                 else
137                         ewarn "No saved config, seeding with the default"
138                         cp "${FILESDIR}"/config config/.config || die
139                 fi
140                 yes "" | emake -j1 oldconfig > /dev/null || die
141         else
142                 use_flag_config
143         fi
144 }
145
146 multilib_src_install() {
147         if multilib_is_native_abi && use savedconfig; then
148                 save_config config/.config
149         fi
150
151         emake PREFIX="${ED}/usr" install
152
153         if ! use static-libs; then
154                 rm -f "${ED}"/usr/$(get_libdir)/libaxtls.a || die
155         fi
156
157         # The build system needs to install before it builds docs
158         if multilib_is_native_abi && use doc; then
159                 emake docs
160                 dodoc -r docsrc/html
161         fi
162 }
163
164 multilib_src_install_all() {
165         if [[ -f "${ED}"/usr/bin/htpasswd ]]; then
166                 mv "${ED}"/usr/bin/{,ax}htpasswd || die
167         fi
168
169         if use httpd; then
170                 newinitd "${FILESDIR}"/axhttpd.initd axhttpd
171                 newconfd "${FILESDIR}"/axhttpd.confd axhttpd
172         fi
173
174         docompress -x /usr/share/doc/${PF}/README
175         dodoc README
176 }