# Template file for 'ipe'
pkgname=ipe
version=7.1.7
revision=6
hostmakedepends="pkg-config git"
makedepends="qt-devel lua-devel libjpeg-turbo-devel cairo-devel poppler-devel"
short_desc="Drawing editor for creating figures in PDF or EPS formats"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="GPL-3, GPL-2"
homepage="http://ipe7.sourceforge.net/"
distfiles="https://github.com/otfried/${pkgname}/raw/master/releases/${version%.*}/${pkgname}-${version}-src.tar.gz"  
checksum=ec670cd7f0fa521271fc54bf9b663570d82280bdbe405be6de59535fec7c00d2

post_extract() {
	# ipe-tools
	local url="git://github.com/otfried/ipe-tools.git"
	msg_normal "Fetching source from ${url}...\n"
	git clone ${url} ipe-tools

	sed -i 's/xlocale.h/locale.h/g' src/ipelib/ipeplatform.cpp
	sed -i '/cstdio/i#include <sys/types.h>' src/include/ipebase.h
}

do_build() {
	make ${makejobs} -C src IPEPREFIX=/usr LUA_PACKAGE=lua
	make ${makejobs} -C ipe-tools/figtoipe
	make ${makejobs} -C ipe-tools/pdftoipe
}

do_install() {
	make -C src install IPEPREFIX=/usr LUA_PACKAGE=lua INSTALL_ROOT=${DESTDIR}
	vbin ipe-tools/figtoipe/figtoipe
	vbin ipe-tools/pdftoipe/pdftoipe
	vbin ipe-tools/svgtoipe/svgtoipe.py svgtoipe
}

ipe-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
		vmove "usr/share/ipe/$version/doc"
	}
}
