# call make 'arch' for suns and make `machine` for decs.

# Use -DDYNAMIC if your system supports rusage calls.
# (though it's an ugly feature)

# Use -DSTATS if you want some tuple space statistics to be gathered

# Use -DDEBUG for debugging (should not be needed)

CFLAGS = -O2  -DSTATS 
# If the DYNAMIC flag is defined you must load librpcsvc.a 
#LIBS = -lrpcsvc
#else
LIBS = 
 
# Change this to wherever you want the binaries and the library to go
BINDIR = ../bin/
LIBDIR = ../lib/

CC = cc 
OBJS = linda_calls.o linda_util.o rpc.o sys_util.o times.o
POSYBL_LIB = libposybl.a

all: ${POSYBL_LIB} tmanager startup system

${POSYBL_LIB}: ${OBJS}
	rm -f ${POSYBL_LIB} 
	ar rv ${POSYBL_LIB} ${OBJS}
	ranlib ${POSYBL_LIB}
 
startup: startup.o sys_util.o
	cc $(CFLAGS) -o startup startup.o sys_util.o $(LIBS)

system: system.o sys_util.o linda_util.o rpc.o
	cc $(CFLAGS) -o system system.o sys_util.o linda_util.o rpc.o $(LIBS)

tmanager: tmanager.o linda_util.o rpc.o hsearch.o hmatch.o sys_util.o
	cc $(CFLAGS) -o tmanager tmanager.o hmatch.o linda_util.o \
	 rpc.o hsearch.o  sys_util.o

# Dependencies
rpc.o:	rpc.h rpc.c
	$(CC) $(CFLAGS) -c -o rpc.o rpc.c
linda_util.o: linda_defs.h linda_util.c
	$(CC) $(CFLAGS) -c -o linda_util.o linda_util.c
linda_calls.o: linda_defs.h linda_calls.c
	$(CC) $(CFLAGS) -c -o linda_calls.o linda_calls.c
tmanager.o: tmanager.h tmanager.c
	$(CC) $(CFLAGS) -c -o tmanager.o tmanager.c
hmatch.o: linda_defs.h hmatch.c
	$(CC) $(CFLAGS) -c -o hmatch.o hmatch.c
hsearch.o: hsearch.h rpc.h hsearch.c
	$(CC) $(CFLAGS) -c -o hsearch.o hsearch.c
times.o: times.c
	$(CC) $(CFLAGS) -c -o times.o times.c
sys_util.o: linda_defs.h sys_util.c
	$(CC) $(CFLAGS) -c -o sys_util.o sys_util.c
startup.o: linda_defs.h startup.c
	$(CC) $(CFLAGS) -c -o startup.o startup.c
system.o: linda_defs.h system.c
	$(CC) $(CFLAGS) -c -o system.o system.c
tmanager.h: linda_defs.h hsearch.h
linda_defs.h: rpc.h

clean:
	rm -f tmanager system startup *.o ${POSYBL_LIB}

#for sun-3
sun3:	all
	cp libposybl.a $(LIBDIR)/libposybl.sun3.a
	ranlib -t $(LIBDIR)/libposybl.sun3.a
	cp system $(BINDIR)/system.sun3
	cp tmanager $(BINDIR)/tmanager.sun3
	cp startup $(BINDIR)/startup.sun3

#for sparcstations and sun-4	
sun4:	all
	cp libposybl.a $(LIBDIR)/libposybl.sun4.a
	ranlib -t $(LIBDIR)/libposybl.sun4.a
	cp system $(BINDIR)/system.sun4
	cp tmanager $(BINDIR)/tmanager.sun4
	cp startup $(BINDIR)/startup.sun4

# for decstations
mips:	all
	cp libposybl.a $(LIBDIR)/libposybl.mips.a
	ranlib -t $(LIBDIR)/libposybl.mips.a
	cp system $(BINDIR)/system.mips
	cp tmanager $(BINDIR)/tmanager.mips
	cp startup $(BINDIR)/startup.mips
