Script to compile the linuxkernel in an easier way

Discuss Programming

Script to compile the linuxkernel in an easier way

Postby maximus » Fri Jan 07, 2005 2:53 am

A nice guy from our linux user group has wrote this script. I think i does a good job (Note: Script is for kernel 2.4.x)

Code: Select all
#!/bin/bash
#
# build - a handy script to build the linux kernel
#
# options:
# -f full, means it compiles the whole kernel including
# the modules and installs them.
#
# -o only, means it compiles ONLY this steps you
# you specify (see expl. of modifiers below)
#
# -s skip, means it compiles the whole kernel but SKIPS
# the steps you specify (see expl. of modifiers below)
#
# -h this help ;)
#
# modifiers:
# d dependents (or 'make dep')
# c clean (or 'make clean')
# z zImage (or 'make zImage')
# b bzImage (or 'make bzImage')
# m modules (or 'make modules')
# i modules_install (or 'make modules_install')
# to be continued....
#
# examples:
# to build the kernel but not the modules nor install them:
# ./build -s mi
#
# to build just the deps and bzImage:
# ./build -m db
#
#
# for any questions, send an PM
#


SRCDIR=/usr/src/linux
PARAM=$1
OPTSTR=$@

die()
{
echo "-- sorry, failed to make $1 :(";
exit 1
}

valid()
{
for i in $OPTSTR ; do
echo "$i" | grep "$1" > /dev/null && return 0
done
return 1
}

cddir()
{
if [ -d $1 ] ; then
cd $1
else
echo "-- sorry, dir $1 not found"
exit 1;
fi
}

case "$PARAM" in "-s" )
cddir $SRCDIR
valid "d" || (echo "making dep" && make dep || die "dep")
valid "c" || (echo "making clean" && make clean || die "clean")
valid "z" || (echo "making zImage" && make zImage || die "zImage")
valid "b" || (echo "making bzImage" && make bzImage || die "bzImage")
valid "m" || (echo "making modules" && make modules || die "modules")
valid "i" || (echo "making mod_inst" && make modules_install \
|| die "modules_install")
exit 0
;;

"-o" )
cddir $SRCDIR
valid "d" && echo "making dep" && (make dep || die "dep")
valid "c" && echo "making clean" && (make clean || die "clean")
valid "z" && echo "making zImage" && (make zImage || die "zImage")
valid "b" && echo "making bzImage" && (make bzImage || die "bzImage")
valid "m" && echo "making modules" && (make modules || die "modules")
valid "i" && echo "making mod_inst" && (make modules_install \
|| die "modules_install")
exit 0
;;

"-f" ) cddir $SRCDIR
make dep && \
make clean && \
make bzImage && \
make modules && \
make modules_install && \
echo "finished.... ;)"
exit 0
;;

"-h" )
head -31 $0|tail -29
exit 0
;;

* ) echo "build - kernel building script"
echo "usage: build [-h] [-f] [-m|-s] (d|c|z|b|m|i)"
exit 0
;;
esac
exit 1
Last edited by maximus on Fri Jan 07, 2005 6:32 am, edited 1 time in total.
maximus
n00b
n00b
 
Posts: 2
Joined: Fri Jan 07, 2005 2:49 am

Postby Calum » Fri Jan 07, 2005 4:40 am

i am going to have to try that out.

you may want to obfuscate his email address, since it's on a web page or he'll likely get a ton of spam in his inbox.
User avatar
Calum
guru
guru
 
Posts: 1343
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland

Postby maximus » Fri Jan 07, 2005 6:32 am

done.
maximus
n00b
n00b
 
Posts: 2
Joined: Fri Jan 07, 2005 2:49 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron