# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               xcode 1.0

name                    vineserver
categories              aqua vnc
homepage                http://www.testplant.com/products/vine_server
maintainers             ryandesign

fetch.type              cvs
cvs.root                :pserver:anonymous@osxvnc.cvs.sourceforge.net:/cvsroot/osxvnc
cvs.module              OSXvnc
worksrcdir              OSXvnc

description \
    a full-featured VNC server (formerly OSXvnc)

long_description \
    Vine Server (formerly OSXvnc) is a full-featured VNC server \
    for Mac OS X providing remote access to the GUI, keyboard and \
    mouse using any VNC client.

depends_build \
    port:libiconv

depends_lib \
    port:zlib

post-patch {
    # Make all strings UTF-16 so CopyStringsFile doesn't fail on Leopard. See #15919.
    foreach strings [glob ${worksrcpath}/*.lproj/Localizable.strings] {
        copy ${strings} ${strings}.orig
        system "${prefix}/bin/iconv -f utf-8 -t utf-16 ${strings}.orig > ${strings}"
    }
}

post-destroot {
    # Fix permissions for users not installing with root
    fs-traverse dir ${destroot} {
        if {[file isdirectory ${dir}]} {
            file attributes ${dir} -permissions 0755
        }
    }
}

if {${name} eq ${subport}} {
    version             4.01
    revision            0
    cvs.date            {"2013-10-02 GMT"}

    platform darwin {
        if {${os.major} < 10} {
            replaced_by ${name}3
            pre-fetch {
                ui_error "${subport} @${version} requires Mac OS X 10.6 or newer. Try the ${name}3 port instead."
                return -code error "incompatible Mac OS X version"
            }
        } elseif {${os.major} == 10} {
            conflicts   ${name}3
        }
    }

    patchfiles          patch-${subport}-OSXvnc.xcodeproj-project.pbxproj.diff

    livecheck.type      regex
    livecheck.url       http://osxvnc.cvs.sourceforge.net/viewvc/osxvnc/OSXvnc/Version.txt
    livecheck.regex     {^([0-9.]+)$}
}

subport ${name}3 {
    version             3.12
    revision            0
    cvs.date            {"2010-10-23 GMT"}
    supported_archs     i386 ppc

    patchfiles          patch-${subport}-OSXvnc.xcodeproj-project.pbxproj.diff \
                        patch-${subport}-OSXvnc-server-rfb.h.diff

    platform darwin {
        if {${os.major} > 10} {
            pre-fetch {
                ui_error "${subport} @${version} requires Mac OS X 10.6 or older. Try the ${name} port instead."
                return -code error "incompatible Mac OS X version"
            }
        } elseif {${os.major} == 10} {
            conflicts   ${name}
        }
    }

    livecheck.type      none
}
