# SPIM S20 MIPS Simulator.
# Imakefile for SPIM.
#
# Copyright (c) 1990-2010, James R. Larus.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# Neither the name of the James R. Larus nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#


#
# To make xpsim, type:
#
#   make xspim
#

#
# The following parameters should be set for the target machine on which XSPIM
# is compiled and installed:
#

# Full path for the directory that will hold the executable files:
BIN_DIR = /usr/local/bin

# Full path for the directory that will hold the exception handler:
EXCEPTION_DIR = /usr/local/lib/spim

# Full path for the directory that will hold the man files:
MAN_DIR = /usr/local/man/en


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

# SPIM needs flex's -I flag 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:
#LEX = lex
#LEXFLAGS =


# Size of the segments when spim starts up (data segment must be >= 64K).
# (These sizes are fine for most users since SPIM dynamically expands
# the memory as necessary.)
MEM_SIZES = -DTEXT_SIZE=65536 -DDATA_SIZE=131072 -DK_TEXT_SIZE=65536


#
# END OF PARAMETERS
#


# Path for directory that contains the source of the CPU code:
CPU_DIR = ../CPU
VPATH = src:$(CPU_DIR)

# Path of directory that contains documentation:
DOC_DIR = ../Documentation


ENDIAN=`cat configuration`

BASE_OBJS = spim-utils.o run.o mem.o inst.o data.o sym-tbl.o y.tab.o lex.yy.o syscall.o display-utils.o string-stream.o

BASE_XOBJS = xspim.o windows.o buttons.o

XOBJS = $(BASE_OBJS) $(BASE_XOBJS)

# lex.yy.c is usually compiled with -O to speed it up.
LEXCFLAGS = -O

YFLAGS = -d


DEPLIBS = XawClientDepLibs
LOCALLIBS = XawClientLibs

CDEBUGFLAGS = -g

INCLUDES = -I. -I$(CPU_DIR)

DEFINES = $(ENDIAN) $(MEM_SIZES) -DDEFAULT_EXCEPTION_HANDLER="\"$(EXCEPTION_DIR)/exceptions.s\"" -DSPIM_VERSION="\"`cat ../VERSION`\""

SYS_LIBRARIES = -lm

#

#
#  Program dependencies:
#
AllTarget(ProgramTargetName(xspim))
NormalProgramTarget(xspim,$(XOBJS),$(DEPLIBS),$(LOCALLIBS),$(SYSLIBS))

force:  configuration

configuration:
	./Configure

InstallProgram(xspim,$(BIN_DIR))
InstallNonExec($(CPU_DIR)/exceptions.s,$(EXCEPTION_DIR)/exceptions.s)
#InstallManPage($(DOC_DIR)/xspim,$(MAN_DIR))


y.tab.h: y.tab.c

y.tab.c: $(CPU_DIR)/parser.y
	$(YACC) $(YFLAGS) $(CPU_DIR)/parser.y

y.tab.o: y.tab.c
	$(CC) $(IFLAGS) $(CFLAGS) $(YCFLAGS) -c y.tab.c


lex.yy.o:	$(CPU_DIR)/scanner.l

lex.yy.c:	$(CPU_DIR)/scanner.l
	$(LEX) $(LEXFLAGS) $(CPU_DIR)/scanner.l

lex.yy.o: lex.yy.c
	$(CC) $(IFLAGS) $(CFLAGS) $(LEXCFLAGS) -c lex.yy.c

#

TAGS:	*.c *.h *.l *.y
	etags *.l *.y *.c *.h


clean::
	rm -f xspim *.o core a.out TAGS y.output y.tab.h y.tab.c lex.yy.c

very-clean: clean
	rm -f configuration

makedepend: y.tab.c
	makedepend -w10 -I. -I$(CPU_DIR) $(CPU_DIR)\*.c *.c

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

data.o: $(CPU_DIR)/spim.h
data.o: $(CPU_DIR)/string-stream.h
data.o: $(CPU_DIR)/spim-utils.h
data.o: $(CPU_DIR)/inst.h
data.o: $(CPU_DIR)/reg.h
data.o: $(CPU_DIR)/mem.h
data.o: $(CPU_DIR)/sym-tbl.h
data.o: $(CPU_DIR)/parser.h
data.o: $(CPU_DIR)/run.h
data.o: $(CPU_DIR)/data.h
display-utils.o: $(CPU_DIR)/spim.h
display-utils.o: $(CPU_DIR)/string-stream.h
display-utils.o: $(CPU_DIR)/spim-utils.h
display-utils.o: $(CPU_DIR)/inst.h
display-utils.o: $(CPU_DIR)/data.h
display-utils.o: $(CPU_DIR)/reg.h
display-utils.o: $(CPU_DIR)/mem.h
display-utils.o: $(CPU_DIR)/run.h
display-utils.o: $(CPU_DIR)/sym-tbl.h
inst.o: $(CPU_DIR)/spim.h
inst.o: $(CPU_DIR)/string-stream.h
inst.o: $(CPU_DIR)/spim-utils.h
inst.o: $(CPU_DIR)/inst.h
inst.o: $(CPU_DIR)/reg.h
inst.o: $(CPU_DIR)/mem.h
inst.o: $(CPU_DIR)/sym-tbl.h
inst.o: y.tab.h
inst.o: $(CPU_DIR)/parser.h
inst.o: $(CPU_DIR)/scanner.h
inst.o: $(CPU_DIR)/data.h
inst.o: $(CPU_DIR)/op.h
mem.o: $(CPU_DIR)/spim.h
mem.o: $(CPU_DIR)/string-stream.h
mem.o: $(CPU_DIR)/spim-utils.h
mem.o: $(CPU_DIR)/inst.h
mem.o: $(CPU_DIR)/reg.h
mem.o: $(CPU_DIR)/mem.h
run.o: $(CPU_DIR)/spim.h
run.o: $(CPU_DIR)/string-stream.h
run.o: $(CPU_DIR)/spim-utils.h
run.o: $(CPU_DIR)/inst.h
run.o: $(CPU_DIR)/reg.h
run.o: $(CPU_DIR)/mem.h
run.o: $(CPU_DIR)/sym-tbl.h
run.o: y.tab.h
run.o: $(CPU_DIR)/syscall.h
run.o: $(CPU_DIR)/run.h
spim-utils.o: $(CPU_DIR)/spim.h
spim-utils.o: $(CPU_DIR)/string-stream.h
spim-utils.o: $(CPU_DIR)/spim-utils.h
spim-utils.o: $(CPU_DIR)/inst.h
spim-utils.o: $(CPU_DIR)/data.h
spim-utils.o: $(CPU_DIR)/reg.h
spim-utils.o: $(CPU_DIR)/mem.h
spim-utils.o: $(CPU_DIR)/scanner.h
spim-utils.o: $(CPU_DIR)/parser.h
spim-utils.o: y.tab.h
spim-utils.o: $(CPU_DIR)/run.h
spim-utils.o: $(CPU_DIR)/sym-tbl.h
string-stream.o: $(CPU_DIR)/spim.h
string-stream.o: $(CPU_DIR)/string-stream.h
sym-tbl.o: $(CPU_DIR)/spim.h
sym-tbl.o: $(CPU_DIR)/string-stream.h
sym-tbl.o: $(CPU_DIR)/spim-utils.h
sym-tbl.o: $(CPU_DIR)/inst.h
sym-tbl.o: $(CPU_DIR)/reg.h
sym-tbl.o: $(CPU_DIR)/mem.h
sym-tbl.o: $(CPU_DIR)/data.h
sym-tbl.o: $(CPU_DIR)/parser.h
sym-tbl.o: $(CPU_DIR)/sym-tbl.h
syscall.o: $(CPU_DIR)/spim.h
syscall.o: $(CPU_DIR)/string-stream.h
syscall.o: $(CPU_DIR)/inst.h
syscall.o: $(CPU_DIR)/reg.h
syscall.o: $(CPU_DIR)/mem.h
syscall.o: $(CPU_DIR)/sym-tbl.h
syscall.o: $(CPU_DIR)/syscall.h
buttons.o: $(CPU_DIR)/spim.h
buttons.o: $(CPU_DIR)/string-stream.h
buttons.o: $(CPU_DIR)/spim-utils.h
buttons.o: xspim.h
buttons.o: $(CPU_DIR)/inst.h
buttons.o: $(CPU_DIR)/reg.h
buttons.o: $(CPU_DIR)/mem.h
buttons.o: $(CPU_DIR)/scanner.h
buttons.o: $(CPU_DIR)/sym-tbl.h
buttons.o: buttons.h
windows.o: $(CPU_DIR)/spim.h
windows.o: $(CPU_DIR)/string-stream.h
windows.o: $(CPU_DIR)/spim-utils.h
windows.o: buttons.h
windows.o: xspim.h
windows.o: windows.h
xspim.o: $(CPU_DIR)/spim.h
xspim.o: $(CPU_DIR)/string-stream.h
xspim.o: $(CPU_DIR)/spim-utils.h
xspim.o: $(CPU_DIR)/inst.h
xspim.o: $(CPU_DIR)/reg.h
xspim.o: $(CPU_DIR)/mem.h
xspim.o: buttons.h
xspim.o: windows.h
xspim.o: xspim.h
xspim.o: $(CPU_DIR)/sym-tbl.h
y.tab.o: $(CPU_DIR)/spim.h
y.tab.o: $(CPU_DIR)/spim-utils.h
y.tab.o: $(CPU_DIR)/inst.h
y.tab.o: $(CPU_DIR)/mem.h
y.tab.o: $(CPU_DIR)/reg.h
y.tab.o: $(CPU_DIR)/sym-tbl.h
y.tab.o: $(CPU_DIR)/data.h
y.tab.o: $(CPU_DIR)/scanner.h
y.tab.o: $(CPU_DIR)/parser.h
lex.yy.o: $(CPU_DIR)/spim.h
lex.yy.o: $(CPU_DIR)/spim-utils.h
lex.yy.o: $(CPU_DIR)/inst.h
lex.yy.o: $(CPU_DIR)/sym-tbl.h
lex.yy.o: y.tab.h
lex.yy.o: $(CPU_DIR)/parser.h
lex.yy.o: $(CPU_DIR)/scanner.h
lex.yy.o: $(CPU_DIR)/op.h
