1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
#!/bin/bash
# Slackware build script for lammps
# Copyright 2023 Giancarlo Dessi, Cagliari, IT
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=lammps
VERSION=${VERSION:-2023.08.02}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
SRCNAM=lammps-stable
SRCVERSION=${SRCVERSION:-2Aug2023}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
# First detect if openmpi or mpich are installed, so we can build LAMMPS with the
# parallel computing and enable some packages
MP=""
mpi=""
if pkg-config --exists ompi; then
MP="openmpi";
mpi="-DBUILD_OMP=yes "
fi
if pkg-config --exists mpich; then
MP="mpich";
mpi="-DBUILD_MPI=yes "
fi
# These internal packages are enabled by default.
# If you do not require some of them you have to edit the conditions in this block
# otherwise pass the respective environment variables set to "no" to the script
# for each package not desired
# (for example: AMOEBA=no ASPHERE=no ./lammps.SlackBuild)
amoeba="" [ "${AMOEBA:-yes}" = "yes" ] && amoeba="-DPKG_AMOEBA=yes "
asphere="" ; [ "${ASPHERE:-yes}" = "yes" ] && asphere="-DPKG_ASPHERE=yes "
atc="" ; [ "${ATC:-yes}" = "yes" ] && atc="-DPKG_ATC=yes "
awpmd="" ; [ "${AWPMD:-yes}" = "yes" ] && awpmd="-DPKG_AWPMD=yes "
bocs="" ; [ "${BOCS:-yes}" = "yes" ] && bocs="-DPKG_BOCS=yes "
body="" ; [ "${BODY:-yes}" = "yes" ] && body="-DPKG_BODY=yes "
bpm="" ; [ "${BPM:-yes}" = "yes" ] && bpm="-DPKG_BPM=yes "
brownian="" ; [ "${BROWNIAN:-yes}" = "yes" ] && brownian="-DPKG_BROWNIAN=yes "
cgdna="" ; [ "${CGDNA:-yes}" = "yes" ] && cgdna="-DPKG_CG-DNA=yes "
cgspica="" ; [ "${CGSPICA:-yes}" = "yes" ] && cgspica="-DPKG_CG-SPICA=yes "
class2="" ; [ "${CLASS2:-yes}" = "yes" ] && class2="-DPKG_CLASS2=yes "
colloid="" ; [ "${COLLOID:-yes}" = "yes" ] && colloid="-DPKG_COLLOID=yes "
colvars="" ; [ "${COLVARS:-yes}" = "yes" ] && colvars="-DPKG_COLVARS=yes "
compress="" ; [ "${COMPRESS:-yes}" = "yes" ] && compress="-DPKG_COMPRESS=yes "
coreshell="" ; [ "${CORESHELL:-yes}" = "yes" ] && coreshell="-DPKG_CORESHELL=yes "
dielectric="" ; [ "${DIELECTRIC:-yes}" = "yes" ] && dielectric="-DPKG_DIELECTRIC=yes "
diffraction="" ; [ "${DIFFRACTION:-yes}" = "yes" ] && diffraction="-DPKG_DIFFRACTION=yes "
dipole="" ; [ "${DIPOLE:-yes}" = "yes" ] && dipole="-DPKG_DIPOLE=yes "
dpdbasic="" ; [ "${DPDBASIC:-yes}" = "yes" ] && dpdbasic="-DPKG_DPD-BASIC=yes "
dpdmeso="" ; [ "${DPDMESO:-yes}" = "yes" ] && dpdmeso="-DPKG_DPD-MESO=yes "
dpdreact="" ; [ "${DPDREACT:-yes}" = "yes" ] && dpdreact="-DPKG_DPD-REACT=yes "
dpdsmooth="" ; [ "${DPDSMOOTH:-yes}" = "yes" ] && dpdsmooth="-DPKG_DPD-SMOOTH=yes "
drude="" ; [ "${DRUDE:-yes}" = "yes" ] && drude="-DPKG_DRUDE=yes "
eff="" ; [ "${EFF:-yes}" = "yes" ] && eff="-DPKG_EFF=yes "
electrode="" ; [ "${ELECTRODE:-yes}" = "yes" ] && electrode="-DPKG_ELECTRODE=yes "
extracompute="" ; [ "${EXTRACOMPUTE:-yes}" = "yes" ] && extracompute="-DPKG_EXTRA-COMPUTE=yes "
extradump="" ; [ "${EXTRADUMP:-yes}" = "yes" ] && extradump="-DPKG_EXTRA-DUMP=yes "
extrafix="" ; [ "${EXTRAFIX:-yes}" = "yes" ] && extrafix="-DPKG_EXTRA-FIX=yes "
extramolecule="" ; [ "${EXTRAMOLECULE:-yes}" = "yes" ] && extramolecule="-DPKG_EXTRA-MOLECULE=yes "
extrapair="" ; [ "${EXTRAPAIR:-yes}" = "yes" ] && extrapair="-DPKG_EXTRA-PAIR=yes "
fep="" ; [ "${FEP:-yes}" = "yes" ] && fep="-DPKG_FEP=yes "
granular="" ; [ "${GRANULAR:-yes}" = "yes" ] && granular="-DPKG_GRANULAR=yes "
intel="" ; [ "${INTEL:-yes}" = "yes" ] && intel="-DPKG_INTEL=yes "
interlayer="" ; [ "${INTERLAYER:-yes}" = "yes" ] && interlayer="-DPKG_INTERLAYER=yes "
kspace="" ; [ "${KSPACE:-yes}" = "yes" ] && kspace="-DPKG_KSPACE=yes "
lepton="" ; [ "${LEPTON:-yes}" = "yes" ] && lepton="-DPKG_LEPTON=yes "
machdyn="" ; [ "${MACHDYN:-yes}" = "yes" ] && machdyn="-DPKG_MACHDYN=yes "
manifold="" ; [ "${MANIFOLD:-yes}" = "yes" ] && manifold="-DPKG_MANIFOLD=yes "
manybody="" ; [ "${MANYBODY:-yes}" = "yes" ] && manybody="-DPKG_MANYBODY=yes "
mc="" ; [ "${MC:-yes}" = "yes" ] && mc="-DPKG_MC=yes "
mdi="" ; [ "${MDI:-yes}" = "yes" ] && mdi="-DPKG_MDI=yes -DDOWNLOAD_MDI=yes "
meam="" ; [ "${MEAM:-yes}" = "yes" ] && meam="-DPKG_MEAM=yes "
mesont="" ; [ "${MESONT:-yes}" = "yes" ] && mesont="-DPKG_MESONT=yes "
mgpt="" ; [ "${MGPT:-yes}" = "yes" ] && mgpt="-DPKG_MGPT=yes "
misc="" ; [ "${MISC:-yes}" = "yes" ] && misc="-DPKG_MISC=yes "
mlhdnnp="" ; [ "${MLHDNNP:-yes}" = "yes" ] && mlhdnnp="-DPKG_ML-HDNNP=yes "
mliap="" ; [ "${MLIAP:-yes}" = "yes" ] && mliap="-DPKG_ML-IAP=yes -DMLIAP_ENABLE_PYTHON=autodetected "
mlpace="" ; [ "${MLPACE:-yes}" = "yes" ] && mlpace="-DPKG_ML-PACE=yes "
mlpod="" ; [ "${MLPOD:-yes}" = "yes" ] && mlpod="-DPKG_ML-POD=yes "
mlrann="" ; [ "${MLRANN:-yes}" = "yes" ] && mlrann="-DPKG_ML-RANN=yes "
mlsnap="" ; [ "${MLSNAP:-yes}" = "yes" ] && mlsnap="-DPKG_ML-SNAP=yes "
mofff="" ; [ "${MOFFF:-yes}" = "yes" ] && mofff="-DPKG_MOFFF=yes "
molecule="" ; [ "${MOLECULE:-yes}" = "yes" ] && molecule="-DPKG_MOLECULE=yes "
opt="" ; [ "${OPT:-yes}" = "yes" ] && opt="-DPKG_OPT=yes "
orient="" ; [ "${ORIENT:-yes}" = "yes" ] && orient="-DPKG_ORIENT=yes "
peri="" ; [ "${PERI:-yes}" = "yes" ] && peri="-DPKG_PERI=yes "
phonon="" ; [ "${PHONON:-yes}" = "yes" ] && phonon="-DPKG_PHONON=yes "
plugin="" ; [ "${PLUGIN:-yes}" = "yes" ] && plugin="-DPKG_PLUGIN=yes "
poems="" ; [ "${POEMS:-yes}" = "yes" ] && poems="-DPKG_POEMS=yes "
ptm="" ; [ "${PTM:-yes}" = "yes" ] && ptm="-DPKG_PTM=yes "
qeq="" ; [ "${QEQ:-yes}" = "yes" ] && qeq="-DPKG_QEQ=yes "
qtb="" ; [ "${QTB:-yes}" = "yes" ] && qtb="-DPKG_QTB=yes "
reaction="" ; [ "${REACTION:-yes}" = "yes" ] && reaction="-DPKG_REACTION=yes "
reaxff="" ; [ "${REAXFF:-yes}" = "yes" ] && reaxff="-DPKG_REAXFF=yes "
replica="" ; [ "${REPLICA:-yes}" = "yes" ] && replica="-DPKG_REPLICA=yes "
rigid="" ; [ "${RIGID:-yes}" = "yes" ] && rigid="-DPKG_RIGID=yes "
shock="" ; [ "${SHOCK:-yes}" = "yes" ] && shock="-DPKG_SHOCK=yes "
smtbq="" ; [ "${SMTBQ:-yes}" = "yes" ] && smtbq="-DPKG_SMTBQ=yes "
sph="" ; [ "${SPH:-yes}" = "yes" ] && sph="-DPKG_SPH=yes "
spin="" ; [ "${SPIN:-yes}" = "yes" ] && spin="-DPKG_SPIN=yes "
srd="" ; [ "${SRD:-yes}" = "yes" ] && srd="-DPKG_SRD=yes "
tally="" ; [ "${TALLY:-yes}" = "yes" ] && tally="-DPKG_TALLY=yes "
uef="" ; [ "${UEF:-yes}" = "yes" ] && uef="-DPKG_UEF=yes "
yaff="" ; [ "${YAFF:-yes}" = "yes" ] && yaff="-DPKG_YAFF=yes "
# If OpenBLAS is installed ELECTRODE will be enabled using the system LAPACK
# otherwise a bundled linear algebra is used. To force the use of internal
# linear algebra edit the CMake flag setting "-DUSE_INTERNAL_LINALG=yes "
if [ "$electrode" = "-DPKG_ELECTRODE=yes " ]; then
if pkg-config --exists openblas; then
electrode=$electrode"-DUSE_INTERNAL_LINALG=no "
fi
fi
if [ "${PYTHON:-yes}" = "yes" ]; then
python="-DPKG_PYTHON=yes "
else
python=""
mliap=""
fi
# The GPU package requires some basic settings that may be customized through environment
# variables. For advanced options requiring specific hardware configurations (GPU) see the
# documentation in lammps.org
# This package causes many issues depending on the hardware/software configuration (build
# failure or segmentation fault) that require additional settings to be solved, so it is
# disabled by default.
if [ "${GPU:-no}" = "yes" ]; then
# by default the GPU package is enabled using bundled OpenCL ICD loader library/headers
# but users may prefer the local opencl installed in the system
opencl_loader="yes" ; [ "${STATIC_OCL:-no}" = "no" ] && opencl_loader="no"
gpu="-DPKG_GPU=yes -DGPU_API=opencl -DUSE_STATIC_OPENCL_LOADER=${opencl_loader} "
else
opencl_loader=""
gpu=""
fi
# Following conditions enable by default all packages that require dependencies if these
# are installed in the system
latboltz=""
openmp=""
scafacos=""
if [ "$MP" = "openmpi" ]; then
latboltz="" ; [ "${LATBOLTZ:-yes}" = "yes" ] && latboltz="-DPKG_LATBOLTZ=yes "
openmp="" ; [ "${OPENMP:-yes}" = "yes" ] && openmp="-DPKG_OPENMP=yes "
scafacos="" ; [ "${SCAFACOS:-yes}" = "yes" ] && scafacos="-DPKG_SCAFACOS=yes "
fi
if [ "$MP" = "mpich" ]; then
latboltz="" ; [ "${LATBOLTZ:-yes}" = "yes" ] && latboltz="-DPKG_LATBOLTZ=yes "
scafacos="" ; [ "${SCAFACOS:-yes}" = "yes" ] && scafacos="-DPKG_SCAFACOS=yes "
fi
if pkg-config --exists plumed; then
plumed="" ; [ "${PLUMED:-yes}" = "yes" ] && plumed="-DPKG_PLUMED=yes -DDOWNLOAD_PLUMED=no "
else
plumed=""
fi
netcdf=""
if pkg-config --exists netcdf; then
netcdf="" ; [ "${NETCDF:-yes}" = "yes" ] && netcdf="-DPKG_NETCDF=yes "
fi
voronoi=""
if [ -f /usr/bin/voro++ ]; then
voronoi="" ; [ "${VORONOI:-yes}" = "yes" ] && voronoi="-DPKG_VORONOI=yes "
fi
h5md=""
if [ -f /usr/bin/h5cc ]; then
h5md="" ; [ "${H5MD:-yes}" = "yes" ] && h5md="-DPKG_H5MD=yes "
fi
# This shouldn't need in 32-bit architectures, however it significantly extends the build times
# and absorbs many resources. Openmpi is strictly required.
kokkos=""
if [ "$ARCH" = "x86_64" ]; then
if [ "${KOKKOS:-yes}" = "yes" ] ; then
kokkos="-DPKG_KOKKOS=yes -DKokkos_ARCH_NATIVE=yes -DKokkos_ENABLE_OPENMP=yes "
fi
if [ "$MP" != "openmpi" ]; then
kokkos=""
fi
fi
# All required cmake flags related to packages are included in a single global variable
packages=$amoeba$asphere$atc$awpmd$bocs$body$bpm$brownian$cgdna$cgspica$class2$colloid\
$colvars$compress$coreshell$dielectric$diffraction$dipole$dpdbasic$dpdmeso$dpdreact\
$dpdsmooth$drude$eff$electrode$extracompute$extradump$extrafix$extramolecule$extrapair\
$fep$gpu$granular$h5md$intel$interlayer$kokkos$kspace$latboltz$lepton$machdyn$manifold\
$manybody$mc$mdi$meam$mesont$mgpt$misc$mlhdnnp$mliap$mlpace$mlpod$mlrann$mlsnap$mofff\
$molecule$netcdf$openmp$opt$orient$peri$phonon$plugin$plumed$poems$ptm$qeq$qtb$reaction\
$reaxff$replica$rigid$scafacos$shock$smtbq$sph$spin$srd$tally$uef$voronoi$yaff
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf ${SRCNAM}_${SRCVERSION}
tar xvf $CWD/${SRCNAM}_${SRCVERSION}.tar.gz
cd ${SRCNAM}_${SRCVERSION}
echo -e "\nFLAGS FOR PACKAGES ENABLED:\n "$packages"\n"
echo -e "FLAGS FOR PYTHON:\n "$python
echo -e "\nFLAGS FOR MPI:\n "$mpi
if [ "$mesont" != "" ]; then
cp -a $CWD/C_10_10.mesocnt ./potentials
if [ "$molecule" = "" ]; then
echo -e "\n\033[33mYou have enabled the package MESONT. Since this package requires also "
echo -e "the package MOLECULE, the build of MOLECULE will be automatically enabled\033[0m\n"
packages=$packages" -DPKG_MOLECULE=yes "
fi
fi
if [ "$MP" = "" ]; then
echo -e "\n\033[33m******************** WARNING ********************\n"
echo " no API supporting MPI (mpich or openmpi) are "
echo " installed on your system. This does not affect "
echo " the build and installation of LAMMPS, but some "
echo " packages cannot be enabled and other may work "
echo " not optimally. "
echo -e "\n*************************************************\n\033[0m"
fi
# Prepare directories to move the extrafiles needed to build some packages
mkdir -p cmake/build
if [ "$opencl_loader" = "yes" ]; then
mkdir -p cmake/build/_deps
cp -a $CWD/opencl-loader-2022.01.04.tar.gz cmake/build/_deps
fi
if [ "$mdi" != "" ]; then
mkdir -p cmake/build/mdi_build_ext/src/
cp -a $CWD/MDI_Library-1.4.16.tar.gz cmake/build/mdi_build_ext/src/v1.4.16.tar.gz
fi
if [ "$mlhdnnp" != "" ]; then
mkdir -p cmake/build/n2p2_build-prefix/src/
cp -a $CWD/n2p2-2.2.0.tar.gz cmake/build/n2p2_build-prefix/src/v2.2.0.tar.gz
fi
if [ "$mlpace" != "" ]; then
cp -a $CWD/lammps-user-pace-v.2023.01.3.fix.tar.gz cmake/build/libpace.tar.gz
fi
if [ "$scafacos" != "" ]; then
mkdir -p cmake/build/scafacos_build-prefix/src
cp -a $CWD/scafacos-1.0.1.tar.gz cmake/build/scafacos_build-prefix/src
fi
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# The Source has not a CMakeLists.txt file in the root directory we
# need to change in the cmake directory
cd cmake
cd build
cmake \
-DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
$mpi \
$python \
$packages \
..
make
make install DESTDIR=$PKG
cd ..
rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
#Since the build installs man in /usr/share we move the directory in /usr
mv -v $PKG/usr/share/man $PKG/usr
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
#Since the build installs etc as subfolder of /usr (?), we move it in the root directory
mv -v $PKG/usr/etc $PKG
cd $TMP/${SRCNAM}_${SRCVERSION}
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a LICENSE README $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|