CC = /usr/local/mips-tools/bin/mips-elf-gcc
AS = /usr/local/mips-tools/bin/mips-elf-as
LD = /usr/local/mips-tools/bin/mips-elf-ld
OBJCPY = /usr/local/mips-tools/bin/mips-elf-objcopy

all: startup.o gdb-stub.o ../../common/gdb-stub-common.o
	$(LD) -EL startup.o gdb-stub.o ../../common/gdb-stub-common.o -T memory.def -o gdb-stub -Map gdb-stub.map
	$(OBJCPY) -O srec gdb-stub gdb-stub.srec
	cd ../../common; make clean; cd ../mips/gdb-stub
../../common/gdb-stub-common.o: ../../common/gdb-stub-common.c
	cd ../../common;make mips;cd ../mips/gdb-stub
startup.o : startup.s
	$(AS) -EL startup.s -mips32 -o startup.o
gdb-stub.o : gdb-stub.c ../../common/gdb-stub-common.h
	$(CC) -mel -mips32 -c -g $< -o gdb-stub.o -I. -I../../common
clean:
	cd ../../common; make clean; cd ../mips/gdb-stub; rm -f *.o gdb-stub *.map *.srec *.hex
