# -*- 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       muniversal 1.0
PortGroup       clang_dependency 1.0

name            readline
set milestone   8.3
set patchlevel  003
version         ${milestone}.${patchlevel}
distname        ${name}-${milestone}
categories      devel
platforms       darwin freebsd
maintainers     {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
license         GPL-3+

description     Library that provides command line editing

long_description \
    The GNU Readline library provides a set of functions for use by         \
    applications that allow users to edit command lines as they are typed   \
    in. Both Emacs and vi editing modes are available. The Readline library \
    includes additional functions to maintain a list of previously-entered  \
    command lines, to recall and perhaps reedit those lines, and perform    \
    csh-like history expansion on previous commands.

homepage        https://tiswww.case.edu/php/chet/readline/rltop.html
master_sites    gnu

patch_sites     gnu:${name}/${distname}-patches/

set i 1
set patchname ${name}[join [split $milestone .] ""]
if {![regexp {0*([1-9]+)} $patchlevel -> lastpatch]} {
    set lastpatch 0
}

while {$i <= $lastpatch} {
    patchfiles-append ${patchname}-[format "%03d" $i]
    incr i
}

checksums        ${patchname}-001 \
                 rmd160  b4b13ea2054821670c2f3564a216628fdef0eaea \
                 sha256  21f0a03106dbe697337cd25c70eb0edbaa2bdb6d595b45f83285cdd35bac84de \
                 size    1846 \
                 ${patchname}-002 \
                 rmd160  a646e94887501df60ead94aa022c27534382a33b \
                 sha256  e27364396ba9f6debf7cbaaf1a669e2b2854241ae07f7eca74ca8a8ba0c97472 \
                 size    1613 \
                 ${patchname}-003 \
                 rmd160  919d83234f8dcb858288b5cd491b852b9b62df56 \
                 sha256  72dee13601ce38f6746eb15239999a7c56f8e1ff5eb1ec8153a1f213e4acdb29 \
                 size    2284 \
                 ${distname}${extract.suffix} \
                 rmd160  62130aa4285c1175e4a08dd6673ca874945a35a6 \
                 sha256  fe5383204467828cd495ee8d1d3c037a7eba1389c22bc6a041f627976f9061cc \
                 size    3419642

if {${os.platform} eq "darwin" && ${os.major} < 11 && ${cxx_stdlib} eq "libc++"} {
    # This port is in the dependency chain for clang 3.7 and later
    clang_dependency.extra_versions 3.7
}

configure.args  --with-curses
configure.universal_args-delete --disable-dependency-tracking
configure.checks.implicit_function_declaration.whitelist-append strchr

depends_lib     port:ncurses

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}/html
    xinstall -m 0644 -W ${worksrcpath} CHANGELOG CHANGES COPYING NEWS README \
        ${destroot}${docdir}
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/*.html] \
        ${destroot}${docdir}/html
}

livecheck.regex     ${name}-(\[\\d.\]+)${extract.suffix}
livecheck.version   ${milestone}
