# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - remove makedepends on pandoc

pkgname=owl-lisp
pkgver=0.1.23
pkgrel=1
pkgdesc='Simple purely functional lisp'
url='https://gitlab.com/owl-lisp/owl.git'
arch=('x86_64')
license=('MIT')
depends=('glibc')
source=(https://gitlab.com/owl-lisp/owl/-/archive/v${pkgver}/owl-v${pkgver}.tar.gz)
sha256sums=('2db71a8f654960e6af055ca20ef8ec71d607bd6b677b04b4ca8632681165894b')
b2sums=('31dcc981471365a0957ccdf36a96a1f59647686964ee8d46ebe33a66d8db9ad1d3554b77d12796f11874e01f6e4f59e90f63458ed3ebdca9f99c0f5efeda3b7e')

prepare() {
  cd owl-v${pkgver}

  # support distro CFLAGS and CPPFLAGS
  sed -e '/export CFLAGS/d' -e '/CFLAGS =/d' \
      -e 's|$(CFLAGS)|$(CFLAGS) $(CPPFLAGS)|g' -i Makefile

  # make build reproducible, we compress ourselves
  sed -e 's|gzip -9|@echo|g' -e 's|\.gz||g' -i Makefile

  # fix missing Makefile entry
  sed 's|manual.md:|manual.md: bin/ol|' -i Makefile

  # remove failing tests (can't run inside makepkg)
  rm tests/getpid.sh
}

build() {
  cd owl-v${pkgver}
  make owl documentation
}

check() {
  cd owl-v${pkgver}
  make -j1 test fasltest
}

package() {
  cd owl-v${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 fasl/* -t "${pkgdir}/var/lib/${pkgname}/fasl"
  install -Dm 644 LICENCE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md doc/manual.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et: