#
# $Id$
#
# Shamelessly lifted and hacked from the
# free bios project.
#
# $Log$
#

### compilers and options
CC	= gcc
CFLAGS	= -g -O2
LD	= ld
LDFLAGS	=  -s -S -T ldscript.ld
OBJCOPY	= objcopy

### objects
OBJECTS	= BootStartup.o BootResetAction.o filtror.o BootPerformPicChallengeResponseAction.o vsprintf.o BootPciPeripheralInitialization.o BootPerformXCodeActions.o BootLinux.o BootVgaInitialization.o

# target:
all	: image.elf image.bin

image.elf : ${OBJECTS}
	${LD} -o $@ ${OBJECTS} ${LDFLAGS} 

clean	:
	rm -rf *.o *~ core *.core ${OBJECTS} image.elf image.bin image.bin.patched

### rules:
%.o	: %.c boot.h consts.h
	${CC} ${CFLAGS} -o $@ -c $<

%.o	: %.S consts.h
	${CC} -DASSEMBLER ${CFLAGS} -o $@ -c $<

%.bin	: %.elf
	${OBJCOPY} --output-target=binary --strip-all  $< $@
	@ls -l $@
#     the following patches the compressed linux kernel into the ROM image at offset 0x8000
#     you can get lmilk from http://warmcat.com/milksop/milk.html
#	@lmilk -d image.bin -b bzImage -a 8000
#     the following send the patched result to a Filtror and starts up the X-Box with the new code
#	@lmilk -f -p image.bin.patched -q
#    this one is the same but additionally runs terminal emulator
#	@lmilk -f -p image.bin.patched -q -t

