# Makefile - simulator suite make file
#
# This file is part of the Alpha simulator tool suite written by
# Raj Desikan as part of the Bullseye project.
# It has been written by extending the SimpleScalar tool suite written by
# Todd M. Austin as a part of the Multiscalar Research Project.
#  
# 
# Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
#
# Copyright (C) 1999 by Raj Desikan
# This source file is distributed "as is" in the hope that it will be
# useful.  It is distributed with no warranty, and no author or
# distributor accepts any responsibility for the consequences of its
# use. 
#
# Everyone is granted permission to copy, modify and redistribute
# this source file under the following conditions:
#
#    This tool set is distributed for non-commercial use only. 
#    Please contact the maintainer for restrictions applying to 
#    commercial use of these tools.
#
#    Permission is granted to anyone to make or distribute copies
#    of this source code, either as received or modified, in any
#    medium, provided that all copyright notices, permission and
#    nonwarranty notices are preserved, and that the distributor
#    grants the recipient permission for further redistribution as
#    permitted by this document.
#
#    Permission is granted to distribute this file in compiled
#    or executable form under the same conditions that apply for
#    source code, provided that either:
#
#    A. it is accompanied by the corresponding machine-readable
#       source code,
#    B. it is accompanied by a written offer, with no time limit,
#       to give anyone a machine-readable copy of the corresponding
#       source code in return for reimbursement of the cost of
#       distribution.  This written offer must permit verbatim
#       duplication by anyone, or
#    C. it is distributed by someone who received only the
#       executable form, and is accompanied by a copy of the
#       written offer of source code that they received concurrently.
#
# In other words, you are welcome to use, share and improve this
# source file.  You are forbidden to forbid anyone else to use, share
# and improve what you give them.
#
#
# 

##################################################################
#
# Modify the following definitions to suit your build environment,
# NOTE: most platforms should not require any changes
#
##################################################################

#
# Define below C compiler and flags, machine-specific flags and libraries,
# build tools and file extensions, these are specific to a host environment,
# pre-tested environments follow...
#

##
## vanilla Unix, GCC build
##
## NOTE: the Alphasim simulator must be compiled with an ANSI C
## compatible compiler.
##
## tested hosts:
##
##	Slackware Linux version 2.0.33, GNU GCC version 2.7.2.2
##	FreeBSD version 3.0-current, GNU egcs version 2.91.50
##	Alpha OSF1 version 4.0, GNU GCC version 2.7.2
##	PA-RISC HPUX version B.10.01, GNU GCC version 2.7-96q3
##	SPARC SunOS version 5.5.1, GNU egcs-2.90.29
##	RS/6000 AIX Unix version 4, GNU GCC version cygnus-2.7-96q4
##	Windows NT version 4.0, Cygnus CygWin/32 beta 19
##
CC = /usr/bin/gcc
#OFLAGS = -O3 -DNDEBUG -Wall
OFLAGS = -g -DDEBUG -Wall
MLIBS = `./sysprobe -libs` -lm
ENDIAN = `./sysprobe -s`
MAKE = make
AR = ar qcv
AROPT =
RANLIB = ranlib
RM = rm -f
RMDIR = rm -f
LN = ln -s
LNDIR = ln -s
DIFF = diff
OEXT = o
LEXT = a
EEXT =
CS = ;
X=/
SFLAGS=
##
## Alpha OSF1 version 4.0, DEC C compiler version V5.2-036
##
#CC = cc -std
#OFLAGS = -O0 -g -w
#MFLAGS = `./sysprobe -flags`
#MLIBS  = `./sysprobe -libs` -lm
#ENDIAN = `./sysprobe -s`
#MAKE = make
#AR = ar qcv
#AROPT =
#RANLIB = ranlib
#RM = rm -f
#RMDIR = rm -f
#LN = ln -s
#LNDIR = ln -s
#DIFF = diff
#OEXT = o
#LEXT = a
#EEXT =
#CS = ;
#X=/

##
## PA-RISC HPUX version B.10.01, c89 HP C compiler version A.10.31.02
##
#CC = c89 +e -D__CC_C89
#OFLAGS = -g
#MFLAGS = `./sysprobe -flags`
#MLIBS  = `./sysprobe -libs` -lm
#ENDIAN = `./sysprobe -s`
#MAKE = make
#AR = ar qcv
#AROPT =
#RANLIB = ranlib
#RM = rm -f
#RMDIR = rm -f
#LN = ln -s
#LNDIR = ln -s
#DIFF = diff
#OEXT = o
#LEXT = a
#EEXT =
#CS = ;
#X=/

##
## SPARC SunOS version 5.5.1, Sun WorkShop C Compiler (acc) version 4.2
##
#CC = gcc
#OFLAGS = -O0 -g -lsocket -lnsl
#MFLAGS = `./sysprobe -flags`
#MLIBS  = `./sysprobe -libs` -lm  -lsocket -lnsl
#ENDIAN = `./sysprobe -s`
#MAKE = make
#AR = ar qcv
#AROPT =
#RANLIB = ranlib
#RM = rm -f
#RMDIR = rm -f
#LN = ln -s
#LNDIR = ln -s
#DIFF = diff
#OEXT = o
#LEXT = a
#EEXT =
#CS = ;
#X=/

##
## RS/6000 AIX Unix version 4, xlc compiler build
##
#CC = xlc -D__CC_XLC
#OFLAGS = -g
#MFLAGS = `./sysprobe -flags`
#MLIBS  = `./sysprobe -libs` -lm
#ENDIAN = `./sysprobe -s`
#MAKE = make
#AR = ar qcv
#AROPT =
#RANLIB = ranlib
#RM = rm -f
#RMDIR = rm -f
#LN = ln -s
#LNDIR = ln -s
#DIFF = diff
#OEXT = o
#LEXT = a
#EEXT =
#CS = ;
#X=/

##
## WinNT, MS VC++ build
##
## NOTE: requires MS VC++ version 5.0 + service pack 3 or later
## NOTE1: before configuring the simulator, delete the symbolic link "tests/"
##
#CC = cl /Za /nologo
#OFLAGS = /W3 /Zi
#MFLAGS = -DBYTES_LITTLE_ENDIAN -DWORDS_LITTLE_ENDIAN -DFAST_SRL -DFAST_SRA
#MLIBS  =
#ENDIAN = little
#MAKE = nmake /nologo
#AR = lib
#AROPT = -out:
#RANLIB = dir
#RM = del/f/q
#RMDIR = del/s/f/q
#LN = copy
#LNDIR = xcopy/s/e/i
#DIFF = dir
#OEXT = obj
#LEXT = lib
#EEXT = .exe
#CS = &&
#X=\\\\

#
# Compilation-specific feature flags
#
# -DDEBUG	- turns on debugging features
# -DBFD_LOADER	- use libbfd.a to load programs (also required BINUTILS_INC
#		  and BINUTILS_LIB to be defined, see below)
# -DGZIP_PATH	- specifies path to GZIP executable, only needed if SYSPROBE
#		  cannot locate binary
# -DSLOW_SHIFTS	- emulate all shift operations, only used for testing as
#		  sysprobe will auto-detect if host can use fast shifts
#
FFLAGS = -D__alpha 
#-DHOST_HAS_QUAD 
#-DFLEXIBLE_SIM

# If enabling this flag, make sure to run the simulator w/o early inst retire
# and use eio traces
#-DFUNC_DEBUG


#
# Point the Makefile to your Simplescalar-based bunutils, these definitions
# should indicate where the include and library directories reside.
# NOTE: these definitions are only required if BFD_LOADER is defined.
#
#BINUTILS_INC = -I../include
#BINUTILS_LIB = -L../lib

#
#


##################################################################
#
# YOU SHOULD NOT NEED TO MODIFY ANYTHING BELOW THIS COMMENT
#
##################################################################

#
# complete flags
#
CFLAGS = $(MFLAGS) $(FFLAGS) $(OFLAGS) $(BINUTILS_INC) $(BINUTILS_LIB)

#
# all the sources
#
SRCS =	main.c memory.c regs.c  resource.c endian.c symbol.c eval.c \
	options.c range.c stats.c endian.c misc.c alpha.c syscall.c fetch.c \
	issue.c writeback.c map.c slot.c commit.c bpred.c loader.c \
	simulate.c tlb.c eventq.c bus.c cache_timing.c eio.c \
	cache_common.c sim-fast.c ssloader.c ssregs.c sssyscall.c \
	ssmemory.c sseio.c dram.c


HDRS =	syscall.h memory.h regs.h sim.h loader.h cache.h \
	resource.h endian.h symbol.h eval.h bitmap.h bus.h cache.h\
	range.h version.h endian.h misc.h alpha.h ecoff.h writeback.h \
	fetch.h issue.h map.h slot.h alpha.def options.h eio.h \
	commit.h bpred.h host.h stats.h mshr.h eventq.h \
	tlb.h  ssloader.h ssregs.h sssyscall.h ssmemory.h \
	ssmachine.h sseio.h dram.h

#
# common objects
#
OBJS = 	main.$(OEXT) memory.$(OEXT) regs.$(OEXT) resource.$(OEXT) \
	symbol.$(OEXT) eval.$(OEXT) options.$(OEXT) range.$(OEXT) \
	stats.$(OEXT) endian.$(OEXT) misc.$(OEXT) alpha.$(OEXT) \
	syscall.$(OEXT) fetch.$(OEXT) issue.$(OEXT) writeback.$(OEXT) \
	map.$(OEXT) slot.$(OEXT) commit.$(OEXT) bpred.$(OEXT) loader.$(OEXT) \
	simulate.$(OEXT) tlb.$(OEXT) eventq.$(OEXT)  cache_timing.$(OEXT) \
	bus.$(OEXT) cache_common.$(OEXT) sim-fast.o ssloader.$(OEXT) \
	ssmemory.$(OEXT) sssyscall.$(OEXT) ssregs.$(OEXT) eio.$(OEXT) \
	sseio.o dram.$(OEXT)

#
# programs to build
#
PROGS = sim-alpha$(EEXT) 

#
# all targets, NOTE: library ordering is important...
#
#BUGFIX 09/03/2003 - Start 
#FLEXIBLE_SIM enabled for now for greater accuracy. Need to reconcile b/n
# default version and FLEXIBLE_SIM
#BUGFIX 09/03/2003 - End

all: SFLAGS=-DFLEXIBLE_SIM
all: $(PROGS)
	@echo "my work is done here..."

sysprobe$(EEXT):	sysprobe.c
	$(CC) $(FFLAGS) -o sysprobe$(EEXT) sysprobe.c
	@echo endian probe results: $(ENDIAN)
	@echo probe flags: $(MFLAGS)
	@echo probe libs: $(MLIBS)

flexible:  SFLAGS=-DFLEXIBLE_SIM 
flexible: sysprobe$(EEXT) $(OBJS) libexo/libexo.$(LEXT)
	 condor_compile $(CC) -o sim-alpha$(EEXT) $(CFLAGS) $(OBJS) libexo/libexo.$(LEXT) $(MLIBS)

functional: SFLAGS=-DFUNC_DEBUG -DFLEXIBLE_SIM
functional: sysprobe$(EEXT) $(OBJS) libexo/libexo.$(LEXT)
	$(CC) -o sim-alpha$(EEXT) $(CFLAGS) $(OBJS) libexo/libexo.$(LEXT) $(MLIBS)

sim-alpha$(EEXT):	sysprobe$(EEXT)  $(OBJS) libexo/libexo.$(LEXT) 
#	$(CC) -o sim-alpha$(EEXT) $(CFLAGS) $(OBJS) libexo/libexo.$(LEXT) $(MLIBS)
	$(CC) -o sim-alpha$(EEXT) $(CFLAGS) $(OBJS) libexo/libexo.$(LEXT) $(MLIBS)

exo libexo/libexo.$(LEXT): sysprobe$(EEXT)
	cd ./libexo $(CS) \
	$(MAKE) "MAKE=$(MAKE)" "CC=$(CC)" "AR=$(AR)" "AROPT=$(AROPT)" "RANLIB=$(RANLIB)" "CFLAGS=$(MFLAGS) $(FFLAGS) $(OFLAGS)" "OEXT=$(OEXT)" "LEXT=$(LEXT)" "EEXT=$(EEXT)" "X=$(X)" "RM=$(RM)" libexo.$(LEXT)


.c.$(OEXT):
	$(CC) $(CFLAGS) $(SFLAGS) -c $*.c

filelist:
	@echo $(SRCS) $(HDRS) Makefile

diffs:
	-rcsdiff RCS/*

clean:
	-$(RM) *.o *.obj core *~ Makefile.bak sysprobe$(EEXT) $(PROGS)
	cd ./libexo $(CS) $(MAKE) "RM=$(RM)" "CS=$(CS)" clean $(CS) cd ..
unpure:
	rm -f sim.pure *pure*.o sim.pure.pure_hardlink sim.pure.pure_linkinfo

depend:
	makedepend.local -n -x $(BINUTILS_INC) $(SRCS)


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

main.$(OEXT): host.h misc.h alpha.h endian.h version.h 
main.$(OEXT): regs.h memory.h options.h stats.h eval.h loader.h sim.h
main.$(OEXT): bpred.h cache.h fetch.h slot.h map.h issue.h writeback.h
memory.$(OEXT): host.h misc.h alpha.h options.h stats.h
memory.$(OEXT): memory.h loader.h regs.h cache.h tlb.h dram.h
regs.$(OEXT): host.h misc.h alpha.h loader.h regs.h 
eventq.$(OEXT): host.h misc.h alpha.h eventq.h writeback.h issue.h
resource.$(OEXT): host.h misc.h resource.h alpha.h issue.h stats.h 
resource.$(OEXT): writeback.h cache.h bpred.h fetch.h
endian.$(OEXT): endian.h loader.h 
symbol.$(OEXT): host.h misc.h ecoff.h loader.h symbol.h
eval.$(OEXT): host.h misc.h eval.h 
options.$(OEXT): host.h misc.h options.h
range.$(OEXT): host.h misc.h alpha.h symbol.h loader.h range.h
stats.$(OEXT): host.h misc.h alpha.h eval.h stats.h
misc.$(OEXT): host.h misc.h alpha.h
loader.$(OEXT): host.h misc.h alpha.h endian.h regs.h memory.h
loader.$(OEXT): sim.h loader.h eio.h ecoff.h
syscall.$(OEXT): host.h misc.h alpha.h regs.h memory.h
syscall.$(OEXT): stats.h loader.h sim.h endian.h 
syscall.$(OEXT): syscall.h eio.h
alpha.$(OEXT): alpha.h eval.h regs.h
fetch.$(OEXT): alpha.h regs.h memory.h loader.h cache.h bpred.h fetch.h
fetch.$(OEXT): tlb.h eventq.h issue.h writeback.h map.h stats.h syscall.h
issue.$(OEXT): alpha.h regs.h bpred.h cache.h fetch.h writeback.h map.h 
issue.$(OEXT): issue.h resource.h eventq.h
map.$(OEXT): alpha.h alpha.def regs.h cache.h bpred.h fetch.h slot.h map.h
map.$(OEXT): issue.h writeback.h commit.h
slot.$(OEXT): alpha.h memory.h syscall.h regs.h cache.h bpred.h fetch.h slot.h
slot.$(OEXT): issue.h writeback.h map.h stats.h eventq.h
writeback.$(OEXT): alpha.h regs.h memory.h syscall.h resource.h sim.h cache.h
writeback.$(OEXT): tlb.h fetch.h bpred.h slot.h issue.h map.h writeback.h 
writeback.$(OEXT): commit.h loader.h eventq.h alpha.def
commit.$(OEXT): alpha.h regs.h memory.h resource.h sim.h cache.h
commit.$(OEXT): loader.h eventq.h fetch.h bpred.h slot.h issue.h map.h 
commit.$(OEXT): writeback.h alpha.def commit.h eventq.h syscall.h
cache_common.$(OEXT): cache.h eventq.h loader.h misc.h tlb.h bus.h
cache_timing.$(OEXT): cache.h eventq.h loader.h misc.h tlb.h bus.h commit.h
cache_timing.$(OEXT): stats.h bpred.h fetch.h map.h issue.h writeback.h 
bus.$(OEXT): alpha.h misc.h cache.h bus.h
tlb.$(OEXT): alpha.h misc.h cache.h bus.h memory.h loader.h sim.h 
tlb.$(OEXT): eventq.h tlb.h 
bpred.$(OEXT): host.h misc.h alpha.h cache.h bpred.h fetch.h
simulate.$(OEXT): host.h misc.h alpha.h options.h regs.h memory.h loader.h
simulate.$(OEXT): eventq.h syscall.h stats.h sim.h bpred.h cache.h fetch.h
simulate.$(OEXT): slot.h map.h issue.h writeback.h resource.h commit.h
simulate.$(OEXT): bus.h tlb.h ssregs.h dram.h
eio.$(OEXT): host.h misc.h alpha.h regs.h memory.h loader.h libexo/libexo.h
eio.$(OEXT): syscall.h sim.h endian.h eio.h cache.h bpred.h fetch.h map.h
dram.$(OEXT): dram.h alpha.h
ssloader.$(OEXT): host.h misc.h ssmachine.h alpha.h ssregs.h ssmemory.h 
ssloader.$(OEXT): sim.h sseio.h ssloader.h
ssregs.$(OEXT): host.h misc.h ssmachine.h ssregs.h
sssyscall.$(OEXT): host.h misc.h ssmachine.h ssregs.h ssmemory.h sim.h sseio.h 
sssyscall.$(EXT): sssyscall.h
ssmemory.$(OEXT): host.h misc.h ssmachine.h options.h stats.h ssmemory.h
sseio.$(OEXT): host.h misc.h ssmachine.h ssregs.h ssmemory.h ssloader.h 
ssio.$(OEXT): libexo/libexo.h sssyscall.h sim.h endian.h sseio.h
sim-fast.$(OEXT): host.h misc.h alpha.h ssregs.h ssmemory.h ssloader.h 
sim-fast.$(OEXT): sssyscall.h sim.h issue.h
