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

# strnlen
legacysupport.newest_darwin_requires_legacy 10

github.setup            ice-wm icewm 3.9.0
revision                0
categories              x11 x11-wm
maintainers             nomaintainer
license                 GNU-2
description             IceWM is a window manager for the X Window System
long_description        {*}${description}. The features of IceWM are speed, simplicity \
                        and not getting in the user’s way.
checksums               rmd160  09787a8dfdf191f6d97c2f29009892fd47879746 \
                        sha256  ca755cb024459ade86518f89202b8a92d3cb9957b9a5e17abdbf824f708ad8de \
                        size    2650512
github.tarball_from     archive

use_autoreconf          yes

compiler.cxx_standard   2011

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

# gdk-pixbuf is still linked to, even if disabled.
depends_lib-append      path:lib/pkgconfig/cairo.pc:cairo \
                        path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2-devel \
                        port:gettext-runtime \
                        path:lib/pkgconfig/glib-2.0.pc:glib2 \
                        port:fontconfig \
                        port:freetype \
                        port:fribidi \
                        port:imlib2 \
                        port:libiconv \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libpng \
                        path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                        port:Xft2 \
                        port:xorg-libice \
                        port:xorg-libsm \
                        port:xorg-libX11 \
                        port:xorg-libXau \
                        port:xorg-libXcomposite \
                        port:xorg-libXcursor \
                        port:xorg-libXdamage \
                        port:xorg-libXdmcp \
                        port:xorg-libXext \
                        port:xorg-libXfixes \
                        port:xorg-libXinerama \
                        port:xorg-libXrandr \
                        port:xorg-libXres \
                        port:xrender

# fdo menus fail to build.
# The build is generally a mess, and upstream has no particular desire to fix anything.
# https://github.com/ice-wm/icewm/issues/207

configure.args-append   --disable-debug \
                        --disable-gdk-pixbuf \
                        --disable-logevents \
                        --disable-menus-fdo \
                        --disable-nanosvg \
                        --disable-silent-rules \
                        --disable-xpm \
                        --enable-fribidi \
                        --enable-i18n \
                        --enable-imlib2 \
                        --enable-librsvg \
                        --enable-nls \
                        --enable-sm \
                        --enable-xfreetype \
                        --enable-xinerama \
                        --enable-xrandr \
                        --enable-xres \
                        --mandir=${prefix}/share/man \
                        --with-cfgdir=${prefix}/etc/icewm \
                        --with-libiconv-prefix=${prefix} \
                        --with-libintl-prefix=${prefix} \
                        --with-x \
                        --with-xterm=xterm \
                        --without-icesound

# https://github.com/ice-wm/icewm/issues/206
if {[string match *clang* ${configure.compiler}]} {
    configure.cxxflags-append \
                        -Wno-c++11-narrowing
}

# The build fails to pass the flag.
# Undefined symbols for architecture x86_64: "_IceAddConnectionWatch"
configure.ldflags-append \
                        -lICE

# sed uses gnuisms here.
build.env               PATH=${prefix}/libexec/gnubin:$env(PATH)
destroot.env            PATH=${prefix}/libexec/gnubin:$env(PATH)

post-destroot {
    ui_msg ""
    ui_msg "To start icewm put \"exec icewm-session\" in your \".xinitrc\" file."
    ui_msg "Don't forget to add the MacPorts Environment to the X Environment too!"
    ui_msg ""
}
