2015-03-26 13:16:22 +08:00
|
|
|
#!/usr/bin/env bash
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2015-05-22 23:42:46 +08:00
|
|
|
# This script's purpose is to ease compiling qTox for users.
|
2016-05-06 00:34:21 +08:00
|
|
|
#
|
2015-05-22 23:42:46 +08:00
|
|
|
# NO AUTOMATED BUILDS SHOULD DEPEND ON IT.
|
2016-05-06 00:34:21 +08:00
|
|
|
#
|
2015-05-22 23:42:46 +08:00
|
|
|
# This script is and will be a subject to breaking changes, and at no time one
|
|
|
|
# should expect it to work - it's something that you could try to use but
|
|
|
|
# don't expect that it will work for sure.
|
|
|
|
#
|
|
|
|
# If script doesn't work, you should use instructions provided in INSTALL.md
|
|
|
|
# before reporting issues like “qTox doesn't compile”.
|
|
|
|
#
|
|
|
|
# With that being said, reporting that this script doesn't work would be nice.
|
|
|
|
#
|
|
|
|
# If you are contributing code to qTox that change its dependencies / the way
|
2016-05-06 00:34:21 +08:00
|
|
|
# it's being build, please keep in mind that changing just bootstrap.sh
|
2015-05-22 23:42:46 +08:00
|
|
|
# *IS NOT* and will not be sufficient - you should update INSTALL.md first.
|
|
|
|
|
2016-05-06 00:34:21 +08:00
|
|
|
set -eu -o pipefail
|
2015-05-22 23:42:46 +08:00
|
|
|
|
2016-05-06 00:34:21 +08:00
|
|
|
# windows check
|
|
|
|
if cmd.exe /c ver 2>/dev/null ; then
|
2015-05-17 05:09:48 +08:00
|
|
|
cd windows
|
|
|
|
./bootstrap.sh
|
|
|
|
exit $?
|
2015-01-05 19:25:32 +08:00
|
|
|
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
|
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}
|
|
|
|
|
|
|
|
# directory names of cloned repositories
|
|
|
|
TOX_CORE_DIR=libtoxcore-latest
|
2015-05-13 22:13:56 +08:00
|
|
|
FILTER_AUDIO_DIR=libfilteraudio-latest
|
2016-05-06 00:34:21 +08:00
|
|
|
SQLCIPHER_DIR=sqlcipher-stable
|
2014-07-08 16:26:40 +08:00
|
|
|
|
2015-05-13 22:13:56 +08:00
|
|
|
# default values for user given parameters
|
|
|
|
INSTALL_TOX=true
|
|
|
|
INSTALL_FILTER_AUDIO=true
|
2016-05-06 00:34:21 +08:00
|
|
|
INSTALL_SQLCIPHER=false
|
2015-05-13 22:13:56 +08:00
|
|
|
SYSTEM_WIDE=true
|
|
|
|
KEEP_BUILD_FILES=false
|
|
|
|
|
2016-05-06 00:34:21 +08:00
|
|
|
# if Fedora, by default install sqlcipher
|
|
|
|
if which dnf &> /dev/null ; then
|
|
|
|
INSTALL_SQLCIPHER=true
|
|
|
|
fi
|
|
|
|
|
2015-05-17 05:09:48 +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-17 05:09:48 +08:00
|
|
|
if [ ${1} = "--with-tox" ] ; then
|
2015-05-13 22:13:56 +08:00
|
|
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
elif [ ${1} = "--with-sqlcipher" ] ; then
|
|
|
|
INSTALL_SQLCIPHER=true
|
|
|
|
shift
|
|
|
|
elif [ ${1} = "--without-sqlcipher" ] ; then
|
|
|
|
INSTALL_SQLCIPHER=false
|
|
|
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
|
2015-01-05 19:25:32 +08:00
|
|
|
# print help
|
2015-05-17 00:36:56 +08:00
|
|
|
echo "Use this script to install/update 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-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"
|
2016-05-06 00:34:21 +08:00
|
|
|
echo " --with-sqlcipher : install/update sqlcipher"
|
|
|
|
echo " --without-sqlcipher : do not install/update sqlcipher"
|
2015-05-13 22:13:56 +08:00
|
|
|
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-17 00:36:56 +08:00
|
|
|
echo " ${0} -- install libtoxcore and libfilteraudio"
|
2014-07-15 00:56:54 +08:00
|
|
|
exit 1
|
2015-05-17 05:09:48 +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
|
|
|
|
2015-05-17 05:09:48 +08:00
|
|
|
############ print debug output ############
|
2015-05-13 22:13:56 +08:00
|
|
|
echo "with tox : ${INSTALL_TOX}"
|
|
|
|
echo "with filter-audio : ${INSTALL_FILTER_AUDIO}"
|
2016-05-06 00:34:21 +08:00
|
|
|
echo "with sqlcipher : ${INSTALL_SQLCIPHER}"
|
|
|
|
echo "install system-wide : ${SYSTEM_WIDE}"
|
2015-05-13 22:13:56 +08:00
|
|
|
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
|
|
|
|
2016-05-06 00:34:21 +08:00
|
|
|
|
|
|
|
# remove not needed dirs
|
|
|
|
remove_build_dirs() {
|
|
|
|
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
|
|
|
|
rm -rf ${BASE_DIR}/${FILTER_AUDIO_DIR}
|
|
|
|
rm -rf ${BASE_DIR}/${SQLCIPHER_DIR}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
remove_build_dirs
|
2014-07-03 20:38:52 +08:00
|
|
|
|
2015-05-17 05:09:48 +08:00
|
|
|
|
|
|
|
############### install step ###############
|
2015-05-13 22:13:56 +08:00
|
|
|
#install libtoxcore
|
|
|
|
if [[ $INSTALL_TOX = "true" ]]; then
|
2016-05-06 00:34:21 +08:00
|
|
|
git clone https://github.com/irungentoo/toxcore.git \
|
|
|
|
${BASE_DIR}/${TOX_CORE_DIR} --depth 1
|
|
|
|
|
2015-05-17 05:09:48 +08:00
|
|
|
pushd ${BASE_DIR}/${TOX_CORE_DIR}
|
|
|
|
./autogen.sh
|
2016-05-06 00:34:21 +08:00
|
|
|
|
2015-05-17 05:57:04 +08:00
|
|
|
# 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
|
2015-05-13 22:13:56 +08:00
|
|
|
./configure
|
2015-05-17 05:57:04 +08:00
|
|
|
fi
|
2016-05-06 00:34:21 +08:00
|
|
|
|
2015-05-17 05:57:04 +08:00
|
|
|
# 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
|
2016-05-06 00:34:21 +08:00
|
|
|
|
2015-05-17 05:57:04 +08:00
|
|
|
# compile
|
2016-05-06 00:34:21 +08:00
|
|
|
make -j $(nproc)
|
|
|
|
|
2015-05-17 05:57:04 +08:00
|
|
|
# install
|
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
|
|
|
make install
|
|
|
|
else
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
git clone https://github.com/irungentoo/filter_audio.git \
|
|
|
|
${BASE_DIR}/${FILTER_AUDIO_DIR} --depth 1
|
2015-05-17 05:09:48 +08:00
|
|
|
pushd ${BASE_DIR}/${FILTER_AUDIO_DIR}
|
2016-05-06 00:34:21 +08:00
|
|
|
|
2015-05-17 05:09:48 +08:00
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
2016-05-06 00:34:21 +08:00
|
|
|
PREFIX=${BASE_DIR} make -j$(nproc)
|
2015-05-17 05:09:48 +08:00
|
|
|
PREFIX=${BASE_DIR} make install
|
|
|
|
else
|
2016-05-06 00:34:21 +08:00
|
|
|
make -j$(nproc)
|
2015-05-17 05:09:48 +08:00
|
|
|
sudo make install
|
|
|
|
sudo ldconfig
|
|
|
|
fi
|
2016-05-06 00:34:21 +08:00
|
|
|
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#install sqlcipher
|
|
|
|
if [[ $INSTALL_SQLCIPHER = "true" ]]; then
|
|
|
|
git clone https://github.com/sqlcipher/sqlcipher.git \
|
|
|
|
${BASE_DIR}/${SQLCIPHER_DIR} \
|
|
|
|
--depth 1 \
|
|
|
|
--branch v3.4.0
|
|
|
|
|
|
|
|
pushd ${BASE_DIR}/${SQLCIPHER_DIR}
|
|
|
|
autoreconf -if
|
|
|
|
|
|
|
|
if [[ $SYSTEM_WIDE = "false" ]]; then
|
|
|
|
./configure --prefix="${BASE_DIR}" \
|
|
|
|
--enable-tempstore=yes \
|
|
|
|
CFLAGS="-DSQLITE_HAS_CODEC"
|
|
|
|
make -j$(nproc)
|
|
|
|
make install || \
|
|
|
|
echo ""
|
|
|
|
echo "Sqlcipher failed to install locally."
|
|
|
|
echo ""
|
|
|
|
echo "Try without \"-l|--local\""
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
./configure \
|
|
|
|
--enable-tempstore=yes \
|
|
|
|
CFLAGS="-DSQLITE_HAS_CODEC"
|
|
|
|
make -j$(nproc)
|
|
|
|
sudo make install
|
|
|
|
sudo ldconfig
|
|
|
|
fi
|
|
|
|
|
2015-05-17 05:09:48 +08:00
|
|
|
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
|
2016-05-06 00:34:21 +08:00
|
|
|
remove_build_dirs
|
2014-07-23 18:00:55 +08:00
|
|
|
fi
|