CC	=	gcc
TOOLS	=	..
LIBDIR	=	$(TOOLS)/lib/$(ARCH)
INCDIR	=	$(TOOLS)/include
BINDIR	=	$(TOOLS)/bin/$(ARCH)
CFLAGS	=	-I. -I$(INCDIR) -Wall
LDLIBS	=	-L$(LIBDIR) -lhash
YFLAGS  =       -vd
LFLAGS  =       -l
PROGS	=	haskell2dafny
OBJS	=	mainprog.o parser.o lexer.o consthash.o funchash.o \
		types.o codegen.o callhash.o semchecks.o

all:	$(PROGS)

install:	$(PROGS)
	install -m755 $(PROGS) $(BINDIR)

clean:
	/bin/rm -f $(PROGS) *.o parser.h parser.c lexer.c \
		core parser.output arithfuncs.h boolfuncs.h \
		types.c types.h eek eek.c

haskell2dafny:	$(OBJS)
	$(CC) -o haskell2dafny $(OBJS) $(LDLIBS)

mainprog.o:	mainprog.c types.h consthash.h funchash.h callhash.h \
		semchecks.h codegen.h
parser.o:	parser.c types.h consthash.h arithfuncs.h boolfuncs.h \
		funchash.h callhash.h
lexer.o:	types.h parser.h
types.o:	types.h
consthash.o:	consthash.h
funchash.o:	funchash.h
callhash.o:	callhash.h
semchecks.o:	semchecks.h
codegen.o:	codegen.h

lexer.c:        lexer.l
	lex $(LFLAGS) -o lexer.c lexer.l

parser.c parser.h:       parser.y
	yacc $(YFLAGS) -o parser.c parser.y

arithfuncs.h	: arithfuncs.in
	./genpair < arithfuncs.in > arithfuncs.h

boolfuncs.h	: boolfuncs.in
	./genpair < boolfuncs.in > boolfuncs.h

types.c types.h:	types.in
	datadec types types.in
