# Template file for 'spim'
pkgname=spim
version=8.0
revision=3
build_wrksrc=spim
build_style=configure
configure_script="./Configure"
make_install_target="install install-man"
hostmakedepends="flex"
short_desc="Self-contained simulator/debugger that runs MIPS32 programs"
maintainer="Toyam Cox <vaelatern@gmail.com>"
license="BSD-3-Clause"
homepage="http://spimsimulator.sourceforge.net/"
distfiles="http://pages.cs.wisc.edu/~larus/SPIM/spim-${version}.tar.gz"
checksum="6f205776cb9fa112729507008843b289012190ed3131cbd426c610a58387ee4b"

pre_configure() {
	sed '/Copyright (c) 1990-2010, James R. Larus./,+26!d' README > LICENSE
	vsed -i Makefile \
		-e 's:CFLAGS =:CFLAGS +=:' \
		-e 's:LDFLAGS =:LDFLAGS +=:' \
		-e 's:CC = gcc:CC ?= gcc:' \
		-e 's:EXCEPTION_DIR = .*:EXCEPTION_DIR = /usr/share/spim:' \
		-e 's:spim.man:spim.1:'
		# EXCEPTION_DIR affects DEFAULT_EXCEPTION_HANDLER in spim.c
}

do_install() {
	vbin spim
	vman ../Documentation/spim.man spim.1
	vlicense LICENSE LICENSE.BSD
	vinstall ../CPU/exceptions.s 644 /usr/share/spim/
}
