easyblock = 'ConfigureMake'

name = 'ncurses'
version = '5.9'

homepage = 'http://www.gnu.org/software/ncurses/'
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."""

toolchain = SYSTEM
toolchainopts = {'optarch': True, 'pic': True}

source_urls = [GNU_SOURCE]
sources = [SOURCE_TAR_GZ]

patches = ['ncurses-%(version)s_configure_darwin.patch']

configopts = [
    # default build
    '--with-shared --enable-overwrite',
    # the UTF-8 enabled version (ncursesw)
    '--with-shared --enable-overwrite --enable-ext-colors --enable-widec --includedir=%(installdir)s/include/ncursesw/'
]

buildopts = "CFLAGS='-fPIC'"

local_libs = ["form", "menu", "ncurses", "panel"]
sanity_check_paths = {
    'files': ['bin/%s' % x for x in ["captoinfo", "clear", "infocmp", "infotocap", "ncurses5-config",
                                     "reset", "tabs", "tic", "toe", "tput", "tset"]] +
    ['lib/lib%s%s.a' % (x, y) for x in local_libs for y in ['', '_g', 'w', 'w_g']] +
    ['lib/lib%s%s.so' % (x, y) for x in local_libs for y in ['', 'w']] +
    ['lib/libncurses++%s.a' % x for x in ['', 'w']],
    'dirs': ['include', 'include/ncursesw'],
}

moduleclass = 'devel'