# -*- 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  muse
name            esopipe-${instrument}-contrib-wkf
conflicts       esopipe-${instrument}-contrib-wkf-devel
version         2.10.14
categories      science
license         GPL-2+
platforms       darwin
maintainers     eso.org:usd-help
homepage        http://www.eso.org/sci/software/pipelines/
description     Extra 3rd party contributed workflows for MUSE
long_description These are additional 3rd party contributed workflows that can \
                 be used with the MUSE instrument pipeline. They are not \
                 part of the officially maintained ESO pipeline distribution, \
                 but are packaged and distributed for convenience.
master_sites    https://ftp.eso.org/pub/dfs/pipelines/instruments/${instrument}
distname        ${instrument}-kit-${version}-1
checksums       sha256 0b1d1a964ad9efe0d14bf1ed7ae874c88d12a12e289587a591a4dc2f9f36ac7b

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:cpl port:pkgconfig
depends_run     port:esopipe-${instrument} \
                port:esopipe-${instrument}-datademo \
                port:esoreflex \
                port:py39-astropy \
                port:py39-matplotlib \
                port:py39-numpy \
                port:py39-scipy \
                port:py39-wxpython-4.0 \
                port:xorg-server

configure.args  --with-cpl=${prefix}

build {}

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

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
