_kernver=2.6.39.1
pkgname=kernel26-my
basekernel=2.6.39
pkgver=2.6.39
pkgrel=1
pkgdesc="The Linux Kernel and modules"
arch=('i686 x86_64')
license=('GPL')
url="http://www.kernel.org"
depends=('module-init-tools')
provides=(kernel26=2.6.39 kernel26-headers=2.6.39)
install=kernel26.install

build() {
  LOCAL_VERSION="$(grep "CONFIG_LOCALVERSION=" $startdir/.config | sed 's/.*"\(.*\)"/\1/')"

  cd ..
  CFLAGS="-march=native -O2 -fomit-frame-pointer -pipe" KCFLAGS="-march=native -O2 -fomit-frame-pointer -pipe" make || return 1
  mkdir -p $startdir/pkg/{lib/modules,boot,firmware}
  CFLAGS="-march=native -O2 -fomit-frame-pointer -pipe" KCFLAGS="-march=native -O2 -fomit-frame-pointer -pipe" make INSTALL_MOD_PATH=$startdir/pkg modules_install || return 1

  # There's no separation of firmware depending on kernel version -
  # comment this line if you intend on using the built kernel exclusively,
  # otherwise there'll be file conflicts with the existing kernel
  rm -rf $startdir/pkg/lib/firmware

  install -Dm644 "System.map" "$startdir/pkg/boot/System.map26$LOCAL_VERSION"
  install -Dm644 "arch/x86/boot/bzImage" "$startdir/pkg/boot/vmlinuz26$LOCAL_VERSION"

  # Change the version strings in kernel26.install
  sed -i \
  	-e "s/KERNEL_VERSION=.*/KERNEL_VERSION=\"$basekernel\"/" \
  	-e "s/LOCAL_VERSION=.*/LOCAL_VERSION=\"$LOCAL_VERSION\"/" \
  	$startdir/kernel26.install
}
