# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;

PortSystem          1.0
PortGroup           muniversal 1.0

name                oxygen-gtk2
subport             oxygen-gtk3 {}

categories          x11 gtk

description         Oxygen-Gtk is a port of the default KDE widget theme (Oxygen) to GTk.

long_description    ${description} \n\
                    Its primary goal is to ensure visual consistency between GTk and Qt-based \
                    applications running under KDE. A secondary objective is to have a \
                    stand-alone nice looking GTk theme that behaves well on other desktop \
                    environments. \n\
                    Unlike other attempts made to port the KDE Oxygen theme to GTk, this attempt \
                    does not depend on Qt (via some Qt to GTk conversion engine), nor does it render \
                    the widget appearance via hardcoded pixmaps.

platforms           darwin
license             LGPL-2+
maintainers         {gmail.com:rjvbertin @RJVB}

homepage            http://kde-look.org/content/show.php/Oxygen+Gtk?content=136216

if {${subport} eq "oxygen-gtk3"} {
    version             1.4.1
    distname            ${subport}-${version}

    PortGroup           cmake 1.0
    cmake.out_of_source yes

    master_sites        kde:stable/${subport}/${version}/src/ \
                        ftp://ftp.kde.org/pub/kde/stable/${subport}/${version}/src
    livecheck.regex     "oxygen-gtk3 - version.*(1\\.\\d+?(\\.\\d+))"

    checksums           rmd160  3279bfd21840cd4c7fa85e4d411c2a962cffa9e3 \
                        sha256  0e64227c85753a479904ecb41160cd06abf0a3da4a2cf33c11edf502bfe4a75d

    depends_lib-append  path:lib/pkgconfig/gtk+-3.0.pc:gtk3
} else {
    version             1.4.5

    PortGroup           cmake 1.0
    cmake.out_of_source yes

    master_sites        kde:stable/${name}/${version}/src/ \
                        ftp://ftp.kde.org/pub/kde/stable/${name}/${version}/src
    livecheck.regex     "Oxygen Gtk.*(1\\.\\d+?(\\.\\d+))"

    checksums           rmd160  51360c2b16887b22d093e29fea3456210d92e335 \
                        sha256  5b6c826a9741c244dc41ff5412657b82f1f4f622e8cfc3f99e6d2aa714c1d303

    depends_lib-append  path:lib/pkgconfig/gtk+-2.0.pc:gtk2
}

livecheck.type      regex
livecheck.url       ${homepage}

use_bzip2           yes

depends_build-append    port:pkgconfig
depends_lib-append  port:xorg-libX11 \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:dbus

post-configure {
    # Default libraries extension is ".dylib" on Darwin, not ".so", but gtk-engines must have a .so extension
    # NB: replacing the extension post-destroot seems to work too, but this seems cleaner to me even if more complicated.
    if {[variant_exists universal] && [variant_isset universal]} {
        reinplace {s/liboxygen-gtk\.dylib/liboxygen-gtk\.so/} ${workpath}/build-x86_64/src/CMakeFiles/oxygen-gtk.dir/build.make \
            ${workpath}/build-x86_64/src/CMakeFiles/oxygen-gtk.dir/cmake_clean.cmake \
            ${workpath}/build-x86_64/src/CMakeFiles/oxygen-gtk.dir/link.txt \
            ${workpath}/build-x86_64/src/cmake_install.cmake
        reinplace {s/liboxygen-gtk\.dylib/liboxygen-gtk\.so/} ${workpath}/build-i386/src/CMakeFiles/oxygen-gtk.dir/build.make \
            ${workpath}/build-i386/src/CMakeFiles/oxygen-gtk.dir/cmake_clean.cmake \
            ${workpath}/build-i386/src/CMakeFiles/oxygen-gtk.dir/link.txt \
            ${workpath}/build-i386/src/cmake_install.cmake
    } else {
        reinplace {s/liboxygen-gtk\.dylib/liboxygen-gtk\.so/} ${workpath}/build/src/CMakeFiles/oxygen-gtk.dir/build.make \
            ${workpath}/build/src/CMakeFiles/oxygen-gtk.dir/cmake_clean.cmake \
            ${workpath}/build/src/CMakeFiles/oxygen-gtk.dir/link.txt \
            ${workpath}/build/src/cmake_install.cmake
    }
}
