# -*- 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 115709 2014-01-09 16:10:16Z eborisch@macports.org $

PortSystem          1.0

PortGroup           active_variants 1.1
PortGroup           compiler_blacklist_versions 1.0
PortGroup           cmake 1.0
PortGroup           github 1.0

github.setup        ukoethe vigra 1-10-0 Version-
version             [strsed ${github.version} {g/-/./}]
revision            2
categories          graphics
platforms           darwin
maintainers         gmail.com:benjamin.seppke
description         Generic Image Processing Library for C++
long_description    VIGRA stands for \"Vision with Generic Algorithms\". \
                    It's a novel computer vision library that puts its \
                    main emphasis on customizable algorithms and data \
                    structures. By using template techniques similar to \
                    those in the C++ Standard Template Library, you can \
                    easily adapt any VIGRA component to the needs of your \
                    application, without thereby giving up execution speed.
homepage            http://hci.iwr.uni-heidelberg.de/vigra/

checksums           rmd160  f54b7742ab74592f404b2af9636ea28ffdbcde51 \
                    sha256  5ac7d71c89b6a70e6be1b30a73b9f81f4373e933d9dede175d97ee8024807a8a

depends_lib         port:jpeg \
                    port:tiff \
                    port:libpng \
                    port:zlib \
                    port:openexr \
                    port:fftw-3-single \
                    port:hdf5-18

# Some additional parameters for cmake. All other params have already been set
# by the cmake PortGroup
configure.args-append   -DWITH_OPENEXR=ON \
                        -DBUILD_SHARED_LIBS=ON

# recursive template instantiation exceeded maximum depth of 128
configure.cxxflags-append -ftemplate-depth-1024

compiler.blacklist *gcc* *dragonegg* {clang < 211.10.1} macports-clang-3.2 macports-clang-3.3
compiler.fallback-append macports-clang-3.4

destroot.env-append DESTDIR=${destroot}

post-destroot {
    if {[variant_isset docs]} {
        # move documentation to a unversioned directory
        xinstall -m 755 -d ${destroot}${prefix}/share/doc
        move ${destroot}${prefix}/doc/${name} \
             ${destroot}${prefix}/share/doc/${name}
    }
    # delete whatever is left in the doc directory
    delete ${destroot}${prefix}/doc
}

variant docs description "Build documentation" {}
if {[variant_isset docs]} {
    depends_lib-append port:doxygen
} else {
    configure.args-append   -DDOXYGEN_DOT_EXECUTABLE= \
                            -DDOXYGEN_EXECUTABLE=
}

variant valgrind description "Include support for VALGRIND" {}
if {[variant_isset valgrind]} {
    depends_lib-append port:valgrind
} else {
    configure.args-append -DWITH_VALGRIND=NO
}

variant python26 conflicts python27 description "Also build vigranumpy python26 bindings" {
    configure.args-append   -DPYTHON_EXECUTABLE=${prefix}/bin/python2.6 \
                            -DPYTHON_SPHINX=${prefix}/bin/sphinx-build-2.6
    depends_lib-append  port:boost \
                        port:python26 \
                        port:py26-numpy \
                        port:py26-sphinx
    require_active_variants boost python26
}

variant python27 conflicts python26 description "Also build vigranumpy python27 bindings" {
    configure.args-append   -DPYTHON_EXECUTABLE=${prefix}/bin/python2.7 \
                            -DPYTHON_SPHINX=${prefix}/bin/sphinx-build-2.7
    depends_lib-append  port:boost \
                        port:python27 \
                        port:py27-numpy \
                        port:py27-sphinx
    require_active_variants boost python27
}

if {![variant_isset python26]} {
    default_variants +python27
}

if {![variant_isset python26] && ![variant_isset python27]} {
    configure.args-append -DWITH_VIGRANUMPY=NO
}

livecheck.version   ${version}
livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     {>version ([0-9.]+)<}
