# Template file for 'flexprop'
pkgname=flexprop
version=5.2.0
revision=1
hostmakedepends="loadp2 which"
makedepends="tk-devel"
depends="loadp2 tk xterm"
short_desc="Simple GUI for creating applications on the Parallax Propeller 2"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://github.com/totalspectrum/flexprop/"
distfiles="https://github.com/totalspectrum/${pkgname}/archive/v${version}.tar.gz"
checksum=bc72b9cc0729869cc0c4d298606f9a8d0fe937f85e9d0ef3a352f4a577147680

do_build() {
	${CPP} -xc++ -I /usr/libexec/p2tools -DTCL_SRC < version.inp > src/version.tcl
}

do_install() {
	vinstall flexprop.tcl 755 usr/libexec/p2tools

	# Install a copy of the examples
	vcopy samples usr/libexec/p2tools

	# No need for flexprop.c which is a Windows source file
	rm -f src/flexprop.c

	# Install a copy of the tcl/tk source scripts
	vcopy src usr/libexec/p2tools

	# Create a wrapper script to run flexprop
	vmkdir usr/bin
	cat >${DESTDIR}/usr/bin/flexprop <<EOF
#!/bin/bash
# Wrapper to run flexprop.tcl
if [ ! -d "\$HOME/.local/share/p2tools" ]; then
	echo "Installing a copy of the examples in \$HOME/.local/share/p2tools ..."
	mkdir -p \$HOME/.local/share/p2tools
	cp -a /usr/libexec/p2tools/samples \$HOME/.local/share/p2tools
fi
cd \$HOME/.local/share/p2tools
export SOURCE=/usr/libexec/p2tools/src
exec /usr/bin/wish /usr/libexec/p2tools/flexprop.tcl
EOF
	chmod 755 ${DESTDIR}/usr/bin/flexprop
	vdoc doc/help.txt
	vlicense License.txt LICENSE
}
