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

github.setup        weizhongli cdhit 4.8.1 V
github.tarball_from archive
name                cdhit
revision            0

categories          science
platforms           darwin
license             GPL-2
maintainers         {reneeotten @reneeotten} openmaintainer

description         A program for clustering and comparing protein or nucleotide sequences
long_description    ${description}

homepage            http://weizhongli-lab.org/cd-hit/

checksums           rmd160  d45a8d8567c3ab02d4dc2a80af613b3df4597400 \
                    sha256  f8bc3cdd7aebb432fcd35eed0093e7a6413f1e36bbd2a837ebc06e57cdb20b70 \
                    size    945639

depends_lib         port:zlib

depends_run         bin:perl:perl5

patchfiles          patch-Makefile.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/Makefile
    reinplace "s|#!/usr/bin/perl|#!${prefix}/bin/perl|g" {*}[glob ${worksrcpath}/*.pl]
}

variant openmp description "enable OpenMP parallel acceleration" {}

if {[variant_isset openmp]} {
    compiler.openmp_version 2.5
} else {
    build.args-append   openmp=no
}

use_configure       no

build.env           CXX=${configure.cxx} \
                    CXXFLAGS=${configure.cxxflags}

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} license.txt README \
        ChangeLog ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath}/doc cdhit-user-guide.pdf \
        ${destroot}${docdir}
}
