Building Asterisk

From Wildsong
Jump to navigationJump to search

Recent changes to this doc: I am now using the pjsip library

  • 2016-Feb-04 Asterisk 13.7.1
  • 2016-Jan-16 Asterisk 13.7
  • 2015-Dec-10 Building on the new Vastra.
  • 2015-Jun-23 Adding XMPP support.
  • 2015-Jun -- Both vastra2 and bellman have been upgraded to Debian 8 and Asterisk 13.4 (trunk on Bellman)
  • 2015-Apr-11 -- Working on my Mac in the Novato public library using the Wildsong PBX virtualbox as my build environment.
  • 2015-Apr-12 -- rebuilding the copy of Asterisk that runs my home PBX on Bellman.

Prerequisites

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install build-essential subversion git ncurses-dev \
 libncurses5 libxml2 libxml2-dev doxygen libcurl4-openssl-dev \
 libncurses5-dev uuid-dev libjansson-dev libsqlite3-dev libspeex-dev python-gobject libresample1-dev libiksemel-dev\
 unixodbc unixodbc-bin unixodbc-dev libltdl-dev libmpg123-dev libmyodbc \
 libc-client2007e-dev libssl-dev libpam0g-dev

For calendars, which I don't have working yet but all the same this is what you need,

sudo apt-get -y install libical-dev libgcal-dev davical libneon27-dev

PJSIP

The PJSIP upgrade for SIP for Asterisk is done using plproject. I have built it but not using it yet. Read about it here: https://wiki.asterisk.org/wiki/display/AST/Building+and+Installing+pjproject

Developer option: Source download via version control

Download the pjsip code from pjsip.org, unpack, or get the experimental svn version. Likewise the asterisk code.

cd ~/src/asterisk/
svn checkout http://svn.pjsip.org/repos/pjproject/trunk pjproject-trunk
svn checkout http://svn.asterisk.org/svn/asterisk/trunk asterisk-trunk
git clone git://git.asterisk.org/dahdi/linux dahdi-linux
git clone git://git.asterisk.org/dahdi/tools dahdi-tools
svn checkout http://svn.asterisk.org/svn/libpri/branches/1.4 libpri

Production code option: Pjproject download from site

cd ~/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://www.pjsip.org/release/2.4.5/pjproject-2.4.5.tar.bz2

Pjproject build

Video support

sudo apt-get install libv4l-dev fswebcam qv4l2 v4l-utils
sudo apt-get install sdl yuv openh264

Suggested flags to configure the build:

cd pjproject-trunk
./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr CFLAGS='-O2 -DNDEBUG'
make dep
make -j 8
sudo make install
sudo ldconfig

More about PJSIP

Dahdi

Dahdi is the part of Asterisk that supports the PSTN hardware. You used to need Dahdi for MeetMe, which I am not using. There are two folders, dahdi-linux and dahdi-tools. Currently I only install Dahdi if I need the support for a PCI card.

sudo apt-get install   linux-headers-`uname -r`
cd dahdi-linux
make -j 6 all
sudo make install
sudo make config
cd ../dahdi-tools
autoconf
./configure
make -j 6
sudo make install

Asterisk

I use officially released code right now, not development releases. You can git clone to get development trunk or use this.

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar xzvf asterisk-13-current.tar.gz
cd asterisk-13.7.2

./configure -with-imap=system
# in add-ons turn on format-mp3 if you do this you need the next step
./contrib/scripts/get_mp3_source.sh
# I turn off a bunch of things I will never use
# note items marked XXX will not be built because of missing dependencies
make menuselect
# Using all the processor cores is MUCH FASTER... I have 8 on Bellman so I use them all
make -j 8
sudo make install
# sudo make samples  # optionally... installs all those files into /etc/asterisk/
# sudo make progdocs # optionally...

If you are rebuilding (for example to add pjsip late in the game) then update. (you can check in menuselect under 'resources' to make sure res-pjsip is included now)

git fetch
./configure
make clean
# etc as above

Packaging for Debian

I need to build packages for easier deployment. I don't want to build on Bellman (a production machine), I want to build on a build machine, create a DPKG file, copy the DPKG to Bellman and install it.

I grabbed Debian sources for asterisk with git, and used the debian directory there as the source for the package builds.

See https://www.debian.org/doc/manuals/maint-guide/first.en.html

sudo apt-get install -y debhelper
sudo apt-get install -y dh-make devscripts

sudo apt-get install -y dahdi-source
sudo apt-get install -y dh-systemd libreadline-dev
sudo apt-get install -y libgsm1-dev libtonezone-dev portaudio19-dev
sudo apt-get install -y libpri-dev libss7-dev libvpb-dev 
sudo apt-get install -y libcap2-dev libspandsp-dev libopenr2-dev libresample1-dev
sudo apt-get install -y libsrtp-dev libpjproject-dev libsrtp0-dev binutils-dev
sudo apt-get install -y dh-autoreconf libnewt-dev libsqlite0-dev
sudo apt-get install -y libsqlite-dev libspeexdsp-dev libpopt-dev 
sudo apt-get install -y libfreeradius-client-dev freetds-dev libvorbis-dev
sudo apt-get install -y libogg-dev libgmime-2.6-dev liblua5.1-0-dev
sudo apt-get install -y libspeexdsp-dev libpopt-dev

dh_make -f ../asterisk-13-current.tar.gz
  1. Find build dependencies, don't need this because we don't care about the source package.
dpkg-depcheck -d ./configure

# Build only binary packages and don't sign them
dpkg-buildpackage -us -uc -c -j8

Working with the Asterisk REST interface (ARI)

Asterisk REST Interface