vmd-1.9.2.ebuild 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit cuda eutils flag-o-matic multilib prefix python-single-r1 toolchain-funcs
  6. DESCRIPTION="Visual Molecular Dynamics"
  7. HOMEPAGE="http://www.ks.uiuc.edu/Research/vmd/"
  8. SRC_URI="
  9. https://dev.gentoo.org/~jlec/distfiles/${P}-gentoo-patches.tar.xz
  10. ${P}.src.tar.gz"
  11. SLOT="0"
  12. LICENSE="vmd"
  13. KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
  14. IUSE="cuda gromacs msms povray sqlite tachyon xinerama"
  15. RESTRICT="fetch"
  16. # currently, tk-8.5* with USE=truetype breaks some
  17. # tk apps such as Sequence Viewer or Timeline.
  18. CDEPEND="
  19. >=dev-lang/tk-8.6.1
  20. dev-lang/perl
  21. dev-libs/expat
  22. dev-python/numpy[${PYTHON_USEDEP}]
  23. sci-libs/netcdf:0=
  24. virtual/opengl
  25. >=x11-libs/fltk-1.1.10-r2:1
  26. x11-libs/libXft
  27. x11-libs/libXi
  28. cuda? ( >=dev-util/nvidia-cuda-toolkit-4.2.9-r1:= )
  29. gromacs? ( >=sci-chemistry/gromacs-5.0.4-r1[tng] )
  30. sqlite? ( dev-db/sqlite:3= )
  31. tachyon? ( >=media-gfx/tachyon-0.99_beta6 )
  32. xinerama? ( x11-libs/libXinerama )"
  33. DEPEND="${CDEPEND}
  34. virtual/pkgconfig
  35. dev-lang/swig"
  36. RDEPEND="${CDEPEND}
  37. sci-biology/stride
  38. sci-chemistry/surf
  39. x11-terms/xterm
  40. msms? ( sci-chemistry/msms-bin )
  41. povray? ( media-gfx/povray )
  42. "
  43. VMD_DOWNLOAD="http://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=VMD"
  44. # Binary only plugin!!
  45. QA_PREBUILT="usr/lib*/vmd/plugins/LINUX/tcl/intersurf1.1/bin/intersurf.so"
  46. QA_FLAGS_IGNORED_amd64=" usr/lib64/vmd/plugins/LINUX/tcl/volutil1.3/volutil"
  47. QA_FLAGS_IGNORED_x86=" usr/lib/vmd/plugins/LINUX/tcl/volutil1.3/volutil"
  48. pkg_nofetch() {
  49. elog "Please download ${P}.src.tar.gz from"
  50. elog "${VMD_DOWNLOAD}"
  51. elog "after agreeing to the license and get"
  52. elog "https://dev.gentoo.org/~jlec/distfiles/${P}-gentoo-patches.tar.xz"
  53. elog "Place both in ${DISTDIR}"
  54. }
  55. src_prepare() {
  56. use cuda && cuda_sanitize
  57. epatch "${FILESDIR}"/${PN}-1.9.1-cuda-device_ptr.patch
  58. cd "${WORKDIR}"/plugins || die
  59. epatch \
  60. "${WORKDIR}"/${P}-gentoo-plugins.patch \
  61. "${FILESDIR}"/${P}-format-security.patch
  62. [[ ${SILENT} == yes ]] || sed '/^.SILENT/d' -i $(find -name Makefile)
  63. sed \
  64. -e "s:CC = gcc:CC = $(tc-getCC):" \
  65. -e "s:CXX = g++:CXX = $(tc-getCXX):" \
  66. -e "s:COPTO =.*\":COPTO = -fPIC -o \":" \
  67. -e "s:LOPTO = .*\":LOPTO = ${LDFLAGS} -fPIC -o \":" \
  68. -e "s:CCFLAGS =.*\":CCFLAGS = ${CFLAGS}\":" \
  69. -e "s:CXXFLAGS =.*\":CXXFLAGS = ${CXXFLAGS}\":" \
  70. -e "s:SHLD = gcc:SHLD = $(tc-getCC) -shared:" \
  71. -e "s:SHXXLD = g++:SHXXLD = $(tc-getCXX) -shared:" \
  72. -e "s:-ltcl8.5:-ltcl:" \
  73. -i Make-arch || die "Failed to set up plugins Makefile"
  74. sed \
  75. -e '/^AR /s:=:?=:g' \
  76. -e '/^RANLIB /s:=:?=:g' \
  77. -i ../plugins/*/Makefile || die
  78. tc-export AR RANLIB
  79. sed \
  80. -e "s:\$(CXXFLAGS)::g" \
  81. -i hesstrans/Makefile || die
  82. # prepare vmd itself
  83. cd "${S}" || die
  84. epatch "${WORKDIR}"/${P}-gentoo-base.patch
  85. # PREFIX
  86. sed \
  87. -e "s:/usr/include/:${EPREFIX}/usr/include:g" \
  88. -i configure || die
  89. sed \
  90. -e "s:gentoo-bindir:${ED}/usr/bin:g" \
  91. -e "s:gentoo-libdir:${ED}/usr/$(get_libdir):g" \
  92. -e "s:gentoo-opengl-include:${EPREFIX}/usr/include/GL:g" \
  93. -e "s:gentoo-opengl-libs:${EPREFIX}/usr/$(get_libdir):g" \
  94. -e "s:gentoo-gcc:$(tc-getCC):g" \
  95. -e "s:gentoo-g++:$(tc-getCXX):g" \
  96. -e "s:gentoo-nvcc:${EPREFIX}/opt/cuda/bin/nvcc:g" \
  97. -e "s:gentoo-cflags:${CFLAGS}:g" \
  98. -e "s:gentoo-cxxflags:${CXXFLAGS}:g" \
  99. -e "s:gentoo-nvflags::g" \
  100. -e "s:gentoo-ldflags:${LDFLAGS}:g" \
  101. -e "s:gentoo-plugindir:${WORKDIR}/plugins:g" \
  102. -e "s:gentoo-fltk-include:$(fltk-config --includedir):g" \
  103. -e "s:gentoo-fltk-libs:$(dirname $(fltk-config --libs)) -Wl,-rpath,$(dirname $(fltk-config --libs)):g" \
  104. -e "s:gentoo-netcdf-include:${EPREFIX}/usr/include:g" \
  105. -e "s:gentoo-netcdf-libs:${EPREFIX}/usr/$(get_libdir):g" \
  106. -i configure || die
  107. if use cuda; then
  108. sed \
  109. -e "s:gentoo-cuda-lib:${EPREFIX}/opt/cuda/$(get_libdir):g" \
  110. -e "/NVCCFLAGS/s:=:= ${NVCCFLAGS}:g" \
  111. -i configure src/Makefile || die
  112. sed \
  113. -e '/compute_/d' \
  114. -i configure || die
  115. sed \
  116. -e 's:-gencode .*code=sm_..::' \
  117. -i src/Makefile || die
  118. fi
  119. sed \
  120. -e "s:LINUXPPC:LINUX:g" \
  121. -e "s:LINUXALPHA:LINUX:g" \
  122. -e "s:LINUXAMD64:LINUX:g" \
  123. -e "s:gentoo-stride:${EPREFIX}/usr/bin/stride:g" \
  124. -e "s:gentoo-surf:${EPREFIX}/usr/bin/surf:g" \
  125. -e "s:gentoo-tachyon:${EPREFIX}/usr/bin/tachyon:g" \
  126. -i "${S}"/bin/vmd.sh || die "failed setting up vmd wrapper script"
  127. EMAKEOPTS=(
  128. TCLINC="-I${EPREFIX}/usr/include"
  129. TCLLIB="-L${EPREFIX}/usr/$(get_libdir)"
  130. TCLLDFLAGS="-shared"
  131. NETCDFLIB="$($(tc-getPKG_CONFIG) --libs-only-L netcdf) ${EPREFIX}/usr/$(get_libdir)/libnetcdf.so"
  132. NETCDFINC="$($(tc-getPKG_CONFIG) --cflags-only-I netcdf) ${EPREFIX}/usr/include"
  133. NETCDFLDFLAGS="$($(tc-getPKG_CONFIG) --libs netcdf)"
  134. NETCDFDYNAMIC=1
  135. EXPATINC="-I${EPREFIX}/usr/include"
  136. EXPATLIB="$($(tc-getPKG_CONFIG) --libs expat)"
  137. EXPATLDFLAGS="-shared"
  138. EXPATDYNAMIC=1
  139. )
  140. if use gromacs; then
  141. EMAKEOPTS+=(
  142. TNGLIB="$($(tc-getPKG_CONFIG) --libs libgromacs)"
  143. TNGINC="-I${EPREFIX}/usr/include"
  144. TNGLDFLAGS="-shared"
  145. TNGDYNAMIC=1
  146. )
  147. fi
  148. if use sqlite; then
  149. EMAKEOPTS+=(
  150. SQLITELIB="$($(tc-getPKG_CONFIG) --libs sqlite3)"
  151. SQLITEINC="-I${EPREFIX}/usr/include"
  152. SQLITELDFLAGS="-shared"
  153. SQLITEDYNAMIC=1
  154. )
  155. fi
  156. }
  157. src_configure() {
  158. local myconf="OPENGL OPENGLPBUFFER COLVARS FLTK TK TCL PTHREADS PYTHON IMD NETCDF NUMPY NOSILENT XINPUT"
  159. rm -f configure.options && echo $myconf >> configure.options
  160. use cuda && myconf+=" CUDA"
  161. # use mpi && myconf+=" MPI"
  162. use tachyon && myconf+=" LIBTACHYON" && append-cflags -I"${EPREFIX}/usr/include/tachyon"
  163. use xinerama && myconf+=" XINERAMA"
  164. export \
  165. PYTHON_INCLUDE_DIR="$(python_get_includedir)" \
  166. PYTHON_LIBRARY_DIR="$(python_get_library_path)" \
  167. PYTHON_LIBRARY="$(python_get_LIBS)" \
  168. NUMPY_INCLUDE_DIR="$(python_get_sitedir)/numpy/core/include" \
  169. NUMPY_LIBRARY_DIR="$(python_get_sitedir)/numpy/core/include"
  170. perl ./configure LINUX \
  171. ${myconf} || die
  172. }
  173. src_compile() {
  174. # build plugins
  175. cd "${WORKDIR}"/plugins || die
  176. emake \
  177. ${EMAKEOPTS[@]} \
  178. LINUX
  179. # build vmd
  180. cd "${S}"/src || die
  181. emake
  182. }
  183. src_install() {
  184. # install plugins
  185. cd "${WORKDIR}"/plugins || die
  186. emake \
  187. PLUGINDIR="${ED}/usr/$(get_libdir)/${PN}/plugins" \
  188. distrib
  189. # install vmd
  190. cd "${S}"/src || die
  191. emake install
  192. # install docs
  193. cd "${S}" || die
  194. dodoc Announcement README doc/ig.pdf doc/ug.pdf
  195. # remove some of the things we don't want and need in
  196. # /usr/lib
  197. cd "${ED}"/usr/$(get_libdir)/vmd || die
  198. rm -fr doc README Announcement LICENSE || \
  199. die "failed to clean up /usr/lib/vmd directory"
  200. # adjust path in vmd wrapper
  201. sed \
  202. -e "s:${ED}::" -i "${ED}"/usr/bin/${PN} \
  203. -e "/^defaultvmddir/s:^.*$:defaultvmddir=\"${EPREFIX}/usr/$(get_libdir)/${PN}\":g" \
  204. || die "failed to set up vmd wrapper script"
  205. # install icon and generate desktop entry
  206. insinto /usr/share/pixmaps
  207. doins "${WORKDIR}"/vmd.png
  208. eprefixify "${WORKDIR}"/vmd.desktop
  209. sed -i '/^Path/d' "${WORKDIR}"/vmd.desktop || die
  210. domenu "${WORKDIR}"/vmd.desktop
  211. }