# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=mediainfo
pkgver=24.04
pkgrel=0
pkgdesc="Supplies technical and tag information about media files"
url="https://mediaarea.net/en/MediaInfo"
arch="all"
license="BSD-2-Clause"
makedepends="
	autoconf
	automake
	libmediainfo-dev~=${pkgver%.*}
	libtool
	libzen-dev
	wxwidgets-dev
	"
subpackages="$pkgname-gui"
source="https://mediaarea.net/download/source/mediainfo/$pkgver/mediainfo_$pkgver.tar.xz"
builddir="$srcdir/MediaInfo"
_clidir="$builddir/Project/GNU/CLI"
_guidir="$builddir/Project/GNU/GUI"

prepare() {
	default_prepare

	rm -Rf "$builddir"/Project/MS*

	cd "$_clidir"
	sh ./autogen.sh
	cd "$_guidir"
	sh ./autogen.sh
}

build() {
	export CFLAGS="$CFLAGS -flto=auto"
	export CXXFLAGS="$CXXFLAGS -flto=auto"

	cd "$_clidir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libdir=/usr/lib \
		--sysconfdir=/etc \
		--enable-static=no
	make
	cd "$_guidir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libdir=/usr/lib \
		--sysconfdir=/etc
	make
}

check() {
	cd "$_clidir"
	./mediainfo --version
}

package() {
	pkgdesc="$pkgdesc (CLI)"
	make -C "$_clidir" DESTDIR="$pkgdir" install
	make -C "$_guidir" DESTDIR="$pkgdir" install

	cd "$pkgdir"
	# legacy
	rm -r usr/share/pixmaps
	rm -r usr/share/kde4
}

gui() {
	pkgdesc="$pkgdesc (GUI)"

	amove \
		usr/bin/mediainfo-gui \
		usr/share
}

sha512sums="
8e3ee394786c142ec837a94f803f02da7f897bd22d20dc8c2d83c724338fb2d3120d00c2740640feb05313b08bf07c282ed6c562d15efad6dc95f9d4db42a40e  mediainfo_24.04.tar.xz
"
