CSRCS   = CQBB-ELuart.c cpu_init.c cpu_uart.c tinylib.c
TARGET  = CQBB-ELuart
ASMSRCS = startup.s
OBJS    = $(ASMSRCS:%.s=%.o) $(CSRCS:%.c=%.o)
LDSCRIPT= memory.def

CC = /usr/local/arm-tools/bin/arm-elf-gcc
AS = /usr/local/arm-tools/bin/arm-elf-as
LD = /usr/local/arm-tools/bin/arm-elf-ld
OBJCOPY = /usr/local/arm-tools/bin/arm-elf-objcopy

all: $(OBJS) $(LDSCRIPT)
	$(LD) -Map $(TARGET).map -T $(LDSCRIPT) $(OBJS) -L$(GCCLIB) -lgcc -o $(TARGET).elf
	$(OBJCOPY) -O srec $(TARGET).elf $(TARGET).srec
	$(OBJCOPY) -O binary $(TARGET).elf $(TARGET).bin
.c.o :
	$(CC) -mcpu=cortex-m3 -mthumb -O0 -g -c $<
.s.o: 
	$(AS) -mcpu=cortex-m3 -mthumb --defsym THUMB=1 $< -o $@
clean:
	rm *.o $(TARGET).elf $(TARGET).map $(TARGET).srec $(TARGET).bin
