summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aae5d72e739aecc18ea553a74a0e7ef62e1d0686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Maintainer: Nomeji <nomeji@emersion.fr>

_emulator=mame
_libretro_pkg=libretro-mame-git

pkgname=kodi-addon-game-libretro-$_emulator-git
pkgver=r33.d0a07d7
pkgrel=1
pkgdesc="MAME for Kodi"
arch=('armv7h' 'x86_64')
url="https://github.com/kodi-game/game.libretro.$_emulator"
license=('GPL')
groups=('kodi-addons')
depends=('kodi-platform' 'kodi-addon-game-libretro' "$_libretro_pkg")
makedepends=('git' 'cmake' 'kodi-dev')
source=("$pkgname::git+https://github.com/kodi-game/game.libretro.$_emulator.git#branch=master")
sha256sums=('SKIP')

pkgver() {
	cd "$pkgname"
	_revision=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)")
	echo "$_revision"
}

_get_libretro_so() {
	pacman -Ql $_libretro_pkg | grep '_libretro.so' | head -1 | cut -d' ' -f2
}

prepare() {
	[[ -d kodi-addons-build ]] && rm -rf kodi-addons-build
	mkdir kodi-addons-build

	# Generate cmake config for libretro emulator

	_lib=$(echo ${_emulator}_LIB | tr 'a-z' 'A-Z')
	_so=$(_get_libretro_so)
	echo "set($_lib $_so)" > libretro-$_emulator-config.cmake 
}

build() {
	cd kodi-addons-build
	cmake \
		-DCMAKE_PREFIX_PATH="../" \
		-DCMAKE_INSTALL_PREFIX=/usr/share/kodi/addons/ \
		-DCMAKE_BUILD_TYPE=Release \
		-DPACKAGE_ZIP=1 \
		"../$pkgname"
	make
}

package() {
	cd kodi-addons-build
	make DESTDIR="$pkgdir/" install

	# Override the copy to use a symlink
	_so=$(_get_libretro_so)
	rm -f "$pkgdir/usr/share/kodi/addons/game.libretro.$_emulator/game.libretro.$_emulator.so"
	ln -s "$_so" "$pkgdir/usr/share/kodi/addons/game.libretro.$_emulator/game.libretro.$_emulator.so"
}