blob: 761b6a3d3128e5a50cf60f87b745828f8ca6e726 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "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"
Andrew Geissler615f2f12022-07-15 14:00:58 -05005LIC_FILES_CHKSUM = "file://COPYING;md5=c5a4600fdef86384c41ca33ecc70a4b8;endline=27"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006SECTION = "libs"
7DEPENDS = "ncurses-native"
Patrick Williams213cb262021-08-07 19:21:33 -05008DEPENDS:class-native = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010BINCONFIG = "${bindir}/ncurses5-config ${bindir}/ncursesw5-config \
11 ${bindir}/ncurses6-config ${bindir}/ncursesw6-config"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012
13inherit autotools binconfig-disabled multilib_header pkgconfig
14
15# Upstream has useful patches at times at ftp://invisible-island.net/ncurses/
Andrew Geissler615f2f12022-07-15 14:00:58 -050016SRC_URI = "git://github.com/mirror/ncurses.git;protocol=https;branch=master"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017
18EXTRA_AUTORECONF = "-I m4"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050019
20CACHED_CONFIGUREVARS = "cf_cv_func_nanosleep=yes"
Andrew Geissler595f6302022-01-24 19:11:47 +000021CACHED_CONFIGUREVARS:append:linux = " cf_cv_working_poll=yes"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023EXTRASITECONFIG = "CFLAGS='${CFLAGS} -I${SYSROOT_DESTDIR}${includedir}'"
24
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025# 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
Patrick Williams39653562024-03-01 08:54:02 -060030# _GNU_SOURCE is required for widec stuff and is not detected automatically
31CPPFLAGS += "-D_GNU_SOURCE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
33# natives don't generally look in base_libdir
Patrick Williams213cb262021-08-07 19:21:33 -050034base_libdir:class-native = "${libdir}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035
36# Display corruption occurs on 64 bit hosts without these settings
37# This was derrived from the upstream debian ncurses which uses
38# these settings for 32 and 64 bit hosts.
39EXCONFIG_ARGS = ""
Patrick Williams213cb262021-08-07 19:21:33 -050040EXCONFIG_ARGS:class-native = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 --disable-lp64 \
42 --with-chtype='long' \
43 --with-mmask-t='long'"
Patrick Williams213cb262021-08-07 19:21:33 -050044EXCONFIG_ARGS:class-nativesdk = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 --disable-lp64 \
46 --with-chtype='long' \
47 --with-mmask-t='long'"
48
49PACKAGES_DYNAMIC = "^${PN}-lib.*"
50
51# Fall back to the host termcap / terminfo for -nativesdk and -native
52# The reality is a work around for strange problems with things like
53# "bitbake -c menuconfig busybox" where it cannot find the terminfo
54# because the sstate had a hard coded search path. Until this is fixed
55# another way this is deemed good enough.
56EX_TERMCAP = ""
Patrick Williams213cb262021-08-07 19:21:33 -050057EX_TERMCAP:class-native = ":/etc/termcap:/usr/share/misc/termcap"
58EX_TERMCAP:class-nativesdk = ":/etc/termcap:/usr/share/misc/termcap"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059EX_TERMINFO = ""
Patrick Williams213cb262021-08-07 19:21:33 -050060EX_TERMINFO:class-native = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
61EX_TERMINFO:class-nativesdk = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
Brad Bishop316dfdd2018-06-25 12:45:53 -040062EX_TERMLIB ?= "tinfo"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
64# Helper function for do_configure to allow multiple configurations
65# $1 the directory to run configure in
66# $@ the arguments to pass to configure
67ncurses_configure() {
68 mkdir -p $1
69 cd $1
70 shift
71 oe_runconf \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 --without-debug \
73 --without-ada \
74 --without-gpm \
75 --enable-hard-tabs \
76 --enable-xmc-glitch \
77 --enable-colorfgbg \
78 --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap${EX_TERMCAP}' \
79 --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo${EX_TERMINFO}' \
80 --with-shared \
81 --disable-big-core \
82 --program-prefix= \
83 --with-ticlib \
Brad Bishop316dfdd2018-06-25 12:45:53 -040084 --with-termlib=${EX_TERMLIB} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 --enable-sigwinch \
86 --enable-pc-files \
87 --disable-rpath-hack \
88 ${EXCONFIG_ARGS} \
89 --with-manpage-format=normal \
Andrew Geissler82c905d2020-04-13 13:39:40 -050090 --without-manpage-renames \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080091 --disable-stripping \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 "$@" || return 1
93 cd ..
94}
95
96# Override the function from the autotools class; ncurses requires a
97# patched autoconf213 to generate the configure script. This autoconf
98# is not available so that the shipped script will be used.
99do_configure() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100 #Remove ${includedir} from CPPFLAGS, need for cross compile
101 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
102
103 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
104 mkdir -p ${PKG_CONFIG_LIBDIR}
105 ( cd ${S}; gnu-configize --force )
106 ncurses_configure "narrowc" || \
107 return 1
108 ! ${ENABLE_WIDEC} || \
109 ncurses_configure "widec" "--enable-widec" "--without-progs"
110
111}
112
113do_compile() {
114 oe_runmake -C narrowc libs
115 oe_runmake -C narrowc/progs
116
117 ! ${ENABLE_WIDEC} || \
118 oe_runmake -C widec libs
119}
120
121# set of expected differences between narrowc and widec header
122#
123# TODO: the NCURSES_CH_T difference can cause real problems :(
124_unifdef_cleanup = " \
125 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
126 -e '/^#define NCURSES_CH_T /d' \
127 -e '/^#include <wchar.h>/d' \
128 -e '\!^/\* .* \*/!d' \
129"
130
131do_test[depends] = "unifdef-native:do_populate_sysroot"
132do_test[dirs] = "${S}"
133do_test() {
134 ${ENABLE_WIDEC} || return 0
135
136 # make sure that the narrow and widec header are compatible
137 # and differ only in minor details.
138 unifdef -k narrowc/include/curses.h | \
139 sed ${_unifdef_cleanup} > curses-narrowc.h
140 unifdef -k widec/include/curses.h | \
141 sed ${_unifdef_cleanup} > curses-widec.h
142
143 diff curses-narrowc.h curses-widec.h
144}
145
146# Split original _install_opts to two parts.
147# One is the options to install contents, the other is the parameters \
148# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500149# Note that install.libs will also implicitly install header files,
150# so we do not need to explicitly specify install.includes.
151# Doing so could in fact result in a race condition, as both targets
152# (install.libs and install.includes) would install the same headers
153# at the same time
154
155_install_opts = " install.libs install.man "
156
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157_install_cfgs = "\
158 DESTDIR='${D}' \
159 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
160"
161
162do_install() {
163 # Order of installation is important; widec installs a 'curses.h'
164 # header with more definitions and must be installed last hence.
165 # Compatibility of these headers will be checked in 'do_test()'.
166 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
167 install.progs
168
169 # The install.data should run after install.libs, otherwise
170 # there would be a race issue in a very critical conditon, since
171 # tic will be run by install.data, and tic needs libtinfo.so
172 # which would be regenerated by install.libs.
173 oe_runmake -C narrowc ${_install_cfgs} \
174 install.data
175
176
177 ! ${ENABLE_WIDEC} || \
178 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
179
180 cd narrowc
181
182 # include some basic terminfo files
183 # stolen ;) from gentoo and modified a bit
184 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
185 do
186 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
187 local basedir="$(basename $(dirname "${termfile}"))"
188
189 if [ -n "${termfile}" ]
190 then
191 install -d ${D}${sysconfdir}/terminfo/${basedir}
192 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
193 ln -s /etc/terminfo/${basedir}/${x} \
194 ${D}${datadir}/terminfo/${basedir}/${x}
195 fi
196 done
197 # i think we can use xterm-color as default xterm
198 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
199 then
200 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
201 fi
202
Brad Bishop316dfdd2018-06-25 12:45:53 -0400203 # When changing ${libdir} to e.g. /usr/lib/myawesomelib/ ncurses
204 # still installs '/usr/lib/terminfo', so try to rm both
205 # the proper path and a slightly hardcoded one
206 rm -f ${D}${libdir}/terminfo ${D}${prefix}/lib/terminfo
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500207
208 # create linker scripts for libcurses.so and libncurses to
209 # link against -ltinfo when needed. Some builds might break
210 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
211 # linker flags.
212 for i in libncurses libncursesw; do
213 f=${D}${libdir}/$i.so
214 test -h $f || continue
215 rm -f $f
216 echo '/* GNU ld script */' >$f
217 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
218 done
219
220 # Make sure that libcurses is linked so that it gets -ltinfo
221 # also, this should be addressed upstream really.
222 ln -sf libncurses.so ${D}${libdir}/libcurses.so
223
224 # create libtermcap.so linker script for backward compatibility
225 f=${D}${libdir}/libtermcap.so
226 echo '/* GNU ld script */' >$f
227 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
228
229 if [ ! -d "${D}${base_libdir}" ]; then
230 # Setting base_libdir to libdir as is done in the -native
231 # case will skip this code
Brad Bishop316dfdd2018-06-25 12:45:53 -0400232 mkdir -p ${D}${base_libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500233 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
234 ! ${ENABLE_WIDEC} || \
235 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
236
237 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
238 rm ${D}${libdir}/libtinfo.so
239
Andrew Geissler595f6302022-01-24 19:11:47 +0000240 # Use ln -rs to ensure this is a relative link despite absolute paths
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500241 # (as we can't know the relationship between base_libdir and libdir).
Andrew Geissler595f6302022-01-24 19:11:47 +0000242 ln -rs ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500243 fi
244 if [ -d "${D}${includedir}/ncurses" ]; then
245 for f in `find ${D}${includedir}/ncurses -name "*.h"`
246 do
247 f=`basename $f`
248 test -e ${D}${includedir}/$f && continue
249 ln -sf ncurses/$f ${D}${includedir}/$f
250 done
251 fi
252 oe_multilib_header curses.h
253}
254
Patrick Williams213cb262021-08-07 19:21:33 -0500255python populate_packages:prepend () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500256 libdir = d.expand("${libdir}")
257 base_libdir = d.expand("${base_libdir}")
258 pnbase = d.expand("${PN}-lib%s")
Brad Bishop19323692019-04-05 15:28:33 -0400259 do_split_packages(d, libdir, r'^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500260 if libdir is not base_libdir:
Brad Bishop19323692019-04-05 15:28:33 -0400261 do_split_packages(d, base_libdir, r'^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500262}
263
264
265inherit update-alternatives
266
267ALTERNATIVE_PRIORITY = "100"
268
Patrick Williams213cb262021-08-07 19:21:33 -0500269ALTERNATIVE:ncurses-tools:class-target = "clear reset"
270ALTERNATIVE:ncurses-terminfo:class-target = "st st-256color"
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500271
272ALTERNATIVE_LINK_NAME[st] = "${datadir}/terminfo/s/st"
273
274ALTERNATIVE_LINK_NAME[st-256color] = "${datadir}/terminfo/s/st-256color"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500275
276BBCLASSEXTEND = "native nativesdk"
277
278PACKAGES += " \
279 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500281 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500282"
283
Patrick Williams213cb262021-08-07 19:21:33 -0500284FILES:${PN} = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285 ${bindir}/tput \
286 ${bindir}/tset \
287 ${bindir}/ncurses5-config \
288 ${bindir}/ncursesw5-config \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500289 ${bindir}/ncurses6-config \
290 ${bindir}/ncursesw6-config \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500291 ${datadir}/tabset \
292"
293
294# This keeps only tput/tset in ncurses
295# clear/reset are in already busybox
Patrick Williams213cb262021-08-07 19:21:33 -0500296FILES:${PN}-tools = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 ${bindir}/tic \
298 ${bindir}/toe \
299 ${bindir}/infotocap \
300 ${bindir}/captoinfo \
301 ${bindir}/infocmp \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500302 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
303 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500304 ${bindir}/tack \
305 ${bindir}/tabs \
306"
307
308# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
Patrick Williams213cb262021-08-07 19:21:33 -0500309RDEPENDS:${PN}-tools = "${PN} ${PN}-terminfo-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500310
Patrick Williams213cb262021-08-07 19:21:33 -0500311FILES:${PN}-terminfo = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500312 ${datadir}/terminfo \
313"
314
Patrick Williams213cb262021-08-07 19:21:33 -0500315FILES:${PN}-terminfo-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316 ${sysconfdir}/terminfo \
317"
318
Patrick Williams213cb262021-08-07 19:21:33 -0500319RSUGGESTS:${PN}-libtinfo = "${PN}-terminfo"
320RRECOMMENDS:${PN}-libtinfo = "${PN}-terminfo-base"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600321
322# Putting terminfo into the sysroot adds around 2800 files to
323# each recipe specific sysroot. We can live without this, particularly
324# as many recipes may have native and target copies.
Patrick Williams213cb262021-08-07 19:21:33 -0500325SYSROOT_DIRS:remove = "${datadir}"