# $Id: PKGBUILD 23627 2009-01-11 14:22:23Z thomas $
# Maintainer: Aaron Griffin <aaron@archlinux.org>
# Maintainer: Thomas Baechler <thomas@archlinux.org>

###
### NOTE: Do not build this package with anything except gcc - using ccache
###  forces others to use it as well as it becomes hardcoded in the klibc
###  script.
###

pkgname=klibc
pkgver=1.5.15
_klibcbranch=Testing #Stable/Testing
_kver=2.6.28-ARCH
pkgrel=30
pkgdesc="A minimal libc made for early-userspace"
arch=(i686 x86_64)
url="http://www.kernel.org/pub/linux/libs/klibc/"
license=('BSD')
groups=('base')
options=(!ccache !strip)
source=(http://www.kernel.org/pub/linux/libs/klibc/${_klibcbranch}/${pkgname}-${pkgver}.tar.gz
        klibc-compile-shared-by-default.patch
        klibc-Kbuild.patch
        klibc-x86_64-fix-io.h.patch
        klibc-fix-2.6.28-includes.patch)
md5sums=('b5527be46f24779884557b11888c8075'
         'c263a7c3fd290fcc84a4e230d456d022'
         'ff5b113024256de31af59c2f1a966516'
         'fcee75cfaa65638b07f9cc4a7719fa29'
         '85e39751debc304119eb481d6bc26d59')
                  
build()
{
  cd $startdir/src/$pkgname-$pkgver
  #INI_DEBUG causes ipconfig to fail within kinit
  sed -i "/#define INI_DEBUG/d" usr/kinit/kinit.h || return 1
  ln -sf /usr/src/linux-${_kver} linux

  # compile binaries shared by default
  patch -p1 -i ../klibc-compile-shared-by-default.patch || return 1
  # don't build gzip, cpio, kill, build shared binaries for kinit and sh
  patch -p1 -i ../klibc-Kbuild.patch || return 1
  # fix errors in io.h header
  patch -p1 -i ../klibc-x86_64-fix-io.h.patch || return 1
  # fix includes for 2.6.28 build
  patch -p1 -i ../klibc-fix-2.6.28-includes.patch || return 1
  
  make EXTRA_KLIBCFLAGS='' || return 1
  make INSTALLROOT=$startdir/pkg install || return 1
  #ln -sf asm-x86 $startdir/pkg/usr/lib/klibc/include/asm
  cp -a linux/arch/x86/include/asm/* $startdir/pkg/usr/lib/klibc/include/asm/
  
  provides[${#provides[@]}]="$(basename $startdir/pkg/lib/klibc-*.so .so)"
  export provides
}