# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Gabriel Martinez < reitaka at gmail dot com >

pkgname=libimobiledevice
pkgver=1.4.0
pkgrel=1
pkgdesc='Library to communicate with services on iOS devices using native protocols'
arch=(x86_64 aarch64)
url='https://libimobiledevice.org/'
license=(LGPL-2.1-or-later)
depends=(
  glibc
  libimobiledevice-glue
  libplist
  libtatsu
  libusbmuxd
  openssl
  readline
)
makedepends=(
  cython
  doxygen
  git
  python-setuptools
)
optdepends=('python: Python bindings')
source=(
  "git+https://github.com/libimobiledevice/libimobiledevice.git#tag=$pkgver"
)
b2sums=('f5471cb7d97b5b87f3fd5f6e89a6dc08e98de1fe6b976af78f6e7b6c1f434639c34c3f03135727b0e3bf22d3f6ddab723e3c9110befe278944d8160eff50f9e4')

prepare() {
  cd $pkgname
  autoreconf -fiv
}

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/"
}
