# -*- 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 107011 2013-06-14 10:41:33Z raphael@macports.org $

PortSystem                      1.0

name                            libQGLViewer
version                         2.4.0
platforms                       darwin
maintainers                     raphael openmaintainer
license                         {GPL-2+ Commercial}
categories                      graphics
description                     A C++ library based on Qt that eases the creation of OpenGL \
                                3D viewers
homepage                        http://www.libqglviewer.com/
long_description                libQGLViewer is a C++ library based on Qt that eases the \
                                creation of OpenGL 3D viewers. It provides some of the typical \
                                3D viewer functionalities, such as the possibility to move the \
                                camera using the mouse, which lacks in most of the other APIs. \
                                Other features include mouse manipulated frames, interpolated \
                                keyFrames, object selection, stereo display, screenshot saving \
                                and much more. It can be used by OpenGL beginners as well as \
                                to create complex applications, being fully customizable and \
                                easy to extend.

master_sites                    ${homepage}src/

checksums                       rmd160  2283aefd96b8c20aa890899d19f869883fef612c \
                                sha256  6135b97502bde59486e2398a6f0cedff6042dfcfd0e03892a471e85fc1fa362a

patchfiles                      patch-QGLViewer.pro.diff \
                                patch-designerPlugin.pro.diff
# the terrain example does not compile on Lion; see #30886
platform darwin 11 {
    patchfiles-append           patch-contribs.pro.diff
}

variant universal {}

variant x11 {}

if {![variant_isset x11]} {
    PortGroup                   qmake 1.0
} else {
    depends_lib-append          port:qt4-x11
    configure.cmd               ${prefix}/libexec/qt4-x11/bin/qmake
    configure.pre_args          PREFIX=${prefix}
    configure.universal_args
    set qt_plugins_dir          ${prefix}/libexec/qt4-x11/plugins/designer
}

post-patch {
    reinplace "s|@@QT_PLUGINS_DIR@@|${qt_plugins_dir}|g" ${worksrcpath}/designerPlugin/designerPlugin.pro

    if {[variant_isset universal]} {
        file copy ${filespath}/universal.sh ${worksrcpath}
        reinplace "s|@@@WRKSRCPATH@@@|${worksrcpath}|" ${worksrcpath}/universal.sh
        reinplace "s|@@@ARCHS@@@|${configure.universal_cxxflags}|" ${worksrcpath}/universal.sh
        system "chmod +x ${worksrcpath}/universal.sh && ${worksrcpath}/universal.sh"
    }
}

configure.pre_args-append       DOC_DIR=${prefix}/share/doc/${name}
configure.post_args-append      -after QMAKE_POST_LINK=\"\"

use_parallel_build              no

post-destroot {
    system -W ${worksrcpath}/examples "make clean"
    copy ${worksrcpath}/examples ${destroot}${applications_dir}/libQGLViewer\ Examples
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        CHANGELOG \
        GPL_EXCEPTION \
        LICENCE \
        README \
        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type                  regex
livecheck.regex                 "Version (\\d+(?:\\.\\d+)*)"
