# $Id: PKGBUILD 307685 2018-03-14 11:15:42Z arodseth $
# Maintainer: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Daichi Shinozaki <dsdseg@gmail.com>
# Contributor: Andy Li <andy@onthewings.net>
# Contributor: Kyle Brady  <kyle at spark-gap dot com>
# Contributor: Patrick Hof <courts@offensivethinking.org>
# Contributor: Michael Fellinger <mf@rubyists.com>

pkgname=haxe
pkgver=3.4.7
pkgrel=1
pkgdesc='Cross-platform toolkit and programming language'
arch=('x86_64')
url='https://haxe.org/'
license=('GPL' 'MIT' 'LGPL')
groups=('devel')
depends=('neko')
optdepends=('python' 'php' 'java-environment' 'mono')
makedepends=('git' 'ocaml' 'camlp4' 'zlib' 'neko')
provides=('haxe' 'haxelib')
options=('!strip' '!makeflags')
source=("$pkgname-$pkgver::git+https://github.com/HaxeFoundation/haxe.git#tag=$pkgver"
        'haxe.sh')
md5sums=('SKIP'
         '977476c8fc1dfc0acbb05bd22f9136b0')

prepare() {
  cd "$pkgname-$pkgver"

  git submodule update --init --recursive
}

build() {
  # Needed to make Haxe build with OCaml 4.06
  # For more info, see: https://github.com/HaxeFoundation/haxe/issues/6883#issuecomment-370142073
  export OCAMLPARAM="safe-string=0,_"

  make -C "$pkgname-$pkgver" all tools
}

check() {
  "$pkgname-$pkgver/haxe" -version && "$pkgname-$pkgver/haxelib" version
}

package() {
  install -d "$pkgdir/usr/"{bin/,share/haxe/}
  install -m 755 "$srcdir/$pkgname-$pkgver"/{haxe,haxelib} "$pkgdir"/usr/bin/
  cp -rf "$srcdir/$pkgname-$pkgver/std" "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 "$srcdir/$pkgname-$pkgver"/extra/LICENSE.txt \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
  install -Dm 644 "$srcdir/haxe.sh" "$pkgdir/etc/profile.d/haxe.sh"
}

# vim: ts=2 sw=2 et:
