# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4
# $Id: Portfile 52729 2009-06-22 06:12:09Z krischik@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					1
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			52694
set prog					atari800-${version}.tar.gz
set rom						xf25.zip
set appbundles				atari800-appbundles-r${patchversion}.tar.gz
set share					atari800-share-r${patchversion}.tar.gz

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

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

checksums					${prog}												\
							md5     53fdbaad6cb7752fb35895c6375ac9a7			\
							sha1    3888ad49718bb5e1232fb544375bb635654b5ca5	\
							rmd160  c793855b27843975fcf04fea47c49499909b49ee	\
							${rom}												\
							md5     4dc3b6b4313e9596c4d474785a37b94d			\
							sha1    e65923fd3a4845c1c72d1677db0fda969187eb42	\
							rmd160  e3960898223dd4d1b9a9cc5cfb1251bd726ea5a7	\
							${share}											\
							md5     0333c3ba853de6db2821fe88fb006665			\
							sha1    3c513bd8229af211e0c8655ca196ba1f436228e2	\
							rmd160  2c734807c03abf14380161b4c79eb1464def2f88	\
							${appbundles}										\
							md5     eb791f7b76bc77bca5f7883156c0acb4			\
							sha1    d295fafd0fba463e791887eb954621f70c8931e5	\
							rmd160  72457afa9d038af558a2794ffbf5b2bd122b38b4

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
	xinstall -m 444								\
		-W ${workpath}/share-r${patchversion}	\
		Setup.command							\
		Sparta32g.XFD							\
		${destroot}${prefix}/share/atari800
	reinplace s|@PREFIX@|${prefix}|g			\
		${destroot}${prefix}/share/atari800/Setup.command
}
platform macosx {
	post-destroot {
		xinstall -d ${destroot}${applications_dir}/Atari-800
		foreach comp { Atari-130XE-Basic Atari-130XE-MyDos Atari-1400XL-Basic Atari-1400XL-MyDos Atari-320XE-Basic Atari-320XE-Sparta Atari-800-Basic Atari-800-Dos Atari-800XL-Basic Atari-800XL-Dos} {
			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/Start.command
		}
	}
}

