+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{8..13} )
+inherit python-single-r1
+
+DESCRIPTION="Tools to use with the Ipe drawing editor."
+HOMEPAGE="https://github.com/otfried/ipe-tools"
+SRC_URI="https://github.com/otfried/ipe-tools/archive/v${PV}.tar.gz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="+annotate +svgtoipe +figtoipe +ipe5toxml +pdftoipe"
+
+DEPEND="annotate? ( ${PYTHON_DEPS} dev-python/pypdf )
+ svgtoipe? ( !media-gfx/svgtoipe ${PYTHON_DEPS} )
+ figtoipe? ( !media-gfx/figtoipe sys-libs/zlib )
+ ipe5toxml? ( !media-gfx/ipe5toxml )
+ pdftoipe? ( !media-gfx/pdftoipe app-text/poppler )"
+RDEPEND="${DEPEND}"
+BDEPEND=""
+
+src_compile() {
+ # Tools with makefile
+ for tool in figtoipe ipe5toxml; do
+ if use ${tool}; then
+ cd ${tool}
+ emake
+ cd ..
+ fi
+ done
+
+ # Fixing python tool naming
+ use svgtoipe && mv svgtoipe/svgtoipe.py svgtoipe/svgtoipe
+ # File collision with annotate from media-libs/gd, hence suffix -ipe
+ use annotate && mv annotate/annotate.py annotate/annotate-ipe
+}
+
+src_install() {
+ exeinto /usr/bin/
+
+ for tool in svgtoipe figtoipe ipe5toxml; do
+ use ${tool} && doexe ${tool}/${tool}
+ use ${tool} && doman ${tool}/${tool}.1
+ done
+
+ use annotate && doexe annotate/annotate-ipe
+
+ # Fixing python tools
+ if use annotate || use svgtoipe; then
+ python_fix_shebang ${ED}/usr/bin
+ fi
+}