+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI="5"
+inherit eutils fixheadtails git-2
+
+IUSE="ssl ipv6 +diskbase -scary_prims debug pcre"
+
+DESCRIPTION="A database-backed multi-user chat server."
+HOMEPAGE="http://www.belfry.com/fuzzball/"
+EGIT_REPO_URI="git://git.code.sf.net/p/fbmuck/code"
+EGIT_PROJECT="fbmuck.git"
+EGIT_SOURCEDIR="${WORKDIR}/${P}"
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS=""
+
+RDEPEND="
+ ssl? ( dev-libs/openssl )
+ pcre? ( dev-libs/libpcre )
+"
+
+DEPEND="${RDEPEND}
+ >=sys-apps/sed-4
+"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/${P}/fbmuck"
+
+src_prepare() {
+ epatch "${FILESDIR}/${P}-gentoo.patch"
+
+ einfo "ensuring configure script is executable"
+ chmod +x configure
+
+ ht_fix_file game/restart.in game/resurrect
+
+ einfo "disabling DB_DOUBLING define"
+ sed -i -e 's:#define DB_DOUBLING:#undef DB_DOUBLING:' include/config.h || die "sed failed"
+
+ if use diskbase
+ then
+ einfo "enabling DISKBASE define"
+ sed -i -e 's:#undef DISKBASE:#define DISKBASE:' include/config.h || die "sed failed"
+ fi
+ if use scary_prims
+ then
+ einfo "enabling SCARY_MUF_PRIMS define"
+ sed -i -e 's:#undef SCARY_MUF_PRIMS:#define SCARY_MUF_PRIMS:' include/config.h || die "sed failed"
+ fi
+}
+
+src_configure() {
+ econf \
+ $(use_with ssl ssl=/usr) \
+ $(use_with pcre pcre=/usr) \
+ $(use_enable ipv6) \
+ $(use_enable debug)
+}
+
+src_compile() {
+ einfo "entering ${S}/src"
+ cd "${S}/src"
+
+ emake all
+}
+
+src_install() {
+ keepdir /usr/share/fbmuck
+
+ emake DESTDIR="${D}" install
+
+ dobin "${FILESDIR}/fbmuckctl"
+
+ doinitd "${FILESDIR}/fbmuck"
+
+ insinto /etc
+ doins "${FILESDIR}/fbmucks"
+
+ dodoc src/CHANGESfb6 INSTALLATION README
+}