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

name                    gkrellm
version                 2.4.0
revision                0
categories              sysutils
maintainers             nomaintainer
license                 GPL-3+

description             A GTK based system monitor

long_description        ${description}

# gkrellm.net invalid 2023 - Author Bill Wilson RIP 2022
homepage                http://gkrellm.srcbox.net
master_sites            http://gkrellm.srcbox.net/releases/

checksums               rmd160  b6748271e78657c842ec14f6bc05bb872c0abca3 \
                        sha256  6f83665760b936ad4b55f9182b1ec7601faf38a0f25ea1e4bddc9965088f032d \
                        size    790070

use_bzip2               yes

depends_build           port:gettext \
                        path:bin/pkg-config:pkgconfig

depends_lib             port:gettext-runtime \
                        path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                        port:xorg-libsm

use_configure           no

variant universal {}

build.type              gnu
build.env               CC=${configure.cc} \
                        "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                        CPPFLAGS=${configure.cppflags} \
                        "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"

platform darwin {
    # May be relevant for *BSD too.
    patchfiles-append   patch-fix-install.diff

    build.target        darwin9
    destroot.target     install_darwin9
}

set plugin_dir          ${prefix}/libexec/gkrellm2/plugins
set theme_dir           ${prefix}/share/gkrellm2/themes

platform darwin 8 {
    build.target        darwin
    destroot.target     install_darwin
}

post-patch {
    reinplace "s|\$(PREFIX)|${prefix}|g" \
        "${worksrcpath}/Makefile"

    reinplace "s|/usr/local/share/gkrellm2/themes|${theme_dir}|g" \
        "${worksrcpath}/src/gkrellm.h"

    reinplace "s|/usr/share/gkrellm2/themes|${theme_dir}|g" \
        "${worksrcpath}/src/gkrellm.h"

    reinplace "s|/usr/local/lib/gkrellm2/plugins|${plugin_dir}|g" \
        "${worksrcpath}/src/gkrellm.h"

    reinplace "s|/usr/lib/gkrellm2/plugins|${plugin_dir}|g" \
        "${worksrcpath}/src/gkrellm.h"
}

post-destroot {
    xinstall -m 755 -d ${destroot}${theme_dir}
    xinstall -m 755 -d ${destroot}${plugin_dir}

    destroot.keepdirs \
        ${destroot}${theme_dir} \
        ${destroot}${plugin_dir}
}

notes "
After the first launch of GkrellM, the directory ~/.gkrellm2/\
is created that contains the file user-config to keep your\
settings, and also contains directories named themes/ and plugins/.\
However, the plugins and themes directories for this port of\
GkrellM are fixed at these locations:

${plugin_dir}
${theme_dir}
"

startupitem.create      yes
startupitem.executable  ${prefix}/bin/gkrellmd
