# New ports collection makefile for:	Music Player Daemon
# Date created:				Thu Oct 02 2003
# Whom:					Mark Reidel <ports@mark.reidel.info>
#
# $FreeBSD: ports/audio/musicpd/Makefile,v 1.39 2008/12/05 21:18:03 danfe Exp $
#

PORTNAME=	musicpd
PORTVERSION=	0.13.2
CATEGORIES=	audio ipv6
MASTER_SITES=	http://musicpd.org/uploads/files/ \
		http://redundancy.redundancy.org/mirror/
MASTER_SITE_SUBDIR=	${PORTNAME}
DISTNAME=	mpd-${PORTVERSION}

MAINTAINER=	jo.lindqvist@gmail.com
COMMENT=	A remote-controllable music daemon

LIB_DEPENDS+=	mad.2:${PORTSDIR}/audio/libmad

USE_BZIP2=	yes
GNU_CONFIGURE=	yes
USE_RC_SUBR=	musicpd.sh
CONFIGURE_ENV=	CPPFLAGS="-I${LOCALBASE}/include" \
		LDFLAGS="-L${LOCALBASE}/lib"

CFLAGS+=	-I${PREFIX}/include

MAN1=		mpd.1
MAN5=		mpd.conf.5

DOCSDIR=	${PREFIX}/share/doc/mpd

SUB_FILES=	pkg-message

OPTIONS=	FLAC		"Support FLAC audio format"		on \
		VORBIS		"Support OGG Vorbis audio format"	on \
		TREMOR		"Support Tremor (integer-only Vorbis)"	off \
		WAV		"Support WAV audio format"		on \
		AAC		"Support MP4/AAC audio format"		off \
		MUSEPACK	"Support MPC audio format"		off \
		MOD		"Support MOD audio format"		off \
		ICONV		"Support international characters"	on \
	        ID3TAG		"Support id3v1 tag encoding"		off \
		IPV6		"Support IPv6 protocol"			on \
		AO		"Support libao audio library"		off \
		PULSEAUDIO	"Support PulseAudio sound server"	off \
		JACK		"Support JACK audio server"		off \
		SHOUTCAST	"Support for Icecast and Shoutcast"	off \
		SAMPLERATE	"Support sample rate conversion"	off

.include <bsd.port.pre.mk>

.if defined(WITHOUT_FLAC)
CONFIGURE_ARGS+=--disable-flac \
		--disable-oggflac
.else
LIB_DEPENDS+=	FLAC.10:${PORTSDIR}/audio/flac
.endif

.if defined(WITHOUT_VORBIS)
CONFIGURE_ARGS+=--disable-ogg
.else
LIB_DEPENDS+=	vorbis.4:${PORTSDIR}/audio/libvorbis
.endif

.if defined(WITH_TREMOR)
CONFIGURE_ARGS+=--with-tremor
LIB_DEPENDS+=	vorbisidec.1:${PORTSDIR}/audio/libtremor
.endif

.if defined(WITHOUT_WAV)
CONFIGURE_ARGS+=--disable-audiofile
.else
LIB_DEPENDS+=	audiofile.0:${PORTSDIR}/audio/libaudiofile
.endif

.if defined(WITH_AAC)
LIB_DEPENDS+=	faad.0:${PORTSDIR}/audio/faad
.else
CONFIGURE_ARGS+=--disable-aac
.endif

.if defined(WITH_MUSEPACK)
LIB_DEPENDS+=	mpcdec.5:${PORTSDIR}/audio/libmpcdec
.else
CONFIGURE_ARGS+=--disable-mpc
.endif

.if defined(WITH_MOD)
LIB_DEPENDS+=	mikmod.2:${PORTSDIR}/audio/libmikmod
.else
CONFIGURE_ARGS+=--disable-mod
.endif

.if defined(WITHOUT_ICONV)
CONFIGURE_ARGS+=--disable-iconv
.else
USE_ICONV=	yes
.endif

.if defined(WITH_ID3TAG)
LIB_DEPENDS+=	id3tag.0:${PORTSDIR}/audio/libid3tag
CONFIGURE_ARGS+=--enable-mpd-id3tag
.endif

.if defined(WITHOUT_IPV6)
CONFIGURE_ARGS+=--disable-ipv6
.endif

.if defined(WITH_AO)
CONFIGURE_ARGS+=--enable-ao
LIB_DEPENDS+=	ao.3:${PORTSDIR}/audio/libao
.endif

.if defined(WITH_PULSEAUDIO)
LIB_DEPENDS+=	pulse.0:${PORTSDIR}/audio/pulseaudio
.else
CONFIGURE_ARGS+=--disable-pulse
.endif

.if defined(WITH_JACK)
LIB_DEPENDS+=	jack.0:${PORTSDIR}/audio/jack
.else
CONFIGURE_ARGS+=--disable-jack
.endif

# libshout streaming support will be disabled by configure script when built
# also with tremor since the latter does not support vorbis encoding
.if defined(WITH_SHOUTCAST) && !defined(WITH_TREMOR)
LIB_DEPENDS+=	shout.5:${PORTSDIR}/audio/libshout2
.else
CONFIGURE_ARGS+=--disable-shout
.endif

.if defined(WITHOUT_SAMPLERATE)
CONFIGURE_ARGS+=--disable-lsr
.else
LIB_DEPENDS+=	samplerate.1:${PORTSDIR}/audio/libsamplerate
.endif

.if defined(NOPORTDOCS)
post-patch:
	@${REINPLACE_CMD} -e '/^install-data-am:/ s|install-docDATA||' \
		${WRKSRC}/Makefile.in ${WRKSRC}/doc/Makefile.in
.endif

post-install:
	@${ECHO_MSG}
	@${CAT} ${PKGMESSAGE}
	@${ECHO_MSG}

.include <bsd.port.post.mk>
