1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python{2_7,3_3} )
9 inherit eutils flag-o-matic fortran-2 multilib python-r1
42 MY_P=${PN}-$((10#${PV:6:2}))$(convert_month ${PV:4:2})${PV:2:2}
44 DESCRIPTION="Large-scale Atomic/Molecular Massively Parallel Simulator"
45 HOMEPAGE="http://lammps.sandia.gov/"
46 SRC_URI="http://lammps.sandia.gov/tars/${MY_P}.tar.gz"
50 KEYWORDS="~amd64 ~x86"
51 IUSE="doc examples gzip lammps-memalign mpi python static-libs"
59 gzip? ( app-arch/gzip )
61 python? ( ${PYTHON_DEPS} )
65 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
67 S="${WORKDIR}/${MY_P}"
70 local LAMMPS_INCLUDEFLAGS
71 LAMMPS_INCLUDEFLAGS="$(usex gzip '-DLAMMPS_GZIP' '')"
72 LAMMPS_INCLUDEFLAGS+="$(usex lammps-memalign ' -DLAMMPS_MEMALIGN=64' '')"
74 # The lammps makefile uses CC to indicate the C++ compiler.
77 CC=$(usex mpi "mpic++" "$(tc-getCXX)") \
78 F90=$(usex mpi "mpif90" "$(tc-getFC)") \
79 LINK=$(usex mpi "mpic++" "$(tc-getCXX)") \
80 CCFLAGS="${CXXFLAGS}" \
81 F90FLAGS="${FCFLAGS}" \
82 LINKFLAGS="${LDFLAGS}" \
83 LMP_INC="${LAMMPS_INCLUDEFLAGS}" \
84 MPI_INC=$(usex mpi "" "-I../STUBS") \
85 MPI_PATH=$(usex mpi "" "-L../STUBS") \
86 MPI_LIB=$(usex mpi "" "-lmpi_stubs") \
87 user-atc_SYSLIB="$(usex mpi "$($(tc-getPKG_CONFIG) --libs blas) $($(tc-getPKG_CONFIG) --libs lapack)" '')"\
91 lmp_activate_packages() {
93 lmp_emake -C src yes-asphere
94 lmp_emake -C src yes-body
95 lmp_emake -C src yes-class2
96 lmp_emake -C src yes-colloid
97 lmp_emake -C src yes-coreshell
98 lmp_emake -C src yes-dipole
99 lmp_emake -C src yes-fld
100 #lmp_emake -C src yes-gpu
101 lmp_emake -C src yes-granular
102 # Need OpenKIM external dependency.
103 #lmp_emake -C src yes-kim
104 # Need Kokkos external dependency.
105 #lmp_emake -C src yes-kokkos
106 lmp_emake -C src yes-kspace
107 lmp_emake -C src yes-manybody
108 lmp_emake -C src yes-mc
109 lmp_emake -C src yes-meam
110 lmp_emake -C src yes-misc
111 lmp_emake -C src yes-molecule
112 #lmp_emake -C src yes-mpiio
113 lmp_emake -C src yes-opt
114 lmp_emake -C src yes-peri
115 lmp_emake -C src yes-poems
116 lmp_emake -C src yes-qeq
117 lmp_emake -C src yes-reax
118 lmp_emake -C src yes-replica
119 lmp_emake -C src yes-rigid
120 lmp_emake -C src yes-shock
121 lmp_emake -C src yes-snap
122 lmp_emake -C src yes-srd
123 lmp_emake -C src yes-voronoi
124 lmp_emake -C src yes-xtc
127 lmp_emake -C src yes-user-atc
129 lmp_emake -C src yes-user-eff
130 lmp_emake -C src yes-user-fep
131 use mpi && lmp_emake -C src yes-user-lb
132 lmp_emake -C src yes-user-phonon
133 lmp_emake -C src yes-user-sph
136 lmp_build_packages() {
137 lmp_emake -C lib/meam -j1 -f Makefile.gfortran
138 lmp_emake -C lib/poems -f Makefile.g++
139 lmp_emake -C lib/reax -j1 -f Makefile.gfortran
140 use mpi && lmp_emake -C lib/atc -f Makefile.g++
143 lmp_clean_packages() {
144 lmp_emake -C lib/meam -f Makefile.gfortran clean
145 lmp_emake -C lib/poems -f Makefile.g++ clean
146 lmp_emake -C lib/reax -f Makefile.gfortran clean
147 use mpi && lmp_emake -C lib/atc -f Makefile.g++ clean
151 # Fix inconsistent use of SHFLAGS.
153 -e 's:voronoi_SYSINC\s\+=.*$:voronoi_SYSINC = -I/usr/include/voro++:' \
154 -e 's:voronoi_SYSPATH\s\+=.*$:voronoi_SYSPATH =:' \
155 lib/voronoi/Makefile.lammps || die
157 # Fix missing .so name.
159 -e 's:SHLIBFLAGS\s\+=\s\+:SHLIBFLAGS = -Wl,-soname,liblammps.so.0 :' \
160 src/MAKE/Makefile.serial || die
162 # Fix makefile in tools.
164 -e 's:g++:$(CXX) $(CXXFLAGS):' \
165 -e 's:gcc:$(CC) $(CCFLAGS):' \
166 -e 's:ifort:$(FC) $(FCFLAGS):' \
167 tools/Makefile || die
170 epatch "${FILESDIR}/lammps-python3-r1.patch"
171 epatch "${FILESDIR}/python-shebang.patch"
176 append-cxxflags -I../../src
179 elog "Activating lammps packages..."
180 lmp_activate_packages
182 # Compile stubs for serial version.
183 use mpi || lmp_emake -C src mpi-stubs
185 elog "Building packages..."
188 if use static-libs; then
189 # Build static library.
190 elog "Building static library..."
191 lmp_emake -C src mode=lib serial
194 # Clean out packages (that's not done by the build system with the clean
195 # target), so we can rebuild the packages with -fPIC.
196 elog "Cleaning packages..."
199 # The build system does not rebuild the packages with -fPIC, adding flag
201 append-cxxflags -fPIC
204 # Compile stubs for serial version.
205 use mpi || lmp_emake -C src mpi-stubs
207 elog "Building packages..."
210 # Build shared library.
211 elog "Building shared library..."
212 lmp_emake -C src mode=shlib serial
214 # Compile main executable. The shared library is always built, and
215 # mode=shexe is simply a way to re-use the object files built in the
216 # "shlib" step when linking the executable. The executable is not actually
217 # using the shared library. If we have built the static library, then we
218 # link that into the executable.
219 elog "Linking executable..."
220 if use static-libs; then
221 lmp_emake -C src mode=exe serial
223 lmp_emake -C src mode=shexe serial
227 elog "Building tools..."
228 lmp_emake -C tools binary2txt chain data2xmovie micelle2d
232 use static-libs && newlib.a src/liblammps_serial.a liblammps.a
233 newlib.so src/liblammps_serial.so liblammps.so.0.0.0
234 dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so
235 dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so.0
236 newbin src/lmp_serial lmp
237 dobin tools/binary2txt
239 dobin tools/data2xmovie
240 dobin tools/micelle2d
241 # Don't forget to add header files of optional packages as they are added
242 # to this ebuild. There may also be .mod files from Fortran based
244 insinto "/usr/include/${PN}"
245 doins -r src/*.h lib/meam/*.mod
247 local LAMMPS_POTENTIALS="usr/share/${PN}/potentials"
248 insinto "/${LAMMPS_POTENTIALS}"
250 echo "LAMMPS_POTENTIALS=${EROOT}${LAMMPS_POTENTIALS}" > 99lammps
253 # Install python script.
254 use python && python_foreach_impl python_domodule python/lammps.py
256 if use examples; then
257 local LAMMPS_EXAMPLES="/usr/share/${PN}/examples"
258 insinto "${LAMMPS_EXAMPLES}"