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
|
#!/bin/bash
# Latest version of this script can be found at:
# https://github.com/NanoComp/meep/blob/master/contrib/build-meep.sh
help ()
{
cat << EOF
$1: Download MEEP sources and dependencies, compile, and install
Usage: $1 [options]
EOF
sed -ne 's,[ \t]*\(-[^ \t]*\))[^#]*#[ \t]*\(.*\), \1 \2,p' "$1"
echo ""
exit 1
}
[ -z "$1" ] && echo "(use -h for help)"
installdeps=true
while [ ! -z "$1" ]; do
case "$1" in
-h) # help
help "$0"
;;
-d) # <installdir> (default: current directory)
DESTDIR="$2"
shift
;;
-s) # use 'sudo' for 'make install'
SUDO=sudo
;;
-n) # do not check for distribution dependencies
installdeps=false
;;
*)
echo "'$1' ?"
help "$0"
;;
esac
shift
done
# detect wether DESTDIR is ending with src/
[ -z ${DESTDIR} ] && DESTDIR=$(pwd)
[ ${DESTDIR##*/} = src ] && DESTDIR=$(cd $(pwd)/..; pwd)
SRCDIR=${DESTDIR}/src
cat << EOF
This sript will download or update sources, compile and install MEEP.
Please ensure the following final paths fit your needs:
'${DESTDIR}/bin/meep'
'${DESTDIR}/lib/...'
'${DESTDIR}/share/...'
'${DESTDIR}/...'
'${SRCDIR}/<sources>'
Press return to continue
EOF
read junk
if ! lsb_release; then
echo "Minimum requirements:"
echo " Ubuntu:"
echo " sudo apt-get -y install lsb-release sudo git"
echo " CentOS:"
echo " sudo yum -y install redhat-lsb-core sudo git"
echo ""
exit 1
fi
set -ex
ubuntu=false
centos=false
distrib=$(lsb_release -r -s)
case "$distrib" in
18.04) # ubuntu 18.04 bionic
libpng=libpng-dev
libpython=libpython3-dev
ubuntu=true
;;
16.04) # ubuntu 16.04 xenial
libpng=libpng16-dev
libpython=libpython3.5-dev
ubuntu=true
;;
7.*) # CentOS 7.x
centos=true
;;
*)
echo "unsupported distribution '$(lsb_release -a)', edit and fix!"
false
;;
esac
mkdir -p ${SRCDIR}
cd ${SRCDIR}
gitclone ()
{
repo=${1##*/}
name=${repo%%.*}
echo $repo $name
if [ -d $name ]; then
( cd $name; git pull; )
else
git clone --depth=1 $1
fi
}
autogensh ()
{
sh autogen.sh PKG_CONFIG_PATH="${PKG_CONFIG_PATH}" RPATH_FLAGS="${RPATH_FLAGS}" LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" \
--disable-static --enable-shared --prefix="${DESTDIR}" \
--with-libctl=${DESTDIR}/share/libctl \
"$@"
}
if $installdeps && $ubuntu; then
sudo apt-get update
sudo apt-get -y install \
build-essential \
gfortran \
libblas-dev \
liblapack-dev \
libgmp-dev \
swig \
libgsl-dev \
autoconf \
pkg-config \
$libpng \
git \
guile-2.0-dev \
libfftw3-dev \
libhdf5-openmpi-dev \
hdf5-tools \
$libpython \
python3-numpy \
python3-scipy \
python3-pip \
ffmpeg \
[ "$distrib" = 16.04 ] && sudo -H pip3 install --upgrade pip
sudo -H pip3 install --no-cache-dir mpi4py
export HDF5_MPI="ON"
sudo -H pip3 install --no-binary=h5py h5py
sudo -H pip3 install matplotlib>3.0.0
RPATH_FLAGS="-Wl,-rpath,${DESTDIR}/lib:/usr/lib/x86_64-linux-gnu/hdf5/openmpi"
LDFLAGS="-L${DESTDIR}/lib -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi ${RPATH_FLAGS}"
CFLAGS="-I${DESTDIR}/include -I/usr/include/hdf5/openmpi"
fi
if $installdeps && $centos; then
sudo yum -y --enablerepo=extras install epel-release
sudo yum -y install \
bison \
byacc \
cscope \
ctags \
cvs \
diffstat \
oxygen \
flex \
gcc \
gcc-c++ \
gcc-gfortran \
gettext \
git \
indent \
intltool \
libtool \
patch \
patchutils \
rcs \
redhat-rpm-config \
rpm-build \
subversion \
systemtap \
wget
sudo yum -y install \
openblas-devel \
fftw3-devel \
libpng-devel \
gsl-devel \
gmp-devel \
pcre-devel \
libtool-ltdl-devel \
libunistring-devel \
libffi-devel \
gc-devel \
zlib-devel \
openssl-devel \
sqlite-devel \
bzip2-devel \
ffmpeg
sudo yum -y install \
openmpi-devel \
hdf5-openmpi-devel \
guile-devel \
swig
export PATH=${PATH}:/usr/lib64/openmpi/bin
RPATH_FLAGS="-Wl,-rpath,${DESTDIR}/lib:/usr/lib64/openmpi/lib"
LDFLAGS="-L${DESTDIR}/lib -L/usr/lib64/openmpi/lib ${RPATH_FLAGS}"
CFLAGS="-I${DESTDIR}/include -I/usr/include/openmpi-x86_64/"
fi
CPPFLAGS=${CFLAGS}
PKG_CONFIG_PATH=${DESDTIR}/pkgconfig
export PKG_CONFIG_PATH
export PATH=${DESTDIR}/bin:${PATH}
mkdir -p $SRCDIR
cd $SRCDIR
gitclone https://github.com/NanoComp/harminv.git
cd harminv/
autogensh
make -j && $SUDO make install
cd $SRCDIR
gitclone https://github.com/NanoComp/libctl.git
cd libctl/
autogensh
make -j && $SUDO make install
cd $SRCDIR
gitclone https://github.com/NanoComp/h5utils.git
cd h5utils/
autogensh CC=mpicc
make -j && $SUDO make install
cd $SRCDIR
gitclone https://github.com/NanoComp/mpb.git
cd mpb/
autogensh CC=mpicc --with-hermitian-eps
make -j && $SUDO make install
cd $SRCDIR
gitclone https://github.com/HomerReid/libGDSII.git
cd libGDSII/
autogensh
make -j && $SUDO make install
cd $SRCDIR
gitclone https://github.com/NanoComp/meep.git
cd meep/
autogensh --with-mpi --with-openmp PYTHON=python3
make -j && $SUDO make install
# all done
|