# Note: SPIM does not work when compiled by a compiler that does
# not distinguish floats from doubles (e.g., pcc and pcc-compatible compilers
# on the VAX).

# Endianness
# BIGENDIAN (e.g. 68000's (i.e. Sun 3, HP Bobcats), RT/PC, SPARC, MIPSebs)
# LITTLEENDIAN (e.g. DECstation, Sequent Symmetry),
ENDIAN=-DLITTLEENDIAN

# Use tt.be for big-endian systems
# Use tt.le for little-endian systems:
TEST_FILE = tt.le

# If you have flex, use it instead of lex.  If you use flex, define this
# variable and set LEXFLAGS.
#MYLEX = flex

# SPIM needs the -I flag to flex since the scanner is used interactively.
# You can set the -8 flag so that funny characters do not hang the scanner.
#LEXFLAGS = -I -8

# If you use lex, set the variables this way:
MYLEX = lex
LEXFLAGS =

# Location of X11 root directory.
TOPDIR = /usr/X11/

# Size of the segments when spim starts up (data segment must be >= 64K).
MEM_SIZES =

# Define these flags if your operating system libraries are missing these:
#
# -DNEED_VSPRINTF   If your system doesn't have vsprintf
# -DNEED_STRTOL     If your system doesn't have strtol
#
#Ultrix, SunOS: no flags.
#Sequent: both
#PC/RT:	  -DNEED_VSPRINTF
#BSD4.3:  -DNEED_STRTOL
SYS_FLAGS=

CC=lcc
IFLAGS= 
CFLAGS= -g $IFLAGS $ENDIAN $MEM_SIZES $SYS_FLAGS
YFLAGS= -d
YCFLAGS=
LDFLAGS=
XLDFLAGS= -L$TOPDIR/lib -lXaw -lXmu -lXt -lXext -lX11
LEXCFLAGS=

OBJS = spim-utils.o run.o mem.o inst.o data.o sym_tbl.o y.tab.o lex.yy.o \
       read-aout.o except.o cache.o mips-syscall.o
XOBJS = windows.o buttons.o

#all: spim xspim

spim:	$OBJS spim.o
	$CC -g $prereq $LDFLAGS -o spim -lm
xspim:	$OBJS $XOBJS xspim.o
	$CC -g $prereq $LDFLAGS $XLDFLAGS -o xspim -lm
spim.o:	spim.c spim.h reg.h mem.h x.tab.h
xspim.o: xspim.c xspim.h spim.c spim.h reg.h mem.h x.tab.h
spim-utils.o: spim-utils.c spim.h inst.h mem.h reg.h x.tab.h VERSION
	$CC $IFLAGS $CFLAGS -DSPIM_VERSION=\"5.0\" -c spim-utils.c
run.o:	run.c spim.h reg.h x.tab.h inst.h mem.h sym_tbl.h
mips-syscall.o:	mips-syscall.c spim.h inst.h mem.h reg.h spim-syscall.h mips-syscall.h
except.o: except.c spim.h reg.h inst.h mem.h sym_tbl.h spim-syscall.h mips-syscall.h
mem.o:	     mem.c spim.h reg.h inst.h mem.h
cache.o:     cache.c reg.h inst.h mem.h
inst.o:      inst.c spim.h reg.h inst.h mem.h sym_tbl.h x.tab.h op.h
data.o:      data.c spim.h mem.h reg.h sym_tbl.h
sym_tbl.o:   sym_tbl.c spim.h inst.h mem.h sym_tbl.h
read_aout.o: read_aout.c inst.h mem.h

x.tab.h:Pcmp -s:y.tab.h
	cp y.tab.h x.tab.h
y.tab.c y.tab.h: parser.y spim.h inst.h mem.h reg.h sym_tbl.h
	yacc $YFLAGS parser.y
y.tab.o: y.tab.c
	$CC $IFLAGS $CFLAGS $YCFLAGS -c y.tab.c

lex.yy.c: scanner.l x.tab.h op.h
	$MYLEX $LEXFLAGS scanner.l
lex.yy.o: lex.yy.c
	$CC $IFLAGS $LEXCFLAGS -c lex.yy.c
windows.o:  windows.c xspim.h
buttons.o:  buttons.c xspim.h

clean:V:
	rm -f *.o *~ y.output core a.out spim.tar.* spim.shar* x.tab.h y.tab.h y.tab.c lex.yy.c
clobber:V:clean
	rm -f spim xspim

FILES= BLURB README COPYING Makefile *.c *.h *.y *.l trap.handler Tests/tt.* \
	ChangeLog VERSION mips.id xinterface.id mem.id stack-frame.id
TAGS:	*.c *.h *.l *.y
	etags *.l *.y *.c *.h
tar:V: clean
	cd ..
	tar cvf spim.tar spim
tar.Z:V:	tar
	compress ../spim.tar
shar:V: clean
	cd ..
	shar spim >spim.shar
