# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=libimobiledevice
pkgver=1.3.0
pkgrel=14
pkgdesc='Library to communicate with services on iOS devices using native protocols'
arch=(x86_64)
url='https://libimobiledevice.org/'
license=(LGPL-2.1-or-later)
depends=(
  glibc
  libimobiledevice-glue
  libplist
  libusbmuxd
  openssl
)
makedepends=(
  cython
  doxygen
  git
  python-setuptools
)
optdepends=('python: Python bindings')
source=("git+https://github.com/libimobiledevice/libimobiledevice.git#tag=$pkgver")
b2sums=(49d7d01a78a618860b774db835e4f0a7fb37743dc8f4b0b1a1fbefe71c3590d07de04616de2129c2a6090ac4211826004227c28dacff0e61e130e1c4c87c3072)

prepare() {
  cd $pkgname

  # Various fixes from upstream
  git cherry-pick -n 1.3.0..6fc41f57fc607df9b07446ca45bdf754225c9bd9

  # Fix build with cython 3
  git cherry-pick -n fb1dec7e2cbb2eae14536d8d68db25d3f9384ac1
  git cherry-pick -n 59ec38cb6465f794cf8e2ab204711b9a10dd9eda

  autoreconf -fi
}

build() (
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
  make docs
)

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

  # Include documentation
  install -dm755 "$pkgdir/usr/share/doc/$pkgname"
  cp -r docs/html "$pkgdir/usr/share/doc/$pkgname/"
}
