# Depends on: autoconf2-13 icu libffi nspr python2 zip

description="JS is Mozilla's JavaScript engine written in C."
url="https://people.mozilla.org"
packager="tnut <tnut@nutyx.org>"

name=js38
version=38.2.1
release=3

source=(http://www.linuxfromscratch.org/patches/blfs/svn/js38-$version-upstream_fixes-2.patch
	 https://people.mozilla.org/~sstangl/mozjs-$version.rc0.tar.bz2)

build() {

  cd mozjs-38.0.0

  patch -Np1 -i ../js38-$version-upstream_fixes-2.patch

  cd js/src
  autoconf-2.13

  ./configure --prefix=/usr       \
              --with-intl-api     \
              --with-system-zlib  \
              --with-system-ffi   \
              --with-system-nspr  \
              --with-system-icu   \
              --enable-threadsafe \
              --enable-readline

  make

  make DESTDIR=$PKG install

  pushd $PKG/usr/include/mozjs-38
  for link in `find . -type l`
  do
    header=`readlink $link`
    rm -f $link
    cp -pv $header $link
    chmod 644 $link
  done
  popd
}
