# -*- 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

PortSystem          1.0
PortGroup           cmake 1.1
PortGroup           github 1.0

github.setup        openbabel openbabel 2-4-1 openbabel-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                openbabel2
conflicts           openbabel
version             [string map {- .} ${github.version}]
revision            1

categories          science devel chemistry
license             GPL-2
maintainers         {reneeotten @reneeotten} openmaintainer

description         A chemistry file translation program.
long_description    Open Babel is a free, open-source version \
                    of the Babel chemistry file translation program. \
                    OpenBabel is a project designed to pick up where \
                    Babel left off, as a cross-platform program and \
                    library designed to interconvert between many \
                    file formats used in molecular modeling and \
                    computational chemistry.

homepage            https://openbabel.org/wiki/Main_Page

checksums           rmd160  0587a3d3dd24c485ff9a680ff83145f052b504f4 \
                    sha256  a58c6540fd07de7c40bd30e4218f8ade36d743b2ecc307df6cfb4c195d1600cb \
                    size    6668659

depends_build-append \
                    path:share/pkgconfig/eigen3.pc:eigen3 \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  path:lib/pkgconfig/cairo.pc:cairo \
                    port:libiconv \
                    port:libxml2 \
                    port:zlib

# Build behaves incoherently, ignoring -DBUILD_GUI=OFF.
# https://trac.macports.org/ticket/71480
patchfiles-append   patch-fix-wxWidgets-search.diff

# eigen3-devel needs C++14 though.
compiler.cxx_standard   2011

configure.args-append \
                    -DBUILD_GUI=OFF \
                    -DBUILD_TESTING=OFF \
                    -DPYTHON_BINDINGS=OFF

github.livecheck.regex  {(2\-[0-9-]+)}

# deactivate hack to have a smooth transition from the original openbabel port (providing version 2.x) to openbabel2
if {![catch {set installed [lindex [registry_active openbabel] 0]}]} {
    set _version [lindex $installed 1]
    if {[vercmp $_version ${version}] <= 0} {
        registry_deactivate_composite openbabel "" [list ports_nodepcheck 1]
    }
}
