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

legacysupport.newest_darwin_requires_legacy 9

name                appstream
version             1.1.5
revision            0

categories          gnome devel
license             GPL-2+ LGPL-2.1+
maintainers         nomaintainer

description         Machine-readable software metadata for desktop environments
long_description    {*}${description}
homepage            https://www.freedesktop.org/wiki/Distributions/AppStream
master_sites        https://www.freedesktop.org/software/${name}/releases/
distname            AppStream-${version}
checksums           rmd160  29d7fbc6b2199d0a3c35852e35923b5c3e8cc09a \
                    sha256  fc57337e250b0d27e75ac4216cc69a76d03c54011a5da5c7a2c57711a3d0cdf9 \
                    size    2842040

use_xz              yes

# Fix broken dependency handling on macOS and use the right prefix:
patchfiles-append   fix-meson.build.diff \
                    patch-as-system-info.c.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/meson.build
}

depends_build-append \
                    port:docbook-xml \
                    port:docbook-xsl-nons \
                    port:gettext \
                    port:gperf \
                    port:itstool \
                    port:lmdb \
                    path:bin/pkg-config:pkgconfig \
                    path:bin/vala:vala

depends_lib-append  port:curl \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libstemmer \
                    port:libxml2 \
                    port:libxmlb \
                    port:libfyaml \
                    port:zstd

gobject_introspection   yes

compiler.c_standard     2017
compiler.cxx_standard   2020

configure.args-append \
                    -Dapidocs=false \
                    -Dbash-completion=false \
                    -Dinstall-docs=false \
                    -Dman=false \
                    -Dqt=false \
                    -Dstemming=true \
                    -Dsvg-support=true \
                    -Dsystemd=false \
                    -Dvapi=true \
                    -Dzstd-support=true

pre-configure {
    configure.args-replace  -Dintrospection=enabled -Dgir=true
}

if {[string match macports-gcc* ${configure.compiler}]} {
    # https://github.com/pantoniou/libfyaml/issues/285
    configure.cflags-append \
                -Wno-error=incompatible-pointer-types
}
