# $Id: Portfile 48826 2009-03-29 22:07:22Z ryandesign@macports.org $
PortSystem 1.0

name			tightvnc
version			1.3.9
revision		2
categories		x11 vnc
maintainers		nomaintainer
description		Enhanced version of VNC
long_description	This is an enhanced version of VNC, called TightVNC, \
					which includes a lot of  new features, improvements, \
					optimizations and bugfixes over the original VNC \
					version.  Note that TightVNC is still free, \
					cross-platform and compatible with the standard VNC. \
					Many users agree that TightVNC is the most advanced \
					free remote desktop  package.
homepage		http://www.tightvnc.com/
master_sites	sourceforge:vnc-tight
distname		${name}-${version}_unixsrc
use_bzip2		yes
checksums		md5 49a0748ea52793f2e3069e05af28f716
platforms		darwin

depends_lib \
	port:xorg-libXaw \
	port:xorg-libXp \
	port:jpeg \
	port:zlib

depends_run		path:bin/perl:perl5

depends_build		path:bin/xmkmf:imake

worksrcdir		vnc_unixsrc

patchfiles		patch-Xvnc.diff \
				patch-vncviewer.diff \
				patch-vncserver.diff \
				patch-vncconnect_vncconnect.c.diff \
				patch-include_vncauth.h.diff
post-patch {
	reinplace "s|@PREFIX@|${prefix}|g" \
		${worksrcpath}/Xvnc/config/cf/vnclibs.def \
		${worksrcpath}/vncserver \
		${worksrcpath}/vncviewer/Imakefile
	if {[catch {set perl [binaryInPath "perl"]}] == 0} {
		reinplace "s|@PERL@|${perl}|g" ${worksrcpath}/vncserver
	}
}

variant no_server {
	depends_run-delete	path:bin/perl:perl5

	patchfiles-append	patch-no_server.diff
}

use_xmkmf		yes

build.target	World

post-build {
	system "cd '${worksrcpath}/Xvnc' && ./configure"
	system "cd '${worksrcpath}/Xvnc' && 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}/classes/*] {
		xinstall -m 0644 $f ${destroot}${prefix}/share/vnc/classes
	}
}

