1SUMMARY = "The New Curses library" 2DESCRIPTION = "SVr4 and XSI-Curses compatible curses library and terminfo tools including tic, infocmp, captoinfo. Supports color, multiple highlights, forms-drawing characters, and automatic recognition of keypad and function-key sequences. Extensions include resizable windows and mouse support on both xterm and Linux console using the gpm library." 3HOMEPAGE = "http://www.gnu.org/software/ncurses/ncurses.html" 4LICENSE = "MIT" 5LIC_FILES_CHKSUM = "file://COPYING;md5=c5a4600fdef86384c41ca33ecc70a4b8;endline=27" 6SECTION = "libs" 7DEPENDS = "ncurses-native" 8DEPENDS:class-native = "" 9 10BINCONFIG = "${bindir}/ncurses5-config ${bindir}/ncursesw5-config \ 11 ${bindir}/ncurses6-config ${bindir}/ncursesw6-config" 12 13inherit autotools binconfig-disabled multilib_header pkgconfig 14 15# Upstream has useful patches at times at ftp://invisible-island.net/ncurses/ 16SRC_URI = "git://salsa.debian.org/debian/ncurses.git;protocol=https;branch=master" 17 18EXTRA_AUTORECONF = "-I m4" 19 20CACHED_CONFIGUREVARS = "cf_cv_func_nanosleep=yes" 21CACHED_CONFIGUREVARS:append:linux = " cf_cv_working_poll=yes" 22 23EXTRASITECONFIG = "CFLAGS='${CFLAGS} -I${SYSROOT_DESTDIR}${includedir}'" 24 25# Whether to enable separate widec libraries; must be 'true' or 'false' 26# 27# TODO: remove this variable when widec is supported in every setup? 28ENABLE_WIDEC ?= "true" 29 30# _GNU_SOURCE is required for widec stuff and is detected automatically 31# for target objects. But it must be set manually for native and sdk 32# builds. 33BUILD_CPPFLAGS += "-D_GNU_SOURCE" 34 35# natives don't generally look in base_libdir 36base_libdir:class-native = "${libdir}" 37 38# Display corruption occurs on 64 bit hosts without these settings 39# This was derrived from the upstream debian ncurses which uses 40# these settings for 32 and 64 bit hosts. 41EXCONFIG_ARGS = "" 42EXCONFIG_ARGS:class-native = " \ 43 --disable-lp64 \ 44 --with-chtype='long' \ 45 --with-mmask-t='long'" 46EXCONFIG_ARGS:class-nativesdk = " \ 47 --disable-lp64 \ 48 --with-chtype='long' \ 49 --with-mmask-t='long'" 50 51PACKAGES_DYNAMIC = "^${PN}-lib.*" 52 53# Fall back to the host termcap / terminfo for -nativesdk and -native 54# The reality is a work around for strange problems with things like 55# "bitbake -c menuconfig busybox" where it cannot find the terminfo 56# because the sstate had a hard coded search path. Until this is fixed 57# another way this is deemed good enough. 58EX_TERMCAP = "" 59EX_TERMCAP:class-native = ":/etc/termcap:/usr/share/misc/termcap" 60EX_TERMCAP:class-nativesdk = ":/etc/termcap:/usr/share/misc/termcap" 61EX_TERMINFO = "" 62EX_TERMINFO:class-native = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo" 63EX_TERMINFO:class-nativesdk = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo" 64EX_TERMLIB ?= "tinfo" 65 66# Helper function for do_configure to allow multiple configurations 67# $1 the directory to run configure in 68# $@ the arguments to pass to configure 69ncurses_configure() { 70 mkdir -p $1 71 cd $1 72 shift 73 oe_runconf \ 74 --without-debug \ 75 --without-ada \ 76 --without-gpm \ 77 --enable-hard-tabs \ 78 --enable-xmc-glitch \ 79 --enable-colorfgbg \ 80 --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap${EX_TERMCAP}' \ 81 --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo${EX_TERMINFO}' \ 82 --with-shared \ 83 --disable-big-core \ 84 --program-prefix= \ 85 --with-ticlib \ 86 --with-termlib=${EX_TERMLIB} \ 87 --enable-sigwinch \ 88 --enable-pc-files \ 89 --disable-rpath-hack \ 90 ${EXCONFIG_ARGS} \ 91 --with-manpage-format=normal \ 92 --without-manpage-renames \ 93 --disable-stripping \ 94 "$@" || return 1 95 cd .. 96} 97 98# Override the function from the autotools class; ncurses requires a 99# patched autoconf213 to generate the configure script. This autoconf 100# is not available so that the shipped script will be used. 101do_configure() { 102 #Remove ${includedir} from CPPFLAGS, need for cross compile 103 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS" 104 105 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed 106 mkdir -p ${PKG_CONFIG_LIBDIR} 107 ( cd ${S}; gnu-configize --force ) 108 ncurses_configure "narrowc" || \ 109 return 1 110 ! ${ENABLE_WIDEC} || \ 111 ncurses_configure "widec" "--enable-widec" "--without-progs" 112 113} 114 115do_compile() { 116 oe_runmake -C narrowc libs 117 oe_runmake -C narrowc/progs 118 119 ! ${ENABLE_WIDEC} || \ 120 oe_runmake -C widec libs 121} 122 123# set of expected differences between narrowc and widec header 124# 125# TODO: the NCURSES_CH_T difference can cause real problems :( 126_unifdef_cleanup = " \ 127 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \ 128 -e '/^#define NCURSES_CH_T /d' \ 129 -e '/^#include <wchar.h>/d' \ 130 -e '\!^/\* .* \*/!d' \ 131" 132 133do_test[depends] = "unifdef-native:do_populate_sysroot" 134do_test[dirs] = "${S}" 135do_test() { 136 ${ENABLE_WIDEC} || return 0 137 138 # make sure that the narrow and widec header are compatible 139 # and differ only in minor details. 140 unifdef -k narrowc/include/curses.h | \ 141 sed ${_unifdef_cleanup} > curses-narrowc.h 142 unifdef -k widec/include/curses.h | \ 143 sed ${_unifdef_cleanup} > curses-widec.h 144 145 diff curses-narrowc.h curses-widec.h 146} 147 148# Split original _install_opts to two parts. 149# One is the options to install contents, the other is the parameters \ 150# when running command "make install" 151# Note that install.libs will also implicitly install header files, 152# so we do not need to explicitly specify install.includes. 153# Doing so could in fact result in a race condition, as both targets 154# (install.libs and install.includes) would install the same headers 155# at the same time 156 157_install_opts = " install.libs install.man " 158 159_install_cfgs = "\ 160 DESTDIR='${D}' \ 161 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \ 162" 163 164do_install() { 165 # Order of installation is important; widec installs a 'curses.h' 166 # header with more definitions and must be installed last hence. 167 # Compatibility of these headers will be checked in 'do_test()'. 168 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \ 169 install.progs 170 171 # The install.data should run after install.libs, otherwise 172 # there would be a race issue in a very critical conditon, since 173 # tic will be run by install.data, and tic needs libtinfo.so 174 # which would be regenerated by install.libs. 175 oe_runmake -C narrowc ${_install_cfgs} \ 176 install.data 177 178 179 ! ${ENABLE_WIDEC} || \ 180 oe_runmake -C widec ${_install_cfgs} ${_install_opts} 181 182 cd narrowc 183 184 # include some basic terminfo files 185 # stolen ;) from gentoo and modified a bit 186 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color 187 do 188 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)" 189 local basedir="$(basename $(dirname "${termfile}"))" 190 191 if [ -n "${termfile}" ] 192 then 193 install -d ${D}${sysconfdir}/terminfo/${basedir} 194 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/ 195 ln -s /etc/terminfo/${basedir}/${x} \ 196 ${D}${datadir}/terminfo/${basedir}/${x} 197 fi 198 done 199 # i think we can use xterm-color as default xterm 200 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ] 201 then 202 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm 203 fi 204 205 # When changing ${libdir} to e.g. /usr/lib/myawesomelib/ ncurses 206 # still installs '/usr/lib/terminfo', so try to rm both 207 # the proper path and a slightly hardcoded one 208 rm -f ${D}${libdir}/terminfo ${D}${prefix}/lib/terminfo 209 210 # create linker scripts for libcurses.so and libncurses to 211 # link against -ltinfo when needed. Some builds might break 212 # else when '-Wl,--no-copy-dt-needed-entries' has been set in 213 # linker flags. 214 for i in libncurses libncursesw; do 215 f=${D}${libdir}/$i.so 216 test -h $f || continue 217 rm -f $f 218 echo '/* GNU ld script */' >$f 219 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f 220 done 221 222 # Make sure that libcurses is linked so that it gets -ltinfo 223 # also, this should be addressed upstream really. 224 ln -sf libncurses.so ${D}${libdir}/libcurses.so 225 226 # create libtermcap.so linker script for backward compatibility 227 f=${D}${libdir}/libtermcap.so 228 echo '/* GNU ld script */' >$f 229 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f 230 231 if [ ! -d "${D}${base_libdir}" ]; then 232 # Setting base_libdir to libdir as is done in the -native 233 # case will skip this code 234 mkdir -p ${D}${base_libdir} 235 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir} 236 ! ${ENABLE_WIDEC} || \ 237 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir} 238 239 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir} 240 rm ${D}${libdir}/libtinfo.so 241 242 # Use ln -rs to ensure this is a relative link despite absolute paths 243 # (as we can't know the relationship between base_libdir and libdir). 244 ln -rs ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so 245 fi 246 if [ -d "${D}${includedir}/ncurses" ]; then 247 for f in `find ${D}${includedir}/ncurses -name "*.h"` 248 do 249 f=`basename $f` 250 test -e ${D}${includedir}/$f && continue 251 ln -sf ncurses/$f ${D}${includedir}/$f 252 done 253 fi 254 oe_multilib_header curses.h 255} 256 257python populate_packages:prepend () { 258 libdir = d.expand("${libdir}") 259 base_libdir = d.expand("${base_libdir}") 260 pnbase = d.expand("${PN}-lib%s") 261 do_split_packages(d, libdir, r'^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True) 262 if libdir is not base_libdir: 263 do_split_packages(d, base_libdir, r'^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True) 264} 265 266 267inherit update-alternatives 268 269ALTERNATIVE_PRIORITY = "100" 270 271ALTERNATIVE:ncurses-tools:class-target = "clear reset" 272ALTERNATIVE:ncurses-terminfo:class-target = "st st-256color" 273 274ALTERNATIVE_LINK_NAME[st] = "${datadir}/terminfo/s/st" 275 276ALTERNATIVE_LINK_NAME[st-256color] = "${datadir}/terminfo/s/st-256color" 277 278BBCLASSEXTEND = "native nativesdk" 279 280PACKAGES += " \ 281 ${PN}-tools \ 282 ${PN}-terminfo-base \ 283 ${PN}-terminfo \ 284" 285 286FILES:${PN} = "\ 287 ${bindir}/tput \ 288 ${bindir}/tset \ 289 ${bindir}/ncurses5-config \ 290 ${bindir}/ncursesw5-config \ 291 ${bindir}/ncurses6-config \ 292 ${bindir}/ncursesw6-config \ 293 ${datadir}/tabset \ 294" 295 296# This keeps only tput/tset in ncurses 297# clear/reset are in already busybox 298FILES:${PN}-tools = "\ 299 ${bindir}/tic \ 300 ${bindir}/toe \ 301 ${bindir}/infotocap \ 302 ${bindir}/captoinfo \ 303 ${bindir}/infocmp \ 304 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \ 305 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \ 306 ${bindir}/tack \ 307 ${bindir}/tabs \ 308" 309 310# 'reset' is a symlink to 'tset' which is in the 'ncurses' package 311RDEPENDS:${PN}-tools = "${PN} ${PN}-terminfo-base" 312 313FILES:${PN}-terminfo = "\ 314 ${datadir}/terminfo \ 315" 316 317FILES:${PN}-terminfo-base = "\ 318 ${sysconfdir}/terminfo \ 319" 320 321RSUGGESTS:${PN}-libtinfo = "${PN}-terminfo" 322RRECOMMENDS:${PN}-libtinfo = "${PN}-terminfo-base" 323 324# Putting terminfo into the sysroot adds around 2800 files to 325# each recipe specific sysroot. We can live without this, particularly 326# as many recipes may have native and target copies. 327SYSROOT_DIRS:remove = "${datadir}" 328