# $Id: Portfile 49336 2009-04-08 00:12:38Z blb@macports.org $

PortSystem      1.0
PortGroup       muniversal 1.0

name            readline
set milestone   6.0
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     b7f65a48add447693be6e86f04a63019 \
                sha1    1e511b091514ef631c539552316787c75ace5262 \
                rmd160  9f886f437dfa3387cb3a4ce3439cefecffc2c789

configure.args  --mandir=${prefix}/share/man \
                --infodir=${prefix}/share/info \
                --with-curses

use_parallel_build  yes

depends_lib     port:ncurses

post-destroot {
    set docdir ${prefix}/share/doc/${name}-${version}
    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
    }

    if { ${os.arch}=="i386" } {
        if { ${os.major} >= 10 } {
            set merger_configure_args(ppc)  --config-cache
        }
        set merger_configure_args(ppc64)    --config-cache
    } else {
        set merger_configure_args(i386)     --config-cache
        set merger_configure_args(x86_64)   --config-cache
    }

    post-extract {
        # Answers to questions configure can't determine without running a program.
        copy ${filespath}/config.cache ${worksrcpath} 
    }
}

livecheck.check     regex
livecheck.url       http://ftp.gnu.org/pub/gnu/${name}/?C=M&O=D
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)
livecheck.version   ${milestone}
