ncurses.inc 12 KB

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