/[gentoo-x86]/sci-physics/lammps/lammps-20150515.ebuild
Gentoo

Contents of /sci-physics/lammps/lammps-20150515.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sun Aug 2 18:46:44 2015 UTC (4 years, 5 months ago) by ago
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +2 -2 lines
Stable for x86, wrt bug #552468

(Portage version: 2.2.20/cvs/Linux x86_64, RepoMan options: --include-arches="x86", signed Manifest commit with key 7194459F)

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sci-physics/lammps/lammps-20150515.ebuild,v 1.2 2015/06/26 12:14:57 ago Exp $
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python{2_7,3_3} )
8
9 inherit eutils flag-o-matic fortran-2 multilib python-r1
10
11 convert_month() {
12 case $1 in
13 01) echo Jan
14 ;;
15 02) echo Feb
16 ;;
17 03) echo Mar
18 ;;
19 04) echo Apr
20 ;;
21 05) echo May
22 ;;
23 06) echo Jun
24 ;;
25 07) echo Jul
26 ;;
27 08) echo Aug
28 ;;
29 09) echo Sep
30 ;;
31 10) echo Oct
32 ;;
33 11) echo Nov
34 ;;
35 12) echo Dec
36 ;;
37 *) echo unknown
38 ;;
39 esac
40 }
41
42 MY_P=${PN}-$((10#${PV:6:2}))$(convert_month ${PV:4:2})${PV:2:2}
43
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"
47
48 LICENSE="GPL-2"
49 SLOT="0"
50 KEYWORDS="amd64 x86"
51 IUSE="doc examples gzip lammps-memalign mpi python static-libs"
52
53 DEPEND="
54 mpi? (
55 virtual/blas
56 virtual/lapack
57 virtual/mpi
58 )
59 gzip? ( app-arch/gzip )
60 sci-libs/voro++
61 python? ( ${PYTHON_DEPS} )
62 "
63 RDEPEND="${DEPEND}"
64
65 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
66
67 S="${WORKDIR}/${MY_P}"
68
69 lmp_emake() {
70 local LAMMPS_INCLUDEFLAGS
71 LAMMPS_INCLUDEFLAGS="$(usex gzip '-DLAMMPS_GZIP' '')"
72 LAMMPS_INCLUDEFLAGS+="$(usex lammps-memalign ' -DLAMMPS_MEMALIGN' '')"
73
74 # The lammps makefile uses CC to indicate the C++ compiler.
75 emake \
76 ARCHIVE=$(tc-getAR) \
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)" '')"\
88 "$@"
89 }
90
91 lmp_activate_packages() {
92 # Build 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
125
126 if use mpi; then
127 lmp_emake -C src yes-user-atc
128 fi
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
134 }
135
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++
141 }
142
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
148 }
149
150 src_prepare() {
151 # Fix inconsistent use of SHFLAGS.
152 sed -i \
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
156
157 # Fix missing .so name.
158 sed -i \
159 -e 's:SHLIBFLAGS\s\+=\s\+:SHLIBFLAGS = -Wl,-soname,liblammps.so.0 :' \
160 src/MAKE/Makefile.serial || die
161
162 # Fix makefile in tools.
163 sed -i \
164 -e 's:g++:$(CXX) $(CXXFLAGS):' \
165 -e 's:gcc:$(CC) $(CCFLAGS):' \
166 -e 's:ifort:$(FC) $(FCFLAGS):' \
167 tools/Makefile || die
168
169 # Patch python.
170 epatch "${FILESDIR}/lammps-python3.patch"
171 epatch "${FILESDIR}/python-shebang.patch"
172 }
173
174 src_compile() {
175 # Fix atc...
176 append-cxxflags -I../../src
177
178 # Acticate packages.
179 elog "Activating lammps packages..."
180 lmp_activate_packages
181
182 # Compile stubs for serial version.
183 use mpi || lmp_emake -C src mpi-stubs
184
185 elog "Building packages..."
186 lmp_build_packages
187
188 if use static-libs; then
189 # Build static library.
190 elog "Building static library..."
191 lmp_emake -C src mode=lib serial
192 fi
193
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..."
197 lmp_clean_packages
198
199 # The build system does not rebuild the packages with -fPIC, adding flag
200 # manually.
201 append-cxxflags -fPIC
202 append-fflags -fPIC
203
204 # Compile stubs for serial version.
205 use mpi || lmp_emake -C src mpi-stubs
206
207 elog "Building packages..."
208 lmp_build_packages
209
210 # Build shared library.
211 elog "Building shared library..."
212 lmp_emake -C src mode=shlib serial
213
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
222 else
223 lmp_emake -C src mode=shexe serial
224 fi
225
226 # Compile tools.
227 elog "Building tools..."
228 lmp_emake -C tools binary2txt chain data2xmovie micelle2d
229 }
230
231 src_install() {
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
238 dobin tools/chain
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
243 # packages.
244 insinto "/usr/include/${PN}"
245 doins -r src/*.h lib/meam/*.mod
246
247 local LAMMPS_POTENTIALS="usr/share/${PN}/potentials"
248 insinto "/${LAMMPS_POTENTIALS}"
249 doins potentials/*
250 echo "LAMMPS_POTENTIALS=${EROOT}${LAMMPS_POTENTIALS}" > 99lammps
251 doenvd 99lammps
252
253 # Install python script.
254 use python && python_foreach_impl python_domodule python/lammps.py
255
256 if use examples; then
257 local LAMMPS_EXAMPLES="/usr/share/${PN}/examples"
258 insinto "${LAMMPS_EXAMPLES}"
259 doins -r examples/*
260 fi
261
262 dodoc README
263 if use doc; then
264 dodoc doc/Manual.pdf
265 dohtml -r doc/*
266 fi
267 }

  ViewVC Help
Powered by ViewVC 1.1.20