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

github.setup        window-maker wmaker 0.96.0 wmaker-
revision            1

name                windowmaker
github.tarball_from releases
categories          x11 x11-wm
platforms           darwin freebsd
license             GPL-2+
maintainers         nomaintainer

description         Window Maker is a X11 window manager supporting GNUstep
long_description    Window Maker is an X11 window manager originally designed to provide \
                    integration support for the GNUstep Desktop Environment. \
                    In every way possible, it reproduces the elegant look and feel \
                    of the NEXTSTEP\[tm\] user interface. \
                    It is fast, feature rich, easy to configure, and easy to use. \
                    It is also free software, with contributions being made \
                    by programmers from around the world.

homepage            https://windowmaker.org/

distname            WindowMaker-${version}

checksums           rmd160  fc19c3327362097a581807cb9e2af3475ac1eabf \
                    sha256  4fe130ba23cf4aa21c156ec8f01f748df537d0604ec06c6bbcec896df1926f6d \
                    size    3443048

universal_variant   no

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

depends_lib-append  port:gettext-runtime \
                    port:giflib \
                    port:libexif \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:tiff \
                    port:webp \
                    port:xorg-libXext \
                    port:xorg-libXinerama \
                    port:xorg-libXmu \
                    port:xpm \
                    port:Xft2

post-patch {
    set fl [glob -directory ${worksrcpath} WindowMaker/*menu*]
    lappend fl ${worksrcpath}/WindowMaker/Defaults/WindowMaker.in \
        ${worksrcpath}/WPrefs.app/Menu.c ${worksrcpath}/WPrefs.app/Paths.c
    reinplace -E -q "s,(/usr|/usr/local|/opt/kde2)/share,${prefix}/share,g" {*}${fl}
}

configure.env-append \
                    "LINGUAS=be bg bs ca cs da de el es et fi fr fy gl hr hu hy it ja ko ms nl no pl pt ro ru sk sv tr uk zh_CN zh_TW" \
                    "LIBS=-L${prefix}/lib -lintl -lX11"

##configure.args      --mandir=${prefix}/share/man \
##                    --with-nlsdir=${prefix}/share/locale \

configure.args-append \
                    --disable-silent-rules \
                    --with-gnustepdir=${prefix}/GNUstep/Local \
                    --disable-magick

# actions.c: error: ‘for’ loop initial declaration used outside C99 mode
configure.cflags-append \
                    -std=c99

compiler.c_standard 1999

variant debug description "Build with debugging flags set" {
    # To keep .c/.o/.dSYM files around, set portautoclean no in macports.conf
    # or use port -k to “keep” files around.
    configure.args-append --enable-debug
    configure.optflags -O0
    configure.cflags-append -g2
}

variant candy description "Enable various eye-candy options" {
    post-configure {
        reinplace "s|undef OPTIMIZE_SHAPE|define OPTIMIZE_SHAPE|" \
            ${worksrcpath}/src/wconfig.h
        reinplace "s|undef ICON_KABOOM_EXTRA|define ICON_KABOOM_EXTRA|" \
            ${worksrcpath}/src/wconfig.h
        reinplace "s|undef WINDOW_BIRTH_ZOOM2|define WINDOW_BIRTH_ZOOM2|" \
            ${worksrcpath}/src/wconfig.h
    }
}
