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

name                ocaml-stk
# Everything later is broken by switching to OCaml 5.x.
version             0.1.0
revision            4
categories          ocaml devel
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             GPL-3
description         SDL-based GUI toolkit
long_description    {*}${description}
homepage            https://zoggy.frama.io/${name}
master_sites        https://framagit.org/zoggy/${name}/-/archive/${version}/
use_bzip2           yes
checksums           rmd160  23f4e196af5e4634865c958c40b6af6ab2a1ce6e \
                    sha256  547c3969f806fcb11099c3e1fd3dfa5a097a3c6e770007386e7717c5b657edab \
                    size    202026

patchfiles          patch-default_theme.json.diff

# Disabled since it does something wrong, apparently.
# https://framagit.org/zoggy/ocaml-stk/-/commit/24418e8e42ce11265111dc2ed94748747993cc43
# patchfiles-append   patch-big-endian.diff
# Discussion in Issue #13 on https://framagit.org/zoggy/chamo

if {${subport} eq ${name}} {
    depends_run     port:liberation-fonts
}

post-patch {
    reinplace "s|/usr/share/fonts/truetype|${prefix}/share/fonts/TTF|" ${worksrcpath}/lib/font.ml
}

depends_lib-append  port:ocaml-css \
                    port:ocaml-fmt \
                    port:ocaml-higlo \
                    port:ocaml-logs \
                    port:ocaml-lwt \
                    port:ocaml-lwt_ppx \
                    port:ocaml-pcre \
                    port:ocaml-ocf \
                    port:ocaml-ocf_ppx \
                    port:ocaml-ppx_blob \
                    port:ocaml-ptime \
                    port:ocaml-sedlex \
                    port:ocaml-tsdl \
                    port:ocaml-tsdl-image \
                    port:ocaml-tsdl-ttf \
                    port:ocaml-uunf \
                    port:ocaml-uutf

ocaml.build_type    dune

subport ocaml-stk_iconv {
    revision        4

    description     Bindings to GNU libiconv

    # Same issue as https://trac.macports.org/ticket/50044
    patchfiles      patch-iconv.diff

    depends_lib     port:libiconv \
                    port:ocaml-ctypes \
                    port:ocaml-ctypes-foreign \
                    port:ocaml-logs
}

# subport ocaml-stk_ocf {
#     description     Utils to build GUI above Ocf
# 
#     depends_lib     port:ocaml-ocf \
#                     port:ocaml-stk
# }

# subport ocaml-stk_ppx {
#     description     PPX used for debug logging in Stk
# 
#     depends_lib     port:ocaml-ppxlib
# }

# subport ocaml-stk_rdf {
#     description     Utilities to display and edit RDF data
# 
#     depends_lib     port:ocaml-rdf \
#                     port:ocaml-stk
# }

# FIXME
# Abominable hack which should not be here,
# but yojson upstream decided to break every dependent.
if {${subport} eq ${name} || ${subport} eq "ocaml-stk_ocf"} {
    depends_build-append \
                    port:ocaml-yojson2
}

livecheck.type      regex
livecheck.regex     ${name}-(\[0-9\.]+).tar.bz2
