1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit flag-o-matic multilib-minimal toolchain-funcs usr-ldscript
9 # See ftp://ftp.cwru.edu/pub/bash/readline-7.0-patches/
14 [[ ${PV} != *_p* ]] && PLEVEL=0
16 [[ ${PLEVEL} -eq 0 ]] && return 1
18 eval set -- {1..${PLEVEL}}
19 set -- $(printf "${PN}${MY_PV/\.}-%03d " "$@")
20 if [[ ${opt} == -s ]] ; then
21 echo "${@/#/${DISTDIR}/}"
24 for u in ftp://ftp.cwru.edu/pub/bash mirror://gnu/${PN} ; do
25 printf "${u}/${PN}-${MY_PV}-patches/%s " "$@"
30 DESCRIPTION="Another cute console display library"
31 HOMEPAGE="https://tiswww.case.edu/php/chet/readline/rltop.html"
34 *_alpha*|*_beta*|*_rc*)
35 SRC_URI+=" ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"
38 SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.gz $(patches)"
43 SLOT="0/7" # subslot matches SONAME major
44 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~amd64-linux ~x86-linux"
45 IUSE="static-libs +unicode utils"
47 RDEPEND=">=sys-libs/ncurses-5.9-r3:0=[static-libs?,unicode?,${MULTILIB_USEDEP}]"
54 "${FILESDIR}"/${PN}-5.0-no_rpath.patch
55 "${FILESDIR}"/${PN}-6.2-rlfe-tgoto.patch #385091
56 "${FILESDIR}"/${PN}-7.0-headers.patch
57 "${FILESDIR}"/${PN}-7.0-missing-echo-proto.patch
58 "${FILESDIR}"/${PN}-7.0-mingw.patch
61 # Needed because we don't want the patches being unpacked
62 # (which emits annoying and useless error messages)
68 [[ ${PLEVEL} -gt 0 ]] && eapply -p0 $(patches -s)
71 # Force ncurses linking. #71420
72 # Use pkg-config to get the right values. #457558
73 local ncurses_libs=$($(tc-getPKG_CONFIG) ncurses$(usex unicode w '') --libs)
75 -e "/^SHLIB_LIBS=/s:=.*:='${ncurses_libs}':" \
76 support/shobj-conf || die
78 -e "/^[[:space:]]*LIBS=.-lncurses/s:-lncurses:${ncurses_libs}:" \
79 examples/rlfe/configure || die
81 # fix building under Gentoo/FreeBSD; upstream FreeBSD deprecated
82 # objformat for years, so we don't want to rely on that.
83 sed -i -e '/objformat/s:if .*; then:if true; then:' support/shobj-conf || die
85 ln -s ../.. examples/rlfe/readline || die # for local readline headers
89 # fix implicit decls with widechar funcs
90 append-cppflags -D_GNU_SOURCE
91 # https://lists.gnu.org/archive/html/bug-readline/2010-07/msg00013.html
92 append-cppflags -Dxrealloc=_rl_realloc -Dxmalloc=_rl_malloc -Dxfree=_rl_free
94 # Make sure configure picks a better ar than `ar`. #484866
95 export ac_cv_prog_AR=$(tc-getAR)
97 # Force the test since we used sed above to force it.
98 export bash_cv_termcap_lib=ncurses
100 # Control cross-compiling cases when we know the right answer.
101 # In cases where the C library doesn't support wide characters, readline
102 # itself won't work correctly, so forcing the answer below should be OK.
103 if tc-is-cross-compiler ; then
104 use kernel_Winnt || export bash_cv_func_sigsetjmp='present'
105 export bash_cv_func_ctype_nonascii='yes'
106 export bash_cv_wcwidth_broken='no' #503312
109 # This is for rlfe, but we need to make sure LDFLAGS doesn't change
110 # so we can re-use the config cache file between the two.
113 multilib-minimal_src_configure
116 multilib_src_configure() {
118 --cache-file="${BUILD_DIR}"/config.cache
120 $(use_enable static-libs static)
122 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
124 if use utils && multilib_is_native_abi && ! tc-is-cross-compiler ; then
125 # code is full of AC_TRY_RUN()
126 mkdir -p examples/rlfe || die
127 cd examples/rlfe || die
128 ECONF_SOURCE="${S}"/examples/rlfe \
129 econf --cache-file="${BUILD_DIR}"/config.cache
133 multilib_src_compile() {
136 if use utils && multilib_is_native_abi && ! tc-is-cross-compiler ; then
137 # code is full of AC_TRY_RUN()
138 cd examples/rlfe || die
140 for l in readline history ; do
141 ln -s ../../shlib/lib${l}$(get_libname)* lib${l}$(get_libname) || die
142 ln -s ../../lib${l}.a lib${l}.a || die
148 multilib_src_install() {
151 if multilib_is_native_abi ; then
152 gen_usr_ldscript -a readline history #4411
154 if use utils && ! tc-is-cross-compiler; then
155 dobin examples/rlfe/rlfe
160 multilib_src_install_all() {
161 HTML_DOCS="doc/history.html doc/readline.html doc/rluserman.html" einstalldocs
168 # Reappeared in #595324 with paludis so keeping this for now...
169 preserve_old_lib /$(get_libdir)/lib{history,readline}.so.{4,5,6}
173 preserve_old_lib_notify /$(get_libdir)/lib{history,readline}.so.{4,5,6}