#
# Makefile to make the mini runtime system
#
RELEASE = 1

VERSION = 0

LIBID = mrts

OSTYPE = $(shell uname)

TOP = $(HOME)/mini

IDIR = $(TOP)/include

LDIR = $(TOP)/lib

CC = gcc

# default CFLAGS
DCFL = -O -Wall

CFLAGS = $(DCFL) -I.

LDFLAGS =

LIBS =

LDLIBS =

SRCS =	rts_error.c \
	rts_alloc.c \
	rts_texts.c \
	rts_ints.c \
	rts_xput.c

HDRS =	rts_error.h \
	rts_alloc.h \
	rts_texts.h \
	rts_ints.h \
	rts_xput.h

OBJS =	rts_error.o \
	rts_alloc.o \
	rts_texts.o \
	rts_ints.o \
	rts_xput.o

TESTOBJS = rts_test.o

ARLIB = lib$(LIBID).a

MAKEFILE = Makefile

TESTPROG = rts_test

JUNK = tmp core

default: help

help:
	@echo "Possible make targets:"
	@echo "all           Create local libraries."
	@echo "install       Build and install libraries."
	@echo "install-lib   Install library only."
	@echo "clean         Free disk space."
	@echo "test          Create test program."
	@echo "help          Dump this information (default)."

all: $(ARLIB)

install: install-hdrs install-lib

install-hdrs: $(HDRS)
	cp $(HDRS) $(IDIR)

install-lib: $(ARLIB)
	rm -f $(LDIR)/$(ARLIB)
	cp $(ARLIB) $(LDIR)
	ranlib $(LDIR)/$(ARLIB)

clean:
	rm -f $(JUNK) $(OBJS) $(ARLIB) $(TESTOBJS) $(TESTPROG)

test: $(TESTPROG)

$(TESTPROG): $(TESTOBJS) $(ARLIB)
	$(CC) $(LDFLAGS) $(TESTOBJS) $(ARLIB) $(LIBS) -o $@ $(LDLIBS)

$(ARLIB): $(OBJS)
	ar cru $(ARLIB) $(OBJS)
	ranlib $(ARLIB)

rts_test.o: $(HDRS)
rts_error.o: rts_error.h
rts_alloc.o: rts_alloc.h rts_error.h
rts_ints.o: rts_ints.h rts_error.h
rts_texts.o: rts_texts.h rts_alloc.h rts_error.h
rts_xput.o: rts_xput.h rts_alloc.h rts_error.h
