1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils flag-o-matic toolchain-funcs multilib-minimal
11 DESCRIPTION="console display library"
12 HOMEPAGE="https://www.gnu.org/software/ncurses/ http://dickey.his.com/ncurses/"
13 SRC_URI="mirror://gnu/ncurses/${MY_P}.tar.gz"
17 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
18 IUSE="ada +cxx debug doc gpm minimal profile static-libs tinfo trace unicode"
20 DEPEND="gpm? ( sys-libs/gpm )"
21 # berkdb? ( sys-libs/db )"
22 # Block the older ncurses that installed all files w/SLOT=5. #557472
24 !<=sys-libs/ncurses-5.9-r4:0
25 !<x11-terms/rxvt-unicode-9.06-r3
27 !<=app-emulation/emul-linux-x86-baselibs-20130224-r12
28 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
30 # Put the MULTILIB_USEDEP on gpm in PDEPEND only to avoid circular deps.
31 # We can move it to DEPEND and drop the --with-gpm=libgpm.so.1 from the econf
32 # line below once we can assume multilib gpm is available everywhere.
33 PDEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )"
36 HOSTTIC_DIR=${WORKDIR}/${P}-host
39 [[ -n ${PV_SNAP} ]] && epatch "${WORKDIR}"/${MY_P}-${PV_SNAP}-patch.sh
40 epatch "${FILESDIR}"/${PN}-5.8-gfbsd.patch
41 epatch "${FILESDIR}"/${PN}-5.7-nongnu.patch
42 epatch "${FILESDIR}"/${PN}-5.9-rxvt-unicode-9.15.patch #192083 #383871
43 epatch "${FILESDIR}"/${PN}-5.9-fix-clang-build.patch #417763
44 epatch "${FILESDIR}"/${PN}-5.9-pkg-config.patch
45 epatch "${FILESDIR}"/${P}-no-I-usr-include.patch #522586
46 epatch "${FILESDIR}"/${P}-gcc-5.patch #545114
50 unset TERMINFO #115036
51 tc-export_build_env BUILD_{CC,CPP}
52 BUILD_CPPFLAGS+=" -D_GNU_SOURCE" #214642
54 # when cross-compiling, we need to build up our own tic
55 # because people often don't keep matching host/target
56 # ncurses versions #249363
57 if tc-is-cross-compiler && ! ROOT=/ has_version ~sys-libs/${P} ; then
59 CFLAGS=${BUILD_CFLAGS} \
60 CXXFLAGS=${BUILD_CXXFLAGS} \
61 CPPFLAGS=${BUILD_CPPFLAGS} \
62 LDFLAGS="${BUILD_LDFLAGS} -static" \
63 BUILD_DIR="${HOSTTIC_DIR}" do_configure cross --without-shared --with-normal
65 multilib-minimal_src_configure
68 multilib_src_configure() {
70 use unicode && do_configure widec --enable-widec --includedir="${EPREFIX}"/usr/include/ncursesw
76 mkdir "${BUILD_DIR}"-$1
77 cd "${BUILD_DIR}"-$1 || die
81 # We need the basic terminfo files in /etc, bug #37026. We will
82 # add '--with-terminfo-dirs' and then populate /etc/terminfo in
84 --with-terminfo-dirs="${EPREFIX}/etc/terminfo:${EPREFIX}/usr/share/terminfo"
86 # Disabled until #245417 is sorted out.
87 #$(use_with berkdb hashed-db)
89 # ncurses is dumb and doesn't install .pc files unless pkg-config
90 # is also installed. Force the tests to go our way. Note that it
91 # doesn't actually use pkg-config ... it just looks for set vars.
93 --with-pkg-config="$(tc-getPKG_CONFIG)"
94 # This path is used to control where the .pc files are installed.
95 PKG_CONFIG_LIBDIR="${EPREFIX}/usr/$(get_libdir)/pkgconfig"
97 # Now the rest of the various standard flags.
102 $(use_with cxx cxx-binding)
105 # The configure script uses ldd to parse the linked output which
106 # is flaky for cross-compiling/multilib/ldd versions/etc...
107 $(use_with gpm gpm libgpm.so.1)
111 --with-manpage-format=normal
115 $(use_enable !ada warnings)
116 $(use_with debug assertions)
117 $(use_enable !debug leaks)
118 $(use_with debug expanded)
119 $(use_with !debug macros)
121 $(use_with tinfo termlib)
123 # The chtype/mmask-t settings below are to retain ABI compat
124 # with ncurses-5.4 so dont change em !
133 # Force bash until upstream rebuilds the configure script with a newer
134 # version of autotools. #545532
135 CONFIG_SHELL=/bin/bash econf "${conf[@]}" "$@"
139 # when cross-compiling, we need to build up our own tic
140 # because people often don't keep matching host/target
141 # ncurses versions #249363
142 if tc-is-cross-compiler && ! ROOT=/ has_version ~sys-libs/${P} ; then
143 make_flags="-C progs tic"
144 BUILD_DIR="${HOSTTIC_DIR}" do_compile cross
147 multilib-minimal_src_compile
150 multilib_src_compile() {
152 multilib_is_native_abi || make_flags="PROGS= "
154 use unicode && do_compile widec
158 cd "${BUILD_DIR}"-$1 || die
160 # A little hack to fix parallel builds ... they break when
161 # generating sources so if we generate the sources first (in
162 # non-parallel), we can then build the rest of the package
163 # in parallel. This is not really a perf hit since the source
164 # generation is quite small.
166 # For some reason, sources depends on pc-files which depends on
167 # compiled libraries which depends on sources which ...
168 # Manually delete the pc-files file so the install step will
169 # create the .pc files we want.
174 multilib_src_install() {
175 # use the cross-compiled tic (if need be) #249363
176 export PATH="${HOSTTIC_DIR}-cross/progs:${PATH}"
178 # install unicode version second so that the binaries in /usr/bin
179 # support both wide and narrow
180 cd "${BUILD_DIR}"-narrowc || die
181 emake DESTDIR="${D}" install
182 if use unicode ; then
183 cd "${BUILD_DIR}"-widec || die
184 emake DESTDIR="${D}" install
187 # Move libncurses{,w} into /lib
188 multilib_is_native_abi && gen_usr_ldscript -a \
190 $(usex unicode 'ncursesw' '') \
191 $(use tinfo && usex unicode 'tinfow' '') \
193 if ! tc-is-static-only ; then
194 ln -sf libncurses$(get_libname) "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
196 use static-libs || find "${ED}"/usr/ -name '*.a' -a '!' -name '*curses++*.a' -delete
198 # Build fails to create this ...
199 dosym ../share/terminfo /usr/$(get_libdir)/terminfo
202 multilib_src_install_all() {
203 # if ! use berkdb ; then
204 # We need the basic terminfo files in /etc, bug #37026
205 einfo "Installing basic terminfo files in /etc..."
206 for x in ansi console dumb linux rxvt rxvt-unicode screen sun vt{52,100,102,200,220} \
207 xterm xterm-color xterm-xfree86
209 local termfile=$(find "${ED}"/usr/share/terminfo/ -name "${x}" 2>/dev/null)
210 local basedir=$(basename $(dirname "${termfile}"))
212 if [[ -n ${termfile} ]] ; then
213 dodir /etc/terminfo/${basedir}
214 mv ${termfile} "${ED}"/etc/terminfo/${basedir}/
215 dosym ../../../../etc/terminfo/${basedir}/${x} \
216 /usr/share/terminfo/${basedir}/${x}
221 echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" > "${T}"/50ncurses
222 doenvd "${T}"/50ncurses
224 use minimal && rm -r "${ED}"/usr/share/terminfo*
225 # Because ncurses5-config --terminfo returns the directory we keep it
226 keepdir /usr/share/terminfo #245374
229 dodoc ANNOUNCE MANIFEST NEWS README* TO-DO doc/*.doc
230 use doc && dohtml -r doc/html/