5db856c1e9582fab0967d9d74ba7958046bab1ab
[openembedded.git] / recipes / ncurses / ncurses_5.9.bb
1 DESCRIPTION = "Ncurses library"
2 HOMEPAGE = "http://www.gnu.org/software/ncurses/ncurses.html"
3 LICENSE = "MIT"
4 SECTION = "libs"
5 PR = "r1"
6
7 DEPENDS = "ncurses-native unifdef-native"
8 DEPENDS_virtclass-native = "unifdef-native"
9
10 inherit autotools binconfig test
11
12 SRC_URI = "${GNU_MIRROR}/ncurses/ncurses-${PV}.tar.gz \
13         file://tic-hang.patch;patch=1 \
14         file://config.cache \
15 "
16
17 SRC_URI[md5sum] = "8cb9c412e5f2d96bc6f459aa8c6282a1"
18 SRC_URI[sha256sum] = "9046298fb440324c9d4135ecea7879ffed8546dd1b58e59430ea07a4633f563b"
19
20 PARALLEL_MAKE = ""
21 EXTRA_AUTORECONF = "-I m4"
22 CONFIG_SITE =+ "${WORKDIR}/config.cache"
23
24 # Whether to enable separate widec libraries; must be 'true' or 'false'
25 #
26 # TODO: remove this variable when widec is supported in every setup?
27 ENABLE_WIDEC = "true"
28
29 # _GNU_SOURCE is required for widec stuff and is detected automatically
30 # for target objects.  But it must be set manually for native and sdk
31 # builds.
32 BUILD_CPPFLAGS += "-D_GNU_SOURCE"
33
34 # Override the function from the autotools class; ncurses requires a
35 # patched autoconf213 to generate the configure script. This autoconf
36 # is not available so that the shipped script will be used.
37 do_configure() {
38         # check does not work with cross-compiling and is generally
39         # broken because it requires stdin to be pollable (which is
40         # not the case for /dev/null redirections)
41         export cf_cv_working_poll=yes
42
43         for i in \
44         'narrowc' \
45         'widec   --enable-widec --without-progs'; do
46                 set -- $i
47                 mkdir -p $1
48                 cd $1
49                 shift
50
51                 oe_runconf \
52                         --disable-static \
53                         --without-debug \
54                         --without-ada \
55                         --without-gpm \
56                         --enable-hard-tabs \
57                         --enable-xmc-glitch \
58                         --enable-colorfgbg \
59                         --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap' \
60                         --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo' \
61                         --with-shared \
62                         --disable-big-core \
63                         --program-prefix= \
64                         --with-ticlib \
65                         --with-termlib=tinfo \
66                         --enable-sigwinch \
67                         --enable-pc-files \
68                         --disable-rpath-hack \
69                         --with-build-cc="${BUILD_CC}" \
70                         --with-build-cpp="${BUILD_CPP}" \
71                         --with-build-ld="${BUILD_LD}" \
72                         --with-build-cflags='${BUILD_CFLAGS}' \
73                         --with-build-cppflags='${BUILD_CPPFLAGS}' \
74                         --with-build-ldflags='${BUILD_LDFLAGS}' \
75                         "$@"
76                 cd ..
77         done
78 }
79
80 do_compile() {
81         oe_runmake -C narrowc libs
82         oe_runmake -C narrowc/progs
83
84         ! ${ENABLE_WIDEC} || \
85             oe_runmake -C widec libs
86 }
87
88 # set of expected differences between narrowc and widec header
89 #
90 # TODO: the NCURSES_CH_T difference can cause real problems :(
91 _unifdef_cleanup = " \
92   -e '\!/\* \$Id: curses.wide,v!,\!/\* \$Id: curses.tail,v!d' \
93   -e '/^#define NCURSES_CH_T /d' \
94   -e '/^#include <wchar.h>/d' \
95   -e '\!^/\* .* \*/!d' \
96 "
97
98 do_test[dirs] = "${S}"
99 do_test() {
100         ${ENABLE_WIDEC} || return 0
101
102         # make sure that the narrow and widec header are compatible
103         # and differ only in minor details.
104         unifdef -k narrowc/include/curses.h | \
105             sed ${_unifdef_cleanup} > curses-narrowc.h
106         unifdef -k widec/include/curses.h | \
107             sed ${_unifdef_cleanup} > curses-widec.h
108
109         diff curses-narrowc.h curses-widec.h
110 }
111
112 _install_opts = "\
113   DESTDIR='${D}' \
114   PKG_CONFIG_LIBDIR='${libdir}/pkgconfig' \
115   install.libs install.includes install.man \
116 "
117
118 do_install() {
119         # Order of installation is important; widec installs a 'curses.h'
120         # header with more definitions and must be installed last hence.
121         # Compatibility of these headers will be checked in 'do_test()'.
122         oe_runmake -C narrowc ${_install_opts} \
123                 install.data install.progs
124
125         ! ${ENABLE_WIDEC} || \
126             oe_runmake -C widec ${_install_opts}
127
128
129         cd narrowc
130
131         # include some basic terminfo files
132         # stolen ;) from gentoo and modified a bit
133         for x in ansi console dumb linux rxvt screen screen-256color sun vt52 vt100 vt102 vt200 vt220 xterm-color xterm-xfree86 xterm-256color
134         do
135                 local termfile="$(find "${D}${datadir}/terminfo/" -name "${x}" 2>/dev/null)"
136                 local basedir="$(basename $(dirname "${termfile}"))"
137
138                 if [ -n "${termfile}" ]
139                 then
140                         install -d ${D}${sysconfdir}/terminfo/${basedir}
141                         mv ${termfile} ${D}${sysconfdir}/terminfo/${basedir}/
142                         ln -s /etc/terminfo/${basedir}/${x} \
143                                 ${D}${datadir}/terminfo/${basedir}/${x}
144                 fi
145         done
146         # i think we can use xterm-color as default xterm
147         #if [ -e ${D}${sysconfdir}/terminfo/x/xterm-color ]
148         #then
149         #        ln -sf xterm-color ${D}${sysconfdir}/terminfo/x/xterm
150         #fi
151
152         if [ "${PN}" = "ncurses" ]; then
153                 mv ${D}${bindir}/clear ${D}${bindir}/clear.${PN}
154                 mv ${D}${bindir}/reset ${D}${bindir}/reset.${PN}
155         fi
156
157
158         # create linker scripts for libcurses.so and libncurses to
159         # link against -ltinfo when needed. Some builds might break
160         # else when '-Wl,--no-copy-dt-needed-entries' has been set in
161         # linker flags.
162         for i in libncurses libncursesw; do
163                 f=${D}${libdir}/$i.so
164                 test -h $f || continue
165                 rm -f $f
166                 echo '/* GNU ld script */'  >$f
167                 echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f
168         done
169
170         # create libtermcap.so linker script for backward compatibility
171         f=${D}${libdir}/libtermcap.so
172         echo '/* GNU ld script */' >$f
173         echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f
174 }
175
176 #python populate_packages_prepend () {
177 #        libdir = bb.data.expand("${libdir}", d)
178 #        pnbase = bb.data.expand("${PN}-lib%s", d)
179 #        do_split_packages(d, libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True)
180 #}
181
182
183 pkg_postinst_ncurses-tools () {
184         if [ "${PN}" = "ncurses" ]; then
185                 update-alternatives --install ${bindir}/clear clear clear.${PN} 100
186                 update-alternatives --install ${bindir}/reset reset reset.${PN} 100
187         fi
188 }
189
190 pkg_prerm_ncurses-tools () {
191         if [ "${PN}" = "ncurses" ]; then
192                 update-alternatives --remove clear clear.${PN}
193                 update-alternatives --remove reset reset.${PN}
194         fi
195 }
196
197 BBCLASSEXTEND = "native sdk"
198
199 PACKAGES += " \
200   ${PN}-tools \
201   ${PN}-terminfo \
202 #  ${PN}-terminfo-base \
203 "
204
205 FILES_${PN} = "\
206   ${bindir}/tput \
207   ${bindir}/tset \
208   ${datadir}/tabset \
209 # \
210   ${libdir}/lib*.so.* \
211   ${datadir}/tabset \
212   ${sysconfdir}/terminfo \
213 "
214
215 # This keeps only tput/tset in ncurses
216 # clear/reset are in already busybox
217 FILES_${PN}-tools = "\
218   ${bindir}/tic \
219   ${bindir}/toe \
220   ${bindir}/infotocap \
221   ${bindir}/captoinfo \
222   ${bindir}/infocmp \
223   ${bindir}/clear.${PN} \
224   ${bindir}/reset.${PN} \
225   ${bindir}/tack \
226   ${bindir}/tabs \
227 "
228 # 'reset' is a symlink to 'tset' which is in the 'ncurses' package
229 RDEPENDS_${PN}-tools = "${PN}"
230
231 FILES_${PN}-terminfo = "\
232   ${datadir}/terminfo \
233 "
234
235 #FILES_${PN}-terminfo-base = "\
236 #  ${sysconfdir}/terminfo \
237 #"
238
239 RSUGGESTS_${PN}-libtinfo = "${PN}-terminfo"
240 #RRECOMMENDS_${PN}-libtinfo = "${PN}-terminfo-base"