# The calling make should define CVLLIB and CVLINCLUDE and CC
#CC = /usr/cs/bin/cc
#CVLLIB = ../cvl/serial
#CVLINCLUDE = ../cvl/serial

SRC1 = actions.c check_args.c constant.c cvl_table.c link_list.c main.c \
	program.c rtstack.c stack.c symbol_table.c vcode_hash.c \
	vcode_table.c vstack.c
SRC2 = lex.yy.c y.tab.c
SRC3 = grammar.yy tokens.ll

OBJS = actions.o check_args.o constant.o cvl_table.o link_list.o main.o \
	program.o rtstack.o stack.o symbol_table.o vcode_hash.o \
	vcode_table.o vstack.o lex.yy.o y.tab.o

LDFLAGS = -L$(CVLLIB)
INCLUDEFLAGS = -I$(CVLINCLUDE)

LIBS = -ly -ll -lcvl $(CVLEXTRA) -lm

#Useful arguments to -D :
#  ASSERTS	turns on assertions in code.  very useful for debugging.
#  BUCKET_DEBUG prints out lots of information about vector heap usage.
#  SPEEDHACKS   makes code faster: several common routines become macros,
#			the bucket manipulation code uses some ugly code
#			that SHOULD be portable (caveat emptor)
#  DEBUG	only if compiling for CM2.  Make cvl calls safer and slower.

CFLAGS = -O -DSPEEDHACKS $(CVLDEFS) $(INCLUDEFLAGS)

vinterp:	$(SRC2) $(OBJS) $(CVLLIB)
	$(CC) $(CFLAGS) -o vinterp $(OBJS) $(LDFLAGS) $(LIBS)

lex.yy.c:	tokens.ll y.tab.h
	lex tokens.ll

y.tab.c y.tab.h:	grammar.yy
	yacc -d grammar.yy

.c.o:	
	$(CC) $(CFLAGS) -c $*.c

clean:
	-rm *.o $(SRC2) vinterp

# make test to test the interpreter
test:	vinterp Test.v
	@echo This should produce a list functions and the value (0)
	./vinterp Test.v
