#Packager: Shador <futur~DOT~andy~AT~googlemail.com>

pkgname=grub2
pkgver=1.97.2
pkgrel=1ab
arch=x86_64
source=("http://alpha.gnu.org/gnu/grub/grub-1.97.2.tar.gz"
		"http://unifoundry.com/unifont-5.1.20080820.bdf.gz"
    "http://gaia.homelinux.org/salix/packages-x86_64/$pkgname/$pkgver/05_salix_theme"
    "http://gaia.homelinux.org/salix/packages-x86_64/$pkgname/$pkgver/salix.jpg"
    "http://gaia.homelinux.org/salix/packages-x86_64/$pkgname/$pkgver/grub2-boot-strings.patch")
sourcetemplate="http://gaia.homelinux.org/salix/packages-x86_64/$pkgname/$pkgver/"
docs=("readme" "install" "copying" "changelog" "authors" "news" "thanks" "todo")
url='http://www.gnu.org/software/grub/grub-2.en.html'
options=('noautodotnew')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (the second GNU GRand Unified Bootloader)"
"GRUB 2 has been rewritten from scratch to clean up everything for"
"modularity and portability."
"Features are: Scripting support, Graphical interface, Rescue mode,"
"cross-platform and many more"
"Briefly, boot loader is the first software program that runs when a"
"computer starts. It is responsible for loading and transferring"
"control to the operating system kernel software (such as the Hurd or"
"the Linux). The kernel, in turn, initializes the rest of the operating"
"system (e.g. GNU)."
)


build() {
	threadcount=$(($(sed -ne '/cpu cores/h;${g;s/[^0-9]*//p}' \
						< /proc/cpuinfo)*2))
	if [ $threadcount -lt 2 ]; then
		threadcount=2
	elif [ $threadcount -gt 8 ]; then
		threadcount=8
	fi
	threads="-j${threadcount}"

	cd $startdir/src/grub-$pkgver
	
	# this is mainly cosmetically (for salixlive), hope we get this upstream too
	patch -p0 -i $startdir/src/grub2-boot-strings.patch || exit 1
	
	UNIFONT_BDF="$startdir/src/unifont-5.1.20080820.bdf" \
	./configure \
		--prefix=/usr \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--mandir=/usr/man \
		--enable-grub-mkfont \
		--disable-grub-emu \
		--disable-grub-emu-usb \
		--disable-grub-fstest || return 1
	make $threads || return 1
	make install DESTDIR=$startdir/pkg || return 1
  
  cd $startdir/src
  install -m644 -vD salix.jpg $startdir/pkg/boot/grub/salix.jpg
  sed -e "s;/lib;/lib${LIBDIRSUFFIX};" -i 05_salix_theme
  install -m755 -vD 05_salix_theme $startdir/pkg/etc/grub.d/05_salix_theme
} 
