# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

name                fzf
github.setup        jethrokuan fzf_ocaml c44df2c24172d1219e99a6ee233bcd3bc5841916
version             0.0.1
revision            0

categories          sysutils ocaml
# There is no license set atm: https://github.com/jethrokuan/fzf_ocaml/issues/1
license             Restrictive
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         FZF clone in OCaml
long_description    {*}${description}

checksums           rmd160  89a94633aa83d8ae828f31df3db8bcf52aa8a40f \
                    sha256  93bb257f20b6dfaa265baf2205940bccfb8efbdd907298068b5d34fa9e00e55a \
                    size    5939
github.tarball_from archive

installs_libs       no

# https://github.com/jethrokuan/fzf_ocaml/issues/2
patchfiles          0001-Fix-build-with-modern-ocaml.patch

# Add support for arrow key navigation:
patchfiles-append   0002-Add-basic-arrow-navigation.patch \
                    0003-Fix-ups-to-navigation.patch

# Add support for extra args:
patchfiles-append   0004-Support-extra-args.patch \
                    0005-Improve-args-handling.patch

# Return a sensible version:
patchfiles-append   0006-Support-version-reporting.patch

platform darwin {
    patchfiles-append \
                    0007-Fix-macOS.patch
}

depends_build-append \
                    port:ocaml-dune
depends_lib-append  port:ocaml \
                    port:ocaml-async \
                    port:ocaml-core \
                    port:ocaml-core_unix \
                    port:ocaml-ppx_jane

use_configure       no
universal_variant   no

build {
    if {${configure.build_arch} in [list ppc ppc64]} {
        system -W ${worksrcpath} "DUNE_CONFIG__COPY_FILE=portable ${prefix}/bin/dune build fzf.bc"
    } else {
        system -W ${worksrcpath} "${prefix}/bin/dune build fzf.exe"
    }
}

destroot {
    if {${configure.build_arch} in [list ppc ppc64]} {
        xinstall -m 755 ${worksrcpath}/_build/default/fzf.bc ${destroot}${prefix}/bin/fzf
    } else {
        xinstall -m 755 ${worksrcpath}/_build/default/fzf.exe ${destroot}${prefix}/bin/fzf
    }
}
