blob: 01e41d5f73587fe966a39bfadade6ed6286129a8 [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 \
90 "$@" || return 1
91 cd ..
92}
93
94# Override the function from the autotools class; ncurses requires a
95# patched autoconf213 to generate the configure script. This autoconf
96# is not available so that the shipped script will be used.
97do_configure() {
98 # check does not work with cross-compiling and is generally
99 # broken because it requires stdin to be pollable (which is
100 # not the case for /dev/null redirections)
101 export cf_cv_working_poll=yes
102 #Remove ${includedir} from CPPFLAGS, need for cross compile
103 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
104
105 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
106 mkdir -p ${PKG_CONFIG_LIBDIR}
107 ( cd ${S}; gnu-configize --force )
108 ncurses_configure "narrowc" || \
109 return 1
110 ! ${ENABLE_WIDEC} || \
111 ncurses_configure "widec" "--enable-widec" "--without-progs"
112
113}
114
115do_compile() {
116 oe_runmake -C narrowc libs
117 oe_runmake -C narrowc/progs
118
119 ! ${ENABLE_WIDEC} || \
120 oe_runmake -C widec libs
121}
122
123# set of expected differences between narrowc and widec header
124#
125# TODO: the NCURSES_CH_T difference can cause real problems :(
126_unifdef_cleanup = " \
127 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
128 -e '/^#define NCURSES_CH_T /d' \
129 -e '/^#include <wchar.h>/d' \
130 -e '\!^/\* .* \*/!d' \
131"
132
133do_test[depends] = "unifdef-native:do_populate_sysroot"
134do_test[dirs] = "${S}"
135do_test() {
136 ${ENABLE_WIDEC} || return 0
137
138 # make sure that the narrow and widec header are compatible
139 # and differ only in minor details.
140 unifdef -k narrowc/include/curses.h | \
141 sed ${_unifdef_cleanup} > curses-narrowc.h
142 unifdef -k widec/include/curses.h | \
143 sed ${_unifdef_cleanup} > curses-widec.h
144
145 diff curses-narrowc.h curses-widec.h
146}
147
148# Split original _install_opts to two parts.
149# One is the options to install contents, the other is the parameters \
150# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500151# Note that install.libs will also implicitly install header files,
152# so we do not need to explicitly specify install.includes.
153# Doing so could in fact result in a race condition, as both targets
154# (install.libs and install.includes) would install the same headers
155# at the same time
156
157_install_opts = " install.libs install.man "
158
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159_install_cfgs = "\
160 DESTDIR='${D}' \
161 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
162"
163
164do_install() {
165 # Order of installation is important; widec installs a 'curses.h'
166 # header with more definitions and must be installed last hence.
167 # Compatibility of these headers will be checked in 'do_test()'.
168 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
169 install.progs
170
171 # The install.data should run after install.libs, otherwise
172 # there would be a race issue in a very critical conditon, since
173 # tic will be run by install.data, and tic needs libtinfo.so
174 # which would be regenerated by install.libs.
175 oe_runmake -C narrowc ${_install_cfgs} \
176 install.data
177
178
179 ! ${ENABLE_WIDEC} || \
180 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
181
182 cd narrowc
183
184 # include some basic terminfo files
185 # stolen ;) from gentoo and modified a bit
186 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
187 do
188 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
189 local basedir="$(basename $(dirname "${termfile}"))"
190
191 if [ -n "${termfile}" ]
192 then
193 install -d ${D}${sysconfdir}/terminfo/${basedir}
194 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
195 ln -s /etc/terminfo/${basedir}/${x} \
196 ${D}${datadir}/terminfo/${basedir}/${x}
197 fi
198 done
199 # i think we can use xterm-color as default xterm
200 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
201 then
202 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
203 fi
204
Brad Bishop316dfdd2018-06-25 12:45:53 -0400205 # When changing ${libdir} to e.g. /usr/lib/myawesomelib/ ncurses
206 # still installs '/usr/lib/terminfo', so try to rm both
207 # the proper path and a slightly hardcoded one
208 rm -f ${D}${libdir}/terminfo ${D}${prefix}/lib/terminfo
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500209
210 # create linker scripts for libcurses.so and libncurses to
211 # link against -ltinfo when needed. Some builds might break
212 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
213 # linker flags.
214 for i in libncurses libncursesw; do
215 f=${D}${libdir}/$i.so
216 test -h $f || continue
217 rm -f $f
218 echo '/* GNU ld script */' >$f
219 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
220 done
221
222 # Make sure that libcurses is linked so that it gets -ltinfo
223 # also, this should be addressed upstream really.
224 ln -sf libncurses.so ${D}${libdir}/libcurses.so
225
226 # create libtermcap.so linker script for backward compatibility
227 f=${D}${libdir}/libtermcap.so
228 echo '/* GNU ld script */' >$f
229 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
230
231 if [ ! -d "${D}${base_libdir}" ]; then
232 # Setting base_libdir to libdir as is done in the -native
233 # case will skip this code
Brad Bishop316dfdd2018-06-25 12:45:53 -0400234 mkdir -p ${D}${base_libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500235 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
236 ! ${ENABLE_WIDEC} || \
237 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
238
239 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
240 rm ${D}${libdir}/libtinfo.so
241
242 # Use lnr to ensure this is a relative link despite absolute paths
243 # (as we can't know the relationship between base_libdir and libdir).
244 # At some point we can rely on coreutils 8.16 which has ln -r.
245 lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
246 fi
247 if [ -d "${D}${includedir}/ncurses" ]; then
248 for f in `find ${D}${includedir}/ncurses -name "*.h"`
249 do
250 f=`basename $f`
251 test -e ${D}${includedir}/$f && continue
252 ln -sf ncurses/$f ${D}${includedir}/$f
253 done
254 fi
255 oe_multilib_header curses.h
256}
257
258python populate_packages_prepend () {
259 libdir = d.expand("${libdir}")
260 base_libdir = d.expand("${base_libdir}")
261 pnbase = d.expand("${PN}-lib%s")
262 do_split_packages(d, libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
263 if libdir is not base_libdir:
264 do_split_packages(d, base_libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
265}
266
267
268inherit update-alternatives
269
270ALTERNATIVE_PRIORITY = "100"
271
272ALTERNATIVE_ncurses-tools_class-target = "clear reset"
273
274BBCLASSEXTEND = "native nativesdk"
275
276PACKAGES += " \
277 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500278 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500279 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280"
281
282FILES_${PN} = "\
283 ${bindir}/tput \
284 ${bindir}/tset \
285 ${bindir}/ncurses5-config \
286 ${bindir}/ncursesw5-config \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500287 ${bindir}/ncurses6-config \
288 ${bindir}/ncursesw6-config \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500289 ${datadir}/tabset \
290"
291
292# This keeps only tput/tset in ncurses
293# clear/reset are in already busybox
294FILES_${PN}-tools = "\
295 ${bindir}/tic \
296 ${bindir}/toe \
297 ${bindir}/infotocap \
298 ${bindir}/captoinfo \
299 ${bindir}/infocmp \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500300 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
301 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302 ${bindir}/tack \
303 ${bindir}/tabs \
304"
305
306# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
307RDEPENDS_${PN}-tools = "${PN}"
308
309FILES_${PN}-terminfo = "\
310 ${datadir}/terminfo \
311"
312
313FILES_${PN}-terminfo-base = "\
314 ${sysconfdir}/terminfo \
315"
316
317RSUGGESTS_${PN}-libtinfo = "${PN}-terminfo"
318RRECOMMENDS_${PN}-libtinfo = "${PN}-terminfo-base"