# -*- 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           app       1.0
PortGroup           github    1.0
PortGroup           wxWidgets 1.0
PortGroup           boost     1.0

github.setup        wojdyr fityk 1.3.2 v
revision            0
categories          math
license             GPL-2
maintainers         nomaintainer

description         fityk is for peak fitting.

long_description    fityk is a program for nonlinear fitting of analytical \
                    functions (especially peak-shaped) to data (usually \
                    experimental data). There are also people using it to \
                    remove the baseline from data, or to display data only.

homepage            https://fityk.nieto.pl
github.tarball_from releases
use_bzip2           yes

checksums           rmd160  8560d216333498082389da0eb9f709f0492a42e9 \
                    sha256  6da5eb6279d90b241108e36c2d4880cafec82d7225a5d49a28675a07b4360f0b \
                    size    1611794

app.name            fityk
app.executable      fityk
app.icon            ${worksrcpath}/fityk.png

wxWidgets.use       wxWidgets-3.0

# WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the pngmath_dvipng setting
depends_build-append port:swig-lua

# https://github.com/wojdyr/fityk/issues/56
patchfiles-append   patch-fix-doc.diff

compiler.cxx_standard \
                    2011

use_autoreconf      yes

set py_ver          3.11
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_lib-append  port:lua \
                    port:ncurses \
                    port:python${py_ver_nodot} \
                    port:readline \
                    port:${wxWidgets.port} \
                    port:xylib \
                    port:zlib

depends_run         port:gnuplot

configure.args-append --with-wxdir=${wxWidgets.wxdir}

platform darwin 10 powerpc {
    # Rosetta misdetects arch
    configure.args-append \
                    --build=powerpc-apple-darwin${os.major}
}

if {[string match *clang* ${configure.compiler}]} {
    configure.cxxflags-append -std=c++11
    } else {
    configure.cxxflags-append -std=gnu++11
}

variant docs description {Build and install documentation} {
    depends_build-append port:py${py_ver_nodot}-sphinx
    # TODO: use a python PortGroup and variable
    pre-build {
        reinplace "s|sphinx-build|${frameworks_dir}/Python.framework/Versions/${py_ver}/bin/sphinx-build|" ${worksrcpath}/doc/Makefile
        system -W ${worksrcpath}/doc make
    }
}

if {![variant_isset docs]} {
    pre-build {
        file mkdir ${worksrcpath}/doc/html/placeholder
    }
}
