# $Id: Portfile,v 1.29 2006/03/28 20:13:16 toby Exp $

PortSystem 1.0

name			fortune
version			4.6.2-RELEASE
revision		6
categories		games
maintainers		toby@opendarwin.org
description		Infamous electronic fortune-cookie generator
long_description	${description}
platforms		darwin
use_bzip2		yes

master_sites    \
		opendarwin \
		http://www.splitbrain.org/_media/projects/fortunes/:sb \
		http://www.netmeister.org/apps/:netmeister \
		http://www.cs.indiana.edu/~crcarter/homer/:homer \
		http://homepage.mac.com/css/code:farscape \
		http://www.pinkemostar.com/files/:

distfiles	\
		${distname}${extract.suffix} \
		fortune-starwars.tgz:sb \
		fortune-hitchhiker.tgz:sb \
		fortune-fgump.tgz:sb \
		fortune-xfiles.tgz:sb \
		fortune-mod-futurama-0.2.tar.gz:netmeister \
		fortune-mod-calvin-0.1.1.tar.gz:netmeister \
		homer-quotes.tar.gz:homer \
		ralph-quotes.tar.gz \
		cbg-quotes.tar.gz \
		fortune-simpsons-chalkboard.tgz:sb \
		farscape-quotes.tar.gz:farscape

checksums	\
		${distname}${extract.suffix} md5 99166e1c47d4b60c865a31d59d359b16 \
		fortune-starwars.tgz md5 2f4443470a5d7bcb7c5efde501f8e6f5 \
		fortune-mod-futurama-0.2.tar.gz md5 6fd2cfa2fd8285ff5aabb5e1236107bf \
		fortune-fgump.tgz md5 d9d8e6ba103898e2fe6736378d352398 \
		fortune-mod-calvin-0.1.1.tar.gz md5 e0dc2036b731aafdee4989e9d1d8ec2a \
		homer-quotes.tar.gz md5 ca7ed106f5e828f826eea1d759e00fa0 \
		ralph-quotes.tar.gz md5 9fcdffff609dc5524ee9999846a40bf0 \
		cbg-quotes.tar.gz md5 6de1139cf55bb71758ba9e3a01f05354 \
		fortune-simpsons-chalkboard.tgz md5 1602ec6df3336a7e01f857b8419c8df1 \
		fortune-xfiles.tgz md5 dfbe17a0b0b78e5914d0838852becb7b \
		fortune-hitchhiker.tgz md5 257df9a3f63db9f2e7c27369006812a3 \
		farscape-quotes.tar.gz md5 36ed384fa254918ef7199a7686260190

extract.only	${name}-${version}.tar.bz2
depends_lib		lib:libcompat.1:libcompat
worksrcdir		${name}
# Need another distdir as fortune-hitchhiker.tgz was updated (duh!)
dist_subdir		${name}-20050807

patchfiles	\
		patch-fortune-Makefile patch-strfile-Makefile \
		patch-unstr-Makefile patch-datfiles-Makefile \
		patch-fortune.c patch-strfile.c

configure {
	cd ${worksrcpath}/fortune
	reinplace "s|/usr|${prefix}|" pathnames.h
	reinplace "s|/usr/share|${prefix}/share|" fortune.6
	reinplace "s|/usr/games/fortune|${prefix}/bin/fortune|" fortune.6
	reinplace "s|XXPREFIX|${prefix}|" Makefile
}

build.type		bsd

set datfiles "fortunes fortunes.dat fortunes-o fortunes-o.dat fortunes2 \
		fortunes2.dat fortunes2-o fortunes2-o.dat limerick \
		limerick.dat murphy murphy.dat murphy-o murphy-o.dat \
		startrek startrek.dat zippy zippy.dat"
set datfiles "${datfiles} starwars starwars.dat"
set datfiles "${datfiles} hitchhiker hitchhiker.dat"
set datfiles "${datfiles} fgump fgump.dat"
set datfiles "${datfiles} xfiles xfiles.dat"
set datfiles "${datfiles} futurama futurama.dat"
set datfiles "${datfiles} calvin calvin.dat"
set datfiles "${datfiles} cbg cbg.dat homer homer.dat \
		  ralph ralph.dat chalkboard chalkboard.dat"
set datfiles "${datfiles} farscape farscape.dat"

post-extract {
	cd ${worksrcpath}
	system "tar xfz ${distpath}/fortune-starwars.tgz"
	system "cp fortune-starwars/* datfiles"
	system "tar xfz ${distpath}/fortune-hitchhiker.tgz"
	system "cp fortune-hitchhiker/* datfiles"
	system "tar xfz ${distpath}/fortune-fgump.tgz"
	system "cp fortune-fgump/* datfiles"
	system "tar xfz ${distpath}/fortune-xfiles.tgz"
	system "cp fortune-xfiles/* datfiles"
	system "tar xfz ${distpath}/fortune-mod-futurama-0.2.tar.gz"
	system "cp fortune-mod-futurama-0.2/* datfiles"
	system "tar xfz ${distpath}/fortune-mod-calvin-0.1.1.tar.gz"
	file copy fortune-mod-calvin-0.1.1/calvin datfiles
	file copy fortune-mod-calvin-0.1.1/calvin.dat datfiles
	system "tar xfz ${distpath}/homer-quotes.tar.gz"
	system "cp fortune-homer/* datfiles"
	system "tar xfz ${distpath}/ralph-quotes.tar.gz"
	system "cp ralph ralph.dat datfiles"
	system "tar xfz ${distpath}/cbg-quotes.tar.gz"
	system "cp cbg cbg.dat datfiles"
	system "tar xfz ${distpath}/fortune-simpsons-chalkboard.tgz"
	system "cp fortune-simpsons-chalkboard/* datfiles"
	system "tar xfz ${distpath}/farscape-quotes.tar.gz"
	system "cp farscape-quotes/* datfiles"
}

destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/games/fortune
	xinstall -m 755 ${worksrcpath}/fortune/fortune \
		${worksrcpath}/strfile/strfile ${worksrcpath}/unstr/unstr \
		${destroot}${prefix}/bin
	xinstall -m 644 ${worksrcpath}/fortune/fortune.6.gz \
		${destroot}${prefix}/share/man/man6
	xinstall -m 644 ${worksrcpath}/strfile/strfile.8.gz \
		${destroot}${prefix}/share/man/man8
	xinstall -m 644 ${worksrcpath}/strfile/strfile.8.gz \
		${destroot}${prefix}/share/man/man8/unstr.8.gz
	
	foreach datfile $datfiles {
		file copy ${worksrcpath}/datfiles/${datfile} \
			${destroot}/${prefix}/share/games/fortune
	}
}
