# configuration variables
INSTALL_DIR?=../install/mips-elf/
CC=mips-elf-gcc
SRCDIR?=./

# main targets
.PHONY: all clean install uninstall

all: libplasma.a crt0p.o

install: libplasma.a crt0p.o ${SRCDIR}/plasma-boot.ld ${SRCDIR}/plasma.ld
	cp libplasma.a crt0p.o ${INSTALL_DIR}/lib
	cp ${SRCDIR}/plasma-boot.ld ${SRCDIR}/plasma.ld ${INSTALL_DIR}/lib/soft-float
	cp ${SRCDIR}/plasma.h ${INSTALL_DIR}/include

uninstall:
	rm -f ${INSTALL_DIR}/lib/libplasma.a ${INSTALL_DIR}/lib/crt0p.o ${INSTALL_DIR}/lib/soft-float/plasma-boot.ld ${INSTALL_DIR}/lib/soft-float/plasma.ld

clean:
	rm -f *.o *.a

# library files
libplasma.a: io.o sys.o mem.o proc.o exit.o
	ar cr $@ $^

crt0p.o: ${SRCDIR}/crt0p.s
	${CC} -c -o $@ $^

# helper target
%.o: ${SRCDIR}/%.c
	${CC} ${CFLAGS} -c -o $@ $^


