# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           gitlab 1.0
PortGroup           makefile 1.0

gitlab.setup        ports1 aee 2.2.22
revision            0
categories          editors
license             Artistic-1
maintainers         nomaintainer
description         easy-to-use text editor
long_description \
    An {*}${description}. Intended to be usable with \
    little or no instruction. Provides both a terminal \
    (curses based) interface and native X-Windows interface \
    (in which case the executable is called xae). Features \
    include pop-up menus, journalling (to recover from \
    system crash or loss of connection), cut-and-paste, \
    multiple buffers (associated with files or not) \
    and much more.
installs_libs       no
checksums           rmd160  fa61291865024c8969bf075568f24292fc1a6d99 \
                    sha256  0eecf2177be09cd6e0cafa6047da96f66702d431a944452fa8ce1ff124c632e9 \
                    size    142490

patchfiles          patch-create.mk.aee.diff patch-create.mk.xae.diff patch-Makefile.diff \
                    patch-localize.diff patch-aee.1.diff

post-patch {
    foreach f {aee.1 create.mk.xae localize.c} {
        reinplace "s,@PREFIX@,${prefix},g" ${worksrcpath}/${f}
    }
    foreach f {create.mk.aee create.mk.xae install-sh} {
        system -W ${worksrcpath} "chmod 544 ${f}"
    }
}

build.target        main

destroot {
    set binDir ${destroot}${prefix}/bin
    set manDir ${destroot}${prefix}/share/man/man1
    set docDir ${destroot}${prefix}/share/doc/aee

    xinstall -m 755 ${worksrcpath}/aee ${binDir}
    system "ln ${binDir}/aee ${binDir}/rae"

    xinstall -m 444 ${worksrcpath}/aee.1 ${manDir}
    system "ln ${manDir}/aee.1 ${manDir}/rae.1"

    if {[variant_isset x11]} {
        xinstall -m 555 ${worksrcpath}/xae ${binDir}
        system "ln ${binDir}/xae ${binDir}/rxae"

        system "ln ${manDir}/aee.1 ${manDir}/xae.1"
        system "ln ${manDir}/aee.1 ${manDir}/rxae.1"
    }

    file mkdir ${docDir}
    xinstall -m 444 ${worksrcpath}/help.ae ${docDir}
}

variant x11 {
    build.target        both
    depends_lib-append  port:xorg-libX11
}
