# $Id: Portfile,v 1.3 2006/07/22 08:54:03 pguyot Exp $

PortSystem			1.0
name				yaws
version				1.64
categories			www
maintainers			pguyot@kallisys.net
platforms			darwin
description			Webserver for dynamic content written in Erlang
long_description	Yaws is a high performance HTTP server for dynamic content \
					written in Erlang. Pages can be dynamic with embedded erlang \
					code. Yaws also features a built-in Wiki.
homepage			http://yaws.hyber.org/
master_sites		http://yaws.hyber.org/download/
checksums			md5 e5a122aede7c120b301d6c10eaf76c9d \
					sha1 42e4b1ce76d91d9823317014910679cbba05c017 \
					rmd160 378ecf8bf2309e3ec2d574e1f44554ca31c6848c

depends_build		bin:erlc:erlang

extract.post_args	| tar -xf - --exclude \
					"${name}-${version}/www/testdir/xx*xx.jpg"

patchfiles			patch-man-yaws.1 \
					patch-man-yaws_api.5 \
					patch-man-yaws.conf.5 \
					patch-scripts-Install \
					patch-scripts-Makefile \
					patch-scripts-yaws.conf.template

post-patch {
	reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/man/yaws.1
	reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/man/yaws.conf.5
	reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/man/yaws_api.5
	reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/scripts/yaws.conf.template
	reinplace "s|__PREFIX|${prefix}|g" ${worksrcpath}/src/yaws_config.erl
}

configure.args		--prefix=${prefix} \
					--sysconfdir=${prefix}/etc \
					--localstatedir=${prefix}/var
					
post-destroot {
	xinstall -d "${destroot}${prefix}/var/log/yaws/"
	system "touch ${destroot}${prefix}/var/log/yaws/.turd"
	file rename "${destroot}${prefix}/etc/yaws.conf" "${destroot}${prefix}/etc/yaws.conf.template"
}

post-install {
	ui_msg "Copy and customize ${prefix}/etc/yaws.conf.template to ${prefix}/etc/yaws.conf"
}

startupitem.create	yes
startupitem.name	yaws
startupitem.start	"${prefix}/bin/yaws --daemon --heart --conf ${prefix}/etc/yaws.conf"
startupitem.stop	"${prefix}/bin/yaws --stop"
