NAME="js185"
VERSION=1.0.0
RELEASE=3
CATEGORY="Interpreters"
SUMMARY="Mozilla JavaScript engine"
DESCRIPTION="SpiderMonkey is Mozilla's JavaScript engine written in C/C++."
HOMEPAGE="http://www.mozilla.org/js/spidermonkey/"
SRC_URI="ftp://ftp.mozilla.org/pub/mozilla.org/js/${NAME}-${VERSION}.tar.gz"
SRC_DIR="js-1.8.5/js/src"
PATCH_URI="
	http://pkgs.fedoraproject.org/cgit/js.git/plain/js185-libedit.patch
	1.8.5-cygwin.patch
"

PKG_NAMES="libmozjs185_1.0 libmozjs185-devel"
libmozjs185_1_0_SUMMARY="${SUMMARY} (runtime)"
libmozjs185_1_0_CONTENTS="usr/bin/cygmozjs185-1.0.dll usr/share/doc/"
libmozjs185_devel_SUMMARY="${SUMMARY} (development)"
libmozjs185_devel_CONTENTS="usr/bin/js-config usr/include/ usr/lib/"

DIFF_EXCLUDES="configure"

src_compile() {
	cd ${S}
	autoconf-2.13 || error
	cd ${B}

	manifestize config/nsinstall.exe

	export ac_cv_have_systemtimetofiletime=no
	export ac_cv_have_getsystemtimeasfiletime=no
	# fix version in js-config and mozjs185.pc
	export MOZILLA_VERSION=1.8.5

	cygconf --enable-ctypes --enable-readline --enable-threadsafe --with-system-nspr
	cygmake
}

src_test() {
	cd ${B}
	./jsapi-tests/jsapi-tests || true
}

src_install() {
	cd ${B}
	cyginstall
#	newbin shell/js.exe js185.exe

	mv ${D}/usr/lib/*.dll ${D}/usr/bin/
	rm ${D}/usr/lib/libmozjs185-1.0.a
	mv ${D}/usr/lib/libmozjs185-1.0.dll.a ${D}/usr/lib/libmozjs185.dll.a
}
DOCS="../../README"
