# Maintainer: John Murray <john@menaceinc.com>

_realname=soil
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.16.0
pkgrel=2
pkgdesc="C library used for loading image files into OpenGL (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://lonesock.net/soil.html'
license=('Public Domain')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
# https://www.lonesock.net/files/${_realname}.zip
source=("${_realname}-${pkgver}.zip::https://web.archive.org/web/20160319195722if_/http://www.lonesock.net/files/soil.zip")
sha256sums=('a2305b8d64f6d636e36d669bbdb0ca5445d1345c754b3d61d3f037dad2e5f701')

build() {
  mkdir -p ${srcdir}/build-${MINGW_CHOST}/obj
  mkdir -p ${srcdir}/build-${MINGW_CHOST}/lib
  cd "${srcdir}/Simple OpenGL Image Library/projects/makefile"
  make OBJDIR=${srcdir}/build-${MINGW_CHOST}/obj LIBDIR=${srcdir}/build-${MINGW_CHOST}/lib
}

package() {
  cd "${srcdir}/Simple OpenGL Image Library/projects/makefile"
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib
  mkdir -p ${pkgdir}${MINGW_PREFIX}/include/SOIL
  make LOCAL=${pkgdir}${MINGW_PREFIX} OBJDIR=${srcdir}/build-${MINGW_CHOST}/obj \
   LIBDIR=${srcdir}/build-${MINGW_CHOST}/lib install
  mv ${pkgdir}${MINGW_PREFIX}/include/SOIL.h ${pkgdir}${MINGW_PREFIX}/include/SOIL/
  
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/doc/SOIL
  cp -r "$srcdir/Simple OpenGL Image Library/soil.html" \
   ${pkgdir}${MINGW_PREFIX}/share/doc/SOIL
  find ${pkgdir}${MINGW_PREFIX} -type f -exec chmod 644 {} \;
  find ${pkgdir}${MINGW_PREFIX} -type d -exec chmod 755 {} \;
}

