abinfo "Building XHPAST ..."
php "$SRCDIR"/support/xhpast/build-xhpast.php
rm -v "$SRCDIR"/support/xhpast/*.o
rm -v "$SRCDIR"/support/xhpast/*.a
rm -v "$SRCDIR"/support/xhpast/xhpast

abinfo "Building PHP-Parser ..."
php -d extension=curl \
	"$SRCDIR"/support/php-parser/build-php-parser.php
rm -v "$SRCDIR"/support/php-parser/php-parser-*.tar.gz

abinfo "Liberating arcanist ..."
php -d extension=curl \
    "$SRCDIR"/bin/arc liberate \
	--alternative-parser

abinfo "Installing arcanist ..."
install -dvm755 "$PKGDIR"/usr/lib/arcanist
cp -vR "$SRCDIR"/{bin,externals,resources,scripts,src,support} "$PKGDIR"/usr/lib/arcanist/

abinfo "Installing binaries ..."
install -dvm755 "$PKGDIR"/usr/bin
ln -sv ../lib/arcanist/bin/arc "$PKGDIR"/usr/bin/arc
ln -sv ../lib/arcanist/bin/phage "$PKGDIR"/usr/bin/phage
ln -sv ../lib/arcanist/src/parser/xhpast/bin/xhpast "$PKGDIR"/usr/bin/xhpast

abinfo "Installing licenses ..."
install -dvm755 "$PKGDIR"/usr/share/doc/arcanist
cp -vR "$SRCDIR"/{LICENSE,NOTICE} "$PKGDIR"/usr/share/doc/arcanist/
