# Template file for 'python-dbus'
pkgname=python-dbus
version=1.2.0
revision=4
lib32disabled=yes
wrksrc="dbus-python-${version}"
build_style=gnu-configure
hostmakedepends="pkg-config python-devel python3.4-devel"
makedepends="glib-devel dbus-glib-devel ${hostmakedepends/pkg-config/}"
depends="python"
replaces="dbus-python>=0"
pycompile_module="dbus"
short_desc="D-Bus Python2 bindings"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2, LGPL-2.1"
homepage="http://www.freedesktop.org/wiki/Software/DBusBindings"
distfiles="http://dbus.freedesktop.org/releases/dbus-python/dbus-python-${version}.tar.gz"
checksum=e12c6c8b2bf3a9302f75166952cbe41d6b38c3441bbc6767dbd498942316c6df

do_configure() {
	if [ "$CROSS_BUILD" ]; then
		ln -s ${wrksrc}/.xbps/bin/python-config ${wrksrc}
	fi

	# python2
	mkdir ${wrksrc}/build-python2
	cd ${wrksrc}/build-python2
	env PYTHON=python ../configure ${configure_args}

	# python3.4
	mkdir ${wrksrc}/build-python3.4
	cd ${wrksrc}/build-python3.4
	env PYTHON=python3.4 ../configure ${configure_args}
}

do_build() {
	# python2
	cd ${wrksrc}/build-python2
	make ${makejobs}

	# python3.4
	cd ${wrksrc}/build-python3.4
	make ${makejobs}
}

do_install() {
	# python2
	cd ${wrksrc}/build-python2
	make DESTDIR=${DESTDIR} install

	# python3.4
	cd ${wrksrc}/build-python3.4
	make DESTDIR=${DESTDIR} install
}

python3.4-dbus_package() {
	lib32disabled=yes
	depends="python3.4"
	replaces="dbus-python3>=0"
	short_desc="${short_desc/Python2/Python3.4}"
	pkg_install() {
		vmkdir usr/lib
		mv ${DESTDIR}/usr/lib/python3.4 ${PKGDESTDIR}/usr/lib
	}
}

python-dbus-devel_package() {
	lib32disabled=yes
	depends="python-devel python3.4-devel
		python-dbus>=${version}_${revision}
		python3.4-dbus>=${version}_${revision}"
	replaces="dbus-python-devel>=0"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/share/doc
	}
}
