# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Maintainer:
pkgname=cmus
pkgver=2.8.0_rc0
pkgrel=0
_ver=${pkgver/_rc/-rc}
pkgdesc="A very feature-rich ncurses-based music player"
url="http://cmus.sourceforge.net/"
arch="all"
license="GPL-2.0-or-later"
depends=""
depends_dev=""
makedepends="alsa-lib-dev faad2-dev flac-dev libmad-dev opusfile-dev
	libogg-dev libvorbis-dev ncurses-dev wavpack-dev ffmpeg-dev
	linux-headers"
install=""
subpackages="
	$pkgname-doc
	$pkgname-zsh-completion:zshcomp:noarch
	$pkgname-bash-completion:bashcomp:noarch"
source="$pkgname-$_ver.tar.gz::https://github.com/cmus/cmus/archive/v${_ver}.tar.gz"

builddir="$srcdir"/$pkgname-$_ver
build() {
	cd "$builddir"
	./configure prefix=/usr || return 1
	make || return 1
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install || return 1

	for file in AUTHORS README.md; do
		install -Dm644 "${file}" "$pkgdir"/usr/share/doc/$pkgname/ || return 1
	done
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/contrib/$pkgname.bash-completion \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

zshcomp() {
	depends=""
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	install -Dm644 "$builddir"/contrib/_$pkgname \
		"$subpkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="0379f18497d6510fad35a2d905c932d12f2726a5694d3ab272ce139e9ea4520cb4dd1cf3fafe890f6ada8a64285f8c04ef7571647a66c2d44df17e2dca80f869  cmus-2.8.0-rc0.tar.gz"
