# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           qt4 1.0

# Kate 4.14 (the last Qt 4 based Kate) built against plain Qt 4, without
# kdelibs, kdeinit, D-Bus or X11: Kate.app (the MDI editor) and KWrite.app.

# Sources: upstream Kate at the KDE/4.14 branch head (23 commits past 4.14.3),
# fetched as GitHub's archive of that commit. The changes to upstream files
# are the patches in files/, one per source area; everything the port adds
# (the qt4compat kdelibs replacement, the build system, the Kate application
# glue, the current upstream syntax highlighting definitions, docs) plus a few
# upstream files rewritten from scratch is the overlay tarball, unpacked over
# the sources before patching. Nothing is deleted: upstream files this build
# no longer uses stay in the tree unused. Both are generated from branch
# qt4-pure of the fork by packaging/macports/make-port.sh (see BUILDING-QT4.md).
github.setup        KDE kate f17e4c99b64efca8afa42bc5511ffe73c8ec2370
version             4.14.3
revision            0
categories          editors aqua
license             {LGPL-2+ GPL-2+}
maintainers         nomaintainer
description         Kate and KWrite text editors built on plain Qt 4, without KDE libraries
long_description    Kate is the KDE advanced text editor: multiple documents and views, \
                    sessions, a document tree, syntax highlighting for hundreds of \
                    languages, code folding, vi mode and scripting. KWrite is its \
                    single-document shell. This port builds the Kate 4.14 code base \
                    against Qt 4 only: the kdelibs pieces it needs are replaced by \
                    a small in-tree compatibility layer, so there is no kdelibs, kdeinit, \
                    ksycoca, D-Bus or X11 dependency. Installs Kate.app and KWrite.app, \
                    with the current upstream set of syntax highlighting definitions \
                    and the multi-file search plugin.
homepage            https://kate-editor.org

# The overlay tarball: host it and point the :overlay site at it, or drop it
# into ${prefix}/var/macports/distfiles/kate-qt4/ for a local build.
set overlay         kate-qt4-overlay-${version}.qt4.0.tar.xz
master_sites-append https://github.com/macos-powerpc/kate/releases/download/v${version}/:overlay
distfiles-append    ${overlay}:overlay
extract.only        ${distname}${extract.suffix}
depends_extract-append \
                    port:xz

github.tarball_from archive
checksums           ${distname}${extract.suffix} \
                    rmd160  73dcb091cc3909835b0995c4ee11ceea9da0dd33 \
                    sha256  ffea4068f8d0e9aaddda67a5885c318cd0503f7b99e0847f1b1a3e3b47d114d4 \
                    size    3814191 \
                    ${overlay} \
                    rmd160  1ce1c462ef3e472ba163caf726de90bd79f47e99 \
                    sha256  d755c2d84f065dfb18bc66054e5d2f18f38abe154e9d87bfa2120414cfe1832a \
                    size    2349624

post-extract {
    # files the port adds, plus the rewritten upstream files listed in
    # packaging/macports/replaced-files.txt of the tree
    system -W ${worksrcpath} "${prefix}/bin/xz -dc ${distpath}/${overlay} | tar -xf -"
}

patch.pre_args-replace  -p0 -p1
patchfiles          patch-part.diff patch-ktexteditor.diff patch-kwrite.diff \
                    patch-kate.diff patch-addons.diff patch-misc.diff

# Perl and Python 3 run upstream's generators for the derived syntax
# highlighting definitions (part/syntax/generators) at build time
set python_branch   3.14
depends_build-append \
                    port:makeicns \
                    path:bin/perl:perl5 \
                    port:python[string map {. {}} ${python_branch}]

# pcre2 is the regular expression engine of syntax highlighting and search
depends_lib-append  port:bzip2 \
                    port:pcre2 \
                    port:zlib

# Kate 4.14 is C++98 code; DO NOT require C++11 here.

configure.args-append \
                    -DBUILD_TESTING=OFF \
                    -DKATE_BUILD_ADDONS=ON \
                    -DKATE_BUILD_KATE=ON \
                    -DKATE_BUILD_KWRITE=ON \
                    -DKATE_INSTALL_BUNDLE_DIR=${applications_dir} \
                    -DPERL_EXECUTABLE=${prefix}/bin/perl5 \
                    -DPYTHON_EXECUTABLE=${prefix}/bin/python${python_branch}

# qt4-mac may be installed in concurrent mode under ${prefix}/libexec/qt4
configure.args-append \
                    -DQT_QMAKE_EXECUTABLE=${qt_qmake_cmd}

livecheck.type      none
