# $Id: Portfile 67391 2010-05-07 07:19:38Z ryandesign@macports.org $

PortSystem              1.0

name                    tightvnc
conflicts               vnc
version                 1.3.10
categories              x11 vnc
maintainers             nomaintainer
platforms               darwin
license                 GPL-2
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     397b35faad32d5246b6d44b142f8304f \
                        sha1    ab4ed3d8e9d5188edf0ff27fce3027495f1a8851 \
                        rmd160  0c24207ec13c1d41f445ccbdea16ce2b5d0729a7

depends_build           port:gccmakedep

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

depends_run             path:bin/perl:perl5

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
    }
    # The Vncviewer sample configuration file conflicts with the vncviewer binary
    # on case-insensitive filesystems like Mac OS X's default Mac OS Extended.
    move ${worksrcpath}/vncviewer/Vncviewer ${worksrcpath}/vncviewer/Vncviewer.sample
}

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
    }
}

variant no_server {
    depends_run-delete  path:bin/perl:perl5
    patchfiles-append   patch-no_server.diff
}
