###############################################################################
#
#                 A make file to build the K2 compiler
#
###############################################################################
#
# Change the definitions of CC and LEX if you don't have gcc or flex, eg :
#
# CC	 	= cc
# LEX	 	= lex
#
# provided that cc is an ANSI C compiler.
#

include ../configuration

#LEX	 	= flex -Cem
LEX	 	= lex
YACC		= yacc -d 

# Remove this if your C compiler is not gcc :

# TARGET_ARCH	= 

#
##############################################################################

.SUFFIXES:
.SUFFIXES: .o .c


k2: k2.o print.o util.o atoms.o forms.o ident.o collect.o propagate.o generation.o
	$(CC) -o k2 k2.o print.o util.o atoms.o forms.o ident.o collect.o propagate.o generation.o

k2.o: k2.c util.h yystype.h forms.h ident.h collect.h objects.h propagate.h tokens.h

forms.c tokens.h: forms.y forms.h yystype.h util.h atoms.h objects.h collect.h
	$(YACC) forms.y
	mv y.tab.c forms.c
	mv y.tab.h tokens.h

atoms.c: atoms.l yystype.h atoms.h tokens.h util.h forms.h objects.h collect.h
	$(LEX) atoms.l
	mv lex.yy.c atoms.c

print.o: print.c print.h tokens.h atoms.h yystype.h objects.h collect.h

util.o: util.c util.h objects.h collect.h

ident.o: ident.c util.h k2.h yystype.h objects.h collect.h atoms.h

collect.o: collect.c util.h objects.h yystype.h k2.h collect.h tokens.h print.h atoms.h

propagate.o: propagate.h util.h objects.h yystype.h k2.h tokens.h print.h collect.h

generation.o: generation.c util.h objects.h yystype.h forms.h k2.h ident.h atoms.h propagate.h tokens.h generation.h collect.h

tags:
	etags -t generation.c objects.h stdlib.h atoms.h generation.h print.c tokens.h atoms.l ident.c print.h util.c collect.c ident.h propagate.c util.h collect.h forms.h k2.c propagate.h yystype.h essai.c forms.y k2.h

clean:
	rm -f *.o TAGS atoms.c forms.c tokens.h core a.out scratch.c *~ .*~ \#*

scratch: clean
	rm -f k2

install: 
	cp k2 $(BINDIR)/k2
	cp Man/manl/k2.l $(MANDIR)/k2.$(MANEXT)
