# $Id$

PortSystem      1.0
PortGroup       muniversal 1.0

name            readline
set milestone   6.3
set patchlevel  003
version         ${milestone}.${patchlevel}
revision        1
distname        ${name}-${milestone}
categories      devel
platforms       darwin freebsd
maintainers     mcalhoun 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        http://cnswww.cns.cwru.edu/~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
}

# remove "-arch_only `/usr/bin/arch`"
patchfiles-append  patch-shobj-conf.diff
while {$i <= $lastpatch} {
    patchfiles-append ${patchname}-[format "%03d" $i]
    incr i
}

checksums           ${patchname}-001 \
                    rmd160  feb98062e9407192a65ab85d62e54b947f119d97 \
                    sha256  1a79bbb6eaee750e0d6f7f3d059b30a45fc54e8e388a8e05e9c3ae598590146f \
                    ${patchname}-002 \
                    rmd160  8985874564ff3d1630231e333e87d7d7596fbe63 \
                    sha256  39e304c7a526888f9e112e733848215736fb7b9d540729b9e31f3347b7a1e0a5 \
                    ${patchname}-003 \
                    rmd160  bc0765b54e0e97cacfe9ddbacc123b4ce007e350 \
                    sha256  ec41bdd8b00fd884e847708513df41d51b1243cecb680189e31b7173d01ca52f \
                    ${distfiles} \
                    rmd160  986262d811d9dbe1e38bc9d714853272967dca7e \
                    sha256  56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43

configure.args  --with-curses

configure.universal_args-delete --disable-dependency-tracking

use_parallel_build  yes

# the configure script runs a program
set merger_must_run_binaries yes

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}
    eval xinstall -m 0644 [glob ${worksrcpath}/doc/*.html] \
        ${destroot}${docdir}/html
}

# Prior to 6.3, the "install_name" of shared libraries were
#    libreadline.X.Y.dylib and libhistory.X.Y.dylib instead of    
#    libreadline.X.dylib   and libhistory.X.dylib
# Therefore, when upgrading, symlinks were installed to avoid breaking ports linked
#    against old versions.
# This was fixed in 6.3.
# For 6.4, therefore, the following should probably be removed.
# Version 6.1 hasn't been around for over three years (r76438), so only create a
#    link for 6.2.
platform darwin {
    post-destroot {
        foreach f {history readline} {
            foreach v {6.2} {
                ln -sf lib${f}.${milestone}.dylib ${destroot}${prefix}/lib/lib${f}.${v}.dylib
            }
        }
    }
}

if {[variant_isset universal]} {

    configure.args-append   bash_cv_must_reinstall_sighandlers=no \
                            bash_cv_func_sigsetjmp=present \
                            bash_cv_func_strcoll_broken=no \
                            bash_cv_func_ctype_nonascii=yes
}

livecheck.version   ${milestone}