# -*- 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           meson 1.0
PortGroup           legacysupport 1.1
PortGroup           active_variants 1.1

# O_CLOEXEC, openat
legacysupport.newest_darwin_requires_legacy 13

name                tracker3
version             3.7.3
revision            2
license             LGPL-2.1+
set branch          [join [lrange [split ${version} .] 0 1] .]
description         Object database, tag/metadata database, search tool \
                    and indexer
long_description    {*}${description}

set real_name       tracker
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
categories          gnome sysutils
homepage            https://wiki.gnome.org/Projects/Tracker
master_sites        gnome:sources/${real_name}/${branch}/
distname            ${real_name}-${version}
use_xz              yes

checksums           rmd160  7ce61a898bfd0830d967d4c60aab83812f90671c \
                    sha256  ab3d4a50937e04c5ed7846f6dbb999e2909819402f389ca592ee6b77dd28d1f9 \
                    size    1789728

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]
configure.python    ${prefix}/bin/python${py_ver}

patchfiles-append   patch-meson.build.diff

post-patch {
    reinplace "s|@PYTHON@|${configure.python}|" ${worksrcpath}/meson.build
    fs-traverse f ${worksrcpath} {
        if {[string match *.py ${f}]} {
            ui_info "patching testpath: ${f}"
            reinplace -q "s|/usr/bin/python3$|${configure.python}|" ${f}
            reinplace -q "s|/usr/bin/env python3$|${configure.python}|" ${f}
        }
    }
}

depends_build-append \
                    port:asciidoc \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot} \
                    path:bin/vala:vala

depends_lib-append  port:avahi \
                    port:dbus \
                    port:gettext-runtime \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:json-glib \
                    port:libsoup-2.4 \
                    port:libxml2 \
                    port:ossp-uuid \
                    port:py${py_ver_nodot}-gobject3 \
                    port:sqlite3

# src/tracker/tracker-main.c:29:10: fatal error: 'gio/gdesktopappinfo.h' file not found
require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 x11

# It does not build with C99 compiler.
# tracker-sparql-grammar.h:496: error: redefinition of typedef ‘TrackerGrammarRule’
compiler.c_standard 2011

configure.args-append \
                    -Dbash_completion=false \
                    -Ddocs=false \
                    -Dsoup=soup2 \
                    -Dstemmer=disabled \
                    -Dsystemd_user_services=false

# https://gitlab.gnome.org/GNOME/tracker/-/issues/443
if {${configure.build_arch} in [list arm i386 ppc]} {
    patchfiles-append \
                    patch-meson.build-32.diff
}
