# $Id: Portfile,v 1.2 2005/04/21 15:57:47 jberry Exp $

PortSystem 1.0

name			atanks
version			1.5a
categories		games
platforms		darwin
maintainers		mww@opendarwin.org
description		atanks is a multi-platform Scorched Earth clone
long_description	${description}

homepage		http://atanks.sourceforge.net/
master_sites	sourceforge
checksums		md5 eca740f3b99feb9f61e93c6c96d0d25c
use_bzip2		yes

depends_lib		port:allegro

extract.post_args	"| tar -xf - --exclude 'Atanks.exe' --exclude 'dumpImages'"

patchfiles		patch-src-Makefile \
				patch-src-parser.cc

configure	{
	cd ${worksrcpath}/src
	reinplace "s|definitions|${prefix}/share/atanks/definitions|g" atanks.cc
	cd ${worksrcpath}/definitions
	reinplace "s|inGameImages/|${prefix}/share/atanks/inGameImages/|g" \
		00plain-missiles.txt 10missile-spreads.txt 20mirvs.txt \
		30cluster-bombs.txt 45shaped-explosives.txt 50burrowers.txt \
		52multi-burrowers.txt 55earth-clearers.txt 60earth-creators.txt \
		70single-rollers.txt 85napalm-bombs.txt 90tremors.txt 95lazers.txt \
		99naturals.txt
	reinplace "s|stockImages/|${prefix}/share/atanks/stockImages/|g" \
		00plain-missiles.txt 10missile-spreads.txt 20mirvs.txt \
		30cluster-bombs.txt 45shaped-explosives.txt 50burrowers.txt \
		52multi-burrowers.txt 55earth-clearers.txt 60earth-creators.txt \
		70single-rollers.txt 85napalm-bombs.txt 90tremors.txt 95lazers.txt \
		99naturals.txt
}

build.env		CFLAGS=-I${prefix}/include \
				LDFLAGS=-L${prefix}/lib
build.args		PREFIX=${prefix}

destroot	{
	xinstall -m 755 ${worksrcpath}/atanks ${destroot}${prefix}/bin
	xinstall -m 755 -d ${destroot}${prefix}/share/atanks
	xinstall -m 644 -W ${worksrcpath} button.dat misc.dat missile.dat \
		sound.dat stock.dat tank.dat tankgun.dat title.dat revenge.txt \
		gloat.txt tanks.txt Help.txt ${destroot}${prefix}/share/atanks
	file copy ${worksrcpath}/definitions ${destroot}${prefix}/share/atanks
	file copy ${worksrcpath}/inGameImages ${destroot}${prefix}/share/atanks
	file copy ${worksrcpath}/stockImages ${destroot}${prefix}/share/atanks
}

variant darwin	{
	post-destroot	{
		xinstall -d -m 755 ${destroot}/Applications/DarwinPorts/ATanks.app/Contents/MacOS
		system "ln -s ${prefix}/bin/atanks \
			${destroot}/Applications/DarwinPorts/ATanks.app/Contents/MacOS/ATanks"
	}
}
