# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>

pkgname=shairport-sync
pkgver=2.2.5
pkgrel=1
pkgdesc='Emulates an AirPort Express for the purpose of streaming music from iTunes and compatible iPods and iPhones'
url='https://github.com/mikebrady/shairport-sync'
arch=(i686 x86_64)
license=(GPL)
backup=(etc/conf.d/shairport-sync)
install=shairport-sync.install
depends=(openssl avahi libsoxr popt alsa-lib)
source=(shairport-sync-$pkgver.zip::https://github.com/mikebrady/shairport-sync/archive/$pkgver.zip
        shairport-sync.service
        shairport-sync.conf
        remove-init.d.patch)
sha1sums=('8e87177836b60695f45ff1c6c1385894230912a2'
          '5b998234e1fbc31645285d8b1fbc5ea6cd69e850'
          'eb937e306436af2e47e7ff1bec1eba88b14e0d81'
          '48174838de1ef4672bd71511753f05fd845b7137')

prepare() {
  cd shairport-sync-$pkgver
  patch -p1 < ../remove-init.d.patch
}

build() {
  cd shairport-sync-$pkgver

  autoreconf -i -f
  ./configure --prefix=/usr --with-alsa --with-avahi --with-ssl=openssl --with-soxr --with-dns_sd
  make
}

package() {
  cd shairport-sync-$pkgver
  make DESTDIR="$pkgdir" install
  install -D -m664 LICENSES "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -D -m644 "$srcdir"/shairport-sync.service "$pkgdir"/usr/lib/systemd/system/shairport-sync.service
  install -D -m644 "$srcdir"/shairport-sync.conf "$pkgdir"/etc/conf.d/shairport-sync
}
