blob: cbb12ca2757e96e4ba1dfef21615cf65a86bb1bd [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 Geissler82c905d2020-04-13 13:39:40 -05005LIC_FILES_CHKSUM = "file://ncurses/base/version.c;beginline=1;endline=27;md5=5526f2f3a29edc95538b368a4771edda"
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/
Brad Bishop316dfdd2018-06-25 12:45:53 -040016SRC_URI = "git://salsa.debian.org/debian/ncurses.git;protocol=https"
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"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022EXTRASITECONFIG = "CFLAGS='${CFLAGS} -I${SYSROOT_DESTDIR}${includedir}'"
23
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024# Whether to enable separate widec libraries; must be 'true' or 'false'
25#
26# TODO: remove this variable when widec is supported in every setup?
27ENABLE_WIDEC ?= "true"
28
29# _GNU_SOURCE is required for widec stuff and is detected automatically
30# for target objects. But it must be set manually for native and sdk
31# builds.
32BUILD_CPPFLAGS += "-D_GNU_SOURCE"
33
34# natives don't generally look in base_libdir
Patrick Williams213cb262021-08-07 19:21:33 -050035base_libdir:class-native = "${libdir}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
37# Display corruption occurs on 64 bit hosts without these settings
38# This was derrived from the upstream debian ncurses which uses
39# these settings for 32 and 64 bit hosts.
40EXCONFIG_ARGS = ""
Patrick Williams213cb262021-08-07 19:21:33 -050041EXCONFIG_ARGS:class-native = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042 --disable-lp64 \
43 --with-chtype='long' \
44 --with-mmask-t='long'"
Patrick Williams213cb262021-08-07 19:21:33 -050045EXCONFIG_ARGS:class-nativesdk = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 --disable-lp64 \
47 --with-chtype='long' \
48 --with-mmask-t='long'"
49
50PACKAGES_DYNAMIC = "^${PN}-lib.*"
51
52# Fall back to the host termcap / terminfo for -nativesdk and -native
53# The reality is a work around for strange problems with things like
54# "bitbake -c menuconfig busybox" where it cannot find the terminfo
55# because the sstate had a hard coded search path. Until this is fixed
56# another way this is deemed good enough.
57EX_TERMCAP = ""
Patrick Williams213cb262021-08-07 19:21:33 -050058EX_TERMCAP:class-native = ":/etc/termcap:/usr/share/misc/termcap"
59EX_TERMCAP:class-nativesdk = ":/etc/termcap:/usr/share/misc/termcap"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060EX_TERMINFO = ""
Patrick Williams213cb262021-08-07 19:21:33 -050061EX_TERMINFO:class-native = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
62EX_TERMINFO:class-nativesdk = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
Brad Bishop316dfdd2018-06-25 12:45:53 -040063EX_TERMLIB ?= "tinfo"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064
65# Helper function for do_configure to allow multiple configurations
66# $1 the directory to run configure in
67# $@ the arguments to pass to configure
68ncurses_configure() {
69 mkdir -p $1
70 cd $1
71 shift
72 oe_runconf \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 --without-debug \
74 --without-ada \
75 --without-gpm \
76 --enable-hard-tabs \
77 --enable-xmc-glitch \
78 --enable-colorfgbg \
79 --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap${EX_TERMCAP}' \
80 --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo${EX_TERMINFO}' \
81 --with-shared \
82 --disable-big-core \
83 --program-prefix= \
84 --with-ticlib \
Brad Bishop316dfdd2018-06-25 12:45:53 -040085 --with-termlib=${EX_TERMLIB} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 --enable-sigwinch \
87 --enable-pc-files \
88 --disable-rpath-hack \
89 ${EXCONFIG_ARGS} \
90 --with-manpage-format=normal \
Andrew Geissler82c905d2020-04-13 13:39:40 -050091 --without-manpage-renames \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080092 --disable-stripping \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 "$@" || return 1
94 cd ..
95}
96
97# Override the function from the autotools class; ncurses requires a
98# patched autoconf213 to generate the configure script. This autoconf
99# is not available so that the shipped script will be used.
100do_configure() {
101 # check does not work with cross-compiling and is generally
102 # broken because it requires stdin to be pollable (which is
103 # not the case for /dev/null redirections)
104 export cf_cv_working_poll=yes
105 #Remove ${includedir} from CPPFLAGS, need for cross compile
106 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
107
108 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
109 mkdir -p ${PKG_CONFIG_LIBDIR}
110 ( cd ${S}; gnu-configize --force )
111 ncurses_configure "narrowc" || \
112 return 1
113 ! ${ENABLE_WIDEC} || \
114 ncurses_configure "widec" "--enable-widec" "--without-progs"
115
116}
117
118do_compile() {
119 oe_runmake -C narrowc libs
120 oe_runmake -C narrowc/progs
121
122 ! ${ENABLE_WIDEC} || \
123 oe_runmake -C widec libs
124}
125
126# set of expected differences between narrowc and widec header
127#
128# TODO: the NCURSES_CH_T difference can cause real problems :(
129_unifdef_cleanup = " \
130 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
131 -e '/^#define NCURSES_CH_T /d' \
132 -e '/^#include <wchar.h>/d' \
133 -e '\!^/\* .* \*/!d' \
134"
135
136do_test[depends] = "unifdef-native:do_populate_sysroot"
137do_test[dirs] = "${S}"
138do_test() {
139 ${ENABLE_WIDEC} || return 0
140
141 # make sure that the narrow and widec header are compatible
142 # and differ only in minor details.
143 unifdef -k narrowc/include/curses.h | \
144 sed ${_unifdef_cleanup} > curses-narrowc.h
145 unifdef -k widec/include/curses.h | \
146 sed ${_unifdef_cleanup} > curses-widec.h
147
148 diff curses-narrowc.h curses-widec.h
149}
150
151# Split original _install_opts to two parts.
152# One is the options to install contents, the other is the parameters \
153# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500154# Note that install.libs will also implicitly install header files,
155# so we do not need to explicitly specify install.includes.
156# Doing so could in fact result in a race condition, as both targets
157# (install.libs and install.includes) would install the same headers
158# at the same time
159
160_install_opts = " install.libs install.man "
161
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162_install_cfgs = "\
163 DESTDIR='${D}' \
164 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
165"
166
167do_install() {
168 # Order of installation is important; widec installs a 'curses.h'
169 # header with more definitions and must be installed last hence.
170 # Compatibility of these headers will be checked in 'do_test()'.
171 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
172 install.progs
173
174 # The install.data should run after install.libs, otherwise
175 # there would be a race issue in a very critical conditon, since
176 # tic will be run by install.data, and tic needs libtinfo.so
177 # which would be regenerated by install.libs.
178 oe_runmake -C narrowc ${_install_cfgs} \
179 install.data
180
181
182 ! ${ENABLE_WIDEC} || \
183 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
184
185 cd narrowc
186
187 # include some basic terminfo files
188 # stolen ;) from gentoo and modified a bit
189 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
190 do
191 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
192 local basedir="$(basename $(dirname "${termfile}"))"
193
194 if [ -n "${termfile}" ]
195 then
196 install -d ${D}${sysconfdir}/terminfo/${basedir}
197 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
198 ln -s /etc/terminfo/${basedir}/${x} \
199 ${D}${datadir}/terminfo/${basedir}/${x}
200 fi
201 done
202 # i think we can use xterm-color as default xterm
203 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
204 then
205 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
206 fi
207
Brad Bishop316dfdd2018-06-25 12:45:53 -0400208 # When changing ${libdir} to e.g. /usr/lib/myawesomelib/ ncurses
209 # still installs '/usr/lib/terminfo', so try to rm both
210 # the proper path and a slightly hardcoded one
211 rm -f ${D}${libdir}/terminfo ${D}${prefix}/lib/terminfo
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500212
213 # create linker scripts for libcurses.so and libncurses to
214 # link against -ltinfo when needed. Some builds might break
215 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
216 # linker flags.
217 for i in libncurses libncursesw; do
218 f=${D}${libdir}/$i.so
219 test -h $f || continue
220 rm -f $f
221 echo '/* GNU ld script */' >$f
222 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
223 done
224
225 # Make sure that libcurses is linked so that it gets -ltinfo
226 # also, this should be addressed upstream really.
227 ln -sf libncurses.so ${D}${libdir}/libcurses.so
228
229 # create libtermcap.so linker script for backward compatibility
230 f=${D}${libdir}/libtermcap.so
231 echo '/* GNU ld script */' >$f
232 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
233
234 if [ ! -d "${D}${base_libdir}" ]; then
235 # Setting base_libdir to libdir as is done in the -native
236 # case will skip this code
Brad Bishop316dfdd2018-06-25 12:45:53 -0400237 mkdir -p ${D}${base_libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500238 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
239 ! ${ENABLE_WIDEC} || \
240 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
241
242 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
243 rm ${D}${libdir}/libtinfo.so
244
245 # Use lnr to ensure this is a relative link despite absolute paths
246 # (as we can't know the relationship between base_libdir and libdir).
247 # At some point we can rely on coreutils 8.16 which has ln -r.
248 lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
249 fi
250 if [ -d "${D}${includedir}/ncurses" ]; then
251 for f in `find ${D}${includedir}/ncurses -name "*.h"`
252 do
253 f=`basename $f`
254 test -e ${D}${includedir}/$f && continue
255 ln -sf ncurses/$f ${D}${includedir}/$f
256 done
257 fi
258 oe_multilib_header curses.h
259}
260
Patrick Williams213cb262021-08-07 19:21:33 -0500261python populate_packages:prepend () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500262 libdir = d.expand("${libdir}")
263 base_libdir = d.expand("${base_libdir}")
264 pnbase = d.expand("${PN}-lib%s")
Brad Bishop19323692019-04-05 15:28:33 -0400265 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 -0500266 if libdir is not base_libdir:
Brad Bishop19323692019-04-05 15:28:33 -0400267 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 -0500268}
269
270
271inherit update-alternatives
272
273ALTERNATIVE_PRIORITY = "100"
274
Patrick Williams213cb262021-08-07 19:21:33 -0500275ALTERNATIVE:ncurses-tools:class-target = "clear reset"
276ALTERNATIVE:ncurses-terminfo:class-target = "st st-256color"
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500277
278ALTERNATIVE_LINK_NAME[st] = "${datadir}/terminfo/s/st"
279
280ALTERNATIVE_LINK_NAME[st-256color] = "${datadir}/terminfo/s/st-256color"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281
282BBCLASSEXTEND = "native nativesdk"
283
284PACKAGES += " \
285 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500286 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500287 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288"
289
Patrick Williams213cb262021-08-07 19:21:33 -0500290FILES:${PN} = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500291 ${bindir}/tput \
292 ${bindir}/tset \
293 ${bindir}/ncurses5-config \
294 ${bindir}/ncursesw5-config \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500295 ${bindir}/ncurses6-config \
296 ${bindir}/ncursesw6-config \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 ${datadir}/tabset \
298"
299
300# This keeps only tput/tset in ncurses
301# clear/reset are in already busybox
Patrick Williams213cb262021-08-07 19:21:33 -0500302FILES:${PN}-tools = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303 ${bindir}/tic \
304 ${bindir}/toe \
305 ${bindir}/infotocap \
306 ${bindir}/captoinfo \
307 ${bindir}/infocmp \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500308 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
309 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500310 ${bindir}/tack \
311 ${bindir}/tabs \
312"
313
314# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
Patrick Williams213cb262021-08-07 19:21:33 -0500315RDEPENDS:${PN}-tools = "${PN} ${PN}-terminfo-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316
Patrick Williams213cb262021-08-07 19:21:33 -0500317FILES:${PN}-terminfo = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500318 ${datadir}/terminfo \
319"
320
Patrick Williams213cb262021-08-07 19:21:33 -0500321FILES:${PN}-terminfo-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500322 ${sysconfdir}/terminfo \
323"
324
Patrick Williams213cb262021-08-07 19:21:33 -0500325RSUGGESTS:${PN}-libtinfo = "${PN}-terminfo"
326RRECOMMENDS:${PN}-libtinfo = "${PN}-terminfo-base"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600327
328# Putting terminfo into the sysroot adds around 2800 files to
329# each recipe specific sysroot. We can live without this, particularly
330# as many recipes may have native and target copies.
Patrick Williams213cb262021-08-07 19:21:33 -0500331SYSROOT_DIRS:remove = "${datadir}"