Kernel compilation batch script

This is what I use:
[cc lang=”bash”]
#!/bin/bash

function msg {
echo -e ‘E[37;44m'”33[1m$welcome33[0m”
}

function lflashery {
clear
anykdir=/home/droidzone/flasher/AnyKernel
if [ ! -d $(pwd)/arch ]
then
echo “The kernel location could not be located. Please re-run script from within kernel source root.”
echo “Script will now terminate!”
exit 1
fi
ksource=$(pwd)
outdir=~/kernel_flashable
packagedir=/home/droidzone/flasher/outdir
tempdir=~/kernel_flashable

echo “==============================================”
welcome=” FLASHABLE ZIP MAKER 1.0 by Droidzone”
msg
#echo ” FLASHABLE ZIP MAKER 1.0 by Droidzone”
echo “==============================================”
echo “Output dir is ” $outdir/home/droidzone/kernel_flashable
echo “Anykernel source is at ” $anykdir
echo “Kernel source is at ” $ksource
echo ” ”
echo “Creating target directories”

if [ ! -d $outdir ]; then mkdir $outdir; fi
if [ ! -d $packagedir ]; then mkdir $packagedir; fi
if [ ! -d $tempdir ]; then mkdir $tempdir; fi
#Copying the new kernel files

if ls $outdir/*.zip > /dev/null 2>&1
then
rm $outdir/*.zip
fi

if ls $tempdir/README > /dev/null 2>&1
then
rm $tempdir/README
fi

echo “Working in temporary directory: $tempdir”
cp -a $anykdir/* $tempdir/

sync

echo “Cleaning up remnants…”
if [ -e $outdir/kernel/zImage ]; then rm $outdir/kernel/zImage; fi

if ls $outdir/system/lib/modules/* > /dev/null 2>&1
then
rm $outdir/system/lib/modules/*
fi

if [ -d $ksource ]
then
if [ ! -e $ksource/arch/arm/boot/zImage ]
then
echo “Kernel source location: $ksource/arch/arm/boot/zImage”

echo “zImage was not located at kernel location. Please re-run script from within kernel source root.”
echo “Script will now terminate!”
exit 1
else
echo “Copying zImage…”
cp $ksource/arch/arm/boot/zImage $outdir/kernel/
fi
else
echo “Kernel source folder: $ksource”

echo “Kernel source folder not found! Please re-run script from within kernel source root.”
echo “Script will now terminate!”
exit 1
fi

cd $ksource
find . -name ‘*.ko’ -exec cp ‘{}’ $outdir/system/lib/modules/ ;
cd $outdir/
#Last minute cleanups
find . -name ‘*~’ -exec rm ‘{}’ ;
find . -name ‘README*’ -exec rm ‘{}’ ;

date_str=`date ‘+%d%m%y_%H%M%S’`
pckdir=$packagedir/kernel_$date_str
mkdir $pckdir
read -p ‘Make Package with Modules (N/y)?’ -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
##############################
# Enable if you need all modules

echo

echo “Creating kmods_$date_str.zip from $(pwd)”
zip -r kmods_$date_str ./

mv kmods_$date_str.zip $pckdir/
###############################
#echo “Removing exotic modules”
welcome=”Created a Full flashable package at $pckdir/kmods_$date_str.zip”
msg

fi

if [ -e $outdir/system/lib/modules/btrfs.ko ]; then rm $outdir/system/lib/modules/btrfs.ko; fi
if [ -e $outdir/system/lib/modules/cifs.ko ]; then rm $outdir/system/lib/modules/cifs.ko; fi
if [ -e $outdir/system/lib/modules/ext3.ko ]; then rm $outdir/system/lib/modules/ext3.ko; fi
if [ -e $outdir/system/lib/modules/ext4.ko ]; then rm $outdir/system/lib/modules/ext4.ko; fi
if [ -e $outdir/system/lib/modules/jbd.ko ]; then rm $outdir/system/lib/modules/jbd.ko; fi
if [ -e $outdir/system/lib/modules/jbd2.ko ]; then rm $outdir/system/lib/modules/jbd2.ko; fi
echo
echo “Creating kbase_$date_str.zip from $(pwd)”
zip -r kbase_$date_str ./
mv kbase_$date_str.zip $pckdir/
echo $packagedir
welcome=”Created flashable zips at $pckdir/kbase_$date_str.zip”
msg
read -p “Open Output folder in Dolphin (N/y)?” -n 1
echo
if [[ $REPLY =~ ^[Nn]$ ]]
then
exit 0
else
dolphin $pckdir &
fi
exit 0
}

function menuconf {
echo “Entering Menuconfig…”
#Working on Kubuntu
#make ARCH=arm CC=”arm-linux-gcc” LD=”arm-linux-ld” AR=”arm-linux-ar” RANLIB=”arm-linux-ranlib” AS=”arm-linux-as” -j10 -i all
make ARCH=arm CROSS_COMPILE=”arm-bravo-” menuconfig
}

function comp () {
echo “Compiling Kernel…”
echo
make ARCH=arm CROSS_COMPILE=”arm-bravo-” -j50
if [ ! -e arch/arm/boot/zImage ]
then
echo “ERROR: An error occured. Kernel was not compiled.”
exit 1
else
echo “Making Modules…”
echo
make ARCH=arm CROSS_COMPILE=”arm-bravo-” modules
echo -en “07”
fi
}

clear
echo
echo “=================================================”
welcome=”Kernel Compilation Script by Droidzone 01-11-2011″
msg
echo “=================================================”
echo
ksource=$(pwd)
read -p “Configure Menuconfig?” -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
menuconf
fi

if [ ! -d $outdir ]; then mkdir $outdir; fi
if [ ! -d $packagedir ]; then mkdir $packagedir; fi
if [ ! -d $tempdir ]; then mkdir $tempdir; fi
#Copying the new kernel files>

if ls $outdir/*.zip > /dev/null 2>&1
then
rm $outdir/*.zip
fi

if ls $tempdir/README > /dev/null 2>&1
then
rm $tem
fi
read -p “Compile Kernel now?” -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
comp
fi

echo
echo “Kernel compilation is over..”
welcome=”Generated the following files:”
msg
find . -name ‘zImage’ -exec echo ‘{}’ ;
find . -name ‘*.ko’ -exec echo ‘{}’ ;
echo “”
read -p “Make Flashable zip now?” -n 1
echo “”
if [[ $REPLY =~ ^[Yy]$ ]]
then
lflashery
fi

exit 0
[/cc]