# -*- 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
# $Id: Portfile 92769 2012-05-06 11:03:24Z raphael@macports.org $

PortSystem              1.0
PortGroup               xcodeversion 1.0

name                    openvrml
version                 0.18.9
categories              graphics x11
maintainers             raphael openmaintainer
description             a cross-platform VRML and X3D browser and C++ runtime \
                        library
long_description        OpenVRML is a free cross-platform runtime for VRML and \
                        X3D available under the GNU Lesser General Public \
                        License. The OpenVRML distribution includes libraries \
                        you can use to add VRML/X3D support to an application. \
                        On platforms where GTK+ is available, OpenVRML also \
                        provides a plug-in to render VRML/X3D worlds in Web \
                        browsers.
homepage                http://www.openvrml.org/
license                 LGPL-3 GPL-3
platforms               darwin
master_sites            sourceforge:project/${name}/${name}/${version}
checksums               rmd160  c79589b11a5dcbf91a09f454deb7fcc439c8a771 \
                        sha256  b3deaf549ccb8ef38db29b674a9c3f6cdf234c4b2b3b159a9479b966373b13c8

depends_lib             port:boost \
                        port:libpng \
                        port:jpeg \
                        port:fontconfig \
                        port:libxml2 \
                        port:zlib \
                        port:libiconv \
                        path:bin/glibtool:libtool
depends_build           port:pkgconfig

minimum_xcodeversions   {9 3.1}

configure.args          --disable-script-node-javascript \
                        --disable-script-node-java \
                        --disable-xembed \
                        --disable-player \
                        --disable-mozilla-plugin \
                        --without-x \
                        --disable-gl-renderer \
                        --disable-examples
configure.ldflags-append    -lboost_system-mt

post-destroot {
                        xinstall -m 644 -W ${worksrcpath} \
                            AUTHORS \
                            COPYING \
                            COPYING.LESSER \
                            ChangeLog \
                            NEWS \
                            README \
                            THANKS \
                            ${destroot}${prefix}/share/doc/${name}-${version}
}

variant js_mozilla requires x11 description {Enable support for JavaScript in the Script node with Mozilla} {
    depends_lib-append          path:lib/xulrunner/libxul.dylib:xulrunner
    configure.args-delete       --disable-script-node-javascript
    configure.args-append       --enable-script-node-javascript
    configure.cppflags-append   `pkg-config libxul --cflags`
}

variant js_spidermonkey description {Enable support for JavaScript in the Script node with Spidermonkey} {
    depends_lib-append          port:spidermonkey
    configure.args-delete       --disable-script-node-javascript
    configure.args-append       --enable-script-node-javascript \
                                --with-libjs
    configure.env-append        JS_CFLAGS="-DXP_UNIX -DJS_THREADSAFE -I${prefix}/include/js"
}

variant opengl conflicts no_opengl description {Build the OpenGL renderer} {
    # examples need SDL player which needs OpenGL
    depends_lib-append          path:lib/pkgconfig/sdl.pc:libsdl
    configure.args-delete       --disable-gl-renderer \
                                --disable-examples
}

variant no_opengl conflicts opengl description {Legacy compatibility variant} {}

variant xembed requires opengl x11 description {Build the XEmbed control} {
    depends_lib-append          port:gtkglext \
                                port:dbus-glib
    configure.args-delete       --disable-xembed
}

variant player requires xembed description {Build the GNOME openvrml-player} {
    depends_lib-append          port:libgnomeui \
                                port:curl
    configure.args-delete       --disable-player
}

variant mozilla_plugin requires xembed description {Build the Mozilla plug-in} {
    depends_lib-append          path:lib/xulrunner/libxul.dylib:xulrunner
    configure.args-delete       --disable-mozilla-plugin
    configure.args-append       --enable-mozilla-plugin
    build.args-append           mozpluginsdir=${prefix}/lib/nsplugins
    destroot.args-append        mozpluginsdir=${prefix}/lib/nsplugins
}

variant x11 conflicts no_x11 {
    configure.args-delete       --without-x
    configure.args-append       --with-x \
                                --x-includes=${prefix}/include \
                                --x-libraries=${prefix}/lib
}

variant no_x11 conflicts x11 description {Legacy compatibility variant} {}

if {[variant_isset no_x11]} {
    default_variants -x11
} else {
    default_variants +x11
}

if {[variant_isset no_opengl]} {
    default_variants -opengl
} else {
    default_variants +opengl
}

if {[variant_isset x11] || [variant_isset opengl]} {
    depends_lib-append          port:mesa
}

livecheck.type                  regex
livecheck.url                   http://sourceforge.net/projects/${name}/files/
livecheck.regex                 ${name}-(\[0-9.\]+)\\.tar
