# -*- 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 68310 2010-05-31 21:47:26Z raphael@macports.org $

PortSystem                      1.0

name                            libQGLViewer
version                         2.3.5
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                       md5     e47223379ddac202d18553c93c9249f0 \
                                sha1    420b853183615550ec3c337c9487d21902170b06 \
                                rmd160  62beedc09e4905b11063d16d3f062c72c4cc6647

depends_build                   port:libicns
depends_lib                     path:bin/qmake-mac:qt4-mac

post-extract {                  system "/usr/bin/sips -p 128 128 \
                                            ${worksrcpath}/doc/images/qglviewer.small.png \
                                            --out ${worksrcpath}/QGLViewer/qglviewer.png && \
                                        ${prefix}/bin/png2icns \
                                            ${worksrcpath}/QGLViewer/qglviewer.icns \
                                            ${worksrcpath}/QGLViewer/qglviewer.png"
}

patchfiles                      patch-QGLViewer.pro.diff \
                                patch-designerPlugin.pro.diff
post-patch {                    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/QGLViewer/QGLViewer.pro
                                if {[variant_isset x11]} {
                                    reinplace "s|qt4-mac|qt4-x11|g" ${worksrcpath}/designerPlugin/designerPlugin.pro
                                }
}

configure.cmd                   qmake-mac
configure.pre_args              PREFIX=${destroot}${prefix} \
                                DOC_DIR=${destroot}${prefix}/share/doc/${name} \
                                -after QMAKE_POST_LINK=
configure.universal_args

use_parallel_build              no

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

variant x11 description {Use X11 for visualization} {
depends_lib-delete              path:bin/qmake-mac:qt4-mac
depends_lib-append              port:qt4-x11
configure.cmd                   qmake-x11
}

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