# -*- 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.2
set patchlevel  013
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  1e3ed3a965558298487eec2b3bf582723f608b7c \
                 sha256  bbf97f1ec40a929edab5aa81998c1e2ef435436c597754916e6a5868f273aff7 \
                 size    1198 \
                 ${patchname}-002 \
                 rmd160  2a630f1cbb02513d70cbdab5f196fd429ade98c2 \
                 sha256  e06503822c62f7bc0d9f387d4c78c09e0ce56e53872011363c74786c7cd4c053 \
                 size    1134 \
                 ${patchname}-003 \
                 rmd160  0819fcf4bfea7ad9714637be606ffe761aa8b7b5 \
                 sha256  24f587ba46b46ed2b1868ccaf9947504feba154bb8faabd4adaea63ef7e6acb0 \
                 size    1201 \
                 ${patchname}-004 \
                 rmd160  3cb95246cb6f66598714d409b72bd35f32f0a03a \
                 sha256  79572eeaeb82afdc6869d7ad4cba9d4f519b1218070e17fa90bbecd49bd525ac \
                 size    1708 \
                 ${patchname}-005 \
                 rmd160  cada135d5df4c5d3a6550f8b57a07e47fda0ee47 \
                 sha256  622ba387dae5c185afb4b9b20634804e5f6c1c6e5e87ebee7c35a8f065114c99 \
                 size    1501 \
                 ${patchname}-006 \
                 rmd160  c6ceadabc6a4a6eabcedf2eb10bc9b2ff0689750 \
                 sha256  c7b45ff8c0d24d81482e6e0677e81563d13c74241f7b86c4de00d239bc81f5a1 \
                 size    3031 \
                 ${patchname}-007 \
                 rmd160  70b08f762d0db694f8ed832f52edc07134c1a55d \
                 sha256  5911a5b980d7900aabdbee483f86dab7056851e6400efb002776a0a4a1bab6f6 \
                 size    1422 \
                 ${patchname}-008 \
                 rmd160  a40a445029df8eccf8001a638842c71587697ef0 \
                 sha256  a177edc9d8c9f82e8c19d0630ab351f3fd1b201d655a1ddb5d51c4cee197b26a \
                 size    1697 \
                 ${patchname}-009 \
                 rmd160  81344561925c2aa05f14ee8e3c4a12d024bcecbd \
                 sha256  3d9885e692e1998523fd5c61f558cecd2aafd67a07bd3bfe1d7ad5a31777a116 \
                 size    2270 \
                 ${patchname}-010 \
                 rmd160  36a6caf90f1a5b2aad9e17e58fb866fcb9f5da63 \
                 sha256  758e2ec65a0c214cfe6161f5cde3c5af4377c67d820ea01d13de3ca165f67b4c \
                 size    2653 \
                 ${patchname}-011 \
                 rmd160  35270fafead819bd6abbcfe54730bc3ef1bd27d6 \
                 sha256  e0013d907f3a9e6482cc0934de1bd82ee3c3c4fd07a9646aa9899af237544dd7 \
                 size    1865 \
                 ${patchname}-012 \
                 rmd160  090c1e2fde5e74ef4d5176b7605a6e24026a8864 \
                 sha256  6c8adf8ed4a2ca629f7fd11301ed6293a6248c9da0c674f86217df715efccbd3 \
                 size    2824 \
                 ${patchname}-013 \
                 rmd160  3581bbf0b074c0a1c52174991bf102e6d3fd8427 \
                 sha256  1ea434957d6ec3a7b61763f1f3552dad0ebdd6754d65888b5cd6d80db3a788a8 \
                 size    5757 \
                 ${distname}${extract.suffix} \
                 rmd160  1865998241027e94ba2d55bd628eb67b245d20d5 \
                 sha256  3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35 \
                 size    3043952

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}
