readline-7.0_p3.ebuild 4.5 KB

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