# $Id$
# 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>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - build aarch64 with -fPIC

pkgname=swi-prolog
pkgver=7.6.1
pkgrel=1
pkgdesc='Prolog environment'
arch=('x86_64' 'i686')
url='http://www.swi-prolog.org/'
license=('GPL' 'LGPL')
depends=('gmp' 'libarchive' 'openssl' 'readline')
makedepends=('libjpeg' 'libxft' 'libxinerama' 'libxpm' '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')
source=("http://www.swi-prolog.org/download/stable/src/swipl-${pkgver/_/-}.tar.gz") # invalid HTTPS cert
sha256sums=('24ada4bd016189fd417592edf1ffc74e4e51ee4f47e569f97e2d11f4d8f89ec3')

build() {
  [[ $CARCH == "aarch64" ]] && CPPFLAGS+=" -fPIC"

  cd "swipl-${pkgver/_/-}"
  ./configure --prefix=/usr --with-world

  cd src
  ./configure --enable-readline --prefix=/usr

  make -C ..
}

check() {
  make -C "swipl-${pkgver/_/-}" check || true
}

package() {
  make -C "swipl-${pkgver/_/-}" DESTDIR="$pkgdir" install

  # Fix for FS#20873
  chmod +x "$pkgdir/usr/lib/swipl-${pkgver/_/-}/library/dialect/sicstus/swipl-lfr.pl"
}

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