ncurses-6.0-r1.ebuild 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit eutils flag-o-matic toolchain-funcs multilib-minimal multiprocessing
  5. MY_PV=${PV:0:3}
  6. PV_SNAP=${PV:4}
  7. MY_P=${PN}-${MY_PV}
  8. DESCRIPTION="console display library"
  9. HOMEPAGE="https://www.gnu.org/software/ncurses/ http://dickey.his.com/ncurses/"
  10. SRC_URI="mirror://gnu/ncurses/${MY_P}.tar.gz"
  11. LICENSE="MIT"
  12. # The subslot reflects the SONAME.
  13. SLOT="0/6"
  14. KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
  15. IUSE="ada +cxx debug doc gpm minimal profile static-libs test threads tinfo trace unicode"
  16. DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )"
  17. # berkdb? ( sys-libs/db )"
  18. # Block the older ncurses that installed all files w/SLOT=5. #557472
  19. RDEPEND="${DEPEND}
  20. !<=sys-libs/ncurses-5.9-r4:5
  21. !<x11-terms/rxvt-unicode-9.06-r3
  22. !<x11-terms/st-0.6-r1
  23. !app-emulation/emul-linux-x86-baselibs"
  24. S=${WORKDIR}/${MY_P}
  25. PATCHES=(
  26. "${FILESDIR}/${PN}-6.0-gfbsd.patch"
  27. "${FILESDIR}/${PN}-5.7-nongnu.patch"
  28. "${FILESDIR}/${PN}-6.0-rxvt-unicode-9.15.patch" #192083 #383871
  29. "${FILESDIR}/${PN}-6.0-pkg-config.patch"
  30. "${FILESDIR}/${PN}-5.9-gcc-5.patch" #545114
  31. "${FILESDIR}/${PN}-6.0-ticlib.patch" #557360
  32. "${FILESDIR}/${PN}-6.0-cppflags-cross.patch" #601426
  33. )
  34. src_prepare() {
  35. [[ -n ${PV_SNAP} ]] && epatch "${WORKDIR}"/${MY_P}-${PV_SNAP}-patch.sh
  36. epatch "${PATCHES[@]}"
  37. }
  38. src_configure() {
  39. unset TERMINFO #115036
  40. tc-export_build_env BUILD_{CC,CPP}
  41. BUILD_CPPFLAGS+=" -D_GNU_SOURCE" #214642
  42. # Build the various variants of ncurses -- narrow, wide, and threaded. #510440
  43. # Order matters here -- we want unicode/thread versions to come last so that the
  44. # binaries in /usr/bin support both wide and narrow.
  45. # The naming is also important as we use these directly with filenames and when
  46. # checking configure flags.
  47. NCURSES_TARGETS=(
  48. ncurses
  49. $(usex unicode 'ncursesw' '')
  50. $(usex threads 'ncursest' '')
  51. $(use unicode && usex threads 'ncursestw' '')
  52. )
  53. multijob_init
  54. # When installing ncurses, we have to use a compatible version of tic.
  55. # This comes up when cross-compiling, doing multilib builds, upgrading,
  56. # or installing for the first time. Build a local copy of tic whenever
  57. # the host version isn't available. #249363 #557598
  58. if ! ROOT=/ has_version "~sys-libs/${P}:0" ; then
  59. local lbuildflags="-static"
  60. # some toolchains don't quite support static linking
  61. local dbuildflags="-Wl,-rpath,${WORKDIR}/lib"
  62. case ${CHOST} in
  63. *-darwin*) dbuildflags= ;;
  64. *-aix*) dbuildflags= ;;
  65. esac
  66. echo "int main() {}" | \
  67. $(tc-getCC) -o x -x c - ${lbuildflags} -pipe >& /dev/null \
  68. || lbuildflags="${dbuildflags}"
  69. # We can't re-use the multilib BUILD_DIR because we run outside of it.
  70. BUILD_DIR="${WORKDIR}" \
  71. CHOST=${CBUILD} \
  72. CFLAGS=${BUILD_CFLAGS} \
  73. CXXFLAGS=${BUILD_CXXFLAGS} \
  74. CPPFLAGS=${BUILD_CPPFLAGS} \
  75. LDFLAGS="${BUILD_LDFLAGS} ${lbuildflags}" \
  76. multijob_child_init do_configure cross --without-shared --with-normal
  77. fi
  78. multilib-minimal_src_configure
  79. multijob_finish
  80. }
  81. multilib_src_configure() {
  82. local t
  83. for t in "${NCURSES_TARGETS[@]}" ; do
  84. multijob_child_init do_configure "${t}"
  85. done
  86. }
  87. do_configure() {
  88. local target=$1
  89. shift
  90. mkdir "${BUILD_DIR}/${target}"
  91. cd "${BUILD_DIR}/${target}" || die
  92. local conf=(
  93. # We need the basic terminfo files in /etc, bug #37026. We will
  94. # add '--with-terminfo-dirs' and then populate /etc/terminfo in
  95. # src_install() ...
  96. --with-terminfo-dirs="${EPREFIX}/etc/terminfo:${EPREFIX}/usr/share/terminfo"
  97. # Disabled until #245417 is sorted out.
  98. #$(use_with berkdb hashed-db)
  99. # ncurses is dumb and doesn't install .pc files unless pkg-config
  100. # is also installed. Force the tests to go our way. Note that it
  101. # doesn't actually use pkg-config ... it just looks for set vars.
  102. --enable-pc-files
  103. --with-pkg-config="$(tc-getPKG_CONFIG)"
  104. # This path is used to control where the .pc files are installed.
  105. --with-pkg-config-libdir="${EPREFIX}/usr/$(get_libdir)/pkgconfig"
  106. # Now the rest of the various standard flags.
  107. --with-shared
  108. --without-hashed-db
  109. $(use_with ada)
  110. $(use_with cxx)
  111. $(use_with cxx cxx-binding)
  112. --with-cxx-shared
  113. $(use_with debug)
  114. $(use_with profile)
  115. # The configure script uses ldd to parse the linked output which
  116. # is flaky for cross-compiling/multilib/ldd versions/etc...
  117. $(use_with gpm gpm libgpm.so.1)
  118. --disable-termcap
  119. --enable-symlinks
  120. --with-rcs-ids
  121. --with-manpage-format=normal
  122. --enable-const
  123. --enable-colorfgbg
  124. --enable-hard-tabs
  125. --enable-echo
  126. $(use_enable !ada warnings)
  127. $(use_with debug assertions)
  128. $(use_enable !debug leaks)
  129. $(use_with debug expanded)
  130. $(use_with !debug macros)
  131. $(multilib_native_with progs)
  132. $(use_with test tests)
  133. $(use_with trace)
  134. $(use_with tinfo termlib)
  135. )
  136. if [[ ${target} == ncurses*w ]] ; then
  137. conf+=( --enable-widec )
  138. else
  139. conf+=( --disable-widec )
  140. fi
  141. if [[ ${target} == ncursest* ]] ; then
  142. conf+=( --with-{pthread,reentrant} )
  143. else
  144. conf+=( --without-{pthread,reentrant} )
  145. fi
  146. # Make sure each variant goes in a unique location.
  147. if [[ ${target} == "ncurses" ]] ; then
  148. # "ncurses" variant goes into "${EPREFIX}"/usr/include
  149. # It is needed on Prefix because the configure script appends
  150. # "ncurses" to "${prefix}/include" if "${prefix}" is not /usr.
  151. conf+=( --enable-overwrite )
  152. else
  153. conf+=( --includedir="${EPREFIX}"/usr/include/${target} )
  154. fi
  155. # See comments in src_configure.
  156. if [[ ${target} != "cross" ]] ; then
  157. local cross_path="${WORKDIR}/cross"
  158. [[ -d ${cross_path} ]] && export TIC_PATH="${cross_path}/progs/tic"
  159. fi
  160. # Force bash until upstream rebuilds the configure script with a newer
  161. # version of autotools. #545532
  162. CONFIG_SHELL=${EPREFIX}/bin/bash \
  163. ECONF_SOURCE=${S} \
  164. econf "${conf[@]}" "$@"
  165. }
  166. src_compile() {
  167. # See comments in src_configure.
  168. if ! ROOT=/ has_version "~sys-libs/${P}:0" ; then
  169. BUILD_DIR="${WORKDIR}" \
  170. do_compile cross -C progs tic
  171. fi
  172. multilib-minimal_src_compile
  173. }
  174. multilib_src_compile() {
  175. local t
  176. for t in "${NCURSES_TARGETS[@]}" ; do
  177. do_compile "${t}"
  178. done
  179. }
  180. do_compile() {
  181. local target=$1
  182. shift
  183. cd "${BUILD_DIR}/${target}" || die
  184. # A little hack to fix parallel builds ... they break when
  185. # generating sources so if we generate the sources first (in
  186. # non-parallel), we can then build the rest of the package
  187. # in parallel. This is not really a perf hit since the source
  188. # generation is quite small.
  189. emake -j1 sources
  190. # For some reason, sources depends on pc-files which depends on
  191. # compiled libraries which depends on sources which ...
  192. # Manually delete the pc-files file so the install step will
  193. # create the .pc files we want.
  194. rm -f misc/pc-files
  195. emake "$@"
  196. }
  197. multilib_src_install() {
  198. local target
  199. for target in "${NCURSES_TARGETS[@]}" ; do
  200. emake -C "${BUILD_DIR}/${target}" DESTDIR="${D}" install
  201. done
  202. # Move main libraries into /.
  203. if multilib_is_native_abi ; then
  204. gen_usr_ldscript -a \
  205. "${NCURSES_TARGETS[@]}" \
  206. $(use tinfo && usex unicode 'tinfow' '') \
  207. $(usev tinfo)
  208. fi
  209. if ! tc-is-static-only ; then
  210. # Provide a link for -lcurses.
  211. ln -sf libncurses$(get_libname) "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
  212. fi
  213. use static-libs || find "${ED}"/usr/ -name '*.a' -delete
  214. # Build fails to create this ...
  215. dosym ../share/terminfo /usr/$(get_libdir)/terminfo
  216. }
  217. multilib_src_install_all() {
  218. # if ! use berkdb ; then
  219. # We need the basic terminfo files in /etc, bug #37026
  220. einfo "Installing basic terminfo files in /etc..."
  221. for x in ansi console dumb linux rxvt rxvt-unicode screen sun vt{52,100,102,200,220} \
  222. xterm xterm-color xterm-xfree86
  223. do
  224. local termfile=$(find "${ED}"/usr/share/terminfo/ -name "${x}" 2>/dev/null)
  225. local basedir=$(basename $(dirname "${termfile}"))
  226. if [[ -n ${termfile} ]] ; then
  227. dodir /etc/terminfo/${basedir}
  228. mv ${termfile} "${ED}"/etc/terminfo/${basedir}/
  229. dosym ../../../../etc/terminfo/${basedir}/${x} \
  230. /usr/share/terminfo/${basedir}/${x}
  231. fi
  232. done
  233. # fi
  234. echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" > "${T}"/50ncurses
  235. doenvd "${T}"/50ncurses
  236. use minimal && rm -r "${ED}"/usr/share/terminfo*
  237. # Because ncurses5-config --terminfo returns the directory we keep it
  238. keepdir /usr/share/terminfo #245374
  239. cd "${S}"
  240. dodoc ANNOUNCE MANIFEST NEWS README* TO-DO doc/*.doc
  241. use doc && dohtml -r doc/html/
  242. }
  243. pkg_preinst() {
  244. preserve_old_lib /$(get_libdir)/libncurses.so.5
  245. use unicode && preserve_old_lib /$(get_libdir)/libncursesw.so.5
  246. }
  247. pkg_postinst() {
  248. preserve_old_lib_notify /$(get_libdir)/libncurses.so.5
  249. use unicode && preserve_old_lib_notify /$(get_libdir)/libncursesw.so.5
  250. }