# $Id: PKGBUILD 333528 2018-05-30 21:43:53Z arojas $
# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=palp
pkgver=2.1
pkgrel=2
pkgdesc="A Package for analyzing Lattice Polytopes"
arch=(x86_64)
url="http://hep.itp.tuwien.ac.at/~kreuzer/CY/CYpalp.html"
license=(GPL3)
depends=(glibc)
source=("http://hep.itp.tuwien.ac.at/~kreuzer/CY/$pkgname/$pkgname-$pkgver.tar.gz")
sha256sums=('3a3b7c746f92a74b91d47879de2bc14b8fda9a1e503f7fbc0f2f02571815fae8')

build() {
  cd $pkgname-$pkgver
  mkdir bin
  mv Global.h Global.h-template
  for dim in 4 5 6 11; do
    sed "s/^#define[^a-zA-Z]*POLY_Dmax.*/#define POLY_Dmax $dim/" Global.h-template > Global.h
    make
    for file in poly class cws nef mori; do
        mv ${file}.x bin/${file}-${dim}d.x
    done
  done
}

package() {
  cd $pkgname-$pkgver
  pushd bin
    for exe in *.x; do
	install -Dm755 $exe -t "$pkgdir"/usr/bin
    done
  popd
  for file in poly class cws nef mori; do
    ln -sf ${file}-6d.x "$pkgdir"/usr/bin/${file}.x
  done
}
