2014-07-03 20:38:52 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
################ parameters ################
|
2014-07-03 20:38:52 +08:00
|
|
|
# directory where the script is located
|
2014-07-15 06:16:20 +08:00
|
|
|
SCRIPT_DIR=$( cd $(dirname $0); pwd -P)
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
# directory where dependencies will be installed
|
|
|
|
INSTALL_DIR=libs
|
|
|
|
|
|
|
|
# just for convenience
|
|
|
|
BASE_DIR=${SCRIPT_DIR}/${INSTALL_DIR}
|
|
|
|
|
2014-09-01 13:25:22 +08:00
|
|
|
SODIUM_VER=0.7.0
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
# directory names of cloned repositories
|
2014-09-01 13:25:22 +08:00
|
|
|
SODIUM_DIR=libsodium-$SODIUM_VER
|
2014-07-08 16:26:40 +08:00
|
|
|
TOX_CORE_DIR=libtoxcore-latest
|
|
|
|
|
|
|
|
# this boolean describes whether the installation of
|
|
|
|
# libsodium should be skipped or not
|
|
|
|
# the default value is 'false' and will be set to 'true'
|
|
|
|
# if this script gets the parameter -t or --tox
|
|
|
|
TOX_ONLY=false
|
2014-07-23 18:00:55 +08:00
|
|
|
GLOBAL=false
|
|
|
|
KEEP=false
|
2014-07-08 16:26:40 +08:00
|
|
|
|
2014-07-15 00:56:54 +08:00
|
|
|
if [ -z "$BASE_DIR" ]; then
|
|
|
|
echo "internal error detected!"
|
|
|
|
echo "BASE_DIR should not be empty... aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$SODIUM_DIR" ]; then
|
|
|
|
echo "internal error detected!"
|
|
|
|
echo "SODIUM_DIR should not be empty... aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$TOX_CORE_DIR" ]; then
|
|
|
|
echo "internal error detected!"
|
|
|
|
echo "TOX_CORE_DIR should not be empty... aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
########## check input parameters ##########
|
2014-07-23 18:00:55 +08:00
|
|
|
while [ $# -ge 1 ] ; do
|
2014-07-08 16:26:40 +08:00
|
|
|
if [ ${1} = "-t" -o ${1} = "--tox" ] ; then
|
|
|
|
TOX_ONLY=true
|
2014-07-23 18:00:55 +08:00
|
|
|
shift
|
|
|
|
elif [ ${1} = "-g" -o ${1} = "--global" ] ; then
|
|
|
|
GLOBAL=true
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "-k" -o ${1} = "--keep" ]; then
|
|
|
|
KEEP=true
|
|
|
|
shift
|
2014-07-08 16:26:40 +08:00
|
|
|
else
|
|
|
|
if [ ${1} != "-h" -a ${1} != "--help" ] ; then
|
|
|
|
echo "[ERROR] Unknown parameter \"${1}\""
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
# print help
|
2014-07-15 00:56:54 +08:00
|
|
|
echo "Use this script to install/update libsodium and libtoxcore in ${INSTALL_DIR}"
|
|
|
|
echo ""
|
|
|
|
echo "usage:"
|
2014-07-23 18:00:55 +08:00
|
|
|
echo " ${0} [-t|--tox|-h|--help|-g|--global|-k|--keep]"
|
2014-07-15 00:56:54 +08:00
|
|
|
echo ""
|
|
|
|
echo "parameters:"
|
2014-07-23 18:00:55 +08:00
|
|
|
echo " -h|--help : displays this help"
|
|
|
|
echo " -t|--tox : only install/update libtoxcore"
|
|
|
|
echo " requires an already installed libsodium"
|
|
|
|
echo " -g|--global: installs libtox* and libsodium globally"
|
|
|
|
echo " (also disables local configure prefixes)"
|
|
|
|
echo " -k|--keep : does not delete the build directories afterwards"
|
2014-07-15 00:56:54 +08:00
|
|
|
echo ""
|
|
|
|
echo "example usages:"
|
|
|
|
echo " ${0} -- to install libsodium and libtoxcore"
|
|
|
|
echo " ${0} -t -- to update already installed libtoxcore"
|
|
|
|
exit 1
|
2014-07-08 16:26:40 +08:00
|
|
|
fi
|
2014-07-23 18:00:55 +08:00
|
|
|
done
|
2014-07-08 16:26:40 +08:00
|
|
|
|
2014-07-23 18:00:55 +08:00
|
|
|
echo "Tox only: $TOX_ONLY"
|
|
|
|
echo "Global : $GLOBAL"
|
|
|
|
echo "Keep : $KEEP"
|
2014-07-08 16:26:40 +08:00
|
|
|
|
|
|
|
############### prepare step ###############
|
2014-07-15 00:56:54 +08:00
|
|
|
# create BASE_DIR directory if necessary
|
2014-07-08 16:26:40 +08:00
|
|
|
mkdir -p ${BASE_DIR}
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-07-04 01:47:35 +08:00
|
|
|
# maybe an earlier run of this script failed
|
2014-07-08 16:26:40 +08:00
|
|
|
# thus we should remove the cloned repositories
|
|
|
|
# if exists, otherwise cloning them may fail
|
|
|
|
rm -rf ${BASE_DIR}/${SODIUM_DIR}
|
2014-07-15 14:20:08 +08:00
|
|
|
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
|
2014-07-04 01:47:35 +08:00
|
|
|
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
|
|
|
|
############### install step ###############
|
2014-09-01 13:25:22 +08:00
|
|
|
# clone current master of libsodium and switch to version $SODIUM_VER
|
2014-07-08 16:26:40 +08:00
|
|
|
# afterwards install libsodium to INSTALL_DIR
|
|
|
|
# skip the installation if TOX_ONLY is true
|
|
|
|
if [[ $TOX_ONLY = "false" ]]; then
|
|
|
|
git clone git://github.com/jedisct1/libsodium.git ${BASE_DIR}/${SODIUM_DIR}
|
|
|
|
pushd ${BASE_DIR}/${SODIUM_DIR}
|
2014-09-01 13:25:22 +08:00
|
|
|
git checkout tags/$SODIUM_VER
|
2014-07-08 16:26:40 +08:00
|
|
|
./autogen.sh
|
2014-08-06 07:57:16 +08:00
|
|
|
|
2014-07-23 18:00:55 +08:00
|
|
|
if [[ $GLOBAL = "false" ]]; then
|
|
|
|
./configure --prefix=${BASE_DIR}/
|
|
|
|
else
|
|
|
|
./configure
|
|
|
|
fi
|
2014-08-06 07:57:16 +08:00
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
make -j2 check
|
2014-07-23 18:00:55 +08:00
|
|
|
|
|
|
|
if [[ $GLOBAL = "false" ]]; then
|
|
|
|
make install
|
|
|
|
else
|
|
|
|
sudo make install
|
|
|
|
fi
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
# clone current master of libtoxcore
|
|
|
|
# make sure to compile with libsodium we just installed to INSTALL_DIR
|
|
|
|
# afterwards install libtoxcore to INSTALL_DIR
|
|
|
|
git clone https://github.com/irungentoo/toxcore.git ${BASE_DIR}/${TOX_CORE_DIR}
|
|
|
|
pushd ${BASE_DIR}/${TOX_CORE_DIR}
|
2014-07-03 20:38:52 +08:00
|
|
|
./autogen.sh
|
2014-07-23 18:00:55 +08:00
|
|
|
if [[ $GLOBAL = "false" ]]; then
|
|
|
|
./configure --prefix=${BASE_DIR}/ --with-libsodium-headers=${BASE_DIR}/include --with-libsodium-libs=${BASE_DIR}/lib
|
|
|
|
else
|
|
|
|
./configure
|
|
|
|
fi
|
|
|
|
|
2014-07-03 20:38:52 +08:00
|
|
|
make -j2
|
|
|
|
|
2014-07-23 18:00:55 +08:00
|
|
|
if [[ $GLOBAL = "false" ]]; then
|
|
|
|
make install
|
|
|
|
else
|
|
|
|
sudo make install
|
|
|
|
fi
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-07-23 18:00:55 +08:00
|
|
|
popd
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-09-10 22:12:15 +08:00
|
|
|
if [[ $GLOBAL = "true" ]]; then
|
|
|
|
sudo ldconfig
|
|
|
|
fi
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
############### cleanup step ###############
|
|
|
|
# remove cloned repositories
|
2014-07-23 18:00:55 +08:00
|
|
|
if [[ $KEEP = "false" ]]; then
|
|
|
|
rm -rf ${BASE_DIR}/${SODIUM_DIR}
|
|
|
|
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
|
|
|
|
fi
|