# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Jachym Barvinek <jachymb@gmail.com>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: John Proctor <jproctor@prium.net>
# Contributor: Juergen Hoetzel <juergen@archlinux.org>

pkgname=swi-prolog
pkgver=8.0.3
pkgrel=2
pkgdesc='Prolog environment'
arch=('x86_64')
url='https://www.swi-prolog.org/'
license=(GPL LGPL)
depends=(libarchive libyaml qt5-base)
makedepends=(cmake jdk-openjdk junit libjpeg libxft libxinerama libxpm ninja unixodbc)
optdepends=('unixodbc:     for using the odbc4pl library'
            'libjpeg:      for using the pl2xpce library'
            'libxpm:       for using the pl2xpce library'
            'libxinerama:  for using the pl2xpce library'
            'libxft:       for using the pl2xpce library'
            'jdk-openjdk:  for using Prolog from Java'
            'java-runtime: for using Prolog from Java')
source=("https://www.swi-prolog.org/download/stable/src/swipl-$pkgver.tar.gz")
sha256sums=('cee59c0a477c8166d722703f6e52f962028f3ac43a5f41240ecb45dbdbe2d6ae')

build() {
  mkdir -p build
  cd build
  cmake ../swipl-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_C_FLAGS="$CFLAGS -fPIC -ffile-prefix-map=$PWD= -w" \
    -DLIBEDIT_LIBRARIES=/usr/lib/libedit.so.0 \
    -DLIBEDIT_INCLUDE_DIR=/usr/include \
    -G Ninja
  ../swipl-$pkgver/scripts/pgo-compile.sh
  ninja
}

check() {
  cd build
  # the prolog_in_java test fails
  ctest -j 8 || true
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
}

# getver: www.swi-prolog.org/download/stable
# vim: ts=2 sw=2 et:
