gromacs-4.6.9999.ebuild 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. TEST_PV="4.6.6"
  5. MANUAL_PV="4.6.6"
  6. CMAKE_MAKEFILE_GENERATOR="ninja"
  7. inherit bash-completion-r1 cmake-utils cuda eutils multilib readme.gentoo-r1 toolchain-funcs
  8. if [[ $PV = *9999* ]]; then
  9. EGIT_REPO_URI="git://git.gromacs.org/gromacs.git
  10. https://gerrit.gromacs.org/gromacs.git
  11. git://github.com/gromacs/gromacs.git
  12. http://repo.or.cz/r/gromacs.git"
  13. EGIT_BRANCH="release-4-6"
  14. inherit git-r3
  15. LIVE_DEPEND="doc? (
  16. app-doc/doxygen
  17. dev-texlive/texlive-latex
  18. dev-texlive/texlive-latexextra
  19. media-gfx/imagemagick
  20. sys-apps/coreutils
  21. )"
  22. KEYWORDS=""
  23. else
  24. SRC_URI="ftp://ftp.gromacs.org/pub/${PN}/${P}.tar.gz
  25. doc? ( ftp://ftp.gromacs.org/pub/manual/manual-${MANUAL_PV}.pdf -> ${PN}-manual-${MANUAL_PV}.pdf )
  26. test? ( http://gerrit.gromacs.org/download/regressiontests-${TEST_PV}.tar.gz )"
  27. LIVE_DEPEND=""
  28. KEYWORDS="~alpha ~amd64 ~arm ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~x86-macos"
  29. fi
  30. ACCE_IUSE="cpu_flags_x86_sse2 cpu_flags_x86_sse4_1 cpu_flags_x86_fma4 cpu_flags_x86_avx"
  31. DESCRIPTION="The ultimate molecular dynamics simulation package"
  32. HOMEPAGE="http://www.gromacs.org/"
  33. # see COPYING for details
  34. # http://repo.or.cz/w/gromacs.git/blob/HEAD:/COPYING
  35. # base, vmd plugins, fftpack from numpy, blas/lapck from netlib, memtestG80 library, mpi_thread lib
  36. LICENSE="LGPL-2.1 UoI-NCSA !mkl? ( !fftw? ( BSD ) !blas? ( BSD ) !lapack? ( BSD ) ) cuda? ( LGPL-3 ) threads? ( BSD )"
  37. SLOT="0/${PV}"
  38. IUSE="X blas cuda doc -double-precision +fftw gsl lapack mkl mpi +offensive openmp +single-precision test +threads zsh-completion ${ACCE_IUSE}"
  39. CDEPEND="
  40. X? (
  41. x11-libs/libX11
  42. x11-libs/libSM
  43. x11-libs/libICE
  44. )
  45. blas? ( virtual/blas )
  46. cuda? ( >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 )
  47. fftw? ( sci-libs/fftw:3.0 )
  48. gsl? ( sci-libs/gsl )
  49. lapack? ( virtual/lapack )
  50. mkl? ( sci-libs/mkl )
  51. mpi? ( virtual/mpi )"
  52. DEPEND="${CDEPEND}
  53. virtual/pkgconfig
  54. ${LIVE_DEPEND}
  55. doc? ( app-doc/doxygen )"
  56. RDEPEND="${CDEPEND}"
  57. REQUIRED_USE="
  58. || ( single-precision double-precision )
  59. cuda? ( single-precision )
  60. mkl? ( !blas !fftw !lapack )"
  61. DOCS=( AUTHORS README )
  62. HTML_DOCS=( "${ED}"/usr/share/gromacs/html/ )
  63. pkg_pretend() {
  64. [[ $(gcc-version) == "4.1" ]] && die "gcc 4.1 is not supported by gromacs"
  65. use openmp && ! tc-has-openmp && \
  66. die "Please switch to an openmp compatible compiler"
  67. }
  68. src_unpack() {
  69. if [[ ${PV} != *9999 ]]; then
  70. default
  71. else
  72. git-r3_src_unpack
  73. if use doc; then
  74. EGIT_REPO_URI="git://git.gromacs.org/manual.git" \
  75. EGIT_BRANCH="release-4-6" EGIT_COMMIT="release-4-6" \
  76. EGIT_CHECKOUT_DIR="${WORKDIR}/manual"\
  77. git-r3_src_unpack
  78. fi
  79. if use test; then
  80. EGIT_REPO_URI="git://git.gromacs.org/regressiontests.git" \
  81. EGIT_BRANCH="release-4-6" EGIT_COMMIT="release-4-6" \
  82. EGIT_CHECKOUT_DIR="${WORKDIR}/regressiontests"\
  83. git-r3_src_unpack
  84. fi
  85. fi
  86. }
  87. src_prepare() {
  88. #notes/todos
  89. # -on apple: there is framework support
  90. cmake-utils_src_prepare
  91. use cuda && cuda_src_prepare
  92. GMX_DIRS=""
  93. use single-precision && GMX_DIRS+=" float"
  94. use double-precision && GMX_DIRS+=" double"
  95. if use test; then
  96. for x in ${GMX_DIRS}; do
  97. mkdir -p "${WORKDIR}/${P}_${x}" || die
  98. cp -al "${WORKDIR}/regressiontests"* "${WORKDIR}/${P}_${x}/tests" || die
  99. done
  100. fi
  101. DOC_CONTENTS="Gromacs can use sci-chemistry/vmd to read additional file formats"
  102. }
  103. src_configure() {
  104. local mycmakeargs_pre=( ) extra fft_opts=( )
  105. #go from slowest to fastest acceleration
  106. local acce="None"
  107. use cpu_flags_x86_sse2 && acce="SSE2"
  108. use cpu_flags_x86_sse4_1 && acce="SSE4.1"
  109. use cpu_flags_x86_fma4 && acce="AVX_128_FMA"
  110. use cpu_flags_x86_avx && acce="AVX_256"
  111. #to create man pages, build tree binaries are executed (bug #398437)
  112. [[ ${CHOST} = *-darwin* ]] && \
  113. extra+=" -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF"
  114. if use fftw; then
  115. fft_opts=( -DGMX_FFT_LIBRARY=fftw3 )
  116. elif use mkl && has_version "=sci-libs/mkl-10*"; then
  117. fft_opts=( -DGMX_FFT_LIBRARY=mkl
  118. -DMKL_INCLUDE_DIR="${MKLROOT}/include"
  119. -DMKL_LIBRARIES="$(echo /opt/intel/mkl/10.0.5.025/lib/*/libmkl.so);$(echo /opt/intel/mkl/10.0.5.025/lib/*/libiomp*.so)"
  120. )
  121. elif use mkl; then
  122. local bits=$(get_libdir)
  123. fft_opts=( -DGMX_FFT_LIBRARY=mkl
  124. -DMKL_INCLUDE_DIR="$(echo /opt/intel/*/mkl/include)"
  125. -DMKL_LIBRARIES="$(echo /opt/intel/*/mkl/lib/*${bits/lib}/libmkl_rt.so)"
  126. )
  127. else
  128. fft_opts=( -DGMX_FFT_LIBRARY=fftpack )
  129. fi
  130. mycmakeargs_pre+=(
  131. "${fft_opts[@]}"
  132. -DGMX_X11=$(usex X)
  133. -DGMX_EXTERNAL_BLAS=$(usex blas)
  134. -DGMX_GSL=$(usex gsl)
  135. -DGMX_EXTERNAL_LAPACK=$(usex lapack)
  136. -DGMX_OPENMP=$(usex openmp)
  137. -DGMX_COOL_QUOTES=$(usex offensive)
  138. -DGMX_DEFAULT_SUFFIX=off
  139. -DGMX_ACCELERATION="$acce"
  140. -DGMXLIB="$(get_libdir)"
  141. -DGMX_VMD_PLUGIN_PATH="${EPREFIX}/usr/$(get_libdir)/vmd/plugins/*/molfile/"
  142. -DGMX_PREFIX_LIBMD=ON
  143. -DGMX_X86_AVX_GCC_MASKLOAD_BUG=OFF
  144. -DGMX_USE_GCC44_BUG_WORKAROUND=OFF
  145. ${extra}
  146. )
  147. for x in ${GMX_DIRS}; do
  148. einfo "Configuring for ${x} precision"
  149. local suffix=""
  150. #if we build single and double - double is suffixed
  151. use double-precision && use single-precision && \
  152. [[ ${x} = "double" ]] && suffix="_d"
  153. local p
  154. [[ ${x} = "double" ]] && p="-DGMX_DOUBLE=ON" || p="-DGMX_DOUBLE=OFF"
  155. local cuda=( "-DGMX_GPU=OFF" )
  156. [[ ${x} = "float" ]] && use cuda && \
  157. cuda=( -DGMX_GPU=ON )
  158. mycmakeargs=( ${mycmakeargs_pre[@]} ${p} -DGMX_MPI=OFF
  159. -DGMX_THREAD_MPI=$(usex threads) "${cuda[@]}" -DGMX_OPENMM=OFF
  160. "$(use test && echo -DREGRESSIONTEST_PATH="${WORKDIR}/${P}_${x}/tests")"
  161. -DGMX_BINARY_SUFFIX="${suffix}" -DGMX_LIBS_SUFFIX="${suffix}" )
  162. BUILD_DIR="${WORKDIR}/${P}_${x}" cmake-utils_src_configure
  163. use mpi || continue
  164. einfo "Configuring for ${x} precision with mpi"
  165. mycmakeargs=( ${mycmakeargs_pre[@]} ${p} -DGMX_THREAD_MPI=OFF
  166. -DGMX_MPI=ON ${cuda} -DGMX_OPENMM=OFF
  167. -DGMX_BINARY_SUFFIX="_mpi${suffix}" -DGMX_LIBS_SUFFIX="_mpi${suffix}" )
  168. BUILD_DIR="${WORKDIR}/${P}_${x}_mpi" CC="mpicc" cmake-utils_src_configure
  169. done
  170. }
  171. src_compile() {
  172. for x in ${GMX_DIRS}; do
  173. einfo "Compiling for ${x} precision"
  174. BUILD_DIR="${WORKDIR}/${P}_${x}"\
  175. cmake-utils_src_compile
  176. use mpi || continue
  177. einfo "Compiling for ${x} precision with mpi"
  178. BUILD_DIR="${WORKDIR}/${P}_${x}_mpi"\
  179. cmake-utils_src_compile mdrun
  180. done
  181. }
  182. src_test() {
  183. for x in ${GMX_DIRS}; do
  184. BUILD_DIR="${WORKDIR}/${P}_${x}"\
  185. cmake-utils_src_make check
  186. done
  187. }
  188. src_install() {
  189. for x in ${GMX_DIRS}; do
  190. BUILD_DIR="${WORKDIR}/${P}_${x}" \
  191. cmake-utils_src_install
  192. #manual can only be build after gromacs was installed once in image
  193. if use doc && [[ $PV = *9999* && ! -d ${WORKDIR}/manual_build ]]; then
  194. mycmakeargs=( -DGMXBIN="${ED}"/usr/bin -DGMXSRC="${WORKDIR}/${P}" )
  195. BUILD_DIR="${WORKDIR}"/manual_build \
  196. CMAKE_USE_DIR="${WORKDIR}/manual" cmake-utils_src_configure
  197. [[ ${CHOST} = *-darwin* ]] && \
  198. export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}${DYLD_LIBRARY_PATH:+:}${ED}/usr/$(get_libdir)"
  199. BUILD_DIR="${WORKDIR}"/manual_build cmake-utils_src_make
  200. [[ ${CHOST} = *-darwin* ]] && DYLD_LIBRARY_PATH="${ED}/usr/$(get_libdir)"
  201. newdoc "${WORKDIR}"/manual_build/gromacs.pdf "${PN}-manual-${PV}.pdf"
  202. fi
  203. use mpi || continue
  204. BUILD_DIR="${WORKDIR}/${P}_${x}_mpi" \
  205. DESTDIR="${D}" cmake-utils_src_make install-mdrun
  206. done
  207. use doc && [[ $PV != *9999* ]] && dodoc "${DISTDIR}/${PN}-manual-${MANUAL_PV}.pdf"
  208. newbashcomp "${ED}"/usr/bin/completion.bash ${PN}
  209. if use zsh-completion ; then
  210. insinto /usr/share/zsh/site-functions
  211. newins "${ED}"/usr/bin/completion.zsh _${PN}
  212. fi
  213. rm -f "${ED}"usr/bin/completion.*
  214. rm -rf "${ED}"usr/share/gromacs/html
  215. rm -f "${ED}"usr/bin/g_options*
  216. rm -f "${ED}"usr/bin/GMXRC*
  217. readme.gentoo_create_doc
  218. }
  219. pkg_postinst() {
  220. einfo
  221. einfo "Please read and cite:"
  222. einfo "Gromacs 4, J. Chem. Theory Comput. 4, 435 (2008). "
  223. einfo "http://dx.doi.org/10.1021/ct700301q"
  224. if use offensive; then
  225. einfo
  226. einfo $(g_luck)
  227. einfo "For more Gromacs cool quotes (gcq) add g_luck to your .bashrc"
  228. fi
  229. einfo
  230. readme.gentoo_print_elog
  231. }