# $Id: PKGBUILD 23620 2009-01-11 14:11:40Z thomas $
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>

pkgname=klibc-udev
pkgver=135
pkgrel=30
pkgdesc="udev compiled for klibc"
arch=(i686 x86_64)
url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
groups=('base')
depends=('coreutils' 'klibc' $(basename /lib/klibc-*.so .so))
license=('GPL')
source=(http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-$pkgver.tar.bz2
        udev-fix-klibc-build.patch
        disable-uid-gid-lookup.patch
        udev_hook
        udev_install
        50-udev-default.rules
        60-persistent-storage.rules
        64-device-mapper.rules
        64-md-raid.rules
        80-drivers.rules
        load-modules.sh)
md5sums=('661b9df34e1304dad10f595d95b472bb'
         'c769a0440fc90ba0fee7a2ae2bf7d76f'
         '89acd170a2771f81ca9e4b7920820555'
         '042fd2ba6a0351bbae30da33ff492c03'
         'a3d81917e2bbe66f6c24486a86d4dc9c'
         'f9095dbad80fc93bcde60d7fe4572022'
         '6625a4000069b9d46ae0ff9d9c2cebb7'
         '258fea1c2b024f9755f905a21bd45a01'
         'e20efd69738bbbba35c49e7b63ee0212'
         'd42740d13b6bb5c5d90bfc2062019f58'
         '5dd248da5d5fa3adfbe87309807ab734')

build() {
  cd ${srcdir}/udev-$pkgver
  patch -p1 -i ../udev-fix-klibc-build.patch || return 1
  # uid/gid lookup fails to build on klibc due to incomplete headers
  # we don't use this feature in klibc, simply omit it
  patch -p1 -i ../disable-uid-gid-lookup.patch || return 1

  CC=klcc LD=klcc ./configure --prefix=""
  make || return 1

  mkdir -p ${pkgdir}/lib/initcpio/udev
  install -m755 udev/udevd ${pkgdir}/lib/initcpio/udev/ || return 1
  install -m755 udev/udevadm  ${pkgdir}/lib/initcpio/udev/ || return 1
  install -m755 extras/path_id/path_id ${pkgdir}/lib/initcpio/udev/ || return 1
  install -m755 extras/volume_id/vol_id ${pkgdir}/lib/initcpio/udev/ || return 1
  install -m755 extras/firmware/firmware.sh ${pkgdir}/lib/initcpio/udev/ || return 1
  for rules in 50-udev-default.rules 60-persistent-storage.rules 64-device-mapper.rules 64-md-raid.rules 80-drivers.rules; do
    install -m644 ${srcdir}/${rules} ${pkgdir}/lib/initcpio/udev/ || return 1
  done
  install -m755 ${srcdir}/load-modules.sh ${pkgdir}/lib/initcpio/udev/ || return 1

  install -D -m644 ${srcdir}/udev_install ${pkgdir}/lib/initcpio/install/udev || return 1
  install -D -m644 ${srcdir}/udev_hook ${pkgdir}/lib/initcpio/hooks/udev || return 1
}