# -*- 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        astromatic sextractor 2.28.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                source-extractor
categories          science
maintainers         {aronnax @lpsinger} openmaintainer
license             GPL-3+

description         tool to make catalogs of sources from astronomical images

long_description    Source Extractor is software \
    for making catalogs of sources from astronomical images. Multi-Extension \
    FITS is now supported. Binary output catalogs are also MEFs. ASCII \
    output catalogs contain detections from all extensions merged together. \
    Use the "EXT_NUMBER" catalog parameter to identify the extension on which \
    a given source was detected. Check-images will also be written as MEFs \
    if the input image is a MEF.

use_autoreconf      yes

depends_lib-append  port:cfitsio \
                    port:fftw-3 \
                    port:fftw-3-single \
                    port:OpenBLAS

checksums           rmd160  32d56c0b46cf67ebbb479ccffda7242370e51e3e \
                    sha256  d386deceff3fb9cc50841f530f6612d12595ba548e1a81970e2d1f54866aee92 \
                    size    2687844

patchfiles          Rename-CLI-tool-to-source-extractor.patch \
                    finite.patch \
                    Fix-format-security-errors.patch
patch.pre_args-replace  -p0 -p1

configure.fc        ${prefix}/bin/no-possible-compiler
configure.cflags-append {*}${configure.cppflags}
configure.args      --enable-openblas \
                    --with-openblas-libdir=${prefix}/lib \
                    --with-openblas-incdir=${prefix}/include/openblas \
                    --with-cfitsio-libdir=${prefix}/lib \
                    --with-cfitsio-incdir=${prefix}/include \
                    --with-fftw=${prefix}/lib \
                    --with-fftw-incdir=${prefix}/include

post-destroot {
    set docdir ${destroot}${prefix}/share/doc
    xinstall -d ${docdir}
    copy ${worksrcpath}/doc ${docdir}/${name}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS \
        COPYRIGHT \
        ChangeLog \
        BUGS \
        HISTORY \
        THANKS \
        ${docdir}/${name}
}
