# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=adol-c
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.7.2
pkgrel=1
pkgdesc='Automatic Differentiation of Algorithms written in C/C++ (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
depends=("${MINGW_PACKAGE_PREFIX}-boost"
         "${MINGW_PACKAGE_PREFIX}-libtool")
makedepends=("${MINGW_PACKAGE_PREFIX}-boost")
license=('EPL')
url='https://github.com/coin-or/ADOL-C'
source=(https://github.com/coin-or/ADOL-C/archive/releases/${pkgver}.tar.gz)
sha256sums=('701E0856BAAE91B98397960D5E0A87A549988DE9D4002D0E9A56FA08F5455F6E')

prepare() {
  cd ${_realname}-releases-${pkgver}
  autoreconf -fi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-releases-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --with-gnu-ld \
    --libdir=${MINGW_PREFIX}/lib \
    --with-openmp-flag="-fopenmp" \
    --with-boost=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make install DESTDIR="${pkgdir}"
  install -Dm644 ${srcdir}/${_realname}-releases-${pkgver}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
