# $Id: PKGBUILD 74318 2012-07-24 15:25:41Z mtorromeo $
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Bob Fanger < bfanger(at)gmail >
# Contributor: Filip <fila pruda com>, Det < nimetonmaili(at)gmail >

pkgname=r8168
pkgver=8.031.00
pkgrel=7
pkgdesc="A kernel module for Realtek 8168 network cards"
url="http://www.realtek.com.tw"
license=("GPL")
arch=('i686' 'x86_64')
depends=('glibc' 'linux>=3.4' 'linux<3.5')
makedepends=('linux-headers')
source=(http://r8168.googlecode.com/files/$pkgname-$pkgver.tar.bz2)
install=$pkgname.install
md5sums=('ec1654f02e2dad930bbeb0210ddab7e5')
sha256sums=('5c617b3c08aca18d1eb24d33f77df40020eb64fb32c8e4008265e08b7ffe5779')

_extramodules=extramodules-3.4-ARCH

build() {
	cd "$pkgname-$pkgver"
	local _kernver="$(cat /usr/lib/modules/$_extramodules/version || true)"

	# avoid using the Makefile directly -- it doesn't understand
	# any kernel but the current.
	make -C /usr/lib/modules/$_kernver/build \
			SUBDIRS="$srcdir/$pkgname-$pkgver/src" \
			EXTRA_CFLAGS="-DCONFIG_R8168_NAPI -DCONFIG_R8168_VLAN" \
			modules
}

package() {
	cd "$pkgname-$pkgver"
	install -Dm644 src/$pkgname.ko "$pkgdir/usr/lib/modules/$_extramodules/$pkgname.ko"
	find "$pkgdir" -name '*.ko' -exec gzip -9 {} +
}

