net-libs/libasyncns: keyword ~arm64
[gentoo.git] / net-libs / axtls / axtls-2.1.3.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit 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         eapply "${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         eapply_user
84
85         multilib_copy_sources
86 }
87
88 use_flag_config() {
89         cp "${FILESDIR}"/config config/.config || die
90
91         #Respect CFLAGS/LDFLAGS
92         sed -i -e "s:^CONFIG_EXTRA_CFLAGS_OPTIONS.*$:CONFIG_EXTRA_CFLAGS_OPTIONS=\"${CFLAGS}\":" \
93                 config/.config || die
94         sed -i -e "s:^CONFIG_EXTRA_LDFLAGS_OPTIONS.*$:CONFIG_EXTRA_LDFLAGS_OPTIONS=\"${LDLAGS}\":" \
95                 config/.config || die
96
97         #The logic is that the default config file enables everything and we disable
98         #here with sed unless a USE flags says to keep it
99         if use httpd; then
100                 if ! use static; then
101                         sed -i -e 's:^CONFIG_HTTP_STATIC_BUILD:# CONFIG_HTTP_STATIC_BUILD:' \
102                                 config/.config || die
103                 fi
104                 if ! use cgi-php && ! use cgi-lua; then
105                         sed -i -e 's:^CONFIG_HTTP_HAS_CGI:# CONFIG_HTTP_HAS_CGI:' \
106                                 config/.config || die
107                 fi
108                 if ! use cgi-php; then
109                         sed -i -e 's:,.php::' config/.config || die
110                 fi
111                 if ! use cgi-lua; then
112                         sed -i -e 's:\.lua,::' \
113                                 -e 's:lua:php:' \
114                                 -e 's:^CONFIG_HTTP_ENABLE_LUA:# CONFIG_HTTP_ENABLE_LUA:' \
115                                 config/.config || die
116                 fi
117         else
118                 sed -i -e 's:^CONFIG_AXHTTPD:# CONFIG_AXHTTPD:' \
119                         config/.config || die
120         fi
121
122         yes "n" | emake -j1 oldconfig > /dev/null || die
123 }
124
125 multilib_src_configure() {
126         #Per-ABI substitutions.
127         sed -i -e 's:^LIBDIR.*/lib:LIBDIR = $(PREFIX)/'"$(get_libdir):" \
128                 Makefile || die
129
130         #Use CC as the host compiler for mconf
131         sed -i -e "s:^HOSTCC.*:HOSTCC=${CC}:" \
132                 config/Rules.mak || die
133
134         if use savedconfig; then
135                 restore_config config/.config
136                 if [[ -f config/.config ]]; then
137                         ewarn "Using saved config, all other USE flags ignored"
138                 else
139                         ewarn "No saved config, seeding with the default"
140                         cp "${FILESDIR}"/config config/.config || die
141                 fi
142                 yes "" | emake -j1 oldconfig > /dev/null || die
143         else
144                 use_flag_config
145         fi
146 }
147
148 multilib_src_install() {
149         if multilib_is_native_abi && use savedconfig; then
150                 save_config config/.config
151         fi
152
153         emake PREFIX="${ED}/usr" install
154
155         if ! use static-libs; then
156                 rm -f "${ED}"/usr/$(get_libdir)/libaxtls.a || die
157         fi
158
159         # The build system needs to install before it builds docs
160         if multilib_is_native_abi && use doc; then
161                 emake docs
162                 dodoc -r docsrc/html
163         fi
164 }
165
166 multilib_src_install_all() {
167         if [[ -f "${ED}"/usr/bin/htpasswd ]]; then
168                 mv "${ED}"/usr/bin/{,ax}htpasswd || die
169         fi
170
171         if use httpd; then
172                 newinitd "${FILESDIR}"/axhttpd.initd axhttpd
173                 newconfd "${FILESDIR}"/axhttpd.confd axhttpd
174         fi
175
176         docompress -x /usr/share/doc/${PF}/README
177         dodoc README
178 }