charm-6.7.1.ebuild 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. FORTRAN_STANDARD="90"
  5. PYTHON_COMPAT=( python2_7 )
  6. inherit eutils flag-o-matic fortran-2 multilib multiprocessing python-any-r1 toolchain-funcs
  7. DESCRIPTION="Message-passing parallel language and runtime system"
  8. HOMEPAGE="http://charm.cs.uiuc.edu/"
  9. SRC_URI="http://charm.cs.uiuc.edu/distrib/${P}.tar.gz"
  10. LICENSE="charm"
  11. SLOT="0"
  12. KEYWORDS="~amd64 ~x86"
  13. IUSE="charmdebug charmtracing charmproduction cmkopt doc examples mlogft mpi ampi numa smp static-libs syncft tcp"
  14. RDEPEND="mpi? ( virtual/mpi )"
  15. DEPEND="
  16. ${RDEPEND}
  17. doc? (
  18. >=app-text/poppler-0.12.3-r3[utils]
  19. dev-tex/latex2html
  20. virtual/tex-base
  21. $(python_gen_any_dep '
  22. >=dev-python/beautifulsoup-4[${PYTHON_USEDEP}]
  23. dev-python/lxml[${PYTHON_USEDEP}]
  24. ')
  25. media-libs/netpbm
  26. ${PYTHON_DEPS}
  27. )"
  28. REQUIRED_USE="
  29. cmkopt? ( !charmdebug !charmtracing )
  30. charmproduction? ( !charmdebug !charmtracing )"
  31. pkg_setup() {
  32. use doc && python-any-r1_pkg_setup
  33. }
  34. get_opts() {
  35. local CHARM_OPTS
  36. # TCP instead of default UDP for socket comunication
  37. # protocol
  38. CHARM_OPTS+="$(usex tcp ' tcp' '')"
  39. # enable direct SMP support using shared memory
  40. CHARM_OPTS+="$(usex smp ' smp' '')"
  41. CHARM_OPTS+="$(usex mlogft ' mlogft' '')"
  42. CHARM_OPTS+="$(usex syncft ' syncft' '')"
  43. # Build shared libraries by default.
  44. CHARM_OPTS+=" --build-shared"
  45. if use charmproduction; then
  46. CHARM_OPTS+=" --with-production"
  47. else
  48. if use charmdebug; then
  49. CHARM_OPTS+=" --enable-charmdebug"
  50. fi
  51. if use charmtracing; then
  52. CHARM_OPTS+=" --enable-tracing --enable-tracing-commthread"
  53. fi
  54. fi
  55. CHARM_OPTS+="$(usex numa ' --with-numa' '')"
  56. echo $CHARM_OPTS
  57. }
  58. src_prepare() {
  59. sed \
  60. -e "/CMK_CF77/s:[fg]77:$(usex mpi "mpif90" "$(tc-getF77)"):g" \
  61. -e "/CMK_CF90/s:f95:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
  62. -e "/CMK_CF90/s:\`which f90.*$::g" \
  63. -e "/CMK_CXX/s:g++:$(usex mpi "mpic++" "$(tc-getCXX)"):g" \
  64. -e "/CMK_CC/s:gcc:$(usex mpi "mpicc" "$(tc-getCC)"):g" \
  65. -e '/CMK_F90_MODINC/s:-p:-I:g' \
  66. -e "/CMK_LD/s:\"$: ${LDFLAGS} \":g" \
  67. -i src/arch/$(usex mpi "mpi" "net")*-linux*/*sh || die
  68. sed \
  69. -e "/CMK_CF90/s:gfortran:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
  70. -e "/F90DIR/s:gfortran:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
  71. -e "/f95target/s:gfortran:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
  72. -e "/f95version/s:gfortran:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
  73. -i src/arch/common/*.sh || die
  74. sed \
  75. -e "s:-o conv-cpm:${LDFLAGS} &:g" \
  76. -e "s:-o charmxi:${LDFLAGS} &:g" \
  77. -e "s:-o charmrun-silent:${LDFLAGS} &:g" \
  78. -e "s:-o charmrun-notify:${LDFLAGS} &:g" \
  79. -e "s:-o charmrun:${LDFLAGS} &:g" \
  80. -e "s:-o charmd_faceless:${LDFLAGS} &:g" \
  81. -e "s:-o charmd:${LDFLAGS} &:g" \
  82. -i \
  83. src/scripts/Makefile \
  84. src/util/charmrun-src/Makefile || die
  85. # CMK optimization
  86. use cmkopt && append-cppflags -DCMK_OPTIMIZE=1
  87. # Fix QA notice. Filed report with upstream.
  88. append-cflags -DALLOCA_H
  89. }
  90. src_compile() {
  91. local build_version="$(usex mpi "mpi" "net")-linux$(usex amd64 "-amd64" '')"
  92. local build_options="$(get_opts)"
  93. #build only accepts -j from MAKEOPTS
  94. local build_commandline="${build_version} ${build_options} -j$(makeopts_jobs)"
  95. # Build charmm++ first.
  96. einfo "running ./build charm++ ${build_commandline}"
  97. ./build charm++ ${build_commandline} || die "Failed to build charm++"
  98. if use ampi; then
  99. einfo "running ./build AMPI ${build_commandline}"
  100. ./build AMPI ${build_commandline} || die "Failed to build charm++"
  101. fi
  102. # make pdf/html docs
  103. if use doc; then
  104. emake -j1 -C doc/charm++
  105. fi
  106. }
  107. src_test() {
  108. make -C tests/charm++ test TESTOPTS="++local" || die
  109. }
  110. src_install() {
  111. # Make charmc play well with gentoo before we move it into /usr/bin. This
  112. # patch cannot be applied during src_prepare() because the charmc wrapper
  113. # is used during building.
  114. epatch "${FILESDIR}/charm-6.5.1-charmc-gentoo.patch"
  115. sed -e "s|gentoo-include|${P}|" \
  116. -e "s|gentoo-libdir|$(get_libdir)|g" \
  117. -e "s|VERSION|${P}/VERSION|" \
  118. -i ./src/scripts/charmc || die "failed patching charmc script"
  119. # In the following, some of the files are symlinks to ../tmp which we need
  120. # to dereference first (see bug 432834).
  121. local i
  122. # Install binaries.
  123. for i in bin/*; do
  124. if [[ -L ${i} ]]; then
  125. i=$(readlink -e "${i}") || die
  126. fi
  127. dobin "${i}"
  128. done
  129. # Install headers.
  130. insinto /usr/include/${P}
  131. for i in include/*; do
  132. if [[ -L ${i} ]]; then
  133. i=$(readlink -e "${i}") || die
  134. fi
  135. doins "${i}"
  136. done
  137. # Install libs incl. charm objects
  138. for i in lib*/*.{so,a}; do
  139. [[ ${i} = *.a ]] && use !static-libs && continue
  140. if [[ -L ${i} ]]; then
  141. i=$(readlink -e "${i}") || die
  142. fi
  143. [[ ${i} = *.so ]] && dolib.so "${i}" || dolib "${i}"
  144. done
  145. # Basic docs.
  146. dodoc CHANGES README
  147. # Install examples.
  148. if use examples; then
  149. find examples/ -name 'Makefile' | xargs sed \
  150. -r "s:(../)+bin/charmc:/usr/bin/charmc:" -i || \
  151. die "Failed to fix examples"
  152. find examples/ -name 'Makefile' | xargs sed \
  153. -r "s:./charmrun:./charmrun ++local:" -i || \
  154. die "Failed to fix examples"
  155. insinto /usr/share/doc/${PF}/examples
  156. doins -r examples/charm++/*
  157. docompress -x /usr/share/doc/${PF}/examples
  158. fi
  159. # Install pdf/html docs
  160. if use doc; then
  161. cd "${S}/doc/charm++"
  162. # Install pdfs.
  163. insinto /usr/share/doc/${PF}/pdf
  164. doins *.pdf
  165. # Install html.
  166. docinto html
  167. dohtml -r manual/*
  168. fi
  169. }
  170. pkg_postinst() {
  171. einfo "Please test your charm installation by copying the"
  172. einfo "content of /usr/share/doc/${PF}/examples to a"
  173. einfo "temporary location and run 'make test'."
  174. }