z3-4.4.1.ebuild 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit flag-o-matic java-pkg-2 java-pkg-simple python-r1 toolchain-funcs
  6. DESCRIPTION="An efficient theorem prover"
  7. HOMEPAGE="http://z3.codeplex.com/"
  8. SRC_URI="https://github.com/Z3Prover/z3/archive/${P}.tar.gz"
  9. SLOT="0"
  10. LICENSE="MIT"
  11. KEYWORDS="~amd64 ~x86"
  12. IUSE="doc examples gmp isabelle java python"
  13. REQUIRED_USE="${PYTHON_REQUIRED_USE}"
  14. RDEPEND="${PYTHON_DEPS}
  15. gmp? ( dev-libs/gmp:0 )"
  16. DEPEND="${RDEPEND}
  17. java? ( >=virtual/jdk-1.8 )"
  18. S=${WORKDIR}/${PN}-${P}
  19. JAVA_SRC_DIR=${S}/src/api/java
  20. SO1="0"
  21. SO2="1"
  22. SOVER="${SO1}.${SO2}"
  23. pkg_setup() {
  24. python_setup
  25. if [[ ${MERGE_TYPE} != binary ]]; then
  26. if [[ $(tc-getCXX)$ == *g++* ]] && ! tc-has-openmp; then
  27. ewarn "Please use an openmp compatible compiler"
  28. ewarn "like >gcc-4.2 with USE=openmp"
  29. die "Openmp support missing in compiler"
  30. fi
  31. fi
  32. }
  33. src_prepare() {
  34. eapply "${FILESDIR}"/${P}-gcc-6.patch
  35. default
  36. sed \
  37. -e 's:-O3::g' \
  38. -e 's:-fomit-frame-pointer::' \
  39. -e 's:-msse2::g' \
  40. -e 's:-msse::g' \
  41. -e "/LINK_EXTRA_FLAGS/s:@LDFLAGS@:-lrt $(usex gmp -lgmp ""):g" \
  42. -e 's:t@\$:t\$:g' \
  43. -i scripts/*mk* || die
  44. sed \
  45. -e "s:SLIBEXTRAFLAGS = '':SLIBEXTRAFLAGS = '-Wl,-soname,lib${PN}.so.${SOVER}':" \
  46. -i scripts/mk_util.py || die
  47. append-ldflags -fopenmp
  48. cat <<- EOF > "${S}/src/api/python/__init__.py" || die
  49. from .z3 import *
  50. from . import z3num
  51. from . import z3poly
  52. from . import z3printer
  53. from . import z3rcf
  54. from . import z3types
  55. from . import z3util
  56. # generated files
  57. from . import z3core
  58. from . import z3consts
  59. EOF
  60. }
  61. src_configure() {
  62. export Z3_INSTALL_LIB_DIR="$(get_libdir)"
  63. export Z3_INSTALL_INCLUDE_DIR="include/z3"
  64. set -- \
  65. $(usex gmp --gmp "") \
  66. $(usex java --java "")
  67. elog ./configure "$@"
  68. ./configure "$@" || die
  69. ${EPYTHON} scripts/mk_make.py || die
  70. }
  71. src_compile() {
  72. emake \
  73. --directory="build" \
  74. CXX=$(tc-getCXX) \
  75. LINK="$(tc-getCXX) ${LDFLAGS}" \
  76. LINK_FLAGS="${LDFLAGS}"
  77. use java && java-pkg-simple_src_compile
  78. }
  79. src_install() {
  80. dodir /usr/include/${PN}
  81. insinto /usr/include/${PN}
  82. doins src/api/z3*.h src/api/c++/z3*.h
  83. dolib.so build/lib${PN}.so
  84. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  85. "/usr/$(get_libdir)/lib${PN}.so.${SO1}" \
  86. || die "Could not create /usr/$(get_libdir)/lib${PN}.so.${SO1} symlink"
  87. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  88. "/usr/$(get_libdir)/lib${PN}.so.${SOVER}" \
  89. || die "Could not create libz3.so soname symlink"
  90. dobin build/z3
  91. if use examples; then
  92. insinto /usr/share/${PN}
  93. doins -r examples
  94. fi
  95. if use python; then
  96. python_moduleinto "${PN}"
  97. instpybind() {
  98. python_domodule src/api/python/*.py
  99. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  100. "$(python_get_sitedir)/${PN}/lib${PN}.so" \
  101. || die "Could not create $(python_get_sitedir)/lib${PN}.so symlink for python module"
  102. }
  103. python_foreach_impl instpybind
  104. fi
  105. use java && java-pkg-simple_src_install
  106. if use isabelle; then
  107. ISABELLE_HOME="${ROOT}usr/share/Isabelle"
  108. dodir "${ISABELLE_HOME}/contrib/${PN}-${PV}/etc"
  109. cat <<- EOF >> "${S}/settings" || die
  110. Z3_COMPONENT="\$COMPONENT"
  111. Z3_HOME="${ROOT}usr/bin"
  112. Z3_SOLVER="${ROOT}usr/bin/z3"
  113. Z3_REMOTE_SOLVER="z3"
  114. Z3_VERSION="${PV}"
  115. Z3_INSTALLED="yes"
  116. Z3_NON_COMMERCIAL="yes"
  117. EOF
  118. insinto "${ISABELLE_HOME}/contrib/${PN}-${PV}/etc"
  119. doins "${S}/settings"
  120. fi
  121. local DOCS=( "README" "RELEASE_NOTES" )
  122. use doc && einstalldocs
  123. }
  124. pkg_postinst() {
  125. if use isabelle; then
  126. if [ -f "${ROOT}etc/isabelle/components" ]; then
  127. if egrep "contrib/${PN}-[0-9.]*" "${ROOT}etc/isabelle/components"; then
  128. sed -e "/contrib\/${PN}-[0-9.]*/d" \
  129. -i "${ROOT}etc/isabelle/components"
  130. fi
  131. cat <<- EOF >> "${ROOT}etc/isabelle/components"
  132. contrib/${PN}-${PV}
  133. EOF
  134. fi
  135. fi
  136. }
  137. pkg_postrm() {
  138. if use isabelle; then
  139. if [ ! -f "${ROOT}usr/bin/Z3" ]; then
  140. if [ -f "${ROOT}etc/isabelle/components" ]; then
  141. # Note: this sed should only match the version of this ebuild
  142. # Which is what we want as we do not want to remove the line
  143. # of a new Isabelle component being installed during an upgrade.
  144. sed -e "/contrib\/${PN}-${PV}/d" \
  145. -i "${ROOT}etc/isabelle/components"
  146. fi
  147. fi
  148. fi
  149. }