summaryrefslogtreecommitdiff
blob: 943f9147ec1d0aeda289d315a3c1279112a904ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/mini_httpd/mini_httpd-1.19.ebuild,v 1.11 2009/08/08 22:19:53 ssuominen Exp $

inherit eutils toolchain-funcs

DESCRIPTION="Small forking webserver with optional ssl and ipv6 support"
HOMEPAGE="http://www.acme.com/software/mini_httpd/"
SRC_URI="http://www.acme.com/software/mini_httpd/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64 ~ia64 ppc s390 sparc x86"
IUSE="ssl ipv6"

RDEPEND="ssl? ( dev-libs/openssl )"
DEPEND="${RDEPEND}"

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}"/${P}-glibc-2.10.patch
}

src_compile() {
	## we need to hack a bit to have the correct install-dir -- no autoconf :(
	mv Makefile Makefile.org
	cat Makefile.org | sed -e "s@/usr/local/sbin@${D}/usr/sbin@; \
		s@/usr/local/man@${D}/usr/share/man@; \
		s@-mkdir -p \${BINDIR}@& \${MANDIR}/man8 \${MANDIR}/man1@" > \
		Makefile || die "error rewriting Makefile"
	rm -f Makefile.org

	## for ssl-support we need another Makefile-patch:
	if use ssl; then
		mv Makefile Makefile.org
		cat Makefile.org | sed -e "s@^#\(SSL_TREE.*=\)\(.*$\)@\1 /usr@; \
			s@^#\(SSL_DEFS.*$\)@\1@; \
			s@^#\(SSL_INC.*$\)@\1@; \
			s@^#\(SSL_LIBS.*$\)@\1@" > \
			Makefile || die "error rewriting Makefile"
		rm -f Makefile.org
	fi

	## ipv6-support: normally this is auto-detected at compile time ... so we
	## need to force a bit ;)
	if ! use ipv6; then
		sed -i 's@#define USE_IPV6@#undef USE_IPV6@' mini_httpd.c
	fi
	emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" || die
}

src_install() {
	make install || die
	mv ${D}/usr/sbin/{,mini_}htpasswd
	mv ${D}/usr/share/man/man1/{,mini_}htpasswd.1

	newinitd "${FILESDIR}"/mini_httpd.init mini_httpd
	newconfd "${FILESDIR}"/mini_httpd.confd-${PV} mini_httpd
	dodoc README
	newdoc ${FILESDIR}/mini_httpd.conf.sample-${PV} mini_httpd.conf.sample
}

pkg_postinst() {
	ewarn "Adjust MINI_HTTPD_DOCROOT in /etc/conf.d/mini_httpd !"
}