# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: spider-mario <spidermario@free.fr>
# Contributor: Daniel Ehlers <danielehlers@mindeye.net>

pkgname=coin-or-clp
pkgver=1.17.11
pkgrel=2
pkgdesc='COIN-OR linear programming solver'
arch=(x86_64 aarch64)
url='https://github.com/coin-or/Clp'
license=(EPL-2.0)
groups=(coin-or)
depends=(coin-or-asl
         coin-or-coinutils
         coin-or-osi
         glibc
         libgcc
         libstdc++
         suitesparse)
makedepends=(git)
source=(git+https://github.com/coin-or/Clp#tag=releases/$pkgver
        fix-build.patch)
sha256sums=('315f15c1815f4fc19532a36d66f7c2ff91f1be197f2fc93bf9731822cbfa88c4'
            'bc7f730484a0f5c92e73e861c78141e5efdb015b7828740fef14656eedfb7541')

prepare() {
  patch -d Clp -p1 < fix-build.patch
}

build() {
  cd Clp
  CFLAGS+=" -Wno-implicit-function-declaration" \
  ./configure --prefix=/usr \
              --with-cholmod-lib='-lcholmod' \
              --with-cholmod-incdir=/usr/include/suitesparse \
              --with-amd-lib='-lamd' \
              --with-amd-incdir=/usr/include/suitesparse
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool # Fix overlinking
  make
}

check() {
  cd Clp
  make test
}

package() {
  cd Clp
  make DESTDIR="$pkgdir" install
}
