Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c to your computer and use it in GitHub Desktop.
Save mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c to your computer and use it in GitHub Desktop.
build-install-freeswitch-1.10-from-source.sh
#!/bin/bash
## Script for building/installing FreeSWITCH from source.
## URL: https://gist.github.com/mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c
## Freely distributed under the MIT license
##
##
set -xe
FREESWITCH_SOURCE=https://github.com/signalwire/freeswitch.git
FREESWITCH_RELEASE=master #or set this to any other version, for example: v1.10.5
PREFIX=/usr/share/freeswitch
# If you want to remove some modules from build, specify/uncomment it here
REMOVED_MODULES=(
# mod_signalwire
# mog_pgsql
)
#Clean old prefix and build
sudo rm -rf $PREFIX
rm -rf ~/build-$FREESWITCH_RELEASE
#install dependencies
sudo apt-get update && sudo apt-get install -y git-core build-essential python python2-dev python3-dev autoconf automake cmake libtool libncurses5 libncurses5-dev make libjpeg-dev pkg-config zlib1g-dev sqlite3 libsqlite3-dev libpcre3-dev libspeexdsp-dev libedit-dev libldns-dev liblua5.1-0-dev libcurl4-gnutls-dev libapr1-dev yasm libsndfile-dev libopus-dev libtiff-dev libavformat-dev libswscale-dev libavresample-dev libpq-dev zip
#clone source and prepares it
mkdir -p ~/build-$FREESWITCH_RELEASE
cd ~/build-$FREESWITCH_RELEASE
PVERSION=( ${FREESWITCH_RELEASE//./ } )
MIN_VERSION=${PVERSION[1]}
PATCH_VERSION=${PVERSION[2]}
if [[ $FREESWITCH_RELEASE = "master" ]] || [[ $MIN_VERSION -ge 10 && $PATCH_VERSION -ge 3 ]]
then
echo "VERSION => 1.10.3 - need to build libsk2, signalwire-c , spandsp and sofia-sip separatedly"
#build and install libks2 - needed for mod_verto and signalwire
git clone https://github.com/signalwire/libks.git
cd libks
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX
make
sudo make install
cd ..
#build and install signalwire-c - needed for mod_signalwire
git clone https://github.com/signalwire/signalwire-c
cd signalwire-c
env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX
make
sudo make install
cd ..
#build and install libspandev
git clone https://github.com/freeswitch/spandsp.git
cd spandsp
git checkout 67d2455efe02e7ff0d897f3fd5636fed4d54549e # workaround for @signalwire/freeswitch#2158 (thx to @9to1url)
./bootstrap.sh
./configure --prefix=$PREFIX
make
sudo make install
cd ..
#build and install mod_sofia
git clone https://github.com/freeswitch/sofia-sip.git
cd sofia-sip
./bootstrap.sh
./configure --prefix=$PREFIX
make
sudo make install
cd ..
fi
#avoid git access's denied error
touch .config && sudo chown $USER:$USER .config
if [ ! -d freeswitch ]
then
git clone $FREESWITCH_SOURCE freeswitch
cd freeswitch
else
cd freeswitch
git fetch origin
fi
git reset --hard $FREESWITCH_RELEASE && git clean -d -x -f
#remove modules from building
for module in "${REMOVED_MODULES[@]}"
do
sed -i "s/applications\/mod_signalwire/#applications\/mod_signalwire/g" build/modules.conf.in
done
#sed -i "s/databases\/mod_pgsql/#databases\/mod_pgsql/g" build/modules.conf.in
./bootstrap.sh
#configure , build and install
env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig ./configure --prefix=$PREFIX --disable-libvpx
env C_INCLUDE_PATH=$PREFIX/include make
sudo make install config-vanilla
#package
cd ~/build-$FREESWITCH_RELEASE
zip -r freeswitch-$FREESWITCH_RELEASE.zip $PREFIX
@wheatforwood
Copy link

wheatforwood commented May 29, 2024

I'm building on a fresh installation of Debian 11. If exclude mod_verto, it works perfectly. But if I try to build mod_verto, I get this error.

mod_verto.c:46:10: fatal error: ks.h: No such file or directory
46 | #include "ks.h"
| ^~~~~~

I see there was previous chatter on this in this thread, about building libks for this. And the script seems to address this by building libks. Yet I still get the error.

I did verify that libks is in ldconfig. and it does seem to be...
debian:~# ldconfig -p | grep libks
libks2.so.2 (libc6,x86-64) => /lib/libks2.so.2
libks2.so (libc6,x86-64) => /lib/libks2.so
libksba.so.8 (libc6,x86-64) => /lib/x86_64-linux-gnu/libksba.so.8

I don't understand why make isn't picking it up. Any thoughts?

@mariogasparoni
Copy link
Author

mariogasparoni commented Jun 24, 2024

@wheatforwood , It looks like libks's headers are missing.

I tried building using debian's 11 docker container and i got no problem. Did you change something before building ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment