### this file is sourced not run
PKGVER=2021.03.27.2022 # patched up to Mar 2022
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=quickjs-2021-03-27.tar.xz
MD5SUM=135182a626aa0c87a49aa2bf58fd39bf
SRC_URL=https://bellard.org/quickjs/$TARBALL
BUNDLE=

SLACKREQ=
SLACKDESC="libquickjs: libquickjs $PKGVER (Javascript interpreter library)
libquickjs: 
libquickjs: QuickJS is a small and embeddable Javascript engine. It supports the 
libquickjs: ES2020 specification including modules, asynchronous generators, 
libquickjs: proxies and BigInt.
libquickjs:
libquickjs: This package only contains qjsc compiler and its header/libraries.
libquickjs: It does not come with the interpreter, examples and documentation.
libquickjs: 
libquickjs: https://bellard.org/quickjs/
libquickjs: https://github.com/bellard/quickjs
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/quickjs* &&
	
	# apply upstream patches
	patch -Np1 -i ../pkg/upstream/fixed-invalid-array-prototype-b9f58802dc8d3e6d8dfb65434dee63c7611c05e8.patch &&
	patch -Np1 -i ../pkg/upstream/added-object-hasown-446099aa9ebd7fcd54d3fdc6f6b25ee8c8c97a7d.patch &&
	patch -Np1 -i ../pkg/upstream/test262-851695958a224decffa65ea0c8b6622d19a971ba.patch &&

	true
}

### default pkg_package

### build
pkg_build() {
	cd /tmp/quickjs* &&
	
	sed -i -e "s|/lib/quickjs|/$LIBDIR/quickjs|" Makefile &&
	make prefix=/usr && make prefix=/usr install &&

	# remove interpreter
	rm -f /usr/bin/{qjs,qjscalc} &&
	
	pkg_build_slackdesc
}
