blob: 1f21cd413d47bbcdeecadedd899f7812e513f10c [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/
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016SRC_URI = "git://anonscm.debian.org/collab-maint/ncurses.git"
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"
62
63# Helper function for do_configure to allow multiple configurations
64# $1 the directory to run configure in
65# $@ the arguments to pass to configure
66ncurses_configure() {
67 mkdir -p $1
68 cd $1
69 shift
70 oe_runconf \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 --without-debug \
72 --without-ada \
73 --without-gpm \
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=tinfo \
84 --enable-sigwinch \
85 --enable-pc-files \
86 --disable-rpath-hack \
87 ${EXCONFIG_ARGS} \
88 --with-manpage-format=normal \
89 "$@" || return 1
90 cd ..
91}
92
93# Override the function from the autotools class; ncurses requires a
94# patched autoconf213 to generate the configure script. This autoconf
95# is not available so that the shipped script will be used.
96do_configure() {
97 # check does not work with cross-compiling and is generally
98 # broken because it requires stdin to be pollable (which is
99 # not the case for /dev/null redirections)
100 export cf_cv_working_poll=yes
101 #Remove ${includedir} from CPPFLAGS, need for cross compile
102 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
103
104 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
105 mkdir -p ${PKG_CONFIG_LIBDIR}
106 ( cd ${S}; gnu-configize --force )
107 ncurses_configure "narrowc" || \
108 return 1
109 ! ${ENABLE_WIDEC} || \
110 ncurses_configure "widec" "--enable-widec" "--without-progs"
111
112}
113
114do_compile() {
115 oe_runmake -C narrowc libs
116 oe_runmake -C narrowc/progs
117
118 ! ${ENABLE_WIDEC} || \
119 oe_runmake -C widec libs
120}
121
122# set of expected differences between narrowc and widec header
123#
124# TODO: the NCURSES_CH_T difference can cause real problems :(
125_unifdef_cleanup = " \
126 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
127 -e '/^#define NCURSES_CH_T /d' \
128 -e '/^#include <wchar.h>/d' \
129 -e '\!^/\* .* \*/!d' \
130"
131
132do_test[depends] = "unifdef-native:do_populate_sysroot"
133do_test[dirs] = "${S}"
134do_test() {
135 ${ENABLE_WIDEC} || return 0
136
137 # make sure that the narrow and widec header are compatible
138 # and differ only in minor details.
139 unifdef -k narrowc/include/curses.h | \
140 sed ${_unifdef_cleanup} > curses-narrowc.h
141 unifdef -k widec/include/curses.h | \
142 sed ${_unifdef_cleanup} > curses-widec.h
143
144 diff curses-narrowc.h curses-widec.h
145}
146
147# Split original _install_opts to two parts.
148# One is the options to install contents, the other is the parameters \
149# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500150# Note that install.libs will also implicitly install header files,
151# so we do not need to explicitly specify install.includes.
152# Doing so could in fact result in a race condition, as both targets
153# (install.libs and install.includes) would install the same headers
154# at the same time
155
156_install_opts = " install.libs install.man "
157
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158_install_cfgs = "\
159 DESTDIR='${D}' \
160 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
161"
162
163do_install() {
164 # Order of installation is important; widec installs a 'curses.h'
165 # header with more definitions and must be installed last hence.
166 # Compatibility of these headers will be checked in 'do_test()'.
167 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
168 install.progs
169
170 # The install.data should run after install.libs, otherwise
171 # there would be a race issue in a very critical conditon, since
172 # tic will be run by install.data, and tic needs libtinfo.so
173 # which would be regenerated by install.libs.
174 oe_runmake -C narrowc ${_install_cfgs} \
175 install.data
176
177
178 ! ${ENABLE_WIDEC} || \
179 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
180
181 cd narrowc
182
183 # include some basic terminfo files
184 # stolen ;) from gentoo and modified a bit
185 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
186 do
187 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
188 local basedir="$(basename $(dirname "${termfile}"))"
189
190 if [ -n "${termfile}" ]
191 then
192 install -d ${D}${sysconfdir}/terminfo/${basedir}
193 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
194 ln -s /etc/terminfo/${basedir}/${x} \
195 ${D}${datadir}/terminfo/${basedir}/${x}
196 fi
197 done
198 # i think we can use xterm-color as default xterm
199 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
200 then
201 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
202 fi
203
204 rm -f ${D}${libdir}/terminfo
205
206 # create linker scripts for libcurses.so and libncurses to
207 # link against -ltinfo when needed. Some builds might break
208 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
209 # linker flags.
210 for i in libncurses libncursesw; do
211 f=${D}${libdir}/$i.so
212 test -h $f || continue
213 rm -f $f
214 echo '/* GNU ld script */' >$f
215 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
216 done
217
218 # Make sure that libcurses is linked so that it gets -ltinfo
219 # also, this should be addressed upstream really.
220 ln -sf libncurses.so ${D}${libdir}/libcurses.so
221
222 # create libtermcap.so linker script for backward compatibility
223 f=${D}${libdir}/libtermcap.so
224 echo '/* GNU ld script */' >$f
225 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
226
227 if [ ! -d "${D}${base_libdir}" ]; then
228 # Setting base_libdir to libdir as is done in the -native
229 # case will skip this code
230 mkdir ${D}${base_libdir}
231 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
232 ! ${ENABLE_WIDEC} || \
233 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
234
235 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
236 rm ${D}${libdir}/libtinfo.so
237
238 # Use lnr to ensure this is a relative link despite absolute paths
239 # (as we can't know the relationship between base_libdir and libdir).
240 # At some point we can rely on coreutils 8.16 which has ln -r.
241 lnr ${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, '^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, '^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"
269
270BBCLASSEXTEND = "native nativesdk"
271
272PACKAGES += " \
273 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500274 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500275 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500276"
277
278FILES_${PN} = "\
279 ${bindir}/tput \
280 ${bindir}/tset \
281 ${bindir}/ncurses5-config \
282 ${bindir}/ncursesw5-config \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500283 ${bindir}/ncurses6-config \
284 ${bindir}/ncursesw6-config \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285 ${datadir}/tabset \
286"
287
288# This keeps only tput/tset in ncurses
289# clear/reset are in already busybox
290FILES_${PN}-tools = "\
291 ${bindir}/tic \
292 ${bindir}/toe \
293 ${bindir}/infotocap \
294 ${bindir}/captoinfo \
295 ${bindir}/infocmp \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500296 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
297 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500298 ${bindir}/tack \
299 ${bindir}/tabs \
300"
301
302# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
303RDEPENDS_${PN}-tools = "${PN}"
304
305FILES_${PN}-terminfo = "\
306 ${datadir}/terminfo \
307"
308
309FILES_${PN}-terminfo-base = "\
310 ${sysconfdir}/terminfo \
311"
312
313RSUGGESTS_${PN}-libtinfo = "${PN}-terminfo"
314RRECOMMENDS_${PN}-libtinfo = "${PN}-terminfo-base"