# Maintainer:  Dave Murphy <davem@devkitpro.org>

pkgname=switch-libconfig
pkgver=1.7.2
pkgrel=1
pkgdesc='C/C++ Configuration File Library (for Nintendo Switch homebrew development)'
arch=('any')
url="https://www.hyperrealm.com/libconfig/libconfig.html"
license=('LGPL')
options=(!strip libtool staticlibs)
source=("https://hyperrealm.github.io/libconfig/dist/libconfig-${pkgver}.tar.gz")
sha256sums=('7c3c7a9c73ff3302084386e96f903eb62ce06953bb1666235fac74363a16fad9')
makedepends=('switch-pkg-config' 'devkitpro-pkgbuild-helpers')

build() {
  cd libconfig-$pkgver

  source /opt/devkitpro/devkita64.sh
  source /opt/devkitpro/switchvars.sh

  ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \
     --disable-shared --enable-static --without-nettle --without-openssl \
     --without-xml2 --without-expat --without-iconv --disable-bsdtar \
     --disable-bsdcpio --disable-acl --disable-examples

  make
}

package() {
  cd libconfig-$pkgver

  source /opt/devkitpro/devkita64.sh
  source /opt/devkitpro/switchvars.sh

  make DESTDIR="$pkgdir" install
  # license
  install -Dm644 COPYING.LIB "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING.LIB
  # remove useless stuff
  rm -r "$pkgdir"${PORTLIBS_PREFIX}/share
}

