# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=vdr
pkgver=2.3.8
pkgrel=3
pkgdesc="Video Disk Recorder"
url="http://www.tvdr.de/"
arch="all"
license="GPL-2.0"
depends=""
depends_dev="libexecinfo-dev fontconfig-dev freetype-dev gettext-dev libjpeg-turbo-dev fribidi-dev
	libcap-dev alsa-lib-dev libvdpau-dev libva-dev libx11-dev xcb-util-dev xcb-util-wm-dev
	ffmpeg-dev libcdio-dev mpv"
makedepends="$depends_dev coreutils"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang $pkgname-softhddevice $pkgname-femon $pkgname-mpv"
options="!check"

_femon_ver=28e4fb8de8578a1b8a36eb38d2e710dc60be7e3f
_softhddevice_ver=4e5da1ac3df6b7c387e1bf666327d2cd3f807048
_mpv_ver=87543f7058b88a3ace8550551bb3982cc304720e
_vnsiserver_ver=02f1631e482002da38f4df4d067cfe2e4c44d255
_streamdev_ver=e2a9b979d3fb92967c7a6a8221e674eb7e55c813

source="ftp://ftp.tvdr.de/vdr/Developer/vdr-${pkgver}.tar.bz2
	vdr-plugin-femon-${_femon_ver}.tar.gz::https://github.com/rofafor/vdr-plugin-femon/archive/${_femon_ver}.tar.gz
	vdr-plugin-softhddevice-${_softhddevice_ver}.tar.gz::https://github.com/rofafor/vdr-plugin-softhddevice/archive/${_softhddevice_ver}.tar.gz
	vdr-plugin-mpv-${_mpv_ver}.tar.gz::https://github.com/chriszero/vdr-plugin-mpv/archive/${_mpv_ver}.tar.gz
	vdr-plugin-vnsiserver-${_vnsiserver_ver}.tar.gz::https://github.com/FernetMenta/vdr-plugin-vnsiserver/archive/${_vnsiserver_ver}.tar.gz
	vdr-plugin-streamdev-${_streamdev_ver}.tar.gz::https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git/snapshot/vdr-plugin-streamdev-${_streamdev_ver}.tar.gz
	musl-compat.patch
	softhddevice-musl.patch
	Make.config
	include-missing-limits-ppc64le.patch"

builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	rm -rf ${builddir}/PLUGINS/src/skincurses
	cp -aP $srcdir/vdr-plugin-femon-${_femon_ver} ${builddir}/PLUGINS/src/femon
	cp -aP $srcdir/vdr-plugin-softhddevice-${_softhddevice_ver} ${builddir}/PLUGINS/src/softhddevice
	cp -aP $srcdir/vdr-plugin-mpv-${_mpv_ver} ${builddir}/PLUGINS/src/mpv
	cp -aP $srcdir/vdr-plugin-vnsiserver-${_vnsiserver_ver} ${builddir}/PLUGINS/src/vnsiserver
	cp -aP $srcdir/vdr-plugin-streamdev-${_streamdev_ver} ${builddir}/PLUGINS/src/streamdev
	cd "$builddir"
	default_prepare
}

build() {
	cd "$builddir"
	cp $srcdir/Make.config $builddir
	make
}

softhddevice() {
	depends="${pkgname}=$pkgver-r$pkgrel"
	cd "$pkgdir"
	mkdir -p ${subpkgdir}/usr/lib/vdr
	mv usr/lib/vdr/lib${subpkgname}.so.${pkgver} ${subpkgdir}/usr/lib/vdr
}

femon() {
	depends="${pkgname}=$pkgver-r$pkgrel"
	cd "$pkgdir"
	mkdir -p ${subpkgdir}/usr/lib/vdr
	mv usr/lib/vdr/lib${subpkgname}.so.${pkgver} ${subpkgdir}/usr/lib/vdr
}

mpv() {
	depends="${pkgname}=$pkgver-r$pkgrel"
	cd "$pkgdir"
	mkdir -p ${subpkgdir}/usr/lib/vdr
	mv usr/lib/vdr/lib${subpkgname}.so.${pkgver} ${subpkgdir}/usr/lib/vdr
}

vnsiserver() {
	depends="${pkgname}=$pkgver-r$pkgrel"
	cd "$pkgdir"
	mkdir -p ${subpkgdir}/usr/lib/vdr
	mv usr/lib/vdr/lib${subpkgname}.so.${pkgver} ${subpkgdir}/usr/lib/vdr
}

streamdev() {
	depends="${pkgname}=$pkgver-r$pkgrel"
	cd "$pkgdir"
	mkdir -p ${subpkgdir}/usr/lib/vdr
	mv lib${subpkgname}-server.so.${pkgver} ${subpkgdir}/usr/lib/vdr
	mv lib${subpkgname}-client.so.${pkgver} ${subpkgdir}/usr/lib/vdr
}

package() {
	cd "$builddir"
	make -j1 DESTDIR="$pkgdir" install
}
sha512sums="9dd8d90b365c255bfdf334f6f20a65671dbaf02da68dffdba003fe59243fc0636213b9df47bd6d350046fe4c6b3cb7568f2d9fd5ccdbff534328bc82e5a18d0b  vdr-2.3.8.tar.bz2
4f09246b0293617ee959ea768f215724c3996e10d7ee09399ce7c571d30e34da062df84d44465142261ea06069b09bac8b4a683a8dee54713385cc73f485c426  vdr-plugin-femon-28e4fb8de8578a1b8a36eb38d2e710dc60be7e3f.tar.gz
bf8ee08c8b61ae5acf13b8b50c12f4022347960adb94cb5c7b4a477866b7241bc9e2b8496d5a0ffe702df0cd825d2c5dc0ee6a11b3c75cd3628d76692c199610  vdr-plugin-softhddevice-4e5da1ac3df6b7c387e1bf666327d2cd3f807048.tar.gz
a9047da75cc11e675123d418c15a9712ac019658836630c7949699e39a0ade555dd2d52845abffd2cce0857e2c810f4bb5a7bf8b80dbc1a3c1b75002392dece3  vdr-plugin-mpv-87543f7058b88a3ace8550551bb3982cc304720e.tar.gz
49bde576df4266d1c27d2372cf81739faccd106a50cd236970fd7fc438b5daf6a42689bfba3bb0066e18fc0a64bcae602fb1f438173029dfc28178d5e9a15707  vdr-plugin-vnsiserver-02f1631e482002da38f4df4d067cfe2e4c44d255.tar.gz
4bd1cb3115ec6d9e91b1ff38f761fb7cd95d314f96ec00e619a993afc8422f2dc5b30f2638e9fbf27afe20fbd9597318aa8e347efca29d4cabeff7e2e4f3c25c  vdr-plugin-streamdev-e2a9b979d3fb92967c7a6a8221e674eb7e55c813.tar.gz
f47461445515e44f5cdb9c6d3b1bcae323bb83ba3de7c77a3be4d9ac99ed9e76ebe2ee720660c5593fa4b6995366b9d98bf1683f7b8786518a444de7754731ca  musl-compat.patch
c6f89ba45bf02c0d85963797ff579f3ae0616a827f2b883685b44241bddea7916c3d6da21790553d161884c39d12ee21fc10f7d9d5aee9767cdde10cde02baac  softhddevice-musl.patch
0add913727ebc2ab290211354e2310573f7ece14fcad8636b0a1d7cff49e32027e2d5a6aab3050e577f62387efff8aecc73dfc16e0f876ae28c5257fc9b6c67f  Make.config
b77b705601f583eda11f72d9f5e55f5d9af447f4a0d5d80c01dc10cbb4a5e3c3a1c457cd07f276dbcd907b321e607fec26efdae79bc3bddc7d89184edf7febfc  include-missing-limits-ppc64le.patch"
