1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 CMAKE_MAKEFILE_GENERATOR="ninja"
8 PYTHON_COMPAT=( python3_{6,7} )
10 DISTUTILS_SINGLE_IMPL=1
12 inherit bash-completion-r1 cmake-utils cuda distutils-r1 eutils multilib readme.gentoo-r1 toolchain-funcs xdg-utils
14 if [[ $PV = *9999* ]]; then
15 EGIT_REPO_URI="git://git.gromacs.org/gromacs.git
16 https://gerrit.gromacs.org/gromacs.git
17 https://github.com/gromacs/gromacs.git
18 https://repo.or.cz/r/gromacs.git"
19 [[ $PV = 9999 ]] && EGIT_BRANCH="master" || EGIT_BRANCH="release-${PV:0:4}"
22 SRC_URI="ftp://ftp.gromacs.org/pub/${PN}/${PN}-${PV/_/-}.tar.gz
23 test? ( http://gerrit.gromacs.org/download/regressiontests-${PV/_/-}.tar.gz )"
24 KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
27 ACCE_IUSE="cpu_flags_x86_sse2 cpu_flags_x86_sse4_1 cpu_flags_x86_fma4 cpu_flags_x86_avx cpu_flags_x86_avx2"
29 DESCRIPTION="The ultimate molecular dynamics simulation package"
30 HOMEPAGE="http://www.gromacs.org/"
32 # see COPYING for details
33 # https://repo.or.cz/w/gromacs.git/blob/HEAD:/COPYING
34 # base, vmd plugins, fftpack from numpy, blas/lapck from netlib, memtestG80 library, mpi_thread lib
35 LICENSE="LGPL-2.1 UoI-NCSA !mkl? ( !fftw? ( BSD ) !blas? ( BSD ) !lapack? ( BSD ) ) cuda? ( LGPL-3 ) threads? ( BSD )"
37 IUSE="X blas cuda +doc -double-precision +fftw +gmxapi +gmxapi-legacy +hwloc lapack +lmfit mkl mpi +offensive opencl openmp +python +single-precision test +threads +tng ${ACCE_IUSE}"
45 blas? ( virtual/blas )
46 cuda? ( >=dev-util/nvidia-cuda-toolkit-6.5.14 )
47 opencl? ( virtual/opencl )
48 fftw? ( sci-libs/fftw:3.0 )
49 hwloc? ( sys-apps/hwloc )
50 lapack? ( virtual/lapack )
51 lmfit? ( sci-libs/lmfit )
61 dev-python/sphinx[${PYTHON_USEDEP}]
64 dev-texlive/texlive-latex
65 dev-texlive/texlive-latexextra
71 || ( single-precision double-precision )
72 cuda? ( single-precision )
74 mkl? ( !blas !fftw !lapack )
75 ${PYTHON_REQUIRED_USE}"
77 DOCS=( AUTHORS README )
79 RESTRICT="!test? ( test )"
81 if [[ ${PV} != *9999 ]]; then
82 S="${WORKDIR}/${PN}-${PV/_/-}"
85 PATCHES=( "${FILESDIR}/${PN}-2020_beta1-pytest.patch" )
88 [[ $(gcc-version) == "4.1" ]] && die "gcc 4.1 is not supported by gromacs"
89 use openmp && ! tc-has-openmp && \
90 die "Please switch to an openmp compatible compiler"
94 python-single-r1_pkg_setup
98 if [[ ${PV} != *9999 ]]; then
103 EGIT_REPO_URI="git://git.gromacs.org/regressiontests.git" \
104 EGIT_BRANCH="${EGIT_BRANCH}" \
105 EGIT_CHECKOUT_DIR="${WORKDIR}/regressiontests"\
113 # -on apple: there is framework support
115 xdg_environment_reset #591952
117 cmake-utils_src_prepare
119 use cuda && cuda_src_prepare
122 use single-precision && GMX_DIRS+=" float"
123 use double-precision && GMX_DIRS+=" double"
126 for x in ${GMX_DIRS}; do
127 mkdir -p "${WORKDIR}/${P}_${x}" || die
128 cp -al "${WORKDIR}/regressiontests"* "${WORKDIR}/${P}_${x}/tests" || die
132 DOC_CONTENTS="Gromacs can use sci-chemistry/vmd to read additional file formats"
134 # try to create policy for imagemagik
135 mkdir -p ${HOME}/.config/ImageMagick
136 cat >> ${HOME}/.config/ImageMagick/policy.xml <<- EOF
137 <?xml version="1.0" encoding="UTF-8"?>
138 <!DOCTYPE policymap [
139 <!ELEMENT policymap (policy)+>
140 !ATTLIST policymap xmlns CDATA #FIXED ''>
141 <!ELEMENT policy EMPTY>
142 <!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
143 name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
144 stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
147 <policy domain="coder" rights="read | write" pattern="PS" />
148 <policy domain="coder" rights="read | write" pattern="PS2" />
149 <policy domain="coder" rights="read | write" pattern="PS3" />
150 <policy domain="coder" rights="read | write" pattern="EPS" />
151 <policy domain="coder" rights="read | write" pattern="PDF" />
152 <policy domain="coder" rights="read | write" pattern="XPS" />
158 local mycmakeargs_pre=( ) extra fft_opts=( )
160 #go from slowest to fastest acceleration
162 use cpu_flags_x86_sse2 && acce="SSE2"
163 use cpu_flags_x86_sse4_1 && acce="SSE4.1"
164 use cpu_flags_x86_fma4 && acce="AVX_128_FMA"
165 use cpu_flags_x86_avx && acce="AVX_256"
166 use cpu_flags_x86_avx2 && acce="AVX2_256"
168 #to create man pages, build tree binaries are executed (bug #398437)
169 [[ ${CHOST} = *-darwin* ]] && \
170 extra+=" -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF"
173 fft_opts=( -DGMX_FFT_LIBRARY=fftw3 )
174 elif use mkl && has_version "=sci-libs/mkl-10*"; then
175 fft_opts=( -DGMX_FFT_LIBRARY=mkl
176 -DMKL_INCLUDE_DIR="${MKLROOT}/include"
177 -DMKL_LIBRARIES="$(echo /opt/intel/mkl/10.0.5.025/lib/*/libmkl.so);$(echo /opt/intel/mkl/10.0.5.025/lib/*/libiomp*.so)"
180 local bits=$(get_libdir)
181 fft_opts=( -DGMX_FFT_LIBRARY=mkl
182 -DMKL_INCLUDE_DIR="$(echo /opt/intel/*/mkl/include)"
183 -DMKL_LIBRARIES="$(echo /opt/intel/*/mkl/lib/*${bits/lib}/libmkl_rt.so)"
186 fft_opts=( -DGMX_FFT_LIBRARY=fftpack )
190 local lmfit_opts=( -DGMX_USE_LMFIT=EXTERNAL )
192 local lmfit_opts=( -DGMX_USE_LMFIT=INTERNAL )
199 -DGMX_EXTERNAL_BLAS=$(usex blas)
200 -DGMX_EXTERNAL_LAPACK=$(usex lapack)
201 -DGMX_OPENMP=$(usex openmp)
202 -DGMX_COOL_QUOTES=$(usex offensive)
203 -DGMX_USE_TNG=$(usex tng)
204 -DGMX_BUILD_MANUAL=$(usex doc)
205 -DGMX_HWLOC=$(usex hwloc)
206 -DGMX_DEFAULT_SUFFIX=off
208 -DGMX_VMD_PLUGIN_PATH="${EPREFIX}/usr/$(get_libdir)/vmd/plugins/*/molfile/"
209 -DBUILD_TESTING=$(usex test)
210 -DGMX_BUILD_UNITTESTS=$(usex test)
211 -DPYTHON_EXECUTABLE="${EPREFIX}/usr/bin/${EPYTHON}"
215 for x in ${GMX_DIRS}; do
216 einfo "Configuring for ${x} precision"
218 #if we build single and double - double is suffixed
219 use double-precision && use single-precision && \
220 [[ ${x} = "double" ]] && suffix="_d"
222 [[ ${x} = "double" ]] && p="-DGMX_DOUBLE=ON" || p="-DGMX_DOUBLE=OFF"
223 local cuda=( "-DGMX_GPU=OFF" )
224 [[ ${x} = "float" ]] && use cuda && \
225 cuda=( "-DGMX_GPU=ON" )
226 local opencl=( "-DGMX_USE_OPENCL=OFF" )
227 use opencl && opencl=( "-DGMX_USE_OPENCL=ON" ) cuda=( "-DGMX_GPU=ON" )
229 ${mycmakeargs_pre[@]} ${p}
231 -DGMX_THREAD_MPI=$(usex threads)
232 -DGMXAPI=$(usex gmxapi)
233 -DGMX_INSTALL_LEGACY_API=$(usex gmxapi-legacy)
236 "$(use test && echo -DREGRESSIONTEST_PATH="${WORKDIR}/${P}_${x}/tests")"
237 -DGMX_BINARY_SUFFIX="${suffix}"
238 -DGMX_LIBS_SUFFIX="${suffix}"
239 -DGMX_PYTHON_PACKAGE=$(usex python)
241 BUILD_DIR="${WORKDIR}/${P}_${x}" cmake-utils_src_configure
242 [[ ${CHOST} != *-darwin* ]] || \
243 sed -i '/SET(CMAKE_INSTALL_NAME_DIR/s/^/#/' "${WORKDIR}/${P}_${x}/gentoo_rules.cmake" || die
245 einfo "Configuring for ${x} precision with mpi"
247 ${mycmakeargs_pre[@]} ${p}
254 -DGMX_BUILD_MDRUN_ONLY=ON
255 -DBUILD_SHARED_LIBS=OFF
256 -DGMX_BUILD_MANUAL=OFF
257 -DGMX_BINARY_SUFFIX="_mpi${suffix}"
258 -DGMX_LIBS_SUFFIX="_mpi${suffix}"
260 BUILD_DIR="${WORKDIR}/${P}_${x}_mpi" CC="mpicc" cmake-utils_src_configure
261 [[ ${CHOST} != *-darwin* ]] || \
262 sed -i '/SET(CMAKE_INSTALL_NAME_DIR/s/^/#/' "${WORKDIR}/${P}_${x}_mpi/gentoo_rules.cmake" || die
267 for x in ${GMX_DIRS}; do
268 einfo "Compiling for ${x} precision"
269 BUILD_DIR="${WORKDIR}/${P}_${x}"\
270 cmake-utils_src_compile
272 BUILD_DIR="${WORKDIR}/${P}_${x}"\
273 cmake-utils_src_compile python_packaging/all
274 BUILD_DIR="${WORKDIR}/${P}" \
275 distutils-r1_src_compile
277 # not 100% necessary for rel ebuilds as available from website
279 BUILD_DIR="${WORKDIR}/${P}_${x}"\
280 cmake-utils_src_compile manual
283 einfo "Compiling for ${x} precision with mpi"
284 BUILD_DIR="${WORKDIR}/${P}_${x}_mpi"\
285 cmake-utils_src_compile
290 for x in ${GMX_DIRS}; do
291 BUILD_DIR="${WORKDIR}/${P}_${x}"\
292 cmake-utils_src_make check
297 for x in ${GMX_DIRS}; do
298 BUILD_DIR="${WORKDIR}/${P}_${x}" \
299 cmake-utils_src_install
301 BUILD_DIR="${WORKDIR}/${P}_${x}" \
302 cmake-utils_src_install python_packaging/install
305 newdoc "${WORKDIR}/${P}_${x}"/docs/manual/gromacs.pdf "${PN}-manual-${PV}.pdf"
308 BUILD_DIR="${WORKDIR}/${P}_${x}_mpi" \
309 cmake-utils_src_install
313 insinto /usr/include/tng
314 doins src/external/tng_io/include/tng/*h
316 # drop unneeded stuff
317 rm "${ED}"/usr/bin/GMXRC* || die
318 for x in "${ED}"/usr/bin/gmx-completion-*.bash ; do
319 local n=${x##*/gmx-completion-}
321 cat "${ED}"/usr/bin/gmx-completion-gmx.bash "$x" > "${T}/${n}" || die
322 newbashcomp "${T}"/"${n}" "${n}"
324 rm "${ED}"/usr/bin/gmx-completion*.bash || die
325 readme.gentoo_create_doc
330 einfo "Please read and cite:"
331 einfo "Gromacs 4, J. Chem. Theory Comput. 4, 435 (2008). "
332 einfo "https://dx.doi.org/10.1021/ct700301q"
334 readme.gentoo_print_elog