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
12 local months=( "" Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )
13 echo ${months[${1#0}]}
16 MY_P=${PN}-$((10#${PV:6:2}))$(convert_month ${PV:4:2})${PV:2:2}
18 DESCRIPTION="Large-scale Atomic/Molecular Massively Parallel Simulator"
19 HOMEPAGE="http://lammps.sandia.gov/"
20 SRC_URI="http://lammps.sandia.gov/tars/${MY_P}.tar.gz"
24 KEYWORDS="~amd64 ~x86"
25 IUSE="doc examples gzip lammps-memalign mpi python static-libs"
33 gzip? ( app-arch/gzip )
35 python? ( ${PYTHON_DEPS} )
39 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
41 S="${WORKDIR}/${MY_P}"
44 local LAMMPS_INCLUDEFLAGS
45 LAMMPS_INCLUDEFLAGS="$(usex gzip '-DLAMMPS_GZIP' '')"
46 LAMMPS_INCLUDEFLAGS+="$(usex lammps-memalign ' -DLAMMPS_MEMALIGN=64' '')"
48 # The lammps makefile uses CC to indicate the C++ compiler.
51 CC=$(usex mpi "mpic++" "$(tc-getCXX)") \
52 F90=$(usex mpi "mpif90" "$(tc-getFC)") \
53 LINK=$(usex mpi "mpic++" "$(tc-getCXX)") \
54 CCFLAGS="${CXXFLAGS}" \
55 F90FLAGS="${FCFLAGS}" \
56 LINKFLAGS="${LDFLAGS}" \
57 LMP_INC="${LAMMPS_INCLUDEFLAGS}" \
58 MPI_INC=$(usex mpi "" "-I../STUBS") \
59 MPI_PATH=$(usex mpi "" "-L../STUBS") \
60 MPI_LIB=$(usex mpi "" "-lmpi_stubs") \
61 user-atc_SYSLIB="$(usex mpi "$($(tc-getPKG_CONFIG) --libs blas) $($(tc-getPKG_CONFIG) --libs lapack)" '')"\
65 lmp_activate_packages() {
67 lmp_emake -C src yes-asphere
68 lmp_emake -C src yes-body
69 lmp_emake -C src yes-class2
70 lmp_emake -C src yes-colloid
71 lmp_emake -C src yes-coreshell
72 lmp_emake -C src yes-dipole
73 lmp_emake -C src yes-fld
74 #lmp_emake -C src yes-gpu
75 lmp_emake -C src yes-granular
76 # Need OpenKIM external dependency.
77 #lmp_emake -C src yes-kim
78 # Need Kokkos external dependency.
79 #lmp_emake -C src yes-kokkos
80 lmp_emake -C src yes-kspace
81 lmp_emake -C src yes-manybody
82 lmp_emake -C src yes-mc
83 lmp_emake -C src yes-meam
84 lmp_emake -C src yes-misc
85 lmp_emake -C src yes-molecule
86 #lmp_emake -C src yes-mpiio
87 lmp_emake -C src yes-opt
88 lmp_emake -C src yes-peri
89 lmp_emake -C src yes-poems
90 lmp_emake -C src yes-qeq
91 lmp_emake -C src yes-reax
92 lmp_emake -C src yes-replica
93 lmp_emake -C src yes-rigid
94 lmp_emake -C src yes-shock
95 lmp_emake -C src yes-snap
96 lmp_emake -C src yes-srd
97 lmp_emake -C src yes-voronoi
98 lmp_emake -C src yes-xtc
101 lmp_emake -C src yes-user-atc
103 lmp_emake -C src yes-user-eff
104 lmp_emake -C src yes-user-fep
105 use mpi && lmp_emake -C src yes-user-lb
106 lmp_emake -C src yes-user-phonon
107 lmp_emake -C src yes-user-sph
110 lmp_build_packages() {
111 lmp_emake -C lib/meam -j1 -f Makefile.gfortran
112 lmp_emake -C lib/poems -f Makefile.g++
113 lmp_emake -C lib/reax -j1 -f Makefile.gfortran
114 use mpi && lmp_emake -C lib/atc -f Makefile.g++
117 lmp_clean_packages() {
118 lmp_emake -C lib/meam -f Makefile.gfortran clean
119 lmp_emake -C lib/poems -f Makefile.g++ clean
120 lmp_emake -C lib/reax -f Makefile.gfortran clean
121 use mpi && lmp_emake -C lib/atc -f Makefile.g++ clean
125 # Fix inconsistent use of SHFLAGS.
127 -e 's:voronoi_SYSINC\s\+=.*$:voronoi_SYSINC = -I/usr/include/voro++:' \
128 -e 's:voronoi_SYSPATH\s\+=.*$:voronoi_SYSPATH =:' \
129 lib/voronoi/Makefile.lammps || die
131 # Fix missing .so name.
133 -e 's:SHLIBFLAGS\s\+=\s\+:SHLIBFLAGS = -Wl,-soname,liblammps.so.0 :' \
134 src/MAKE/Makefile.serial || die
136 # Fix makefile in tools.
138 -e 's:g++:$(CXX) $(CXXFLAGS):' \
139 -e 's:gcc:$(CC) $(CCFLAGS):' \
140 -e 's:ifort:$(FC) $(FCFLAGS):' \
141 tools/Makefile || die
144 epatch "${FILESDIR}/lammps-python3-r1.patch"
145 epatch "${FILESDIR}/python-shebang.patch"
150 append-cxxflags -I../../src
153 elog "Activating lammps packages..."
154 lmp_activate_packages
156 # Compile stubs for serial version.
157 use mpi || lmp_emake -C src mpi-stubs
159 elog "Building packages..."
162 if use static-libs; then
163 # Build static library.
164 elog "Building static library..."
165 lmp_emake -C src mode=lib serial
168 # Clean out packages (that's not done by the build system with the clean
169 # target), so we can rebuild the packages with -fPIC.
170 elog "Cleaning packages..."
173 # The build system does not rebuild the packages with -fPIC, adding flag
175 append-cxxflags -fPIC
178 # Compile stubs for serial version.
179 use mpi || lmp_emake -C src mpi-stubs
181 elog "Building packages..."
184 # Build shared library.
185 elog "Building shared library..."
186 lmp_emake -C src mode=shlib serial
188 # Compile main executable. The shared library is always built, and
189 # mode=shexe is simply a way to re-use the object files built in the
190 # "shlib" step when linking the executable. The executable is not actually
191 # using the shared library. If we have built the static library, then we
192 # link that into the executable.
193 elog "Linking executable..."
194 if use static-libs; then
195 lmp_emake -C src mode=exe serial
197 lmp_emake -C src mode=shexe serial
201 elog "Building tools..."
202 lmp_emake -C tools binary2txt chain data2xmovie micelle2d
206 use static-libs && newlib.a src/liblammps_serial.a liblammps.a
207 newlib.so src/liblammps_serial.so liblammps.so.0.0.0
208 dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so
209 dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so.0
210 newbin src/lmp_serial lmp
211 dobin tools/binary2txt
213 dobin tools/data2xmovie
214 dobin tools/micelle2d
215 # Don't forget to add header files of optional packages as they are added
216 # to this ebuild. There may also be .mod files from Fortran based
218 insinto "/usr/include/${PN}"
219 doins -r src/*.h lib/meam/*.mod
221 local LAMMPS_POTENTIALS="usr/share/${PN}/potentials"
222 insinto "/${LAMMPS_POTENTIALS}"
224 echo "LAMMPS_POTENTIALS=${EROOT}${LAMMPS_POTENTIALS}" > 99lammps
227 # Install python script.
228 use python && python_foreach_impl python_domodule python/lammps.py
230 if use examples; then
231 local LAMMPS_EXAMPLES="/usr/share/${PN}/examples"
232 insinto "${LAMMPS_EXAMPLES}"