# $Id: PKGBUILD 356 2008-04-18 22:56:27Z aaron $
# Contributor: Sasha Zbrozek <kleptophobiac@gmail.com>
# Maintainer: Paul Mattal <paul@archlinux.org>

pkgname=ivtv-utils
pkgver=1.0.3
pkgrel=1
_kernver=2.6.23-ARCH
pkgdesc="Non-mainline kernel drivers and userspace utilities for Hauppauge PVR cards"
arch=(i686 x86_64)
license=('GPL')
url="http://ivtvdriver.org"
source=("http://dl.ivtvdriver.org/ivtv/archive/1.0.x/ivtv-$pkgver.tar.gz" \
	'http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware.tar.gz' )
depends=('gcc-libs')
md5sums=('2c0e04a861cb7409ea82a2935b1e0050' 'b9a871f1c569025be9c48a77b3515faf')

build() {
  # SET UP
  cd $startdir/src/ivtv-$pkgver || return 1

  # don't call depmod here
  sed -i 's|/sbin/depmod -a||' driver/Makefile i2c-drivers/Makefile || return 1

  # install the utils in /usr/bin, not /usr/local/bin
  sed -i "s%PREFIX = /usr/local%PREFIX = /usr%g" utils/Makefile || return 1

  #cd to utils as that is all we need since ivtv is now in the kernel
  cd  utils/

  # build
  make INSTALLDIR=/usr/bin || return 1

  # install
  make DESTDIR=$startdir/pkg install || return 1

  # remove the kernel modules in the utils package
  rm -rf $startdir/pkg/lib/modules || return 1

  # install the firmware
  cd $startdir/src || return 1
  for file in  v4l-cx2341x-dec.fw v4l-cx2341x-enc.fw v4l-cx2341x-init.mpg v4l-cx25840.fw v4l-pvrusb2-24xxx-01.fw v4l-pvrusb2-29xxx-01.fw
  do
	  install -D -m 0644 $file $startdir/pkg/lib/firmware/$file || return 1
  done
}