# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4
# $Id: Portfile 52669 2009-06-20 23:52:57Z ryandesign@macports.org $
# vim: set fileencoding=utf-8 tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab filetype=tcl :

PortSystem 1.0

name						atari800
version						2.1.0
#revision					0
platforms					darwin
categories					emulators
maintainers					krischik
description					Atari 800 emulator
long_description			atari800 is an emulator of the classic Atari 800 8bit computer.

homepage					http://atari800.sourceforge.net/
master_sites				sourceforge:prog									\
							macports:atari800:appbundles

set patchversion			52646
set prog					atari800-${version}.tar.gz
set rom						xf25.zip
set appbundles				atari800-appbundles-r${patchversion}.tar.gz

distfiles					${prog}:prog										\
							${appbundles}:appbundles							\
							${rom}:prog

extract.only				${prog}												\
							${appbundles}

checksums					${prog}												\
							md5     bf76fcb62100f66f7d3b6a9776dbc1e9			\
							sha1    d1483e549bfa35aa4caefccfd6d66a5dc653220a	\
							rmd160  8d23c0139ff9c30ba22aa5d639aeed6371474f76	\
							${rom}												\
							md5     4dc3b6b4313e9596c4d474785a37b94d			\
							sha1    e65923fd3a4845c1c72d1677db0fda969187eb42	\
							rmd160  e3960898223dd4d1b9a9cc5cfb1251bd726ea5a7	\
							${appbundles}										\
                    md5     f8fa3d56eece44c65dfdc659e3a669d6 \
                    sha1    b22b35b1300e3a729cb0a6dd84df3bfdb67baf20 \
                    rmd160  2f4ac42d6cb69b91cae66f6cc56fca4e83865d4c

depends_lib					port:libsdl											\
							port:libpng											\
							port:libsdl_image									\
							port:libsdl_sound

configure.args				--target="sdl"										\
							--mandir='\${prefix}/share/man'						\
							--datadir='\${prefix}/share/atari800'				\
							--sysconfdir='\${prefix}/etc/${name}'
configure.cxxflags-append	"-I${prefix}/include"
configure.env-append		CFLAGS="-O2 -I${prefix}/include -I${prefix}/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE"

worksrcdir					${name}-${version}/src
use_parallel_build			yes

post-extract {
	system "unzip -q ${distpath}/${rom} -d ${workpath}/xf25"
}

post-destroot {
	xinstall -m 775 -d ${destroot}${prefix}/share/atari800

	xinstall -m 444							\
		-W ${workpath}/xf25					\
		ATARIBAS.ROM						\
		ATARIOSB.ROM						\
		ATARIXL.ROM							\
		DEMOS1.XFD							\
		DEMOS2.XFD							\
		DOS25.XFD							\
		MYDOS45D.ATR						\
		${destroot}${prefix}/share/atari800
}
platform macosx {
	post-destroot {
		xinstall -d ${destroot}${applications_dir}/Atari-800
		foreach comp {Atari-320XE-Basic Atari-320XE-MyDos} {
			copy														\
				${workpath}/appbundles-r${patchversion}/${comp}.app		\
				${destroot}${applications_dir}/Atari-800
			reinplace s|@PREFIX@|${prefix}|g \
				${destroot}${applications_dir}/Atari-800/${comp}.app/Contents/MacOS/Atari320XE.command
		}
	}
}

