1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/bootstrap.sh

176 lines
4.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2014-07-03 20:38:52 +08:00
WINDOWS_VERSION=$(cmd.exe /c ver 2>/dev/null | grep "Microsoft Windows")
if [ ! -z "$WINDOWS_VERSION" ]; then
2015-05-17 05:09:48 +08:00
cd windows
./bootstrap.sh
exit $?
fi
2015-05-17 05:09:48 +08:00
2014-07-08 16:26:40 +08:00
################ parameters ################
2014-07-03 20:38:52 +08:00
# directory where the script is located
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}
# directory names of cloned repositories
TOX_CORE_DIR=libtoxcore-latest
FILTER_AUDIO_DIR=libfilteraudio-latest
2014-07-08 16:26:40 +08:00
if [ -z "$BASE_DIR" ]; then
echo "internal error detected!"
echo "BASE_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."
2014-12-17 08:50:28 +08:00
exit 1
fi
2014-07-08 16:26:40 +08:00
# default values for user given parameters
INSTALL_TOX=true
INSTALL_FILTER_AUDIO=true
SYSTEM_WIDE=true
KEEP_BUILD_FILES=false
2015-05-17 05:09:48 +08:00
########## parse input parameters ##########
while [ $# -ge 1 ] ; do
2015-05-17 05:09:48 +08:00
if [ ${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
shift
2014-09-11 06:41:46 +08:00
elif [ ${1} = "-l" -o ${1} = "--local" ] ; then
SYSTEM_WIDE=false
shift
elif [ ${1} = "-k" -o ${1} = "--keep" ]; then
KEEP_BUILD_FILES=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
2015-05-17 00:36:56 +08:00
echo "Use this script to install/update libtoxcore and libfilteraudio"
echo ""
echo "usage:"
echo " ${0} PARAMETERS"
echo ""
echo "parameters:"
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"
echo ""
echo "example usages:"
2015-05-17 00:36:56 +08:00
echo " ${0} -- install libtoxcore and libfilteraudio"
exit 1
2015-05-17 05:09:48 +08:00
fi
done
2014-07-08 16:26:40 +08:00
2015-05-17 05:09:48 +08:00
############ print debug output ############
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 ###############
# 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
# 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
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
2015-05-17 05:09:48 +08:00
############### install step ###############
#install libtoxcore
if [[ $INSTALL_TOX = "true" ]]; then
2015-05-17 05:09:48 +08:00
git clone https://github.com/irungentoo/toxcore.git ${BASE_DIR}/${TOX_CORE_DIR} --depth 1
pushd ${BASE_DIR}/${TOX_CORE_DIR}
./autogen.sh
# configure
2015-05-17 05:09:48 +08:00
if [[ $SYSTEM_WIDE = "false" ]]; then
2015-05-17 00:36:56 +08:00
./configure --prefix=${BASE_DIR}
2014-12-17 08:50:28 +08:00
else
./configure
fi
# ensure A/V support is enabled
if ! grep -Fxq "BUILD_AV_TRUE=''" config.log
then
echo "A/V support of libtoxcore is disabled but required by qTox. Aborting."
echo "Maybe the dev-packages of libopus and libvpx are not installed?"
exit 1
fi
# compile
make -j 2
# install
if [[ $SYSTEM_WIDE = "false" ]]; then
make install
else
sudo make install
sudo ldconfig
2014-12-17 08:50:28 +08:00
fi
popd
2014-07-08 16:26:40 +08:00
fi
#install libfilteraudio
if [[ $INSTALL_FILTER_AUDIO = "true" ]]; then
2015-05-17 05:09:48 +08:00
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
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
if [[ $KEEP_BUILD_FILES = "false" ]]; then
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
rm -rf ${BASE_DIR}/${FILTER_AUDIO_DIR}
fi