blob: 5f2cc35823390ae3de6f886c1033eaeef54aed0d [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"
5LIC_FILES_CHKSUM = "file://ncurses/base/version.c;beginline=1;endline=27;md5=cbc180a8c44ca642e97c35452fab5f66"
6SECTION = "libs"
7DEPENDS = "ncurses-native"
8DEPENDS_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"
19CONFIG_SITE =+ "${WORKDIR}/config.cache"
20
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021EXTRASITECONFIG = "CFLAGS='${CFLAGS} -I${SYSROOT_DESTDIR}${includedir}'"
22
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023# 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 detected automatically
29# for target objects. But it must be set manually for native and sdk
30# builds.
31BUILD_CPPFLAGS += "-D_GNU_SOURCE"
32
33# natives don't generally look in base_libdir
34base_libdir_class-native = "${libdir}"
35
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 = ""
40EXCONFIG_ARGS_class-native = " \
41 --disable-lp64 \
42 --with-chtype='long' \
43 --with-mmask-t='long'"
44EXCONFIG_ARGS_class-nativesdk = " \
45 --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 = ""
57EX_TERMCAP_class-native = ":/etc/termcap:/usr/share/misc/termcap"
58EX_TERMCAP_class-nativesdk = ":/etc/termcap:/usr/share/misc/termcap"
59EX_TERMINFO = ""
60EX_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 \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080090 --disable-stripping \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 "$@" || 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 # check does not work with cross-compiling and is generally
100 # broken because it requires stdin to be pollable (which is
101 # not the case for /dev/null redirections)
102 export cf_cv_working_poll=yes
103 #Remove ${includedir} from CPPFLAGS, need for cross compile
104 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
105
106 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
107 mkdir -p ${PKG_CONFIG_LIBDIR}
108 ( cd ${S}; gnu-configize --force )
109 ncurses_configure "narrowc" || \
110 return 1
111 ! ${ENABLE_WIDEC} || \
112 ncurses_configure "widec" "--enable-widec" "--without-progs"
113
114}
115
116do_compile() {
117 oe_runmake -C narrowc libs
118 oe_runmake -C narrowc/progs
119
120 ! ${ENABLE_WIDEC} || \
121 oe_runmake -C widec libs
122}
123
124# set of expected differences between narrowc and widec header
125#
126# TODO: the NCURSES_CH_T difference can cause real problems :(
127_unifdef_cleanup = " \
128 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
129 -e '/^#define NCURSES_CH_T /d' \
130 -e '/^#include <wchar.h>/d' \
131 -e '\!^/\* .* \*/!d' \
132"
133
134do_test[depends] = "unifdef-native:do_populate_sysroot"
135do_test[dirs] = "${S}"
136do_test() {
137 ${ENABLE_WIDEC} || return 0
138
139 # make sure that the narrow and widec header are compatible
140 # and differ only in minor details.
141 unifdef -k narrowc/include/curses.h | \
142 sed ${_unifdef_cleanup} > curses-narrowc.h
143 unifdef -k widec/include/curses.h | \
144 sed ${_unifdef_cleanup} > curses-widec.h
145
146 diff curses-narrowc.h curses-widec.h
147}
148
149# Split original _install_opts to two parts.
150# One is the options to install contents, the other is the parameters \
151# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500152# Note that install.libs will also implicitly install header files,
153# so we do not need to explicitly specify install.includes.
154# Doing so could in fact result in a race condition, as both targets
155# (install.libs and install.includes) would install the same headers
156# at the same time
157
158_install_opts = " install.libs install.man "
159
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160_install_cfgs = "\
161 DESTDIR='${D}' \
162 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
163"
164
165do_install() {
166 # Order of installation is important; widec installs a 'curses.h'
167 # header with more definitions and must be installed last hence.
168 # Compatibility of these headers will be checked in 'do_test()'.
169 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
170 install.progs
171
172 # The install.data should run after install.libs, otherwise
173 # there would be a race issue in a very critical conditon, since
174 # tic will be run by install.data, and tic needs libtinfo.so
175 # which would be regenerated by install.libs.
176 oe_runmake -C narrowc ${_install_cfgs} \
177 install.data
178
179
180 ! ${ENABLE_WIDEC} || \
181 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
182
183 cd narrowc
184
185 # include some basic terminfo files
186 # stolen ;) from gentoo and modified a bit
187 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
188 do
189 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
190 local basedir="$(basename $(dirname "${termfile}"))"
191
192 if [ -n "${termfile}" ]
193 then
194 install -d ${D}${sysconfdir}/terminfo/${basedir}
195 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
196 ln -s /etc/terminfo/${basedir}/${x} \
197 ${D}${datadir}/terminfo/${basedir}/${x}
198 fi
199 done
200 # i think we can use xterm-color as default xterm
201 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
202 then
203 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
204 fi
205
Brad Bishop316dfdd2018-06-25 12:45:53 -0400206 # When changing ${libdir} to e.g. /usr/lib/myawesomelib/ ncurses
207 # still installs '/usr/lib/terminfo', so try to rm both
208 # the proper path and a slightly hardcoded one
209 rm -f ${D}${libdir}/terminfo ${D}${prefix}/lib/terminfo
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500210
211 # create linker scripts for libcurses.so and libncurses to
212 # link against -ltinfo when needed. Some builds might break
213 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
214 # linker flags.
215 for i in libncurses libncursesw; do
216 f=${D}${libdir}/$i.so
217 test -h $f || continue
218 rm -f $f
219 echo '/* GNU ld script */' >$f
220 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
221 done
222
223 # Make sure that libcurses is linked so that it gets -ltinfo
224 # also, this should be addressed upstream really.
225 ln -sf libncurses.so ${D}${libdir}/libcurses.so
226
227 # create libtermcap.so linker script for backward compatibility
228 f=${D}${libdir}/libtermcap.so
229 echo '/* GNU ld script */' >$f
230 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
231
232 if [ ! -d "${D}${base_libdir}" ]; then
233 # Setting base_libdir to libdir as is done in the -native
234 # case will skip this code
Brad Bishop316dfdd2018-06-25 12:45:53 -0400235 mkdir -p ${D}${base_libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
237 ! ${ENABLE_WIDEC} || \
238 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
239
240 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
241 rm ${D}${libdir}/libtinfo.so
242
243 # Use lnr to ensure this is a relative link despite absolute paths
244 # (as we can't know the relationship between base_libdir and libdir).
245 # At some point we can rely on coreutils 8.16 which has ln -r.
246 lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
247 fi
248 if [ -d "${D}${includedir}/ncurses" ]; then
249 for f in `find ${D}${includedir}/ncurses -name "*.h"`
250 do
251 f=`basename $f`
252 test -e ${D}${includedir}/$f && continue
253 ln -sf ncurses/$f ${D}${includedir}/$f
254 done
255 fi
256 oe_multilib_header curses.h
257}
258
259python populate_packages_prepend () {
260 libdir = d.expand("${libdir}")
261 base_libdir = d.expand("${base_libdir}")
262 pnbase = d.expand("${PN}-lib%s")
Brad Bishop19323692019-04-05 15:28:33 -0400263 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 -0500264 if libdir is not base_libdir:
Brad Bishop19323692019-04-05 15:28:33 -0400265 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 -0500266}
267
268
269inherit update-alternatives
270
271ALTERNATIVE_PRIORITY = "100"
272
273ALTERNATIVE_ncurses-tools_class-target = "clear reset"
274
275BBCLASSEXTEND = "native nativesdk"
276
277PACKAGES += " \
278 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500279 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500280 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281"
282
283FILES_${PN} = "\
284 ${bindir}/tput \
285 ${bindir}/tset \
286 ${bindir}/ncurses5-config \
287 ${bindir}/ncursesw5-config \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500288 ${bindir}/ncurses6-config \
289 ${bindir}/ncursesw6-config \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500290 ${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 \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500301 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
302 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303 ${bindir}/tack \
304 ${bindir}/tabs \
305"
306
307# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
308RDEPENDS_${PN}-tools = "${PN}"
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"