# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=mruby
pkgver=1.3.0
pkgrel=0
pkgdesc="Lightweight Ruby"
url="http://mruby.org"
arch="all"
license="MIT"
depends=""
makedepends="$depends_dev bison ruby"
subpackages="$pkgname-tools $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/mruby/mruby/archive/$pkgver.tar.gz
	build_config.rb"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	MRUBY_CONFIG="$srcdir/build_config.rb" ./minirake --verbose
}

package() {
	cd "$builddir"

	install -d "$pkgdir"/usr/bin
	cp build/host-debug/bin/* "$pkgdir"/usr/bin/ || return 1
	cp build/host/bin/* "$pkgdir"/usr/bin/ || return 1

	install -d "$pkgdir"/usr/lib
	cp build/host/lib/*.a "$pkgdir"/usr/lib/
}

tools() {
	pkgdesc="$pkgdesc (tools)"

	install -d "$subpkgdir"/usr/bin

	mv "$pkgdir"/usr/bin/* "$subpkgdir"/usr/bin/ \
		&& mv "$subpkgdir"/usr/bin/mruby "$pkgdir"/usr/bin/
}

sha512sums="13a57306706d2d60693151919ae15bb3621e6e7ed3b5e9c6d3b1c8d44e52b898c1ad394b39946d730ff82a19f5e3b7c2a374f9dcc3b6c6f990581e504f1cb9cb  mruby-1.3.0.tar.gz
9c51108d9766e3e3129ac89d76fc7dcc797b206bcc5660d60e89426adb93707fcf5acdffb24cd3438b3eabfcc02e3767a17e9233c25e0762ebe2ddab9f159252  build_config.rb"