
#
# assembler source files are now handled in a radically different
# fashion. We build a pre-processor program, asmtrans, that
# takes the .spp files, merges them with an include file that
# gives various offsets into structures of interest, and produces
# the .s files as output. This has two major advantages:
# (1) it lets us use the same source for both the Lattice and
#     gcc assembler files (the translator will convert), and
# (2) if we change the CONTEXT or PROC structures, we don't
#     have to dig through the source code looking for
#     magic numbers
#

# depending on your version of bison/yacc, you may
# need to change these names, e.g. to
# YACC = yacc
# YTABC = y.tab.c
# YTABH = y.tab.h

YACC = bison
YTABC = asm.tab.c
YTABH = asm.tab.h

#YACC = byacc -b y_
#YTABC = y_tab.c
#YTABH = y_tab.h

#
# compiler specific
#
CC = gcc
CFLAGS = -O4 -Wall -Wmissing-prototypes
LIBS =

#
# the asm translator program
#

OBJS = asmtab.o trutil.o trans.o
ATRANS = asmtrans.ttp
SRC = asm.y asmtab.c asmtab.h asmtrans.h trutil.c trans.c

$(ATRANS): $(OBJS)
	$(CC) $(CFLAGS) -o $(ATRANS) $(OBJS) $(LIBS)

asmtab.o: asmtab.c asmtrans.h
	$(CC) $(CFLAGS) -o $@ -c asmtab.c

trutil.o: trutil.c asmtrans.h
	$(CC) $(CFLAGS) -o $@ -c trutil.c

trans.o: trans.c asmtrans.h
	$(CC) $(CFLAGS) -o $@ -c trans.c


asmtab.c asmtab.h:	asm.y
	$(YACC) -d asm.y
	mv $(YTABC) asmtab.c
	mv $(YTABH) asmtab.h

#
# macros for cleaning up
#

GENFILES = $(OBJS) $(ATRANS)
EXTRAS = asmtab.c asmtab.h

clean:
	$(RM) $(GENFILES)
	$(RM) $(EXTRAS)
	$(RM) *~

