\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\W}[1]{ \; #1 \; }\)
example_install.sh¶
View page sourceAn Example Installation¶
Syntax¶
tools/example_install.sh
#
# build_type
eval $(tools/install_settings.py | grep '^build_type')
#
# dismod_at_prefix
eval $(tools/install_settings.py | grep '^dismod_at_prefix')
# -----------------------------------------------------------------------------
# bash function that echos and executes a command
echo_eval() {
echo $*
eval $*
}
# --------------------------------------------------------------------------
# remove old version of
# example_install.log, example_install.err, cpapd_mixed.log, cppad_mixed.err
for script in example_install get_cppad_mixed
do
for ext in log err
do
if [ -e "$script.$ext" ]
then
echo_eval rm "$script.$ext"
fi
done
done
# --------------------------------------------------------------------------
# set build link to build.debug or build.release depending on build_type
if echo "$dismod_at_prefix" | grep '/dismod_at$' > /dev/null
then
tools/build_type.sh example_install.sh $dismod_at_prefix $build_type
fi
# -----------------------------------------------------------------------------
# install cppad_mixed and it's special requirements
echo_eval tools/get_cppad_mixed.sh
# ----------------------------------------------------------------------------
# sqlite3
if which apt-get >& /dev/null
then
if ! dpkg-query -l | sed -e 's| *| |g' -e 's|^ii ||' | \
grep "^libsqlite3-dev" > /dev/null
then
echo_eval sudo apt-get install -y sqlite3 libsqlite3-dev
fi
elif which dnf >& /dev/null
then
if ! dnf list --installed | sed -e 's| *| |g' | \
grep "^sqlite-devel" > /dev/null
then
echo_eval sudo dnf install -y sqlite-devel
fi
fi
# ----------------------------------------------------------------------------
# numpy, matplotlib, scipy
for package in numpy matplotlib scipy
do
if ! pip list | grep "^$package" > /dev/null
then
echo_eval pip install $package
fi
done
# ----------------------------------------------------------------------------
# dismod_at
# -----------------------------------------------------------------------------
# Check we can find ipopt.pc, echo PKG_CONFIG_PATH to help user set this value
dir=`find -L $dismod_at_prefix -name 'ipopt.pc' | sed -e 's|/ipopt.pc||'`
if [ "$dir" == '' ]
then
echo "Cannot find ipopt.pc in $dismod_at_prefix directory"
exit 1
else
echo 'pkg-config setting for ipopt'
echo_eval export PKG_CONFIG_PATH="$dir"
fi
#
# tools/run_cmake.sh
echo "tools/run_cmake.sh 1>> example_install.log 2>> example_install.err"
tools/run_cmake.sh 1>> example_install.log 2>> example_install.err
#
# change into build directory
echo_eval cd build
#
if which nproc >& /dev/null
then
n_job=$(nproc)
else
n_job=$(sysctl -n hw.ncpu)
fi
#
# build dismod_at using n_jobs
echo "make -j $n_job 1>> ../example_install.log 2>> ../example_install.err"
if ! make -j $n_job 1>> ../example_install.log 2>> ../example_install.err
then
echo "Try running the follow command in $(pwd)"
echo " make -j $n_job"
echo 'to see wy the build of dismod_at failed.'
exit 1
fi
#
# make check, speed, install, install_python
for cmd in check speed install install_python
do
echo "make $cmd 1>> example_install.log 2>> example_install.err"
if ! make $cmd 1>> ../example_install.log 2>> ../example_install.err
then
echo "Try running the follow command in $(pwd)"
echo " make $cmd"
echo 'to see wy the check of dismod_at failed.'
exit 1
fi
done
cd ..
# -----------------------------------------------------------------------------
echo 'tools/example_install.sh: OK'
exit 0