# Template file for 'MonkeysAudio'
pkgname=MonkeysAudio
version=5.28
revision=3
create_wrksrc=yes
build_style="gnu-makefile"
depends="libMAC>=${version}_${revision}"
short_desc="Fast and powerful lossless audio (de)compressor"
maintainer="Orphaned <orphan@voidlinux.org>"
license="custom:MIT-like"
homepage="https://monkeysaudio.com/"
distfiles="https://monkeysaudio.com/files/MAC_SDK_${version//./}.zip
 https://monkeysaudio.com/license.html"
checksum="0000cbfad5f008014bf3d963b72039c518a1e93ded55b23da715d912c830623e
 7d60dabaf760f32180e272b5955d5f1a2febcf9930eff13e49a1934a286a5819"
skip_extraction="license.html"

do_build() {
	cp -p ${XBPS_SRCDISTDIR}/${pkgname}-${version}/license.html ${wrksrc}
	ln Source/Projects/NonWindows/Makefile .
	vsed -i Makefile \
		-e "s;^VERSION.*;VERSION = 6.0.0;" \
		-e "s;^DLLLDOPTS.*;DLLLDOPTS = -shared -Wl,-soname,libMAC.so.6;"
	make ${makejobs}
}

do_install() {
	make prefix="${DESTDIR}"/usr install
	ln -s libMAC.so.6.0.0 "${DESTDIR}"/usr/lib/libMAC.so.6.0
	ln -s libMAC.so.6.0.0 "${DESTDIR}"/usr/lib/libMAC.so.6

	vmkdir usr/lib/pkgconfig
	sed ${FILESDIR}/MAC.pc \
		-e "s;%VER%;${version};" \
		-e "s;%REL%;${revision};" \
		> ${DESTDIR}/usr/lib/pkgconfig/MAC.pc

	vlicense license.html
	vdoc Readme.txt
}

libMAC-devel_package() {
	short_desc+=" - development files"
	depends="libMAC>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/lib/libMAC.so
	}
}

libMAC_package() {
	short_desc+=" - library"
	pkg_install() {
		vmove "usr/lib/libMAC.so.*"
	}
}
