# $Id$
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - configure with --without-optimizecpu to avoid overrides to our CFLAGS

pkgname=motion
pkgver=4.0.1
pkgrel=2
pkgdesc="A software motion detector which grabs images from video4linux devices and/or from webcams"
arch=('i686' 'x86_64')
license=('GPL')
url="http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome"
depends=('libjpeg' 'v4l-utils' 'ffmpeg')
backup=('etc/motion/motion.conf')
options=('!makeflags')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Motion-Project/motion/archive/release-$pkgver.tar.gz")
sha256sums=('2f67669a09ce0481ecd987028dae1c5cb135dfdc3c254c06ab7c9ca0c6c183f0')

build() {
  cd "${srcdir}/${pkgname}-release-${pkgver}"
  autoreconf
  ./configure --prefix=/usr \
    --without-pgsql \
    --without-mysql \
    --sysconfdir=/etc \
    --with-ffmpeg \
    --without-optimizecpu
  make
}

package(){
  cd "${srcdir}/${pkgname}-release-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "motion-dist.conf" "${pkgdir}/etc/motion/motion.conf"
  install -Dm644 "motion.service" "${pkgdir}/usr/lib/systemd/system/motion.service"
}