# $Id: Portfile 78305 2011-05-02 19:03:46Z mmoll@macports.org $

PortSystem 1.0
PortGroup cmake 1.0

name                ompl
version             0.9.3
revision            1
categories          science
maintainers         mmoll
description         The Open Motion Planning Library (OMPL)
long_description    The Open Motion Planning Library (OMPL) consists of a set \
                    of sampling-based motion planning algorithms.
homepage            http://ompl.kavrakilab.org
platforms           darwin
license             BSD
master_sites        sourceforge
checksums           md5     b95b4b3a6eebc15a668a52a133384cc1 \
                    sha1    f98fd0828be7fc0986caab1607f1c1f4b6ded67a \
                    rmd160  62f80874b9a2e467953f813748fa63ab5452a531
distname            ${name}-${version}-Source
depends_lib-append  port:boost port:ode
test.run            yes

configure.args-append   -DOMPL_BUILD_TESTS=OFF -DOMPL_BUILD_DEMOS=OFF

# The +app variant includes all the content of the regular OMPL version, but 
# adds a simple GUI and an extra library with bindings to the assimp and pqp
# libraries. The cascade of dependencies due to pyqt4 is rather large, so by 
# default the +app variant is not enabled. Also, the additions to OMPL in 
# this variant are distributed under a slightly different license than the
# regular OMPL version.
variant app description {Include GUI and extra demo code} {
    distname            omplapp-${version}-Source
    license             multiple
    pre-extract {
        ui_warn "The +app variant causes some extra code to be compiled that is
distributed under the Rice University Software Distribution License. For 
details, please read:
http://ompl.kavrakilab.org/license.html#ricelicense"
    }
    depends_lib-append  port:assimp port:pqp
    checksums           md5     71350b5c11972784fbb0d1857acd1425 \
                        sha1    f58bafa3b1599ad6b32364942d0713ee9339fd3c \
                        rmd160  dfe0d7b3aa341e1f6dfa6be5bde3e08dd5007c4c
}

variant python26 description {Use python2.6 for python bindings} conflicts python27 {
    depends_lib-append      port:python26
    if { [variant_isset app] } {
        depends_lib-append      port:py26-pyqt4 port:py26-opengl
        post-destroot {
            reinplace "s|#!/usr/bin/env python|#!${prefix}/bin/python2.6|g" \
                ${destroot}${prefix}/bin/ompl_app
        }
    } else {
        # ompl +app contains pre-generated python binding code, ompl does not
        build.target            update_bindings all
        depends_build-append    port:py26-pyplusplus-devel
    }
    configure.env-append    PYTHON_EXEC=${prefix}/bin/python2.6
}

variant python27 description {Use python2.7 for python bindings} conflicts python26 {
    depends_lib-append      port:python27
    if { [variant_isset app] } {
        depends_lib-append  port:py27-pyqt4 port:py27-opengl
        post-destroot {
            reinplace "s|#!/usr/bin/env python|#!${prefix}/bin/python2.7|g" \
                ${destroot}${prefix}/bin/ompl_app
        }
    } else {
        # ompl +app contains pre-generated python binding code, ompl does not
        build.target            update_bindings all
        depends_build-append    port:py27-pyplusplus-devel
    }
    configure.env-append    PYTHON_EXEC=${prefix}/bin/python2.7
}

# enable one python variant so that the python bindings can be compiled
if { ![variant_isset python26] && ![variant_isset python27] } {
    default_variants        +python26
}

# the python bindings rely on Boost.Python, so make sure it is installed.
pre-fetch {
    if {![file exists ${prefix}/lib/libboost_python-mt.dylib]} {
        return -code error "Please reinstall boost with the +python26 or +python27 variant enabled."
    }
}

livecheck.type  regex
livecheck.url   http://ompl.kavrakilab.org/download.html
livecheck.regex (\[0-9.\]+), released
