UBUNTU:
-------

http://releases.ubuntu.com/14.04.1/ubuntu-14.04.1-server-amd64.iso


INSTALL PACKAGES:
-----------------

$ sudo apt-get update
$ sudo apt-get install git git-core subversion cvs mercurial
$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install ninja gyp libexpat1 libexpat1-dev libfreetype6 libfreetype6-dev


CONFIGURE GIT:
--------------

$ git config --global user.name "John Smith"
$ git config --global user.email "john@smith.org"
$ git config --global core.autocrlf false
$ git config --global core.filemode false
$ git config --global branch.autosetuprebase always


CONFIGURE GYP:
--------------

https://sites.google.com/a/chromium.org/dev/developers/how-tos/api-keys

$ mkdir ~/.gyp
$ vim ~/.gyp/include.gypi

{
 'variables': {
   'google_api_key':               'your_api_key',
   'google_default_client_id':     'your_client_id',
   'google_default_client_secret': 'your_client_secret',

   # … other variables you may have ...
 },
}

OR (without API keys baked in so it is provided at run-time)

$ cat >> ~/.bashrc<<EOD
export GOOGLE_API_KEY='your_api_key'
export GOOGLE_DEFAULT_CLIENT_ID='your_client_id'
export GOOGLE_DEFAULT_CLIENT_SECRET='your_client_secret'
EOD
$ export GOOGLE_API_KEY='your_api_key'
$ export GOOGLE_DEFAULT_CLIENT_ID='your_client_id'
$ export GOOGLE_DEFAULT_CLIENT_SECRET='your_client_secret'


INSTALL DEPOT_TOOLS:
--------------------

$ sudo mkdir /opt/repos
$ sudo chown john:john /opt/repos
$ cd /opt/repos
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ cat >> ~/.bashrc<<EOD
export PATH=/opt/repos/depot_tools:$PATH
EOD
$ export PATH=/opt/repos/depot_tools:$PATH


INSTALL JAVA:
-------------

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

$ cd archive
$ tar xzvf jdk-7u67-linux-x64.tar.gz
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jdk1.7.0_67 /usr/lib/jvm

$ cat >> ~/.bashrc<<EOD
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
EOD
$ export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_67/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_67/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_67/bin/javaws" 1
$ sudo update-alternatives --install "/usr/bin/keytool" "keytool" "/usr/lib/jvm/jdk1.7.0_67/bin/keytool" 1

sudo chmod a+x /usr/bin/java 
sudo chmod a+x /usr/bin/javac 
sudo chmod a+x /usr/bin/javaws
sudo chmod a+x /usr/bin/keytool
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0_67


COMPILING WEBRTC:
-----------------

$ echo "sudo apt-get install libpulse-dev glib-2.0 gobject-2.0 gtk+-2.0 gthread-2.0 libglib2.0-doc glib-2.0-dev gobject-2.0-dev gtk+-2.0-dev gthread-2.0-dev libnss3-dev libdbus-1-dev libgconf2-dev libgnome-keyring* libudev* g++ libnss3-dev libasound2-dev libjpeg62-dev libxv-dev libgtk2.0-dev libexpat1-dev libasound* pulseaudio*"

$ sudo apt-get install apt-file libgl1-mesa-glx-lts-trusty g++-multilib gcc-multilib
$ apt-file update

$ cd /opt/repos
$ mkdir webrtc
$ cd webrtc
$ gclient config http://webrtc.googlecode.com/svn/trunk
$ gclient sync --force

$ cd cd /opt/repos/webrtc/trunk
$ ./build/install-build-deps.sh

Generate ninja builds
$ cd /opt/repos/webrtc
$ ninja -C out/Debug
$ ninja -C out/Release

This is not needed
$ cd /opt/repos/webrtc
$ export GYP_GENERATORS=make
$ gclient runhooks --force
$ cd trunk/webrtc
$ make


INSTALL KALDI:
--------------

$ sudo apt-get install libatlas* liblapack* automake autogen autoconf aclocal speex libspeex-*

$ cd /opt/repos
$ svn co https://svn.code.sf.net/p/kaldi/code/trunk kaldi
$ svn co -r 4111 https://svn.code.sf.net/p/kaldi/code/sandbox/online kaldi-online

$ cd /opt/repos/kaldi/tools
$ make
$ ./install_portaudio.sh
$ cd ../src
$ ./configure --shared
$ make depend
$ make


$ cd /opt/repos/kaldi-online/tools
$ make
$ ./install_portaudio.sh
$ cd ../src
$ ./configure --shared
$ make depend
$ make


INSTALL DAHDI:
--------------

http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

$ tar xzvf dahdi-linux-complete-current.tar.gz 
$ cd dahdi-linux-complete-2.9.2+2.9.2
$ make
$ sudo make install
$ sudo make config


INSTALL LIBPRI:
---------------

http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz

$ tar xzvf libpri-1.4-current.tar.gz
$ cd libpri-1.4.15
$ make
$ sudo make install


INSTALL ASTERISK:
-----------------

http://downloads.asterisk.org/pub/telephony/certified-asterisk/certified-asterisk-11.6-current.tar.gz
http://downloads.asterisk.org/pub/telephony/certified-asterisk/certified-asterisk-1.8.15-current.tar.gz

$ sudo apt-get install mysql-server mysql-client mysql-workbench mysql-common mysqltuner php5-mysql unixODBC unixODBC-dev freetts libmysql* libical*  jack libjack-dev resample libresample1-dev openssl-* libspandsp* sqlite libiksemel* libvorbis* lua5.2 liblua5.2 libgmime-* libsrtp-* netsnmp-* libnewt* libpoppler-dev corosync corosync-dev libsqlite-dev freetds-dev libcorosync-dev libportaudio2 doxygen graphviz

$ tar xzvf certified-asterisk-1.8.15-current.tar.gz
$ cd certified-asterisk-1.8.15-current
$ sudo ./configure
$ sudo ./contrib/scripts/get_mp3_source.sh 
$ sudo make menuselect
$ sudo make
$ sudo make install
$ sudo make progdocs
$ sudo make samples


INSTALL UNIMRCP-DEPS:
---------------------

http://www.unimrcp.org/project/release-view/unimrcp-deps-1-2-1

$ tar xzvf unimrcp-deps-1.2.1.tar.g
$ cd unimrcp-deps-1.2.1
$ sudo ./build-dep-libs.sh 

$ cd libs/apr
$ sudo make
$ sudo make install

$ cd ../apr-util
$ sudo make
$ sudo make install

$ cd ../sofia-sip
$ sudo make
$ sudo make install


INSTALL SPHINXBASE:
-------------------

$ sudo mkdir -p /usr/local/share/software/archive
$ cd /usr/local/share/software
$ sudo tar xzvf archive/sphinxbase-0.8.tar.gz
$ cd sphinxbase-0.8
$ sudo ./configure
$ sudo make
$ sudo make install


INSTALL POCKETSPHINX:
---------------------

$ cd /usr/local/share/software
$ sudo tar xzvf archive/pocketsphinx-0.8.tar.gz 
$ cd pocketsphinx-0.8
$ sudo ./configure --with-sphinxbase=/usr/local/share/software/sphinxbase-0.8
$ sudo make
$ sudo make install


INSTALL FLITE:
--------------

$ cd /usr/local/share/software
$ sudo tar xjvf archive/flite-1.4-release.tar.bz2 
$ cd flite-1.4-release
$ sudo tar xjvf ../flite-1.4-WM-8KHzvoices.tar.bz2 
$ sudo ./configure --with-lang --with-vox --with-lex --enable-shared CFLAGS=-fPIC
$ sudo make
$ sudo make install


INSTALL SADE:
-------------

$ svn co https://41.181.16.116/svn/repos/sade sade


INSTALL UNIMRCP:
----------------

$ cd /opt/repos
$ svn checkout https://unimrcp.googlecode.com/svn/trunk unimrcp
$ ./bootstrap
$ ./configure --enable-flite-plugin --with-flite=/usr/local/share/software/flite-1.4-release --enable-pocketsphinx-plugin --with-pocketsphinx=/usr/local --with-sphinxbase=/usr/local/share/software/sphinxbase-0.8 --disable-kaldi-plugin --with-kaldi=/opt/repos/kaldi --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config
$ make
$ sudo make install

$ cd /usr/local/unimrcp/bin
$ sudo vim start.sh
#!/bin/bash

export LD_LIBRARY_PATH=/usr/local/apr/lib:/usr/local/unimrcp/lib:$LD_LIBRARY_PATH
cd /usr/local/unimrcp/bin
./unimrcpserver
$ sudo chmod a+x start.sh

INSTALL UNIMRCP-SOLUTIONS:
--------------------------

$ cd /opt/repos
$ svn co https://unimrcp.googlecode.com/svn/solutions unimrcp-solutions


INSTALL ASTERISK-UNIMRCP:
-------------------------

$ cd /opt/repos
$ svn co https://unimrcp.googlecode.com/svn/solutions/asterisk-unimrcp asterisk-unimrcp
$ cd asterisk-unimrcp
$ ./bootstrap
$ ./configure/etc/profile.d/depot_tools.s
$ make
$ make install


GENERAL:
--------

$ sudo vim /etc/ld.so.conf.d/local.conf
/usr/local/lib

$ sudo vim /etc/ld.so.conf.d/kaldi.conf
/opt/repos/kaldi-online/tools/portaudio/install/lib/
/opt/repos/kaldi-online/tools/openfst/lib
/opt/repos/kaldi-online/src/lib

$ sudo vim /etc/profile.d/apr.sh
export PATH=$PATH:/usr/local/apr/bin
$ sudo chmod a+x /etc/profile.d/apr.sh

$ sudo vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/jdk1.7.0_67
export JDK_HOME=/usr/jdk1.7.0_67
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$J2RE_HOME/bin:$PATH
$ sudo chmod a+x /etc/profile.d/java.sh

$ sudo vim /etc/profile.d/depot_tools.sh
export PATH=/opt/repos/depot_tools:$PATH
$ sudo chmod a+x /etc/profile.d/depot_tools.sh

$ sudo vim /etc/ld.so.conf.d/webrtc.conf
/opt/repos/webrtc/trunk/out/Release
$ sudo /sbin/ldconfig
$ ldd /opt/repos/webrtc/trunk/out/Release/libjingle_peerconnection_so.so


PATCH UNIMRCP:
--------------

$ cd /opt/repos/unimrcp/libs/mpf/src
$ mv mpf_activity_detector.c mpf_activity_detector.c.orig
$ cp /opt/repos/sade/trunk/unimrcp/libs/mpf/src/mpf_activity_detector.c ./
$ cd /opt/repos/unimrcp
$ diff -Naur libs/mpf/src/mpf_activity_detector.c.orig libs/mpf/src/mpf_activity_detector.c > webrtc_patch.txt
$ mv libs/mpf/src/mpf_activity_detector.c.orig libs/mpf/src/mpf_activity_detector.c
$ patch libs/mpf/src/mpf_activity_detector.c < webrtc_patch.txt 
$ rm -f webrtc_patch.txt

OR

$ cd /opt/repos/unimrcp/libs/mpf/src
$ cp /opt/repos/sade/trunk/unimrcp/libs/mpf/src/mpf_activity_detector.c ./


ADD WEBRTC TO UNIMRCP:
----------------------

Fix kaldi.mk (for kaldi-online) to look like this (remove check for dynamic and always add -fPIC to CXXFLAGS):
-------------------------------------------------------------------------------
# ifeq ($(KALDI_FLAVOR), dynamic)
# CXXFLAGS += -fPIC
# endif
-------------------------------------------------------------------------------

Copy files and directories from /opt/repos/sade/trunk/unimrcp over /opt/repos/unimrcp

$ cd /opt/repos/unimrcp
$ ./bootstrap
$ ./configure --enable-flite-plugin --with-flite=/usr/local/share/software/flite-1.4-release --enable-pocketsphinx-plugin --with-pocketsphinx=/usr/local --with-sphinxbase=/usr/local/share/software/sphinxbase-0.8 --enable-kaldi-plugin --with-kaldi=/opt/repos/kaldi-online --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --enable-webrtc --with-webrtc=/opt/repos/webrtc/trunk
$ make
$ sudo make install



