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

name                cell-id
version             1.4.6
revision            2
categories          science biology
license             LGPL-2.1+
maintainers         fbmc.fcen.uba.ar:abush
description         Microscopy based cytometry segmentation software
long_description    Cell-ID is a command line software that segments bright field \
                    microscopy images of yeast and mammalian cells, tracks cells \
                    over time and quantifies morphological and fluorescence \
                    features for each cell.
homepage            https://sourceforge.net/projects/cell-id
master_sites        sourceforge:project/cell-id
distname            cell_id_${version}
livecheck.regex     /cell_id_(\\d+(?:\\.\\d+)*)
use_zip             yes

checksums           rmd160  1406f30acdd62d87f1135eaa5b8e791663237c70 \
                    sha256  43fed46ef32bd4a45e75e77f78a5ec52b3500634a5561c09a5d033b50d04710b \
                    size    524550

depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:tiff

post-patch {
    reinplace "s|-static|${configure.cflags} ${configure.cc_archflags}|g" ${worksrcpath}/Makefile
    reinplace "s|-I/local|-I${prefix}|g" ${worksrcpath}/Makefile
    reinplace "s|-L/local/lib|-I${prefix}/lib/glib-2.0/include -L${prefix}/lib|g" ${worksrcpath}/Makefile
    reinplace "s|rm cell|rm -f cell|g" ${worksrcpath}/Makefile
    reinplace "s|gcc|\$(CC)|g" ${worksrcpath}/Makefile
}

use_configure       no

pre-build {
    system -W ${worksrcpath} "${build.cmd} clean"
}

build.target        cell
build.env           CC=${configure.cc}
use_parallel_build  no

destroot {
    xinstall ${worksrcpath}/cell ${destroot}${prefix}/bin/cell
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} Cell-ID-help.txt GNU_Lesser_General_Public_License.txt \
        README.txt cell_id_description_of_output_file_R.txt \
        cell_id_description_of_output_files_PAW.txt parameters.txt \
        ${destroot}${prefix}/share/doc/${name}
}
