Makefile 2.39 KB
#
# Makefile for RSP assembler
#
# This Makefile is a little unusual because the assembler uses
# yacc, lex, awk scripts, other-people's C files, etc.
#

include $(ROOT)/usr/include/make/commondefs

CVERSION = -ansi
OPTIMIZER = -g

# local defs
LCDEFS = 
# local includes
LCINCS = -I. -I./Include -I$(ROOT)/PR/include

YFLAGS = -v -d -t

#
# This list is so clobber can really clean up...
#
GENERATED_FILES = y.tab.h y.tab.c y.output codetablesetup.h lex.yy.c \
		  Include/y.tab.h

#
# The assembler uses the disassembly module from the simulator.
# This is ugly, but assures they are both in synch.
#
DISASM_OBJS = disasm.o
CFILES = rspasm.c codetable.c
PARSER_OBJS = parser.lx.o parser.g.o
OBJECTS =$(CFILES:.c=.o) $(PARSER_OBJS) $(DISASM_OBJS)

LDLIBS = -ll -lm

TARGETS = rspasm buildtask

default: ${TARGETS}

install: ${TARGETS}
	$(INSTALL) -m 555 -F /usr/sbin $(TARGETS)


exports install: default

clean:
	/bin/rm -rf ${OBJECTS}

clobber:
	/bin/rm -rf ${OBJECTS} ${TARGETS} ${MKDEPFILE} ${GENERATED_FILES}

buildtask: buildtask.o
	$(CC) -o $@ buildtask.o ${LDFLAGS}

rspasm: ${OBJECTS}
	$(CC) -o $@ ${OBJECTS} ${LDFLAGS}

parser.g.o: parser.g.y y.tab.h y.tab.c ./Include/types.h ./Include/macros.h
	nawk -f ./AwkScripts/hackyacc.awk < y.tab.c > /usr/tmp/y.tab.c
	mv /usr/tmp/y.tab.c y.tab.c
	$(CC) -c ${INCLUDES} $(CFLAGS) y.tab.c -o parser.g.o

parser.lx.o: parser.lx.l y.tab.h
	lex parser.lx.l
	$(CC) -c ${INCLUDES} $(CFLAGS) lex.yy.c -o parser.lx.o

y.tab.h : parser.g.y ./Include/types.h ./Include/macros.h
	rm -f y.tab.h
	yacc $(YFLAGS) parser.g.y
	nawk -f ./AwkScripts/wrapfile.awk y.tab.h > /tmp/y.tab.h
	mv /tmp/y.tab.h y.tab.h
	cp y.tab.h ./Include

y.tab.c: y.tab.h

#
# Tricky, since we are using the original .c, the compile will leave the
# .o in this directory. So enforce the dependencies to make sure we get
# an up-to-date copy.
#
disasm.o: ../rspsim/disasm.c ../rspsim/disasm.h
	$(CC) -c ${INCLUDES} $(CFLAGS) ../rspsim/disasm.c -o ./disasm.o

codetablesetup.h: ./Include/vopcodetable.t ./Include/opcodetable.t ./AwkScripts/buildopcode.awk
	cat ./Include/opcodetable.t ./Include/vopcodetable.t | nawk -f ./AwkScripts/buildopcode.awk > codetablesetup.h

#
# Apparently we need these explicit rules because makedepend isn't
# smart enough to figure out the machine-generated .h files and
# do the right thing...
#
rspasm.c: y.tab.h
codetable.c: y.tab.h codetablesetup.h

# DO NOT DELETE THIS LINE -- make depend depends on it.