

MAKEFILE=	Makefile

CFILES	=	adj.c\
		bucket.c\
		clip.c\
		colour.c\
		ctop.c\
		enew.c\
		label.c\
		odds+ends.c\
		point.c\
		ptoc.c\
		read_cgo.c\
		rnd.c\
		vhash.c\
		vnew.c\
		new_write_cgo.c\
		write_cgo.c\
		stack.c

LFILES	=	lex.l

YFILES	=	parse.y

COBJS	=	adj.o\
		bucket.o\
		clip.o\
		colour.o\
		ctop.o\
		enew.o\
		label.o\
		odds+ends.o\
		point.o\
		ptoc.o\
		read_cgo.o\
		rnd.o\
		vhash.o\
		vnew.o\
		new_write_cgo.o\
		write_cgo.o\
		stack.o

LOBJS	=	lex.o

YOBJS	=	parse.o

OBJECTS	=	$(YOBJS) $(LOBJS) $(COBJS)


INCLUDE	=	../h

CFLAGS	=	-Dvoid=int -I$(INCLUDE) -g

PRINTER	=	imprint -P -n -L

../lib.a:	$(OBJECTS)
		ar ruv ../lib.a $?
		ranlib ../lib.a



clean:
		@echo "Removing objects and lex/yacc output..."
		rm -f $(OBJECTS) parse.c lex.c ../h/parse.h

clobber:
		@echo "Removing objects, lex/yacc output and the library..."
		rm -f $(OBJECTS) parse.c lex.c ../h/parse.h ../lib.a

print:
		@echo "Printing subroutine source code..."
		$(PRINTER) $(MAKEFILE) $(YFILES) $(LFILES) $(CFILES)

parse.c:	parse.y
		yacc -d parse.y
		mv y.tab.h ../h/parse.h
		mv y.tab.c parse.c

# Dependancy rules
../h/parse.h:	parse.y

parse.o:	../h/defs.h ../h/edge.h ../h/point.h ../h/vertex.h \
		/usr/include/stdio.h parse.c parse.y

lex.c:		lex.l

lex.o:		../h/parse.h /usr/include/stdio.h lex.c

colour.o:	../h/defs.h colour.c

label.o:	../h/defs.h label.c

adj.o:		../h/defs.h adj.c

odds+ends.o:	../h/defs.h /usr/include/stdio.h odds+ends.c

units.o:	units.c

vhash.o:	../h/defs.h ../h/edge.h ../h/point.h ../h/types.h \
		../h/vertex.h /usr/include/stdio.h vhash.c

stack.o:	../h/stack.h
