# $Id: Portfile 47470 2009-02-28 10:14:49Z jeremyhu@macports.org $
PortSystem 1.0

name			vnc
version			3.3.7
revision		3
categories		x11 vnc
maintainers		nomaintainer
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		port:xorg-libXaw \
				lib:libz.1:zlib
depends_run		bin:perl:perl5

set serverdir	Xvnc
set javadir		classes

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

variant no_server {
	depends_run-delete	bin:perl:perl5

	patchfiles-append	patch-no_server
}

configure.cppflags-append	"-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

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

