Merge remote-tracking branch 'github/pr/400'.
[gentoo.git] / sys-libs / ncurses / ncurses-5.9-r4.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="4"
6 inherit eutils flag-o-matic toolchain-funcs multilib-minimal
7
8 MY_PV=${PV:0:3}
9 PV_SNAP=${PV:4}
10 MY_P=${PN}-${MY_PV}
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"
14
15 LICENSE="MIT"
16 SLOT="0"
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"
19
20 DEPEND="gpm? ( sys-libs/gpm )"
21 #       berkdb? ( sys-libs/db )"
22 # Block the older ncurses that installed all files w/SLOT=5. #557472
23 RDEPEND="${DEPEND}
24         !<=sys-libs/ncurses-5.9-r4:0
25         !<x11-terms/rxvt-unicode-9.06-r3
26         abi_x86_32? (
27                 !<=app-emulation/emul-linux-x86-baselibs-20130224-r12
28                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
29         )"
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}] )"
34
35 S=${WORKDIR}/${MY_P}
36 HOSTTIC_DIR=${WORKDIR}/${P}-host
37
38 src_prepare() {
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
47 }
48
49 src_configure() {
50         unset TERMINFO #115036
51         tc-export_build_env BUILD_{CC,CPP}
52         BUILD_CPPFLAGS+=" -D_GNU_SOURCE" #214642
53
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
58                 CHOST=${CBUILD} \
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
64         fi
65         multilib-minimal_src_configure
66 }
67
68 multilib_src_configure() {
69         do_configure narrowc
70         use unicode && do_configure widec --enable-widec --includedir="${EPREFIX}"/usr/include/ncursesw
71 }
72
73 do_configure() {
74         ECONF_SOURCE=${S}
75
76         mkdir "${BUILD_DIR}"-$1
77         cd "${BUILD_DIR}"-$1 || die
78         shift
79
80         local conf=(
81                 # We need the basic terminfo files in /etc, bug #37026.  We will
82                 # add '--with-terminfo-dirs' and then populate /etc/terminfo in
83                 # src_install() ...
84                 --with-terminfo-dirs="${EPREFIX}/etc/terminfo:${EPREFIX}/usr/share/terminfo"
85
86                 # Disabled until #245417 is sorted out.
87                 #$(use_with berkdb hashed-db)
88
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.
92                 --enable-pc-files
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"
96
97                 # Now the rest of the various standard flags.
98                 --with-shared
99                 --without-hashed-db
100                 $(use_with ada)
101                 $(use_with cxx)
102                 $(use_with cxx cxx-binding)
103                 $(use_with debug)
104                 $(use_with profile)
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)
108                 --disable-termcap
109                 --enable-symlinks
110                 --with-rcs-ids
111                 --with-manpage-format=normal
112                 --enable-const
113                 --enable-colorfgbg
114                 --enable-echo
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)
120                 $(use_with trace)
121                 $(use_with tinfo termlib)
122
123                 # The chtype/mmask-t settings below are to retain ABI compat
124                 # with ncurses-5.4 so dont change em !
125                 --with-chtype=long
126                 --with-mmask-t=long
127                 --disable-ext-colors
128                 --disable-ext-mouse
129                 --without-pthread
130                 --without-reentrant
131         )
132
133         # Force bash until upstream rebuilds the configure script with a newer
134         # version of autotools. #545532
135         CONFIG_SHELL=/bin/bash econf "${conf[@]}" "$@"
136 }
137
138 src_compile() {
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
145         fi
146
147         multilib-minimal_src_compile
148 }
149
150 multilib_src_compile() {
151         make_flags=""
152         multilib_is_native_abi || make_flags="PROGS= "
153         do_compile narrowc
154         use unicode && do_compile widec
155 }
156
157 do_compile() {
158         cd "${BUILD_DIR}"-$1 || die
159
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.
165         emake -j1 sources
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.
170         rm -f misc/pc-files
171         emake ${make_flags}
172 }
173
174 multilib_src_install() {
175         # use the cross-compiled tic (if need be) #249363
176         export PATH="${HOSTTIC_DIR}-cross/progs:${PATH}"
177
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
185         fi
186
187         # Move libncurses{,w} into /lib
188         multilib_is_native_abi && gen_usr_ldscript -a \
189                 ncurses \
190                 $(usex unicode 'ncursesw' '') \
191                 $(use tinfo && usex unicode 'tinfow' '') \
192                 $(usev tinfo)
193         if ! tc-is-static-only ; then
194                 ln -sf libncurses$(get_libname) "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
195         fi
196         use static-libs || find "${ED}"/usr/ -name '*.a' -a '!' -name '*curses++*.a' -delete
197
198         # Build fails to create this ...
199         dosym ../share/terminfo /usr/$(get_libdir)/terminfo
200 }
201
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
208                 do
209                         local termfile=$(find "${ED}"/usr/share/terminfo/ -name "${x}" 2>/dev/null)
210                         local basedir=$(basename $(dirname "${termfile}"))
211
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}
217                         fi
218                 done
219 #       fi
220
221         echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" > "${T}"/50ncurses
222         doenvd "${T}"/50ncurses
223
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
227
228         cd "${S}"
229         dodoc ANNOUNCE MANIFEST NEWS README* TO-DO doc/*.doc
230         use doc && dohtml -r doc/html/
231 }