# -*- 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           meson 1.0

name                appstream
version             1.1.4
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  94b4a4796de0c3566a1f99e418d2d34cda32425d \
                    sha256  42ee663ef1ef3defc94cafc842be8c427e7a6ee660c9ca08fabdd0262d38fb9c \
                    size    2839320

use_xz              yes

patchfiles-append   patch-use-correct-include-dir.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

# In 1.1.4 someone decided to enable wayland by default on macOS...
# https://github.com/ximion/appstream/issues/765

configure.args-append \
                    -Dapidocs=false \
                    -Dbash-completion=false \
                    -Dinstall-docs=false \
                    -Dman=false \
                    -Dqt=false \
                    -Dstemming=true \
                    -Dsvg-support=true \
                    -Dsystemd=false \
                    -Dvapi=true \
                    -Dwayland=false \
                    -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
}
