gmp-6.0.0a.ebuild 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="4"
  4. inherit eutils libtool toolchain-funcs multilib-minimal
  5. MY_PV=${PV/_p*}
  6. MY_P=${PN}-${MY_PV}
  7. PLEVEL=${PV/*p}
  8. DESCRIPTION="Library for arithmetic on arbitrary precision integers, rational numbers, and floating-point numbers"
  9. HOMEPAGE="http://gmplib.org/"
  10. SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.xz
  11. ftp://ftp.gmplib.org/pub/${MY_P}/${MY_P}.tar.xz
  12. doc? ( http://gmplib.org/${PN}-man-${MY_PV}.pdf )"
  13. LICENSE="|| ( LGPL-3+ GPL-2+ )"
  14. SLOT="0"
  15. KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
  16. IUSE="doc cxx pgo static-libs"
  17. DEPEND="sys-devel/m4
  18. app-arch/xz-utils"
  19. RDEPEND=""
  20. S=${WORKDIR}/${MY_P%a}
  21. DOCS=( AUTHORS ChangeLog NEWS README doc/configuration doc/isa_abi_headache )
  22. HTML_DOCS=( doc )
  23. MULTILIB_WRAPPED_HEADERS=( /usr/include/gmp.h )
  24. src_prepare() {
  25. [[ -d ${FILESDIR}/${PV} ]] && EPATCH_SUFFIX="diff" EPATCH_FORCE="yes" epatch "${FILESDIR}"/${PV}
  26. # note: we cannot run autotools here as gcc depends on this package
  27. elibtoolize
  28. # GMP uses the "ABI" env var during configure as does Gentoo (econf).
  29. # So, to avoid patching the source constantly, wrap things up.
  30. mv configure configure.wrapped || die
  31. cat <<-\EOF > configure
  32. #!/bin/sh
  33. exec env ABI="${GMPABI}" "$0.wrapped" "$@"
  34. EOF
  35. # Patches to original configure might have lost the +x bit.
  36. chmod a+rx configure{,.wrapped}
  37. }
  38. multilib_src_configure() {
  39. # Because of our 32-bit userland, 1.0 is the only HPPA ABI that works
  40. # http://gmplib.org/manual/ABI-and-ISA.html#ABI-and-ISA (bug #344613)
  41. if [[ ${CHOST} == hppa2.0-* ]] ; then
  42. GMPABI="1.0"
  43. fi
  44. # ABI mappings (needs all architectures supported)
  45. case ${ABI} in
  46. 32|x86) GMPABI=32;;
  47. 64|amd64|n64) GMPABI=64;;
  48. [onx]32) GMPABI=${ABI};;
  49. esac
  50. export GMPABI
  51. tc-export CC
  52. ECONF_SOURCE="${S}" econf \
  53. --localstatedir=/var/state/gmp \
  54. --enable-shared \
  55. $(use_enable cxx) \
  56. $(use_enable static-libs static)
  57. }
  58. multilib_src_compile() {
  59. emake
  60. if use pgo ; then
  61. emake -j1 -C tune tuneup
  62. ebegin "Trying to generate tuned data"
  63. ./tune/tuneup | tee gmp.mparam.h.new
  64. if eend $(( 0 + ${PIPESTATUS[*]/#/+} )) ; then
  65. mv gmp.mparam.h.new gmp-mparam.h || die
  66. emake clean
  67. emake
  68. fi
  69. fi
  70. }
  71. multilib_src_test() {
  72. emake check
  73. }
  74. multilib_src_install() {
  75. emake DESTDIR="${D}" install
  76. # should be a standalone lib
  77. rm -f "${D}"/usr/$(get_libdir)/libgmp.la
  78. # this requires libgmp
  79. local la="${D}/usr/$(get_libdir)/libgmpxx.la"
  80. use static-libs \
  81. && sed -i 's:/[^ ]*/libgmp.la:-lgmp:' "${la}" \
  82. || rm -f "${la}"
  83. }
  84. multilib_src_install_all() {
  85. einstalldocs
  86. use doc && cp "${DISTDIR}"/gmp-man-${MY_PV}.pdf "${D}"/usr/share/doc/${PF}/
  87. }
  88. pkg_preinst() {
  89. preserve_old_lib /usr/$(get_libdir)/libgmp.so.3
  90. }
  91. pkg_postinst() {
  92. preserve_old_lib_notify /usr/$(get_libdir)/libgmp.so.3
  93. }