# -*- 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 119403 2014-04-24 20:51:12Z mf2k@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0

name                OpenCSG
version             1.3.2
revision            2
license             GPL-2
categories          science
maintainers         mf2k openmaintainer
description         OpenCSG is a library that does image-based CSG rendering using OpenGL
long_description    CSG is short for Constructive Solid Geometry and denotes an approach \
                    to model complex 3D-shapes using simpler ones. I.e., two shapes can be \
                    combined by taking the union of them, by intersecting them, or by \
                    subtracting one shape of the other. The most basic shapes, which are \
                    not result of such a CSG operation, are called primitives. Primitives \
                    must be solid, i.e., they must have a clearly defined interior and \
                    exterior. By construction, a CSG shape is also solid then.
platforms           darwin
homepage            http://www.opencsg.org/
master_sites        ${homepage}

checksums           rmd160  4480778c310a3d5f84933c1b35508dd94adf2332 \
                    sha256  c790c92998f7113cb35cde825f81c5532755908a0a3f43c3c3c8df2326b3b925

# only need qmake, don't care about it's arch

if {[file exists ${qt_frameworks_dir}/QtCore/QtCore]} {
    depends_build-append path:Library/Frameworks/QtCore/QtCore:qt4-mac
} else {
    depends_build-append path:lib/libQtCore.4.dylib:qt4-mac
}
set depends_skip_archcheck {qt4-mac}

depends_lib         port:glew

worksrcdir          ${distname}/src

post-patch {
    reinplace "s@\\.\\./glew/include@@" ${worksrcpath}/src.pro
}

pre-configure {
    configure.post_args "CONFIG+=\"${qt_arch_types}\""
}

configure.cmd       ${qt_qmake_cmd}
configure.pre_args
configure.args      -o Makefile src.pro LIBS+="-lGLEW"
configure.universal_args
configure.args-append "CONFIG-=qt"

destroot {
    eval file copy [glob ${worksrcpath}/../lib/*] ${destroot}${prefix}/lib
    eval file copy [glob ${worksrcpath}/../include/*] ${destroot}${prefix}/include
    system "install_name_tool -id ${prefix}/lib/libopencsg.[lindex [split ${version} .] 0].dylib ${destroot}${prefix}/lib/libopencsg.dylib"
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.-\]+)\\.tar.gz
