# -*- 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
# $Id$
PortSystem      1.0

set instrument  giraf
name            esopipe-${instrument}-wkf
conflicts       esopipe-${instrument}-wkf-devel
version         2.18.4
categories      science
license         GPL-2+
platforms       darwin
maintainers     eso.org:usd-help
homepage        http://www.eso.org/sci/software/pipelines/
description     ESO GIRAFFE instrument pipeline (workflows)
long_description ESO data reduction pipeline workflows for the GIRAFFE instrument. \
                 See www.eso.org/pipelines for a description of the ESO pipeline systems.
master_sites    https://ftp.eso.org/pub/dfs/pipelines/instruments/${instrument}fe
distname        ${instrument}-kit-${version}
checksums       sha256 dc1d9249f32a9b9aba68fa8afa2066f35ac6f020c55fc7d8d5102b9b82b65ce3

worksrcdir          ${instrument}-${version}
extract.post_args   "| tar -xf - ${distname}/${instrument}-${version}.tar.gz"

post-extract {
    system "tar -xzf ${workpath}/${distname}/${instrument}-${version}.tar.gz -C ${workpath}"
    system "rm -rf ${workpath}/${distname}"
}

depends_build   port:cfitsio port:cpl port:pkgconfig
depends_lib     port:adari_core port:edps
depends_run     port:esopipe-${instrument}-recipes \
                port:esoreflex \
                port:py311-astropy \
                port:py311-matplotlib \
                port:py311-numpy \
                port:py311-wxpython-4.0 \
                port:xorg-server

configure.args  --with-cext=${prefix} \
                --with-cfitsio=${prefix} \
                --with-cpl=${prefix}

build {}

destroot {
    system "cd ${worksrcpath}/reflex && make DESTDIR=${destroot} install"
    system "find ${destroot} -type f -path '*/contrib_wkf/*' -delete"
    system "cd ${worksrcpath}/reports && make DESTDIR=${destroot} install"
    system "cd ${worksrcpath}/workflows && make DESTDIR=${destroot} install"
}

post-destroot {
    if {[file exists ${filespath}/setup_wkf_dirs] == 1} {
        system "find ${destroot}${prefix}/share/reflex/workflows/${instrument}-${version} -name \*.xml -exec sh ${filespath}/setup_wkf_dirs ${prefix} ${instrument} {}  \\; "
        system "find ${destroot}${prefix}/share/esopipes/${instrument}-${version}/reflex -name \*.xml -exec sh ${filespath}/setup_wkf_dirs ${prefix} ${instrument} {}  \\; "
    } else {
        return -code error "Problem with Portfile, missing ${filespath}/setup_wkf_dirs!"
    }
}

use_parallel_build  no
