# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gtk-xfce-engine
pkgver=3.2.0
pkgrel=2
pkgdesc="Xfce theme engine"
url="https://xfce.org/"
arch="all"
license="GPL-2.0"
makedepends="gtk+2.0-dev gtk+3.0-dev"
source="http://archive.xfce.org/src/xfce/gtk-xfce-engine/${pkgver%.*}/gtk-xfce-engine-$pkgver.tar.bz2
fix-utf8-codec-can-not-decode-byte.patch"
subpackages="gtk2-xfce-engine:_gtk2 gtk3-xfce-engine:_gtk3"

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

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libexecdir=/usr/lib \
		--localstatedir=/var \
		--disable-static \
		--enable-gtk3 \
		--enable-gtk2
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

_split() {
	local _ver=${1%.*}
	pkgdesc="$pkgdesc - ${_ver/-/ }"
	install_if="$pkgname=$pkgver-r$pkgrel ${1/-/+}"
	cd "$pkgdir"
	for dir in usr/lib/$1 usr/share/themes/*/$1; do
		mkdir -p "$subpkgdir"/${dir%/*}
		mv $dir "$subpkgdir"/${dir%/*}
	done
}

_gtk2() { _split gtk-2.0; }
_gtk3() { _split gtk-3.0; }

sha512sums="c965e597c1b4aa04f3b474f3c4cea249aa6e753be697d5d3d7a19184adca650fc084f39acbd357f53eaf4180d96d5d3499866367e221ae445de4864fc9487012  gtk-xfce-engine-3.2.0.tar.bz2
2ab7d90f82bc9ec911ac18d6a6c676813038076b9f140e00c24e235f54c31d107d9ef2ef28f5e9f4b3f8de0e56ccab5b73ba691d98441ddb55c3bb3748813897  fix-utf8-codec-can-not-decode-byte.patch"
