#
# User-configurable options:
#
# DEBUG
#   -DINIT_SERIAL	initialize serial port (for debugging output by boot or
#			by the kernel)
#   -DDEBUG		generate debugging output in boot
#   -DPSION		enable drivers and initialize DSR and RTS on Psion
#
# OPTIONS
#   -DAUTODETECT	auto-detect free memory (instead of using free memory
#			map provided by EPOC)

DEBUG= #-DINIT_SERIAL -DDEBUG -DPSION
OPTIONS=-DAUTODETECT

XDEV=arm-linux-
XKINCL=-I /scratch/psion/kernel/work/include
MEMFILES=mem.geofox mem.psion mem.psion5-r101-145 mem.psion5mx

CPP=gcc -E
HOSTCC=gcc
CC=$(XDEV)gcc
LD=$(XDEV)ld
AS=$(XDEV)as
OBJCOPY=$(XDEV)objcopy

CFLAGS=-O2 -fomit-frame-pointer -Wall
LDFLAGS=--oformat=binary -Ttext 0xc0028000

all:		boot.bin

boot.bin:	boot.o
		$(OBJCOPY) -O binary boot.o boot.bin

boot.o:		boot.s
		$(AS) -o boot.o boot.s || { rm -f boot.o; exit 1; }

boot.s:		boot.S FiPaBol.S findmem.S map.inc
		$(CPP) $(DEBUG) $(OPTIONS) boot.S >boot.s || \
		  { rm -f boot.s; exit 1; }

map.inc:	mergemem.pl $(MEMFILES) Makefile
		perl mergemem.pl $(MEMFILES) >map.inc || \
		  { rm -f map.inc; exit 1; }

#initrd:		hello.arm mkinitrd
#		./mkinitrd || { rm -f initrd; exit 1; }

#hello.arm:	hello.c
#		$(CC) -nostdlib $(XKINCL) -o hello.arm hello.c

clean:
		rm -f boot.s boot.o map.inc

spotless:	clean
		rm -f boot.bin #hello.arm initrd
