.SUFFIXES: .z .o .c

.c.o:
	cc $(CFLAGS) $*.c -s /ram/$*.s && asm -p /ram/$*.s -o $*.o 
	rm /ram/$*.s
.c.s:
	cc $(CFLAGS) $*.c -s $*.s

LIBS = /helios/lib/cstart.o /helios/lib/alloca.o 
LDFLAGS = -v -f

DESTDIR=
# where the installed binary goes
BINDIR = $(DESTDIR)/helios/local/bin

# where the parsers go
PARSERDIR = $(DESTDIR)/helios/local/lib

# names of parser files
PFILE = bison.sim
PFILE1 = bison.hai

# It is unwise ever to compile a program without symbols.
CFLAGS = -wadfsv -epz -dUSG -dHELIOS 

PFILES = -DXPFILE=\"$(PARSERDIR)/$(PFILE)\" \
	 -DXPFILE1=\"$(PARSERDIR)/$(PFILE1)\"


OBJECTS = LR0.o allocate.o closure.o conflicts.o derives.o files.o \
getargs.o gram.o lalr.o	lex.o main.o nullable.o output.o print.o \
reader.o symtab.o warshall.o getopt.o mktemp.o

start: bison

clean:
	rm -f *.o core bison

install: bison
	install bison $(BINDIR)
	cp $(PFILE) $(PFILE1) $(PARSERDIR)

bison: $(OBJECTS)
	asm $(LDFLAGS) $(LIBS) $(OBJECTS) -s30000  -o bison

# This file is different to pass the parser file names
# to the compiler.
files.o: files.c files.h new.h gram.h
	cc $(CFLAGS) $(PFILES) $*.c -s /ram/$*.s && \
	asm -p /ram/$*.s -o $*.o && rm /ram/$*.s

reader.o: files.h new.h symtab.h lex.h gram.h
	cc $(CFLAGS) $(PFILES) $*.c -s $*.s && asm -p $*.s -o $*.o
	rm $*.s

LR0.o: machine.h new.h gram.h state.h
closure.o: machine.h new.h gram.h
conflicts.o: machine.h new.h files.h gram.h state.h
derives.o: new.h types.h gram.h
getargs.o: files.h
lalr.o: machine.h types.h state.h new.h gram.h
lex.o: files.h symtab.h lex.h
main.o: machine.h
nullable.o: types.h gram.h new.h
output.o: machine.h new.h files.h gram.h state.h
print.o: machine.h new.h files.h gram.h state.h
symtab.o: new.h symtab.h gram.h
warshall.o: machine.h
