2015-03-26 13:16:22 +08:00
|
|
|
#!/usr/bin/env bash
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2015-01-05 19:25:32 +08:00
|
|
|
WINDOWS_VERSION=$(cmd.exe /c ver 2>/dev/null | grep "Microsoft Windows")
|
|
|
|
if [ ! -z "$WINDOWS_VERSION" ]; then
|
|
|
|
cd windows
|
|
|
|
./bootstrap.sh
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
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}
|
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
# the sodium version to use
|
2015-02-18 12:08:12 +08:00
|
|
|
SODIUM_VER=1.0.2
|
2014-09-01 13:25:22 +08:00
|
|
|
|
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
|
2015-05-13 22:13:56 +08:00
|
|
|
FILTER_AUDIO_DIR=libfilteraudio-latest
|
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-12-17 08:50:28 +08:00
|
|
|
if [ -z "$FILTER_AUDIO_DIR" ]; then
|
|
|
|
echo "internal error detected!"
|
|
|
|
echo "FILTER_AUDIO_DIR should not be empty... aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-07-08 16:26:40 +08:00
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
# default values for user given parameters
|
|
|
|
INSTALL_SODIUM=true
|
|
|
|
INSTALL_TOX=true
|
|
|
|
INSTALL_FILTER_AUDIO=true
|
|
|
|
SYSTEM_WIDE=true
|
|
|
|
KEEP_BUILD_FILES=false
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
########## parse input parameters ##########
|
2014-07-23 18:00:55 +08:00
|
|
|
while [ $# -ge 1 ] ; do
|
2015-05-13 22:13:56 +08:00
|
|
|
if [ ${1} = "--with-sodium" ] ; then
|
|
|
|
INSTALL_SODIUM=true
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--without-sodium" ] ; then
|
|
|
|
INSTALL_SODIUM=false
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--with-tox" ] ; then
|
|
|
|
INSTALL_TOX=true
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--without-tox" ] ; then
|
|
|
|
INSTALL_TOX=false
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--with-filter-audio" ] ; then
|
|
|
|
INSTALL_FILTER_AUDIO=true
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--without-filter-audio" ] ; then
|
|
|
|
INSTALL_FILTER_AUDIO=false
|
2014-07-23 18:00:55 +08:00
|
|
|
shift
|
2014-09-11 06:41:46 +08:00
|
|
|
elif [ ${1} = "-l" -o ${1} = "--local" ] ; then
|
2015-05-13 22:13:56 +08:00
|
|
|
SYSTEM_WIDE=false
|
2014-07-23 18:00:55 +08:00
|
|
|
shift
|
|
|
|
elif [ ${1} = "-k" -o ${1} = "--keep" ]; then
|
2015-05-13 22:13:56 +08:00
|
|
|
KEEP_BUILD_FILES=true
|
2014-07-23 18:00:55 +08:00
|
|
|
shift
|
2014-07-08 16:26:40 +08:00
|
|
|
else
|
|
|
|
if [ ${1} != "-h" -a ${1} != "--help" ] ; then
|
|
|
|
echo "[ERROR] Unknown parameter \"${1}\""
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
2015-01-05 19:25:32 +08:00
|
|
|
# print help
|
2015-05-13 22:13:56 +08:00
|
|
|
echo "Use this script to install/update libsodium, libtoxcore and libfilteraudio"
|
2014-07-15 00:56:54 +08:00
|
|
|
echo ""
|
|
|
|
echo "usage:"
|
2015-05-13 22:13:56 +08:00
|
|
|
echo " ${0} PARAMETERS"
|
2014-07-15 00:56:54 +08:00
|
|
|
echo ""
|
|
|
|
echo "parameters:"
|
2015-05-13 22:13:56 +08:00
|
|
|
echo " --with-sodium : install/update libsodium"
|
|
|
|
echo " --without-sodium : do not install/update libsodium"
|
|
|
|
echo " --with-tox : install/update libtoxcore"
|
|
|
|
echo " --without-tox : do not install/update libtoxcore"
|
|
|
|
echo " --with-filter-audio : install/update libfilteraudio"
|
|
|
|
echo " --without-filter-audio : do not install/update libfilteraudio"
|
|
|
|
echo " -h|--help : displays this help"
|
|
|
|
echo " -l|--local : install packages into ${INSTALL_DIR}"
|
|
|
|
echo " -k|--keep : keep build files after installation/update"
|
2014-07-15 00:56:54 +08:00
|
|
|
echo ""
|
|
|
|
echo "example usages:"
|
2015-05-13 22:13:56 +08:00
|
|
|
echo " ${0} -- install libsodium, libtoxcore and libfilteraudio"
|
2014-07-15 00:56:54 +08:00
|
|
|
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
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
|
|
|
|
########## print debug output ##########
|
|
|
|
echo "with sodium : ${INSTALL_SODIUM}"
|
|
|
|
echo "with tox : ${INSTALL_TOX}"
|
|
|
|
echo "with filter-audio : ${INSTALL_FILTER_AUDIO}"
|
|
|
|
echo "install into ${INSTALL_DIR} : ${SYSTEM_WIDE}"
|
|
|
|
echo "keep build files : ${KEEP_BUILD_FILES}"
|
|
|
|
|
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-12-17 08:50:28 +08:00
|
|
|
rm -rf ${BASE_DIR}/${FILTER_AUDIO_DIR}
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
|
|
|
|
############### install step ###############
|
2015-05-13 22:13:56 +08:00
|
|
|
# install libsodium
|
|
|
|
if [[ $INSTALL_SODIUM = "true" ]]; then
|
|
|
|
git clone --branch $SODIUM_VER git://github.com/jedisct1/libsodium.git ${BASE_DIR}/${SODIUM_DIR} --depth 1
|
|
|
|
pushd ${BASE_DIR}/${SODIUM_DIR}
|
|
|
|
./autogen.sh
|
|
|
|
|
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
|
|
|
./configure --prefix=${BASE_DIR}
|
|
|
|
make -j2 check
|
2014-07-23 18:00:55 +08:00
|
|
|
make install
|
|
|
|
else
|
2015-05-13 22:13:56 +08:00
|
|
|
./configure
|
|
|
|
make -j2 check
|
2014-07-23 18:00:55 +08:00
|
|
|
sudo make install
|
2015-05-13 22:13:56 +08:00
|
|
|
sudo ldconfig
|
2014-07-23 18:00:55 +08:00
|
|
|
fi
|
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
popd
|
2015-05-13 22:13:56 +08:00
|
|
|
fi
|
2014-12-17 08:50:28 +08:00
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
#install libtoxcore
|
|
|
|
if [[ $INSTALL_TOX = "true" ]]; then
|
|
|
|
git clone https://github.com/irungentoo/toxcore.git ${BASE_DIR}/${TOX_CORE_DIR} --depth 1
|
|
|
|
pushd ${BASE_DIR}/${TOX_CORE_DIR}
|
|
|
|
./autogen.sh
|
|
|
|
|
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
|
|
|
./configure --prefix=${BASE_DIR} --with-libsodium-headers=${BASE_DIR}/include --with-libsodium-libs=${BASE_DIR}/lib
|
|
|
|
make -j2
|
|
|
|
make install
|
2014-12-17 08:50:28 +08:00
|
|
|
else
|
2015-05-13 22:13:56 +08:00
|
|
|
./configure
|
|
|
|
make -j2
|
2015-02-18 12:08:12 +08:00
|
|
|
sudo make install
|
2015-05-13 22:13:56 +08:00
|
|
|
sudo ldconfig
|
2014-12-17 08:50:28 +08:00
|
|
|
fi
|
2015-05-13 22:13:56 +08:00
|
|
|
|
|
|
|
popd
|
2014-07-08 16:26:40 +08:00
|
|
|
fi
|
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
#install libfilteraudio
|
|
|
|
if [[ $INSTALL_FILTER_AUDIO = "true" ]]; then
|
|
|
|
git clone https://github.com/irungentoo/filter_audio.git ${BASE_DIR}/${FILTER_AUDIO_DIR} --depth 1
|
|
|
|
pushd ${BASE_DIR}/${FILTER_AUDIO_DIR}
|
|
|
|
|
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
|
|
|
PREFIX=${BASE_DIR} make -j2
|
|
|
|
PREFIX=${BASE_DIR} make install
|
|
|
|
else
|
|
|
|
make -j2
|
|
|
|
sudo make install
|
|
|
|
sudo ldconfig
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd
|
2014-07-23 18:00:55 +08:00
|
|
|
fi
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2014-09-10 22:12:15 +08:00
|
|
|
|
2014-07-08 16:26:40 +08:00
|
|
|
############### cleanup step ###############
|
|
|
|
# remove cloned repositories
|
2015-05-13 22:13:56 +08:00
|
|
|
if [[ $KEEP_BUILD_FILES = "false" ]]; then
|
2014-07-23 18:00:55 +08:00
|
|
|
rm -rf ${BASE_DIR}/${SODIUM_DIR}
|
|
|
|
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
|
2015-05-13 22:13:56 +08:00
|
|
|
rm -rf ${BASE_DIR}/${FILTER_AUDIO_DIR}
|
2014-07-23 18:00:55 +08:00
|
|
|
fi
|