#!/bin/sh
# $Id: 4.kernel.sh,v 1.12 2004/09/15 15:43:28 drizzt Exp $

set -e -u

. ./config.sh
. ./.common.sh

echo "Copying FreeSBIE configuration file in /usr/src/sys/i386/conf"

if [ "$RELEASE" -ge "5" ];
then
    cp $LOCALDIR/files/FREESBIE.5 /usr/src/sys/i386/conf/FREESBIE || print_error
    cp /usr/src/sys/i386/conf/GENERIC.hints $FREESBIEBASEDIR/boot/device.hints || print_error
    echo hint.psm.0.flags=\"0x1000\" >> $FREESBIEBASEDIR/boot/device.hints || print_error
    sh $LOCALDIR/files/kernel_patch.sh || print_error
else
    cp $LOCALDIR/files/FREESBIE /usr/src/sys/i386/conf/ || print_error
fi

echo "Building FreeSBIE kernel..."
sleep 1
export __MAKE_CONF=$LOCALDIR/files/make.conf # Redefine make.conf path

cd /usr/src || print_error
$MAKE kernel DESTDIR=$FREESBIEBASEDIR $MAKEOPT || print_error

rm -f /usr/src/sys/i386/conf/FREESBIE

if [ "$RELEASE" -ge "5" ];
then
    cd $FREESBIEBASEDIR/boot/kernel || print_error
    gzip kernel || print_error
fi
