#Packager: Dimitris Tzemos <dijemos@gmail.com>

pkgname=mpd
pkgver=0.23.16
pkgrel=1dj
source=("https://www.musicpd.org/download/${pkgname}/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz"
        'mpd-initial.sh')
docs=("readme" "install" "copying" "upgrading" "authors" "news")
url='http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki'

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (The Music Player Daemon)"
"Music Player Daemon (MPD) allows remote access for playing music"
"(MP3, Ogg Vorbis, FLAC, AAC, Mod, and wave files) and managing"
"playlists. MPD is designed for integrating a computer into a stereo"
"system that provides control for music playback over a local network."
"It also makes a great desktop music player, especially if you are a"
"console junkie, like frontend options, or restart X often."
""
"You can use \"mpd-initial.sh\" to setup mpd for your user."
)


build() {
    set -e
	# undocumented, but allow disabling pulseaudio
	if [ "${PULSE:-yes}" = "yes" ]; then
		PULSE="enabled"
	else
		PULSE="disabled"
	fi
	
    cd $startdir/src/$pkgname-$pkgver/build
    CFLAGS="$SLKCFLAGS" \
	CXXFLAGS="$SLKCFLAGS" \
	LDFLAGS="-L/usr/lib${LIBDIRSUFFIX} -lnsl" \
		
	meson .. \
    -Dsystemd=disabled \
    -Dpulse=$PULSE \
    --buildtype=release \
    --infodir=/usr/info \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --localstatedir=/var \
    --mandir=/usr/man \
    --prefix=/usr \
    --sysconfdir=/etc
  ${NINJA:-ninja}
  
  DESTDIR=$PKG ninja install
	cd ..

	# Use sample config, without overwriting
	install -D -m 644 doc/mpdconf.example $PKG/etc/mpd.conf.new
	# 20200411 bkw: meson doesn't support --docdir
	mkdir -p $PKG/usr/doc/$pkgname-$pkgver
	mv $PKG/usr/share/doc/* $PKG/usr/doc/$pkgname-$pkgver
	rm -rf $PKG/usr/share/doc

    sed -e "s/@PKGVER@/$pkgver/" -i $startdir/src/mpd-initial.sh
    install -vD -m 755 $startdir/src/mpd-initial.sh $startdir/pkg/usr/bin/mpd-initial.sh

    set +e
}
