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