# Template file for 'mpg123-extras'
# Sync with mpg123
pkgname=mpg123-extras
version=1.33.5
revision=2
build_style=gnu-configure
# --with-cpu not necessary, upstream detects features correctly
# --with-optimization=0 makes the configure script respect xbps-src's defaults.
configure_args="--with-optimization=0 --with-default-audio=alsa"
hostmakedepends="pkg-config"
makedepends="alsa-lib-devel SDL2-devel jack-devel pulseaudio-devel sndio-devel"
depends="mpg123-sdl mpg123-jack mpg123-pulseaudio mpg123-sndio"
short_desc="Fast console MPEG audio decoder/player - extra plugins"
maintainer="Orphaned <orphan@voidlinux.org>"
license="LGPL-2.1-only"
homepage="https://www.mpg123.org/"
changelog="https://www.mpg123.de/trunk/NEWS"
distfiles="https://www.mpg123.org/download/mpg123-${version}.tar.bz2"
checksum=0d7ebc8da0aff3ca383c8c6b5a6adbe402ee5bb256685b8c5499f3a739f9d6dd

# Restrict extras to the same matching version, ignore revision
_depends="libmpg123>=${version}_1<=${version}_9999"

if [ "$XBPS_TARGET_LIBC" = musl ]; then
	configure_args+=" --disable-lfs-alias"
fi

post_install() {
	# Prune everything except the plugins that will be installed
	find ${DESTDIR} \
		'(' -name output_sdl.so \
			-o -name output_jack.so \
			-o -name output_pulse.so \
			-o -name output_sndio.so \
		')' -o '(' -not -type d -delete ')'

	# Main package cannot be empty
	vdoc README
}

mpg123-sdl_package() {
	depends="${_depends}"
	short_desc="${short_desc%% - *} - SDL output plugin"
	pkg_install() {
		vmove usr/lib/mpg123/output_sdl.so
	}
}

mpg123-jack_package() {
	depends="${_depends}"
	short_desc="${short_desc%% - *} - JACK output plugin"
	pkg_install() {
		vmove usr/lib/mpg123/output_jack.so
	}
}

mpg123-pulseaudio_package() {
	depends="${_depends}"
	short_desc="${short_desc%% - *} - Pulseaudio output plugin"
	pkg_install() {
		vmove usr/lib/mpg123/output_pulse.so
	}
}

mpg123-sndio_package() {
	depends="${_depends}"
	short_desc="${short_desc%% - *} - sndio output plugin"
	pkg_install() {
		vmove usr/lib/mpg123/output_sndio.so
	}
}
