# $Id: Portfile 54162 2009-07-22 06:25:10Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               xcode 1.0

name                    graphviz-gui
set my_name             graphviz
# keep version in sync between graphviz and graphviz-gui
version                 2.24.0
categories              graphics aqua
maintainers             ryandesign
homepage                http://www.graphviz.org/
master_sites            ${homepage}pub/graphviz/stable/SOURCES/
use_parallel_build      yes
dist_subdir             ${my_name}
distname                ${my_name}-${version}
xcode.configuration     Release

description \
    Mac OS X Aqua GUI for viewing and exporting Graphviz graphs

long_description \
    ${description}.

checksums \
    md5     806a30dbc3f8deb219216f35be0e7a40 \
    sha1    1d91b3a7d2c7fa15e5e718eb456210cd15731e14 \
    rmd160  d003cfa57e73c44fbb71ae8f8726ecc9c74735f9

depends_lib \
    port:graphviz

pre-fetch {
    if {"darwin" != ${os.platform}} {
        ui_error "${name} requires Mac OS X."
        return -code error "incompatible operating system"
    }
    if {${os.major} < 9} {
        ui_error "${name} requires Mac OS X 10.5 or greater. Try graphviz-oldgui instead."
        return -code error "incompatible Mac OS X version"
    }
}

pre-extract {
    if {"darwin" == ${os.platform} && 9 == ${os.major}} {
        # graphviz needs Xcode 3.1+ to avoid the libGL error when building the smyrna variant
        # graphviz-gui needs Xcode 3.1.2+; see #18811
        set minimum_xcodeversion 3.1.2
        set current_xcodeversion [exec defaults read /Developer/Applications/Xcode.app/Contents/Info CFBundleShortVersionString]
        if {[rpm-vercomp ${current_xcodeversion} ${minimum_xcodeversion}] < 0} {
            ui_error "On Mac OS X ${macosx_version}, ${name} ${version} requires Xcode ${minimum_xcodeversion} or later but you have Xcode ${current_xcodeversion}."
            return -code error "incompatible Xcode version"
        }
    }
}

extract.post_args-append ${worksrcdir}/macosx ${worksrcdir}/doc

patchfiles              patch-project.pbxproj.diff

build.dir               ${worksrcpath}/macosx
xcode.build.settings    PREFIX=${prefix}

xcode.destroot.settings ${xcode.build.settings}

# keep livecheck in sync between graphviz and graphviz-gui
livecheck.check         regex
livecheck.url           ${homepage}Download_source.php
livecheck.regex         ${my_name}-(\[0-9\]+\\.\[0-9\]*\[02468\](\\.\[0-9\]+)*)\\.tar
