# Template file for 'scratch'
pkgname=scratch
version=1.4.0.7
revision=2
build_style=gnu-makefile
hostmakedepends="pkg-config"
makedepends="squeak pango-devel shared-mime-info desktop-file-utils gtk-update-icon-cache"
depends="${makedepends/pango-devel/}"
short_desc="Create and share your own interactive stories, games, music and art"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only, MIT"
homepage="http://scratch.mit.edu"
distfiles="http://download.scratch.mit.edu/${pkgname}-${version}.src.tar.gz"
checksum=b94d89278ecef2ba2d1147eec23936dd99697293ffa2c216c0a375ba98226a3e

post_patch() {
	sed -n -e '/Author:/,/IN THE SOFTWARE/p' \
		src/plugins/wedo/WeDoLinux.c >LICENSE.MIT
	find . -name Makefile -exec \
		sed -i -e '
			/gcc.*CFLAGS/s/gcc/$(CC) $(CPPFLAGS)/
			/gcc -shared/s/gcc/$(CC) $(LDFLAGS)/
			' {} +
}

do_install() {
	vbin src/scratch
	vinstall Scratch.image 644 usr/lib/scratch
	vinstall Scratch.ini 644 usr/lib/scratch
	vinstall src/scratch.desktop 644 usr/share/applications
	vman src/man/scratch.1.gz
	vinstall src/scratch.xml 644 usr/share/mime/packages
	install -dm755 ${DESTDIR}/usr/share/{scratch,icons/hicolor}

	cp -rp Help locale Media Projects README ${DESTDIR}/usr/share/scratch
	cp -rp Plugins ${DESTDIR}/usr/lib/scratch

	for res in 32 48 128; do
	install -D -m644 src/icons/${res}x${res}/scratch.png \
		${DESTDIR}/usr/share/icons/hicolor/${res}x${res}/apps/scratch.png
	done
	vlicense NOTICE
	vlicense LICENSE.MIT
}
