# Template file for 'python-sip'
pkgname=python-sip
version=4.16.2
revision=2
wrksrc="sip-${version}"
maintainer="Dominik Honnef <dominik@honnef.co>"
hostmakedepends="python-devel python3.4-devel"
makedepends="${hostmakedepends}"
depends="python"
license="GPL"
homepage="http://www.riverbankcomputing.co.uk/software/sip/intro"
short_desc="Python extension module generator for C and C++ libraries"
distfiles="http://sourceforge.net/projects/pyqt/files/sip/sip-4.16.2/sip-4.16.2.tar.gz"
checksum=a55a2324a46ab42e42ae57c52ef06583b17d25c987973fe2e7ff2e8a649294ce

_do_sip_build() {
	local v=$1 suffix=$2

	python${v} configure.py  \
		--bindir="/usr/bin" \
		--sipdir="/usr/share/sip${v}" \
		--destdir="/usr/lib/python${v}/site-packages" \
		--incdir="/usr/include/python${v}${suffix}" \
		INCDIR="${XBPS_CROSS_BASE}/usr/include/python${v}${suffix}" \
		CC="${CC}" \
		CFLAGS="${CFLAGS}" \
		CXX="${CXX}" \
		CXXFLAGS="${CXXFLAGS}" \
		LINK="${CXX}" \
		LINK_SHLIB="${CXX}" \
		LFLAGS="${LDFLAGS}" \
		STRIP=""

	make $makejobs
	make DESTDIR=${DESTDIR} install
	mv ${DESTDIR}/usr/bin/sip ${DESTDIR}/usr/bin/sip${v}
}

do_build() {
	_do_sip_build 2.7
	_do_sip_build 3.4 "m"
}

do_install() {
	ln -s /usr/bin/sip2.7 ${DESTDIR}/usr/bin/sip
}

python3.4-sip_package() {
	depends="python3.4"
	pkg_install() {
		sed -i -e "s|'/usr/bin/sip'|'/usr/bin/sip3.4'|g" ${DESTDIR}/usr/lib/python3.4/site-packages/sipconfig.py
		mkdir -p ${PKGDESTDIR}/usr/{lib,bin,include}
		mv ${DESTDIR}/usr/bin/sip3.4 ${PKGDESTDIR}/usr/bin/
		mv ${DESTDIR}/usr/lib/python3.4 ${PKGDESTDIR}/usr/lib/
		mv ${DESTDIR}/usr/include/python3.4m ${PKGDESTDIR}/usr/include/
	}
}
