########################################################################################
# Makefile for "bootstrap interpreter"
# B. Boser,  1/95

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

TARGET	= si

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

CS	= cs
CC	= cc -std1 -G0 -w
AWK	= gawk
SI	= ./si

########################################################################################
# make interpreter with the interface specified in CLASSES
#
all:		$(TARGET) test

$(TARGET):	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) -only_reachable  $(SAFLAGS)
		@echo compilation finished.

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

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)

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