# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Arjan Timmerman <arjan.archlinux.org>
# Contributor: Tom Newsom <Jeepster.gmx.co.uk>

pkgname=imlib2
pkgver=1.12.6
pkgrel=1
pkgdesc='Library that does image file loading and saving as well as rendering, manipulation, arbitrary polygon support'
url='https://sourceforge.net/projects/enlightenment/'
arch=('x86_64' 'aarch64')
license=('BSD')
makedepends=(# Currently highway does provide a static library only, that libjxl links to.
             # This introduces a build dependency for now...
             'highway'
             'libheif' 'libid3tag' 'libjxl' 'librsvg' 'libspectre' 'libwebp' 'openjpeg2')
depends=('bzip2' 'freetype2' 'giflib' 'libjpeg-turbo' 'libpng' 'libtiff' 'libxext' 'xz')
optdepends=('libheif: HEIF loader (for AVIF)'
            'libid3tag: ID3 loader'
            'libjxl: JXL loader'
            'librsvg: SVG loader'
            'libspectre: PS loader'
            'libwebp: WEBP loader'
            'openjpeg2: J2K loader')
source=("https://downloads.sourceforge.net/project/enlightenment/imlib2-src/${pkgver}/${pkgname}-${pkgver}.tar.xz")
sha256sums=('250f9752f69dc522e529a81aaa9395705f7fc312ff2453e5de59ac2ba1f2858f')
sha512sums=('e62b7e89f6d75fb6a649a589f06fea34d08bba696c68d9ece59ee9500558af874c1073ffecae2d1cadd6d603f1acf4d071a415dbf2ba73b505ccf11fe45eea62')

build() {
  cd "${pkgname}-${pkgver}"

  local config_opts=(
    --prefix=/usr
    --sysconfdir=/etc/imlib2
    --x-libraries=/usr/lib
  )

  if [[ $CARCH == "x86_64" ]]; then
    config_opts+=(--enable-amd64)
  fi

  ./configure "${config_opts[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}


check() {
  cd "${pkgname}-${pkgver}"
  make check
}


package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  # Install License
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
