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