Drop arm-linux keyword from tree.
[gentoo.git] / sys-libs / readline / readline-7.0_p3.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils multilib toolchain-funcs flag-o-matic multilib-minimal
7
8 # Official patches
9 # See ftp://ftp.cwru.edu/pub/bash/readline-7.0-patches/
10 PLEVEL=${PV##*_p}
11 MY_PV=${PV/_p*}
12 MY_PV=${MY_PV/_/-}
13 MY_P=${PN}-${MY_PV}
14 [[ ${PV} != *_p* ]] && PLEVEL=0
15 patches() {
16         [[ ${PLEVEL} -eq 0 ]] && return 1
17         local opt=$1
18         eval set -- {1..${PLEVEL}}
19         set -- $(printf "${PN}${MY_PV/\.}-%03d " "$@")
20         if [[ ${opt} == -s ]] ; then
21                 echo "${@/#/${DISTDIR}/}"
22         else
23                 local u
24                 for u in ftp://ftp.cwru.edu/pub/bash mirror://gnu/${PN} ; do
25                         printf "${u}/${PN}-${MY_PV}-patches/%s " "$@"
26                 done
27         fi
28 }
29
30 DESCRIPTION="Another cute console display library"
31 HOMEPAGE="http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html"
32 case ${PV} in
33 *_alpha*|*_beta*|*_rc*) SRC_URI+=" ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz" ;;
34 *) SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.gz $(patches)" ;;
35 esac
36
37 LICENSE="GPL-3"
38 SLOT="0/7"  # subslot matches SONAME major
39 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
40 IUSE="static-libs utils"
41
42 RDEPEND=">=sys-libs/ncurses-5.9-r3:0=[static-libs?,${MULTILIB_USEDEP}]"
43 DEPEND="${RDEPEND}
44         virtual/pkgconfig"
45
46 S=${WORKDIR}/${MY_P}
47
48 src_unpack() {
49         unpack ${MY_P}.tar.gz
50 }
51
52 src_prepare() {
53         [[ ${PLEVEL} -gt 0 ]] && epatch $(patches -s)
54         epatch "${FILESDIR}"/${PN}-5.0-no_rpath.patch
55         epatch "${FILESDIR}"/${PN}-6.2-rlfe-tgoto.patch #385091
56         epatch "${FILESDIR}"/${PN}-7.0-headers.patch
57         epatch "${FILESDIR}"/${PN}-7.0-missing-echo-proto.patch
58
59         # Force ncurses linking. #71420
60         # Use pkg-config to get the right values. #457558
61         local ncurses_libs=$($(tc-getPKG_CONFIG) ncurses --libs)
62         sed -i \
63                 -e "/^SHLIB_LIBS=/s:=.*:='${ncurses_libs}':" \
64                 support/shobj-conf || die
65         sed -i \
66                 -e "/^[[:space:]]*LIBS=.-lncurses/s:-lncurses:${ncurses_libs}:" \
67                 examples/rlfe/configure || die
68
69         # fix building under Gentoo/FreeBSD; upstream FreeBSD deprecated
70         # objformat for years, so we don't want to rely on that.
71         sed -i -e '/objformat/s:if .*; then:if true; then:' support/shobj-conf || die
72
73         ln -s ../.. examples/rlfe/readline # for local readline headers
74 }
75
76 src_configure() {
77         # fix implicit decls with widechar funcs
78         append-cppflags -D_GNU_SOURCE
79         # https://lists.gnu.org/archive/html/bug-readline/2010-07/msg00013.html
80         append-cppflags -Dxrealloc=_rl_realloc -Dxmalloc=_rl_malloc -Dxfree=_rl_free
81
82         # Make sure configure picks a better ar than `ar`. #484866
83         export ac_cv_prog_AR=$(tc-getAR)
84
85         # Force the test since we used sed above to force it.
86         export bash_cv_termcap_lib=ncurses
87
88         # Control cross-compiling cases when we know the right answer.
89         # In cases where the C library doesn't support wide characters, readline
90         # itself won't work correctly, so forcing the answer below should be OK.
91         if tc-is-cross-compiler ; then
92                 export bash_cv_func_sigsetjmp='present'
93                 export bash_cv_func_ctype_nonascii='yes'
94                 export bash_cv_wcwidth_broken='no' #503312
95         fi
96
97         # This is for rlfe, but we need to make sure LDFLAGS doesn't change
98         # so we can re-use the config cache file between the two.
99         append-ldflags -L.
100
101         multilib-minimal_src_configure
102 }
103
104 multilib_src_configure() {
105         ECONF_SOURCE=${S} \
106         econf \
107                 --cache-file="${BUILD_DIR}"/config.cache \
108                 --docdir='$(datarootdir)'/doc/${PF} \
109                 --with-curses \
110                 $(use_enable static-libs static)
111
112         if use utils && multilib_is_native_abi && ! tc-is-cross-compiler ; then
113                 # code is full of AC_TRY_RUN()
114                 mkdir -p examples/rlfe || die
115                 cd examples/rlfe || die
116                 ECONF_SOURCE=${S}/examples/rlfe \
117                 econf --cache-file="${BUILD_DIR}"/config.cache
118         fi
119 }
120
121 multilib_src_compile() {
122         emake
123
124         if use utils && multilib_is_native_abi && ! tc-is-cross-compiler ; then
125                 # code is full of AC_TRY_RUN()
126                 cd examples/rlfe || die
127                 local l
128                 for l in readline history ; do
129                         ln -s ../../shlib/lib${l}$(get_libname)* lib${l}$(get_libname)
130                         ln -sf ../../lib${l}.a lib${l}.a
131                 done
132                 emake
133         fi
134 }
135
136 multilib_src_install() {
137         default
138
139         if multilib_is_native_abi ; then
140                 gen_usr_ldscript -a readline history #4411
141
142                 if use utils && ! tc-is-cross-compiler; then
143                         dobin examples/rlfe/rlfe
144                 fi
145         fi
146 }
147
148 multilib_src_install_all() {
149         einstalldocs
150         dodoc USAGE
151         dohtml -r doc/.
152         docinto ps
153         dodoc doc/*.ps
154 }
155 pkg_preinst() {
156         # bug #29865
157         # Reappeared in #595324 with paludis so keeping this for now...
158         preserve_old_lib /$(get_libdir)/lib{history,readline}.so.{4,5,6}
159 }
160
161 pkg_postinst() {
162         preserve_old_lib_notify /$(get_libdir)/lib{history,readline}.so.{4,5,6}
163 }