NAME	= test

CC      = gcc
LD      = ld
AR      = ar
AS      = as
GS      = gasp
RM      = rm

.SUFFIXES : .o .c .s

CFLAGS = -c -g -I /mcore/include
AFLAGS = -as


all: test.rec

crt0.o: crt0.s
	$(AS) $(AFLAGS) -o $@ $<

regs.o: regs.s
	$(AS) $(AFLAGS) -o $@ $<

ucos.o: ucos.c includes.h ucos.h os_cfg.h ucos_mc.h interupt.h
	$(CC) $(CFLAGS) $< -o $@

ucos_mcc.o: ucos_mcc.c includes.h ucos.h os_cfg.h ucos_mc.h interupt.h
	$(CC) $(CFLAGS) $< -o $@

ucos_mca.o: ucos_mca.s
	$(CC) $(CFLAGS) $< -o $@

uart.o: uart.c uart.h
	$(CC) $(CFLAGS) $< -o $@

timer.o: timer.c timer.h
	$(CC) $(CFLAGS) $< -o $@

interupt.o: interupt.c interupt.h
	$(CC) $(CFLAGS) $< -o $@

sbrk.o: sbrk.c
	$(CC) $(CFLAGS) $< -o $@

crt0init.o: crt0init.c
	$(CC) $(CFLAGS) $< -o $@

test.o: test.c
	$(CC) $(CFLAGS) $< -o $@

test.rec: test.o ucos.o ucos_mcc.o ucos_mca.o timer.o interupt.o uart.o sbrk.o crt0init.o crt0.o regs.o test.ld
	$(AR) -rv ucos.a ucos.o ucos_mcc.o ucos_mca.o
	$(AR) -rv crt0.a crt0.o crt0init.o sbrk.o
	$(AR) -rv mcore.a regs.o timer.o uart.o interupt.o
	$(LD) -T test.ld -Map test.map

clean:
	$(RM) *.o
	$(RM) *.a
	$(RM) *.map
	$(RM) *.rec
