#
#	This is the Makefile for the Pascal to Modula-2 converter
#

$INCLUDE "../Metafile.defines"

all:	p2m2

CFLAGS = -g
PFLAGS = -w -C -g
PC     = ../mod/wrlpc

OBJS =	p2m2.o \
	y.tab.o stringtab.o keywords.o scanner.o \
	error.o io.o util.o

p2m2:	$(OBJS)
	${PC} -w -o p2m2 $(OBJS)

error.o: error.p stringtab.h tokens.h globals.h error.h scanner.h
keywords.o: keywords.p stringtab.h tokens.h globals.h keywords.h
p2m2.o: p2m2.p tokens.h stringtab.h globals.h error.h scanner.h io.h\
	keywords.h util.h
scanner.o: scanner.p tokens.h stringtab.h globals.h error.h scanner.h io.h\
	keywords.h util.h
stringtab.o: stringtab.p stringtab.h tokens.h error.h globals.h util.h
util.o: util.p tokens.h stringtab.h error.h globals.h scanner.h util.h
io.o:	io.c io.h

y.tab.c: pascal.gram
	@echo should produce 3 shift/reduce conflicts
	yacc -vd pascal.gram

y.tab.o: y.tab.c
	cc $(CFLAGS) -c -DYYMAXDEPTH=250 y.tab.c

Makefile: Metafile ../Metafile.defines
	mv Makefile Makefile.bak
	../prep/prep -Dvax=$(VAX) -Dmips=$(MIPS) <Metafile > Makefile

quickinstall: ${DESTDIR}$(BINDIR)
	install -c -s p2m2 ${DESTDIR}$(BINDIR)/$(P2M2BINNAME)

install: ${DESTDIR}$(BINDIR) ${DESTDIR}$(BINDIR)/$(P2M2BINNAME)

${DESTDIR}$(BINDIR):
	-test -d $@ || $(MKDIR) $@

${DESTDIR}$(BINDIR)/$(P2M2BINNAME): p2m2
	install -c -s p2m2 ${DESTDIR}$(BINDIR)/$(P2M2BINNAME)

clean:
	-$(RM) *.o y.tab.c y.tab.h y.output p2m2
