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

# posix_memalign
legacysupport.newest_darwin_requires_legacy 9

name                libdazzle
conflicts           libdazzle-devel
set my_name         libdazzle
version             3.38.0
revision            0

categories          gnome
license             GPL-3+
maintainers         nomaintainer

description         ${my_name} is a companion library to GObject and Gtk+.
long_description    {*}${description} It includes a collection of dazzling Gtk widgets, \
                    data structures, search engines, a shortcut engine, panels, \
                    desktop integration, and those missing pieces from common libraries \
                    that help you write cleaner and safer code
homepage            https://gitlab.gnome.org/GNOME/${my_name}

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        gnome:sources/${my_name}/${branch}/
distname            ${my_name}-${version}
dist_subdir         ${my_name}
use_xz              yes

checksums           rmd160  dcef5df588c735a4046b63967ef1597117721561 \
                    sha256  e18af28217943bcec106585298a91ec3da48aa3ad62fd0992f23f0c70cd1678f \
                    size    447304

depends_build-append \
                    port:pkgconfig \
                    path:bin/vala:vala

depends_lib-append  path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3

compiler.c_standard 2011

# uses g-ir-scanner, which uses $CC from env
if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})  "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch})  "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append       "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
}


test.run            yes
test.cmd            meson
test.target         test

platform darwin 8 {
    test.env-append "DYLD_LIBRARY_PATH=${build_dir}/src"
}

# PowerPC support
if {[string match *gcc* ${configure.compiler}] && ${os.arch} eq "powerpc" } {
    # https://trac.macports.org/ticket/63490
    patchfiles-append patch-libdazzle-gcc-powerpc-packed.diff

    # Work around some fstack-protector-strong link errors. We could patch
    # locally, but the same error affects the g-ir-scanner invocation, so it
    # won't do any good until gnome.generate_gir is fixed in meson.
    # See: https://gitlab.gnome.org/GNOME/libdazzle/-/merge_requests/56
    configure.args-append --buildtype=plain
}

livecheck.type      gnome
livecheck.name      ${my_name}
