### this file is sourced not run
PKGVER=4.19.1 # this is the linux kernel version
PKGBUILD=1
PKGARCH=x86_64

# source: james / arch linux
# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/linux-tools
TARBALL=kernel-source-4.19.1.sfs
MD5SUM=74c9f6404ef9ffeeaa7c915a8c6400f7
SRC_URL=http://distro.ibiblio.org/fatdog/sfs/800/$TARBALL
BUNDLE=

SLACKREQ='pciutils'
SLACKDESC="linux-tools: linux-tools $PKGVER (Linux kernel tools)
linux-tools: 
linux-tools: This package contains a set of tools for the Linux kernel. Included 
linux-tools: are: cpupower (replacement for cpufreq-utils), tmon (thermal zone 
linux-tools: monitor), turbostat (Intel CPU 'boost-frequency' stats), 
linux-tools: cgroup_event_listener, and usbip ('USB over IP'), and acpidump/
linux-tools: acpidbg tools.
linux-tools: 
linux-tools: http://www.kernel.org
linux-tools: 
linux-tools: 
"

### if we have 'kernel' directory, use it as SRC_DIR
if [ -d $SRC_DIR/../kernel ]; then
	SRC_DIR=$(readlink -f $SRC_DIR/../kernel)
fi

### default pkg_download
### prepare
pkg_prepare() {
	if pkg_check $SRC_DIR $TARBALL $MD5SUM; then
		unsquashfs -d tmp/squashfs-root $SRC_DIR/$TARBALL
	fi
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/sq*/usr/src/linux-$PKGVER/tools
	
	# we don't only build all tools like Arch, only the interesting stuff

	# cpupower
	pushd power/cpupower &&
	make VERSION=$PKGVER &&
	make install install-man mandir=/usr/share/man docdir=/usr/share/doc/cpupower-$PKGVER &&
	popd &&

	# tmon
	pushd thermal/tmon &&
	make && make install &&
	popd &&

	# turbostat
	pushd power/x86/turbostat &&
	make && make install &&
	popd &&

	# cgroup event listener
	pushd cgroup &&
	make &&
	install -Dm755 cgroup_event_listener /usr/bin &&
	popd &&

	# usbip
	pushd usb/usbip &&
	./autogen.sh &&
	./configure $CONFFLAGS --disable-static &&
	make && make install &&
	popd &&

	# acpidumper
	pushd power/acpi &&
	make && make install mandir=/usr/share/man &&
	popd &&
	
	
	pkg_build_slackdesc
}


