# -*- 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           gobject_introspection 1.0
PortGroup           yelp 1.0

name                gnome-music
version             3.24.2
revision            3
license             GPL-2
set branch          [join [lrange [split ${version} .] 0 1] .]
description         Music is the GNOME music playing application.
long_description    ${description}

maintainers         {devans @dbevans} openmaintainer
categories          gnome
platforms           darwin
homepage            https://wiki.gnome.org/Apps/Music
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  8a16fdf884bbf0a43b7f81807e430910ccbc8ba7 \
                    sha256  1a72b7972cac66c7aba7a4fbcbf8df99b3df7c46f26957b3e16089550d3ef62c

depends_build       port:pkgconfig \
                    port:intltool \
                    port:yelp-tools \
                    port:itstool \
                    port:gnome-common \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:desktop-file-utils \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:grilo-plugins \
                    port:tracker \
                    port:libnotify

depends_run         port:adwaita-icon-theme

gobject_introspection yes

patchfiles          patch-configure.ac.diff

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
    reinplace "s|^#!/.*|#!${configure.python}|" ${worksrcpath}/gnome-music.in
}

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

configure.cmd       ./autogen.sh

configure.args      --disable-schemas-compile \
                    --disable-silent-rules

# requires python >= 3.3
# default to python 3.6

variant python35 conflicts python36 python37 description {Use Python 3.5 at run time} {
    depends_lib-append  port:py35-gobject3 \
                        port:py35-requests \
                        port:dbus-python35

    configure.python            ${prefix}/bin/python3.5
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.5
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
}

variant python36 conflicts python35 python37 description {Use Python 3.6 at run time} {
    depends_lib-append  port:py36-gobject3 \
                        port:py36-requests \
                        port:dbus-python36

    configure.python            ${prefix}/bin/python3.6
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.6
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
}

variant python37 conflicts python35 python36 description {Use Python 3.7 at run time} {
    depends_lib-append  port:py37-gobject3 \
                        port:py37-requests \
                        port:dbus-python37

    configure.python            ${prefix}/bin/python3.7
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.7
    configure.pkg_config_path   ${python_prefix}/lib/pkgconfig
}

if {![variant_isset python35] && ![variant_isset python37]} {
    default_variants +python36
}

# port installs hicolor icons, desktop application file, and gschemas
post-activate {
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type      gnome
