#!/bin/bash

CHECKSUM=`./checksum Image | grep checksum | sed "s/checksum: //g"`;
echo "Replacing image checksum with 0x$CHECKSUM";
sed -i "s/#define KERN_CHECKSUM 0x[0-9a-fA-F]*/#define KERN_CHECKSUM 0x$CHECKSUM/" bootTest.c

gcc  -nostdlib -c bootTestCrt.S
gcc  -nostdlib -c bootTest.c
gcc  -nostdlib -c tags.c
gcc  -nostdlib -c led.c

ld -o bootTest -Ttext 0x83900000 bootTest.lds bootTestCrt.o bootTest.o tags.o led.o

# -Ttext required despite the linker scripty
# as it seems to totally ignore the initial location instruction
#
#--section-start kernel=0x8000 --section-start pagetables=0x4000

#objdump -D bootTest > bootTest.dis.txt
objcopy -R .note -R .comment -O binary bootTest bootTest.bin

