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

# https://trac.macports.org/ticket/66159
legacysupport.newest_darwin_requires_legacy 12
legacysupport.redirect_bins gdk-pixbuf-csource gdk-pixbuf-pixdata gdk-pixbuf-query-loaders gdk-pixbuf-thumbnailer

name                gdk-pixbuf2-devel
conflicts           gdk-pixbuf2
set my_name         gdk-pixbuf2

# GNOME project name
set gname           gdk-pixbuf

version             2.42.11
revision            1
epoch               0

checksums           rmd160  b4a6a43269a805623656d2116999dc82ad6cae4c \
                    sha256  49dcb402388708647e8c321d56b6fb30f21e51e515d0c5a942268d23052a2f00 \
                    size    6524192

categories          graphics
platforms           darwin
license             LGPL
maintainers         {mascguy @mascguy} openmaintainer

description         The gdk-pixbuf-2.0 library
long_description    ${description}
homepage            http://www.gtk.org/

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

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

set python_branch   3.12
set python_version  [string map {. {}} ${python_branch}]

depends_build-append \
                    port:gi-docgen \
                    port:gtk-doc \
                    port:libxslt \
                    port:pkgconfig \
                    port:py${python_version}-docutils

depends_lib-append \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    port:shared-mime-info \
                    port:libpng \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:tiff

license_noconflict  gobject-introspection

patchfiles-append   patch-override-math-function-tests.diff
# Specify name of executable for 'rst2man'
patchfiles-append   patch-docs-rst2man.diff
# Build bug in 2.42.11
patchfiles-append   patch-build-failure-others.diff

post-patch {
    reinplace "s|@@PYTHON_VERSION@@|${python_branch}|g" \
        ${worksrcpath}/docs/meson.build
}

compiler.c_standard \
                    1999

configure.ldflags-append \
                    -lintl

configure.args-append \
                    -Dgtk_doc=false \
                    -Dothers=enabled

# gobject-introspection 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}"
}

platform darwin 8 {
    # meson on Tiger cannot use rpaths, so we workaround with this to find dylib
    build.env-append       "DYLD_LIBRARY_PATH=${build_dir}/gdk-pixbuf"
    destroot.env-append    "DYLD_LIBRARY_PATH=${build_dir}/gdk-pixbuf"
}

variant bundle description {Enable application bundle relocation support} {
    configure.args-append  -Drelocatable=true
}

post-activate {
        system "${prefix}/bin/gdk-pixbuf-query-loaders --update-cache"
}

livecheck.type      gnome
livecheck.name      ${gname}
