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

name            rxvt-unicode
version         9.31
revision        1
categories      x11
license         GPL-3+
maintainers     {gmail.com:emanuele.giaquinta @exg} openmaintainer
description     Unicode-aware rxvt clone.
long_description \
                rxvt-unicode is a clone of the well-known terminal \
                emulator rxvt. Some of its main features over rxvt are \
                use of UCS-2 or UCS-4 to store text internally, \
                locale-correct in- and output, stability, \
                completely flicker-free \
                display, support for Xft and core fonts in any \
                combination, etc.
homepage        http://software.schmorp.de/pkg/rxvt-unicode.html
master_sites    http://dist.schmorp.de/rxvt-unicode/ \
                http://dist.schmorp.de/rxvt-unicode/Attic/
use_bzip2       yes

checksums       rmd160  0cce3f8818e75a6557ddaabf86ed706e766e7acf \
                sha256  aaa13fcbc149fe0f3f391f933279580f74a96fd312d6ed06b8ff03c2d46672e8 \
                size    880148

perl5.major     5.34

depends_build \
        port:pkgconfig

# urxvt also depends on xorg-libX11, xrender and fontconfig but all these ports are in the dependency tree of Xft2
depends_lib \
        port:libptytty \
        port:Xft2 \
        port:startup-notification \
        port:xorg-libXext \
        port:xorg-libXmu \
        port:ncurses \
        port:perl${perl5.major}

# clang++ 3.0 produces unstable urxvt binary which sometimes causes errors like:
#        "terminate called throwing an exceptionAbort trap: 6"
compiler.blacklist {clang < 318}

configure.perl  ${perl5.bin}

patchfiles      patch-Makefile.in.diff \
                patch-fix-osc-response.diff \
                patch-perl-embed-args.diff

compiler.cxx_standard 2011
configure.cxxflags-append -std=c++11

configure.args  --enable-everything \
                --enable-256-color \
                --with-term=rxvt-unicode-256color \
                --disable-pixbuf \
                --mandir=${prefix}/share/man

use_parallel_build  yes

variant pixbuf description {gdk-pixbuf support} {
    configure.args-append   --enable-pixbuf
    depends_lib-append      path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2
}

variant lite description {lightweight build options} {
    depends_lib-delete      port:Xft2 \
                            port:startup-notification \
                            port:perl${perl5.major}
    depends_lib-append      port:xorg-libX11
    configure.args-delete   --enable-everything
    configure.args-append   --disable-everything \
                            --enable-combining \
                            --enable-resources \
                            --enable-frills \
                            --enable-font-styles \
                            --enable-selectionscrolling \
                            --enable-mousewheel \
                            --enable-pointer-blank
}

destroot.env    TERMINFO=${destroot}${prefix}/share/terminfo
pre-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/terminfo
}
post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}/etc
    xinstall -m 644 -W ${worksrcpath} COPYING Changes INSTALL README.FAQ README.configure ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath}/doc/etc rxvt-unicode.termcap rxvt-unicode.terminfo ${destroot}${prefix}/share/doc/${name}/etc
}

livecheck.type  regex
livecheck.url   [lindex ${master_sites} 0]
livecheck.regex ${name}-(\[0-9.\]+)${extract.suffix}
