CFLAGS 	:= -Wall -Wstrict-prototypes -g -fomit-frame-pointer -ffreestanding -I./ -I../common/inc
all : ../common/src/crt.S ../common/src/startup.c sendmain.c revmain.c lpc2000_spi.c

	arm-elf-gcc $(CFLAGS) -c -o crt.o ../common/src/crt.S
	arm-elf-gcc $(CFLAGS) -c -o startup.o ../common/src/startup.c
	arm-elf-gcc $(CFLAGS) -c -o lpc2000_spi.o lpc2000_spi.c

	arm-elf-gcc $(CFLAGS) -c -o sendmain.o sendmain.c
	arm-elf-gcc $(CFLAGS) -c -o revmain.o revmain.c

	arm-elf-ld -T../common/lpc2148-rom.ld  crt.o startup.o sendmain.o lpc2000_spi.o -o send.elf
	arm-elf-ld -T../common/lpc2148-rom.ld  crt.o startup.o revmain.o lpc2000_spi.o -o rev.elf

	arm-elf-objcopy -O binary -S send.elf send.bin
	arm-elf-objcopy -O ihex send.elf send.hex
	arm-elf-objdump -D -m arm  send.elf > send.dis

	arm-elf-objcopy -O binary -S rev.elf rev.bin
	arm-elf-objcopy -O ihex rev.elf rev.hex
	arm-elf-objdump -D -m arm  rev.elf > rev.dis

clean:
	rm -f *.dis *.bin *.elf *.o *.hex
