z3-4.5.0.ebuild 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. doc? ( app-doc/doxygen )
  18. java? ( >=virtual/jdk-1.8 )"
  19. S=${WORKDIR}/${PN}-${P}
  20. JAVA_SRC_DIR=${S}/src/api/java
  21. SO1="0"
  22. SO2="1"
  23. SOVER="${SO1}.${SO2}"
  24. pkg_setup() {
  25. python_setup
  26. if [[ ${MERGE_TYPE} != binary ]]; then
  27. if [[ $(tc-getCXX)$ == *g++* ]] && ! tc-has-openmp; then
  28. ewarn "Please use an openmp compatible compiler"
  29. ewarn "like >gcc-4.2 with USE=openmp"
  30. die "Openmp support missing in compiler"
  31. fi
  32. fi
  33. }
  34. src_prepare() {
  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. sed -e 's:api\\html\\ml:api/html/ml:' \
  48. -e 's:python/z3.py:python/z3/z3.py:' \
  49. -i doc/mk_api_doc.py || die
  50. append-ldflags -fopenmp
  51. }
  52. src_configure() {
  53. local PYTHON_SITEDIR
  54. python_export PYTHON_SITEDIR
  55. export Z3_INSTALL_LIB_DIR="$(get_libdir)"
  56. export Z3_INSTALL_INCLUDE_DIR="include/z3"
  57. set -- \
  58. --pypkgdir="${PYTHON_SITEDIR}/${PN}" \
  59. --prefix="${ROOT}usr" \
  60. $(usex gmp --gmp "") \
  61. $(usex python --python "") \
  62. $(usex java --java "")
  63. elog ./configure "$@"
  64. # LANG=C to force external tools to output ascii text only
  65. # otherwise configure crashes as:
  66. # File "scripts/mk_make.py", line 21, in <module>
  67. # UnicodeEncodeError: 'ascii' codec can't encode characters in position 80-82: ordinal not in range(128)
  68. LANG=C ./configure "$@" || die
  69. elog ${EPYTHON} scripts/mk_make.py "$@"
  70. LANG=C ${EPYTHON} scripts/mk_make.py || die
  71. }
  72. src_compile() {
  73. emake \
  74. --directory="build" \
  75. CXX=$(tc-getCXX) \
  76. LINK="$(tc-getCXX) ${LDFLAGS}" \
  77. LINK_FLAGS="${LDFLAGS}"
  78. use java && java-pkg-simple_src_compile
  79. if use doc; then
  80. pushd doc || die
  81. ${EPYTHON} mk_api_doc.py || die
  82. popd || die
  83. fi
  84. }
  85. src_install() {
  86. emake \
  87. --directory="build" \
  88. CXX=$(tc-getCXX) \
  89. LINK="$(tc-getCXX) ${LDFLAGS}" \
  90. LINK_FLAGS="${LDFLAGS}" \
  91. install DESTDIR="${D}"
  92. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  93. "/usr/$(get_libdir)/lib${PN}.so.${SO1}" \
  94. || die "Could not create /usr/$(get_libdir)/lib${PN}.so.${SO1} symlink"
  95. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  96. "/usr/$(get_libdir)/lib${PN}.so.${SOVER}" \
  97. || die "Could not create libz3.so soname symlink"
  98. if use examples; then
  99. insinto /usr/share/${PN}
  100. doins -r examples
  101. fi
  102. if use python; then
  103. python_moduleinto "${PN}"
  104. instpybind() {
  105. python_domodule src/api/python/z3/*.py
  106. dosym "/usr/$(get_libdir)/lib${PN}.so" \
  107. "$(python_get_sitedir)/${PN}/lib${PN}.so" \
  108. || die "Could not create $(python_get_sitedir)/lib${PN}.so symlink for python module"
  109. }
  110. python_foreach_impl instpybind
  111. fi
  112. use java && java-pkg-simple_src_install
  113. if use isabelle; then
  114. ISABELLE_HOME="${ROOT}usr/share/Isabelle"
  115. dodir "${ISABELLE_HOME}/contrib/${PN}-${PV}/etc"
  116. cat <<- EOF >> "${S}/settings" || die
  117. Z3_COMPONENT="\$COMPONENT"
  118. Z3_HOME="${ROOT}usr/bin"
  119. Z3_SOLVER="${ROOT}usr/bin/z3"
  120. Z3_REMOTE_SOLVER="z3"
  121. Z3_VERSION="${PV}"
  122. Z3_INSTALLED="yes"
  123. Z3_NON_COMMERCIAL="yes"
  124. EOF
  125. insinto "${ISABELLE_HOME}/contrib/${PN}-${PV}/etc"
  126. doins "${S}/settings"
  127. fi
  128. local DOCS=( "README.md" "RELEASE_NOTES" )
  129. local HTML_DOCS=( "doc/api/html/." )
  130. use doc && einstalldocs
  131. }
  132. pkg_postinst() {
  133. if use isabelle; then
  134. if [ -f "${ROOT}etc/isabelle/components" ]; then
  135. if egrep "contrib/${PN}-[0-9.]*" "${ROOT}etc/isabelle/components"; then
  136. sed -e "/contrib\/${PN}-[0-9.]*/d" \
  137. -i "${ROOT}etc/isabelle/components"
  138. fi
  139. cat <<- EOF >> "${ROOT}etc/isabelle/components"
  140. contrib/${PN}-${PV}
  141. EOF
  142. fi
  143. fi
  144. }
  145. pkg_postrm() {
  146. if use isabelle; then
  147. if [ ! -f "${ROOT}usr/bin/Z3" ]; then
  148. if [ -f "${ROOT}etc/isabelle/components" ]; then
  149. # Note: this sed should only match the version of this ebuild
  150. # Which is what we want as we do not want to remove the line
  151. # of a new Isabelle component being installed during an upgrade.
  152. sed -e "/contrib\/${PN}-${PV}/d" \
  153. -i "${ROOT}etc/isabelle/components"
  154. fi
  155. fi
  156. fi
  157. }