# TILO - Trivial Image LOader
#
# by Jan Vondrak (C) 1998
#
# This is just a simple wrapper for maketilo...

if [ $# -lt 4 ]
then
	echo "Usage: tilo <sun4c/m/d kernel> <sun4u kernel> <root image> <output TILO image>"
	exit 1
fi 

echo Converting ELF to a.out:

for KERNEL in $1
do
	elftoaout $KERNEL -o $KERNEL.out
	tail --bytes +33 $KERNEL.out >$KERNEL.raw
	rm $KERNEL.out
done

echo GZipping...

gzip -c9 $1.raw >$1.gz
SUN4C_PSIZE=`ls -l $1.gz | awk '{print$5}'`
SUN4C_SIZE=`ls -l $1.raw | awk '{print$5}'`
SUN4C_ROOT=`nm $1 | awk '/A end$/{print$1}'`
rm $1.raw
echo Sun4c/m/d kernel ... raw size = $SUN4C_SIZE, packed size = $SUN4C_PSIZE

ROOT_SIZE=`ls -l $3 | awk '{print$5}'`
echo Root image       ... packed size = $ROOT_SIZE

/root/tilo-0.1/maketilo sun4c=$1.gz size4c=$SUN4C_SIZE root4c=$SUN4C_ROOT \
    root4u=$SUN4U_ROOT root=$3 out=$4

rm $1.gz

TILO_SIZE=`ls -l $4 | awk '{print$5}'`
echo TILO size = $TILO_SIZE
