# Template file for 'quickjs'
pkgname=quickjs
version=2024.01.13
revision=1
build_style=gnu-makefile
make_use_env=true
make_build_args="CONFIG_LTO="
short_desc="Small and embeddable Javascript engine"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="MIT"
homepage="https://bellard.org/quickjs/"
distfiles="https://bellard.org/quickjs/quickjs-${version//./-}.tar.xz"
checksum=3c4bf8f895bfa54beb486c8d1218112771ecfc5ac3be1036851ef41568212e03

if [ "$CROSS_BUILD" ]; then
	make_build_args+=" CROSS_PREFIX=${XBPS_CROSS_TRIPLET}-"
fi
make_install_args="${make_build_args}"

pre_configure() {
	vsed -i -e 's|%s/lib/quickjs|%s/lib|' qjsc.c
	cat >>Makefile <<EOF
CFLAGS += ${CFLAGS}
LDFLAGS += ${LDFLAGS}
BUILD_CFLAGS += \$(DEFINES) ${BUILD_CFLAGS}
EOF
}

post_install() {
	mv ${DESTDIR}/usr/lib/quickjs/* ${DESTDIR}/usr/lib
	vlicense LICENSE
}

quickjs-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/bin/qjsc
		vmove usr/include
		vmove usr/lib/*.a
	}
}
