# Template file for 'dash'
pkgname=dash
version=0.5.12
revision=2
build_style=gnu-configure
hostmakedepends="bison"
makedepends="libedit-devel"
short_desc="POSIX-compliant Unix shell, much smaller than GNU bash"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="BSD-3-Clause"
homepage="http://gondor.apana.org.au/~herbert/dash/"
distfiles="http://gondor.apana.org.au/~herbert/dash/files/$pkgname-$version.tar.gz"
checksum=6a474ac46e8b0b32916c4c60df694c82058d3297d8b385b74508030ca4a8f28a
register_shell="/usr/bin/sh /usr/bin/dash /bin/sh /bin/dash"

alternatives="
 sh:sh:/usr/bin/dash
 sh:sh.1:/usr/share/man/man1/dash.1"

build_options="static"

do_configure() {
	mkdir -p build-minimal build-libedit
	cd ${wrksrc}/build-minimal
	../configure ${configure_args} $(vopt_enable static) --without-libedit
	cd ${wrksrc}/build-libedit
	../configure ${configure_args} --with-libedit
}

do_build() {
	make -C build-minimal ${makejobs}
	make -C build-libedit ${makejobs}
}

do_check() {
	make -C build-minimal ${makejobs} check
	make -C build-libedit ${makejobs} check
}

do_install() {
	make -C build-minimal ${makejobs} install DESTDIR=${DESTDIR}
	vlicense COPYING
}

dash-libedit_package() {
	short_desc+=" - with libedit"
	register_shell="/usr/bin/sh /usr/bin/dash /bin/sh /bin/dash"
	alternatives="
	 sh:sh:/usr/bin/dash
	 sh:sh.1:/usr/share/man/man1/dash.1"
	provides="dash-${version}_${revision}"
	replaces="dash>=0"
	pkg_install() {
		make -C build-libedit ${makejobs} install DESTDIR=${PKGDESTDIR}
		vlicense COPYING
	}
 }
