# $Id$

PortSystem 1.0

name            ncurses
version         6.0
categories      devel
platforms       darwin freebsd
license         MIT
maintainers     jmr openmaintainer
description     emulation of curses in System V Release 4.0
long_description \
    The Ncurses (new curses) library is a free software emulation of    \
    curses in System V Release 4.0, and more. It uses Terminfo format,  \
    supports pads and color and multiple highlights and forms           \
    characters and function-key mapping, and has all the other          \
    SYSV-curses enhancements over BSD Curses.

homepage        http://www.gnu.org/software/ncurses/ncurses.html
master_sites    gnu

checksums       rmd160 4d9e5938f00b400bfb0d37f3c54f2f36c4157d48 \
                sha256 f551c24b30ce8bfb6e96d9f59b42fbea30fa3a6123384172f9e7284bcf647260

# hex.diff from http://opensource.apple.com/source/ncurses/ncurses-44/patches.applied/
patchfiles      hex.diff configure.diff

configure.cppflags
configure.ldflags
configure.args  --enable-widec \
                --disable-lib-suffixes \
                --enable-overwrite \
                --with-shared \
                --with-cxx-shared \
                --without-debug  \
                --without-ada \
                --with-manpage-format=normal \
                --enable-pc-files \
                --with-pkg-config-libdir="${prefix}/lib/pkgconfig" \
                --disable-mixed-case

# Prevent -lstdc++ from creeping into the build when not needed
if {[string match *clang* ${configure.cxx}]} {
    configure.env-append \
        CXXLIBS=-stdlib=${configure.cxx_stdlib} \
        cf_cv_libstdcpp=no
}

if {[variant_isset universal]} {
    # check that this doesn't start breaking anything with new versions
    post-configure {
        reinplace s/1UL/1U/g "${worksrcpath}/include/curses.head"
        system -W ${worksrcpath} "ed - include/curses.head < ${filespath}/include_curses.head.ed"
    }
}

post-destroot {
    set major [lindex [split $version .] 0]
    foreach f {form menu ncurses ncurses++ panel} {
        ln -s lib${f}.${major}.dylib ${destroot}${prefix}/lib/lib${f}w.dylib
        ln -s lib${f}.${major}.dylib ${destroot}${prefix}/lib/lib${f}w.${major}.dylib
        ln -s lib${f}.a ${destroot}${prefix}/lib/lib${f}w.a
        ln -s ${f}.pc ${destroot}${prefix}/lib/pkgconfig/${f}w.pc
    }
    ln -s libncurses.${major}.dylib ${destroot}${prefix}/lib/libtermcap.dylib
    ln -s ncurses6-config ${destroot}${prefix}/bin/ncursesw6-config
}