blob: ff0117b8226ace50ef69ff2ee7dd135f1c24e1b5 [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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050010BINCONFIG = "${bindir}/ncurses5-config ${bindir}/ncursesw5-config"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
12inherit autotools binconfig-disabled multilib_header pkgconfig
13
14# Upstream has useful patches at times at ftp://invisible-island.net/ncurses/
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050015SRC_URI = "git://anonscm.debian.org/collab-maint/ncurses.git"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
17EXTRA_AUTORECONF = "-I m4"
18CONFIG_SITE =+ "${WORKDIR}/config.cache"
19
20# Whether to enable separate widec libraries; must be 'true' or 'false'
21#
22# TODO: remove this variable when widec is supported in every setup?
23ENABLE_WIDEC ?= "true"
24
25# _GNU_SOURCE is required for widec stuff and is detected automatically
26# for target objects. But it must be set manually for native and sdk
27# builds.
28BUILD_CPPFLAGS += "-D_GNU_SOURCE"
29
30# natives don't generally look in base_libdir
31base_libdir_class-native = "${libdir}"
32
33# Display corruption occurs on 64 bit hosts without these settings
34# This was derrived from the upstream debian ncurses which uses
35# these settings for 32 and 64 bit hosts.
36EXCONFIG_ARGS = ""
37EXCONFIG_ARGS_class-native = " \
38 --disable-lp64 \
39 --with-chtype='long' \
40 --with-mmask-t='long'"
41EXCONFIG_ARGS_class-nativesdk = " \
42 --disable-lp64 \
43 --with-chtype='long' \
44 --with-mmask-t='long'"
45
46PACKAGES_DYNAMIC = "^${PN}-lib.*"
47
48# Fall back to the host termcap / terminfo for -nativesdk and -native
49# The reality is a work around for strange problems with things like
50# "bitbake -c menuconfig busybox" where it cannot find the terminfo
51# because the sstate had a hard coded search path. Until this is fixed
52# another way this is deemed good enough.
53EX_TERMCAP = ""
54EX_TERMCAP_class-native = ":/etc/termcap:/usr/share/misc/termcap"
55EX_TERMCAP_class-nativesdk = ":/etc/termcap:/usr/share/misc/termcap"
56EX_TERMINFO = ""
57EX_TERMINFO_class-native = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
58EX_TERMINFO_class-nativesdk = ":/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo"
59
60# Helper function for do_configure to allow multiple configurations
61# $1 the directory to run configure in
62# $@ the arguments to pass to configure
63ncurses_configure() {
64 mkdir -p $1
65 cd $1
66 shift
67 oe_runconf \
68 --disable-static \
69 --without-debug \
70 --without-ada \
71 --without-gpm \
72 --enable-hard-tabs \
73 --enable-xmc-glitch \
74 --enable-colorfgbg \
75 --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap${EX_TERMCAP}' \
76 --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo${EX_TERMINFO}' \
77 --with-shared \
78 --disable-big-core \
79 --program-prefix= \
80 --with-ticlib \
81 --with-termlib=tinfo \
82 --enable-sigwinch \
83 --enable-pc-files \
84 --disable-rpath-hack \
85 ${EXCONFIG_ARGS} \
86 --with-manpage-format=normal \
87 "$@" || return 1
88 cd ..
89}
90
91# Override the function from the autotools class; ncurses requires a
92# patched autoconf213 to generate the configure script. This autoconf
93# is not available so that the shipped script will be used.
94do_configure() {
95 # check does not work with cross-compiling and is generally
96 # broken because it requires stdin to be pollable (which is
97 # not the case for /dev/null redirections)
98 export cf_cv_working_poll=yes
99 #Remove ${includedir} from CPPFLAGS, need for cross compile
100 sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
101
102 # The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
103 mkdir -p ${PKG_CONFIG_LIBDIR}
104 ( cd ${S}; gnu-configize --force )
105 ncurses_configure "narrowc" || \
106 return 1
107 ! ${ENABLE_WIDEC} || \
108 ncurses_configure "widec" "--enable-widec" "--without-progs"
109
110}
111
112do_compile() {
113 oe_runmake -C narrowc libs
114 oe_runmake -C narrowc/progs
115
116 ! ${ENABLE_WIDEC} || \
117 oe_runmake -C widec libs
118}
119
120# set of expected differences between narrowc and widec header
121#
122# TODO: the NCURSES_CH_T difference can cause real problems :(
123_unifdef_cleanup = " \
124 -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
125 -e '/^#define NCURSES_CH_T /d' \
126 -e '/^#include <wchar.h>/d' \
127 -e '\!^/\* .* \*/!d' \
128"
129
130do_test[depends] = "unifdef-native:do_populate_sysroot"
131do_test[dirs] = "${S}"
132do_test() {
133 ${ENABLE_WIDEC} || return 0
134
135 # make sure that the narrow and widec header are compatible
136 # and differ only in minor details.
137 unifdef -k narrowc/include/curses.h | \
138 sed ${_unifdef_cleanup} > curses-narrowc.h
139 unifdef -k widec/include/curses.h | \
140 sed ${_unifdef_cleanup} > curses-widec.h
141
142 diff curses-narrowc.h curses-widec.h
143}
144
145# Split original _install_opts to two parts.
146# One is the options to install contents, the other is the parameters \
147# when running command "make install"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500148# Note that install.libs will also implicitly install header files,
149# so we do not need to explicitly specify install.includes.
150# Doing so could in fact result in a race condition, as both targets
151# (install.libs and install.includes) would install the same headers
152# at the same time
153
154_install_opts = " install.libs install.man "
155
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156_install_cfgs = "\
157 DESTDIR='${D}' \
158 PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
159"
160
161do_install() {
162 # Order of installation is important; widec installs a 'curses.h'
163 # header with more definitions and must be installed last hence.
164 # Compatibility of these headers will be checked in 'do_test()'.
165 oe_runmake -C narrowc ${_install_cfgs} ${_install_opts} \
166 install.progs
167
168 # The install.data should run after install.libs, otherwise
169 # there would be a race issue in a very critical conditon, since
170 # tic will be run by install.data, and tic needs libtinfo.so
171 # which would be regenerated by install.libs.
172 oe_runmake -C narrowc ${_install_cfgs} \
173 install.data
174
175
176 ! ${ENABLE_WIDEC} || \
177 oe_runmake -C widec ${_install_cfgs} ${_install_opts}
178
179 cd narrowc
180
181 # include some basic terminfo files
182 # stolen ;) from gentoo and modified a bit
183 for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
184 do
185 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
186 local basedir="$(basename $(dirname "${termfile}"))"
187
188 if [ -n "${termfile}" ]
189 then
190 install -d ${D}${sysconfdir}/terminfo/${basedir}
191 mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
192 ln -s /etc/terminfo/${basedir}/${x} \
193 ${D}${datadir}/terminfo/${basedir}/${x}
194 fi
195 done
196 # i think we can use xterm-color as default xterm
197 if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
198 then
199 ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
200 fi
201
202 rm -f ${D}${libdir}/terminfo
203
204 # create linker scripts for libcurses.so and libncurses to
205 # link against -ltinfo when needed. Some builds might break
206 # else when '-Wl,--no-copy-dt-needed-entries' has been set in
207 # linker flags.
208 for i in libncurses libncursesw; do
209 f=${D}${libdir}/$i.so
210 test -h $f || continue
211 rm -f $f
212 echo '/* GNU ld script */' >$f
213 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
214 done
215
216 # Make sure that libcurses is linked so that it gets -ltinfo
217 # also, this should be addressed upstream really.
218 ln -sf libncurses.so ${D}${libdir}/libcurses.so
219
220 # create libtermcap.so linker script for backward compatibility
221 f=${D}${libdir}/libtermcap.so
222 echo '/* GNU ld script */' >$f
223 echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
224
225 if [ ! -d "${D}${base_libdir}" ]; then
226 # Setting base_libdir to libdir as is done in the -native
227 # case will skip this code
228 mkdir ${D}${base_libdir}
229 mv ${D}${libdir}/libncurses.so.* ${D}${base_libdir}
230 ! ${ENABLE_WIDEC} || \
231 mv ${D}${libdir}/libncursesw.so.* ${D}${base_libdir}
232
233 mv ${D}${libdir}/libtinfo.so.* ${D}${base_libdir}
234 rm ${D}${libdir}/libtinfo.so
235
236 # Use lnr to ensure this is a relative link despite absolute paths
237 # (as we can't know the relationship between base_libdir and libdir).
238 # At some point we can rely on coreutils 8.16 which has ln -r.
239 lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
240 fi
241 if [ -d "${D}${includedir}/ncurses" ]; then
242 for f in `find ${D}${includedir}/ncurses -name "*.h"`
243 do
244 f=`basename $f`
245 test -e ${D}${includedir}/$f && continue
246 ln -sf ncurses/$f ${D}${includedir}/$f
247 done
248 fi
249 oe_multilib_header curses.h
250}
251
252python populate_packages_prepend () {
253 libdir = d.expand("${libdir}")
254 base_libdir = d.expand("${base_libdir}")
255 pnbase = d.expand("${PN}-lib%s")
256 do_split_packages(d, libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
257 if libdir is not base_libdir:
258 do_split_packages(d, base_libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
259}
260
261
262inherit update-alternatives
263
264ALTERNATIVE_PRIORITY = "100"
265
266ALTERNATIVE_ncurses-tools_class-target = "clear reset"
267
268BBCLASSEXTEND = "native nativesdk"
269
270PACKAGES += " \
271 ${PN}-tools \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500272 ${PN}-terminfo-base \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500273 ${PN}-terminfo \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500274"
275
276FILES_${PN} = "\
277 ${bindir}/tput \
278 ${bindir}/tset \
279 ${bindir}/ncurses5-config \
280 ${bindir}/ncursesw5-config \
281 ${datadir}/tabset \
282"
283
284# This keeps only tput/tset in ncurses
285# clear/reset are in already busybox
286FILES_${PN}-tools = "\
287 ${bindir}/tic \
288 ${bindir}/toe \
289 ${bindir}/infotocap \
290 ${bindir}/captoinfo \
291 ${bindir}/infocmp \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500292 ${bindir}/clear${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
293 ${bindir}/reset${@['', '.${BPN}']['${CLASSOVERRIDE}' == 'class-target']} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 ${bindir}/tack \
295 ${bindir}/tabs \
296"
297
298# 'reset' is a symlink to 'tset' which is in the 'ncurses' package
299RDEPENDS_${PN}-tools = "${PN}"
300
301FILES_${PN}-terminfo = "\
302 ${datadir}/terminfo \
303"
304
305FILES_${PN}-terminfo-base = "\
306 ${sysconfdir}/terminfo \
307"
308
309RSUGGESTS_${PN}-libtinfo = "${PN}-terminfo"
310RRECOMMENDS_${PN}-libtinfo = "${PN}-terminfo-base"