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

R.setup             bioconductor girke-lab ChemmineOB 1.42.0
revision            0
categories-append   bioconductor
maintainers         nomaintainer
license             Artistic-2
description         R interface to a subset of OpenBabel functionalities
long_description    {*}${description}
homepage            https://github.com/girke-lab/ChemmineOB
checksums           rmd160  1ef2d715160868a57c4fc443b7cf615c2c08a24c \
                    sha256  7c914fec647ab0e8db8edf230788f341e9c11fdbc602137a6d615d135eabdb9f \
                    size    1367470

depends_build-append \
                    port:pkgconfig
depends_lib-append  path:share/pkgconfig/eigen3.pc:eigen3 \
                    port:openbabel \
                    port:R-BH \
                    port:R-BiocGenerics \
                    port:R-Rcpp \
                    port:R-zlibbioc

patchfiles          patch-fix-flags.diff

post-patch {
    # https://github.com/girke-lab/ChemmineOB/issues/35
    # https://github.com/girke-lab/ChemmineOB/issues/40
    if {${configure.cxx_stdlib} ne "libc++"} {
        reinplace "s|@PKG_CPPFLAGS@|-D_GLIBCXX_USE_CXX11_ABI=0 -DUSE_BOOST -DHAVE_EIGEN -I${prefix}/include/openbabel3 -I${prefix}/include/eigen3|" \
                    ${worksrcpath}/src/Makevars.in
    } else {
        reinplace "s|@PKG_CPPFLAGS@|-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -DUSE_BOOST -DHAVE_EIGEN -I${prefix}/include/openbabel3 -I${prefix}/include/eigen3|" \
                    ${worksrcpath}/src/Makevars.in
    }
    reinplace "s|@PKG_LIBS@|-L${prefix}/lib -lopenbabel|" ${worksrcpath}/src/Makevars.in
}

depends_test-append port:R-BiocManager \
                    port:R-BiocStyle \
                    port:R-ChemmineR \
                    port:R-knitr \
                    port:R-knitrBootstrap \
                    port:R-rmarkdown \
                    port:R-RUnit

test.run            yes
