# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py-gobject3
pkgver=3.24.1
pkgrel=2
pkgdesc="Python bindings for the GObject library"
url="http://www.pygtk.org/"
arch="all"
license="GPL"
makedepends="python2-dev python3-dev py2-cairo-dev py3-cairo-dev gobject-introspection-dev
	libffi-dev glib-dev gnome-common autoconf automake libtool"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3 $pkgname-dev"
source="https://download.gnome.org/sources/pygobject/${pkgver%.*}/pygobject-$pkgver.tar.xz"
builddir="$srcdir"/pygobject-$pkgver

prepare() {
	default_prepare
	aclocal
	cp -r "$builddir" "$srcdir"/python2
	cp -r "$builddir" "$srcdir"/python3
}

build()	{
	_build python2
	_build python3
}

package() {
	mkdir -p "$pkgdir"
}

_build() {
	local python="$1"
	export PYTHON=$python
	cd "$srcdir"/$python
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-compile-warnings=minimum
	make
}

_py2() {
	depends="py2-cairo"
	_py python2
}

_py3() {
	depends="py3-cairo"
	_py python3
}

_py() {
	local python="$1"
	pkgdesc="$pkgdesc (for $python)"
	install_if="$pkgname=$pkgver-r$pkgrel $python"
	cd "$srcdir/$python"
	make DESTDIR="$pkgdir" install
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/${python}.* "$subpkgdir"/usr/lib/
}

sha512sums="f35968ab12b872c85af6b2410cadedcf9fa7e17352a40f3dc557c86203aa1c38753710aab9ce55e986ee2c98b64e14123c65083655445e993d0b53431db6dc93  pygobject-3.24.1.tar.xz"
