# $Id: Portfile 54529 2009-07-29 08:08:43Z toby@macports.org $

PortSystem 1.0
name            spim
version         7.4
revision        2
categories      emulators devel lang x11
maintainers     gmail.com:mdippery
description     an assembly language MIPS R2000/R3000 simulator
long_description \
	SPIM S20 is a software simulator that runs assembly language programs for \
	the MIPS R2000/R3000 RISC computers.  SPIM can read and immediately run \
	files containing assembly language statements.  SPIM is a self-contained \
	system for running these programs and contains a debugger and interface to \
	the operating system. \
	\
	SPIM implements almost the entire MIPS assembler-extended instruction set \
	for the R2000/R3000 (I've omitted some the complex floating point comparisons \
	and details of the memory system page tables).  The MIPS architecture has \
	evolved considerably since then (in particular the 64 bit extensions), which \
	means that SPIM will not run programs compiled for recent MIPS or SGI \
	processors.
homepage        http://pages.cs.wisc.edu/~larus/spim.html
platforms       darwin

master_sites    http://pages.cs.wisc.edu/~larus/SPIM
checksums       md5 4aae83509d47a5a98d37db5b469cbe9e \
		sha1 7c0772389dc7db54854681bceae432ea0e4c1587 \
		rmd160 e134bb9271a65e4324375d4aa5b4f81d4d6b9963

depends_lib     port:xorg-libXaw port:xorg-libXp

depends_build   port:rman port:flex port:bison path:bin/xmkmf:imake

worksrcdir      ${name}-${version}

patchfiles      patch-spim_Makefile.diff patch-xspim_Imakefile.diff

configure {
	system "cd ${worksrcpath}/spim && ./Configure"
	system "cd ${worksrcpath}/xspim && xmkmf && ./Configure"
}
post-configure {
	reinplace {s|$(DESTDIR)$(MAN_DIR)/$(DOC_DIR)/xspim.$(MANSUFFIX)|$(DESTDIR)$(MAN_DIR)/xspim.$(MANSUFFIX)|} ${worksrcpath}/xspim/Makefile
}

build {
	system "cd ${worksrcpath}/spim && make prefix=${prefix} spim"
	system "cd ${worksrcpath}/xspim && make prefix=${prefix} xspim"
}

test {
	system "cd ${worksrcpath}/spim && make test"
}

destroot {
	system "cd ${worksrcpath}/spim && make DESTDIR=${destroot} prefix=${prefix} install install-man"
	system "cd ${worksrcpath}/xspim && make DESTDIR=${destroot} prefix=${prefix} install install.man"
}

