# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mplayer
pkgver=1.5.0_git20230717
pkgrel=1
# this is r38435 from svn
# the commit in the linked repo says which svn r it is, too.
_gitrev=8c62eea81f5959ad94de8506ec5b46f060fa237c
pkgdesc="Movie player for linux"
url="http://www.mplayerhq.hu/design7/news.html"
arch="x86_64 aarch64 armv7"
license="GPL-2.0-or-later"
subpackages="$pkgname-doc"
makedepends="
	alsa-lib-dev
	faac-dev
	ffmpeg-dev
	fontconfig-dev
	freetype-dev
	lame-dev
	libao-dev
	libcdio-paranoia-dev
	libdvdread-dev
	libmad-dev
	libpng-dev
	libtheora-dev
	libvdpau-dev
	libxv-dev
	libxvmc-dev
	libxxf86dga-dev
	mesa-dev
	nasm
	sdl2-dev
	x264-dev
	xvidcore-dev
	zlib-dev
	"
source="https://dev.alpinelinux.org/archive/mplayer/mplayer-$pkgver.tar.xz
	x11-libs.patch
	"
options="!check" # no tests

snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir"
	cd "$srcdir"
	git clone --filter=tree:0 https://git.mplayerhq.hu/mplayer .
	git archive --format tar --prefix=$pkgname-$pkgver/ $_gitrev > "$SRCDEST"/mplayer-$pkgver.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$pkgname-$pkgver.tar
	rsync --progress -La "$SRCDEST"/$pkgname-$pkgver.tar.xz dev.alpinelinux.org:/archive/mplayer/
}

build() {
	./configure \
		--prefix=/usr \
		--enable-runtime-cpudetection \
		--disable-gui \
		--disable-gif \
		--disable-arts \
		--enable-x11 \
		--confdir=/etc/mplayer \
		--disable-nas \
		--enable-gl \
		--disable-tv-v4l1 \
		--enable-tv-v4l2 \
		--disable-ffmpeg_a \
		--disable-liblzo \
		--disable-speex \
		--disable-openal \
		--disable-fribidi \
		--disable-libdv \
		--disable-musepack \
		--language=all \
		--disable-esd \
		--disable-mga \
		--disable-lirc \
		--enable-debug \
		--enable-radio \
		--enable-radio-capture \
		--extra-cflags="-O2 -fno-PIC -fno-PIE" \
		--extra-ldflags="-no-pie" \
		--disable-nemesi \
		--enable-freetype \
		--enable-xvmc \
		--yasm=nasm
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 etc/codecs.conf etc/input.conf etc/example.conf \
		"$pkgdir"/etc/mplayer/
}

sha512sums="
bea683c452452f1bf76fd28e9ad01b4586fed5f6502c476c631f246f613ecbcc601166247623a7de83a68818b5a4b03ed92a0e839d23a5377c86d8b714427a5e  mplayer-1.5.0_git20230717.tar.xz
bba012c5a116cbc6715955a0a563c89a33a1d8ad3c44301a083ce65296ba9112a88a58e38c874d9347f9c3133054e62bd16d3b3367383f207ee40ddae105081c  x11-libs.patch
"
