# $Id$

PortSystem 1.0

name            ncurses
version         5.9
revision        1
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       md5     8cb9c412e5f2d96bc6f459aa8c6282a1 \
                sha1    3e042e5f2c7223bffdaac9646a533b8c758b65b5 \
                rmd160  dd7dffe38fcc908230ce3e036b71ced2d270ac9e

# from http://www.opensource.apple.com/source/ncurses/ncurses-27/patches/
patchfiles      hex.diff ungetch_guard.diff configure.diff \
                constructor_types.diff

configure.cppflags
configure.ldflags
configure.env   PKG_CONFIG_LIBDIR="${prefix}/lib/pkgconfig"
configure.args  --enable-widec \
                --enable-overwrite \
                --with-shared \
                --without-debug  \
                --without-ada \
                --enable-sigwinch \
                --mandir=${prefix}/share/man \
                --with-manpage-format=normal \
                --enable-pc-files \
                --enable-symlinks \
                --disable-mixed-case
# using symlinks because of ticket #13601

if {[variant_isset universal]} {
    configure.args-append --with-chtype=int

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

use_parallel_build yes

post-destroot {
    set major [lindex [split $version .] 0]
    foreach f {form menu 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++.a ${destroot}${prefix}/lib/libncurses++w.a
    ln -s ncurses++.pc ${destroot}${prefix}/lib/pkgconfig/ncurses++w.pc
    ln -s libncurses.${major}.dylib ${destroot}${prefix}/lib/libtermcap.dylib
    ln -s ncurses5-config ${destroot}${prefix}/bin/ncursesw5-config
}