Merge remote-tracking branch 'github/pr/682'.
[gentoo.git] / www-servers / monkeyd / monkeyd-9999.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils flag-o-matic toolchain-funcs multilib
8
9 DESCRIPTION="A small, fast, and scalable web server"
10 HOMEPAGE="http://www.monkey-project.com/"
11 MY_P="${PN/d}-${PV}"
12 if [[ ${PV} == "9999" ]] ; then
13         EGIT_REPO_URI="https://github.com/monkey/monkey.git"
14         inherit git-2
15         KEYWORDS=""
16 else
17         SRC_URI="http://monkey-project.com/releases/${PV:0:3}/${MY_P}.tar.gz"
18         KEYWORDS="~amd64 ~arm ~mips ~ppc ~ppc64 ~x86"
19 fi
20
21 LICENSE="GPL-2"
22 SLOT="0"
23
24 # jemalloc is also off until we figure out how to work CMakeLists.txt magic.
25 #IUSE="cgi -debug fastcgi jemalloc php static-plugins ${PLUGINS}"
26
27 PLUGINS="monkeyd_plugins_auth monkeyd_plugins_cheetah monkeyd_plugins_dirlisting +monkeyd_plugins_liana monkeyd_plugins_logger monkeyd_plugins_mandril monkeyd_plugins_tls"
28 IUSE="cgi -debug fastcgi php static-plugins ${PLUGINS}"
29
30 # uclibc is often compiled without backtrace info so we should
31 # force this off.  If someone complains, consider relaxing it.
32 REQUIRED_USE="
33         monkeyd_plugins_tls? ( !static-plugins )
34         elibc_uclibc? ( !debug )
35         cgi? ( php )"
36
37 #DEPEND="jemalloc? ( >=dev-libs/jemalloc-3.3.1 )"
38 DEPEND="
39         dev-util/cmake
40         monkeyd_plugins_tls? ( net-libs/mbedtls:= )"
41 RDEPEND="
42         php? ( dev-lang/php )
43         cgi? ( dev-lang/php[cgi] )"
44
45 S="${WORKDIR}/${MY_P}"
46
47 WEBROOT="/var/www/localhost"
48
49 pkg_setup() {
50         if use debug; then
51                 ewarn
52                 ewarn "\033[1;33m**************************************************\033[00m"
53                 ewarn "Do not use debug in production!"
54                 ewarn "\033[1;33m**************************************************\033[00m"
55                 ewarn
56         fi
57 }
58
59 src_prepare() {
60         # Unconditionally get rid of the bundled jemalloc
61         rm -rf "${S}"/deps
62         epatch "${FILESDIR}"/${PN}-1.6.8-system-mbedtls.patch
63 }
64
65 src_configure() {
66         local myconf=""
67
68         use elibc_uclibc && myconf+=" --uclib-mode"
69         use elibc_musl && myconf+=" --musl-mode"
70
71         #use jemalloc || myconf+=" --malloc-libc"
72         myconf+=" --malloc-libc"
73
74         if use debug; then
75                 myconf+=" --debug --trace"
76         else
77                 myconf+=" --no-backtrace"
78         fi
79
80         local enable_plugins=""
81         local disable_plugins=""
82         # We use 'cgi' and 'fastcgi' because they are global flags
83         # instead of the corresponding monkeyd_plugins_*
84         use cgi && enable_plugins+="cgi," || disable_plugins+="cgi,"
85         use fastcgi && enable_plugins+="fastcgi," || disable_plugins+="fastcgi,"
86         # For the rest, we scan the monkeyd_plugins_* and parse out the plugin name.
87         local p
88         for p in ${PLUGINS}; do
89                 pp=${p/+/}
90                 cp=${pp/monkeyd_plugins_/}
91                 use $pp && enable_plugins+="${cp}," || disable_plugins+="${cp},"
92         done
93         myconf+=" --enable-plugins=${enable_plugins%,} --disable-plugins=${disable_plugins%,}"
94         if use static-plugins; then
95                 myconf+=" --static-plugins=${enable_plugins%,}"
96         fi
97
98         # For O_CLOEXEC which is guarded by _GNU_SOURCE in uClibc,
99         # but shouldn't because it is POSIX.  This needs to be fixed
100         # in uClibc.  Also, we really should us append-cppflags but
101         # monkey's build system doesn't respect CPPFLAGS.  This needs
102         # to be fixed in monkey.
103         use elibc_uclibc && append-cflags -D_GNU_SOURCE
104
105         # Non-autotools configure
106         ./configure \
107                 --pthread-tls \
108                 --prefix=/usr \
109                 --sbindir=/usr/sbin \
110                 --webroot=${WEBROOT}/htdocs \
111                 --logdir=/var/log/${PN} \
112                 --mandir=/usr/share/man \
113                 --libdir=/usr/$(get_libdir) \
114                 --pidfile=/run/monkey.pid \
115                 --sysconfdir=/etc/${PN} \
116                 ${myconf} \
117                 || die
118 }
119
120 src_compile() {
121         emake VERBOSE=1
122 }
123
124 src_install() {
125         default
126
127         newinitd "${FILESDIR}"/monkeyd.initd-r1 monkeyd
128         newconfd "${FILESDIR}"/monkeyd.confd monkeyd
129
130         # Move htdocs to docdir, bug #429632
131         docompress -x /usr/share/doc/"${PF}"/htdocs.dist
132         mv "${D}"${WEBROOT}/htdocs \
133                 "${D}"/usr/share/doc/"${PF}"/htdocs.dist || die
134
135         keepdir \
136                 /var/log/monkeyd \
137                 ${WEBROOT}/htdocs
138
139         # This needs to be created at runtime
140         rm -rf "${D}"/run
141 }