# Depends on bc

# Exit on error:
set -e

# Be verbose:
set -v

wget http://linux-libre.fsfla.org/pub/linux-libre/releases/3.10-gnu/linux-libre-3.10-gnu.tar.xz
wget http://linux-libre.fsfla.org/pub/linux-libre/releases/3.10.7-gnu/patch-3.10-gnu-3.10.7-gnu.xz
tar xf linux-libre-3.10-gnu.tar.xz
unxz patch-3.10-gnu-3.10.7-gnu.xz

cd linux-3.10
patch -Np1 -i ../patch-3.10-gnu-3.10.7-gnu
cd ..
tar -cf linux-libre-3.10.7-gnu.tar linux-3.10
xz -9 linux-libre-3.10.7-gnu.tar

cd linux-3.10
make mrproper
cp arch/x86/configs/i386_defconfig .config

# Remember to activate the two options below to be able to boot:
# Device Drivers
# > Generic Driver Options
#   > [*] Maintain a devtmpfs filesystem to mount on /dev
#   > [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs.
#
# Also ensure you have CONFIG_DRM_I915_KMS=y in your .config after the
# configuration step, working under tty is more pleasant with a nice resolution.
#
# Disable the tux logo with:
# Device Drivers
# > Graphics support
#   > [ ] Bootup logo

make menuconfig
make
make modules_install
cp arch/x86/boot/bzImage /boot/vmlinuz-3.10.7-gnu
cp System.map /boot/System.map-3.10.7-gnu
cp .config /boot/config-3.10.7-gnu
cd ..

rm -rf linux-3.10
rm linux-libre-3.10-gnu.tar.xz

exit 0
