# $Id: Portfile 62528 2010-01-09 23:27:19Z jmr@macports.org $

PortSystem      1.0
PortGroup       muniversal 1.0

name            readline
set milestone   6.1
set patchlevel  000
version         ${milestone}.${patchlevel}
revision        1
distname        ${name}-${milestone}
categories      devel
platforms       darwin freebsd
maintainers     mcalhoun openmaintainer
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
}

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

post-patch {
    reinplace "s|__MACPORTS_PATCHLEVEL__|${patchlevel}|" ${worksrcpath}/support/shobj-conf
}

checksums       md5     fc2f7e714fe792db1ce6ddc4c9fb4ef3 \
                sha1    54840a0dc907e7fa598d7ffcdcbd17bae69ace83 \
                rmd160  b50f47a3952e354655056d9684b05ee65027e291

configure.args  --with-curses

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

use_parallel_build  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
}

# Install symlinks to avoid breaking ports linked against the old versions
platform darwin {
    post-destroot {
        foreach f {history readline} {
            foreach v {0 1 2} {
                ln -sf lib${f}.${milestone}.dylib ${destroot}${prefix}/lib/lib${f}.5.${v}.dylib
            }
        }
    }
}

if {[variant_isset universal]} {

    pre-configure {
        # Eliminate warning.
        configure.args-delete  --disable-dependency-tracking
    }

    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
} elseif {![info exists configure.ld_archflags]} {
    configure.ldflags-append   ${configure.cc_archflags}
}

livecheck.version   ${milestone}
