########################################################################################
# Makefile for custom interpreter
# B. Boser,  1/95

MATLAB_LIB = /usr/sww/matlab/extern/lib/dec_risc/libmat.a

# Sather compile flags
SAFLAGS = -check all /usr/sww/lib/libgetline.a $(MATLAB_LIB)

TARGET	= si

I_DIR	= ../Interpreter
L_DIR   = ../Library.sa
G_DIR	= ../Graph
B_DIR	= ../Boot

CS	= cs
CC	= cc -std1 -G0 -w
AWK	= gawk
SI	= $(B_DIR)/$(TARGET)

########################################################################################
# make interpreter with the interface specified in CLASSES
#
$(TARGET):	mg.sa glue.o
		@echo compiling interpreter ...
		@$(CS) $(I_DIR)/main.sa mg.sa glue.o \
			-com $(I_DIR)/inter.commands \
			-com $(L_DIR)/base.commands \
			-o $(TARGET) $(SAFLAGS) \
			-only_reachable

mg.sa:		CLASSES omit.txt
		@echo generating dummy main.sa to constuct type graph ...
		echo 'SYSTEM::dummy_main("CLASSES", "main.sa")' | $(SI)
		@echo computing type graph ...
		@$(G_DIR)/browser $(I_DIR)/mg.short.sa main.sa \
			-com $(L_DIR)/base.commands \
			-com $(I_DIR)/inter.commands >features.txt
		@echo generating interface.sig from features.txt ...
		$(AWK) -f $(G_DIR)/interface.awk features.txt >interface.sig
		@echo running interpreter to produce mg.sa ...
		echo 'SYSTEM::interface("CLASSES", "interface.sig", "mg.sa")' | $(SI)

test:		$(TARGET)
		@echo "#TEST_SI.main" | \
			$(TARGET) -com ../Library.si/base.commands >test.out

########################################################################################
# c stuff
#
glue.o:		$(I_DIR)/glue.c
		$(CC) -c -o glue.o $(I_DIR)/glue.c
