# 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 $2
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

gzip -c9 $2.raw >$2.gz
SUN4U_PSIZE=`ls -l $2.gz | awk '{print$5}'`
SUN4U_SIZE=`ls -l $2.raw | awk '{print$5}'`
SUN4U_ROOT=`nm $2 | awk '/A end$/{print$1}'`
rm $2.raw
echo Sun4u kernel     ... raw size = $SUN4U_SIZE, packed size = $SUN4U_PSIZE

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

`echo $0 | sed 's/tilo$/maketilo/'` sun4c=$1.gz size4c=$SUN4C_SIZE root4c=$SUN4C_ROOT \
				 sun4u=$2.gz size4u=$SUN4U_SIZE root4u=$SUN4U_ROOT root=$3 out=$4

rm $1.gz
rm $2.gz

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