# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: AndyRTR <andyrtr@archlinux.org>

pkgname=lpsolve
_origname=lp_solve
pkgver=5.5.2.11
_mainver=5.5
pkgrel=3
pkgdesc="a Mixed Integer Linear Programming (MILP) solver"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="http://lpsolve.sourceforge.net/" # no https
license=('LGPL-2.1-or-later'
         'GPL-2.0-or-later WITH Bison-exception-2.2'
         'BSD-3-Clause')
depends=('glibc')
source=(https://downloads.sourceforge.net/project/lpsolve/lpsolve/${pkgver}/lp_solve_${pkgver}_source.tar.gz
        lpsolve-5.5.2.11-misc.patch)
sha256sums=('6d4abff5cc6aaa933ae8e6c17a226df0fc0b671c438f69715d41d09fe81f902f'
            'ac1fc22a94318189c53c83fd728bd2a6c97ae2680308a852880842f78a0536c5')

prepare() {
  cd ${_origname}_${_mainver}
  # Gentoo patch to fix build and include flags fixes
  patch -Np1 -i "$srcdir"/lpsolve-5.5.2.11-misc.patch
}

build() {
  cd ${_origname}_${_mainver}

  # taken from Fedora spec
  cd lpsolve55
  sh -x ccc
  rm bin/ux*/liblpsolve55.a

  cd ../lp_solve
  sh -x ccc
}

package() {
  cd ${_origname}_${_mainver}

  install -dm755 "${pkgdir}"/usr/{bin,lib,include/lpsolve}
  install -m755 lp_solve/bin/ux*/lp_solve "${pkgdir}"/usr/bin/
  install -m755 lpsolve55/bin/ux*/liblpsolve55.so "${pkgdir}"/usr/lib/
  install -m644 lp*.h "${pkgdir}"/usr/include/lpsolve/

  install -D -m644 README.txt -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
