# $Id: Portfile,v 1.7 2005/08/11 21:33:43 rshaw Exp $
PortSystem 1.0

name			vnc
version			3.3.7
revision		2
categories		x11 vnc
maintainers		darwinports@opendarwin.org
description		Remote display system for X11 applications
long_description	Creates a virtual X11 windowing environment that can \
					be viewed not only on the machine where it is \
					running, but from anywhere on the Internet and from \
					a wide variety of machine architectures.
homepage		http://www.realvnc.com/
master_sites	${homepage}/dist/
distname		${name}-${version}-unixsrc
checksums		md5 511ffbc8ed8d9df82e7c67852164728c
platforms		darwin

depends_lib		lib:libX11.6:XFree86 \
				lib:libz.1:zlib
depends_run		bin:perl:perl5.8

set serverdir	Xvnc
set javadir		classes

patchfiles		patch-Xvnc \
				patch-configure \
				patch-vncserver \
				patch-vncviewer
post-patch {
	cd ${worksrcpath}
	reinplace "s|@PREFIX@|${prefix}|g" vncserver
	if {[catch {set perl [binaryInPath "perl"]}] == 0} {
		reinplace "s|@PERL@|${perl}|g" vncserver
	}
}

variant no_server {
	depends_run-delete	bin:perl:perl5.8

	patchfiles-append	patch-no_server
}

configure.env	CPPFLAGS="-no-cpp-precomp"
configure.args	--with-x --with-installed-zlib

post-build {
	system "cd '${worksrcpath}/${serverdir}' && make World"
}

destroot.cmd	./vncinstall
destroot.target	${destroot}${prefix}/bin ${destroot}${prefix}/share/man 
destroot.destdir
post-destroot {
	xinstall -d -m 0755 ${destroot}${prefix}/share/vnc/classes
	foreach f [glob ${worksrcpath}/${javadir}/*] {
		xinstall -m 0644 $f ${destroot}${prefix}/share/vnc/classes
	}
}

variant beta {
	version		4.0b4
	distname	${name}-${version}-unixsrc
	checksums	md5 0eed650932d0e9fb14ed87eb6c7d419e

	set serverdir	xc
	set javadir		java

	# NOTE: Beta version requires XFree source to build the Xvnc server.
	# Therefore the beta variant has been setup to not build the Xvnc
	# server for now.
	depends_run-delete	bin:perl:perl5.8

	patchfiles-delete	patch-Xvnc \
						patch-configure \
						patch-vncserver \
						patch-vncviewer
	patchfiles-append	patch-vncserver-beta \
						patch-no_server-beta
}

