Software to install
*******************

* mingw32, using Automated windows installer (when launched, choose candidate to have lastest binaries)
* msys, using windows installer too.

run msys as Administrator (right click on the icon, and click 'run as administrator')

Download zip and unzip (download setup.exe and run) from http://gnuwin32.sourceforge.net
	- add them to your path in msys terminal:
		export PATH=$PATH:/c/Program\ Files/GnuWin32/bin

Download from mingw download page (http://www.mingw.org, click download):
	- MSYS automake-1.11 
	- MSYS autoconf-2.63
	- MSYS libtool>=2.2.7 
	- MSYS libcrypt*-bin
	- MSYS perl
	- MSYS gettext-*bin* and gettext-*dev*
	===> Uncompress all these packages in /
	- from gcc-4.4 directory
		Download: 
			- gcc-core*-bin
			- gcc-core-*-dll
			- gcc-c++*-bin
			- gcc-c++*-dll
			- gmp*-dll
			- mpfr*-dll
	- w32api*-dev
	- mingwrt-dev and mingwrt-dll (mingw run time)
	- gnu binutils 2.19
	===> Uncompress all these packages in /mingw

note: lzma files can be uncompressed using tar --lzma -xvf <file>

* Download intltool (quicklink: 
	http://ftp.acc.umu.se/pub/GNOME/binaries/win32/intltool/0.40/intltool_0.40.4-1_win32.zip
	note: -dev package is not needed.)
  uncompress in  / with 'unzip' command.

* Download lastest gtk+bundle from http://www.gtk.org , uncompress in /
* Download libglade and libglade-dev >=2.6.3 from gnome ftp:
    http://ftp.gnome.org/pub/GNOME/binaries/win32/libglade/2.6/libglade-dev_2.6.4-1_win32.zip
    http://ftp.gnome.org/pub/GNOME/binaries/win32/libglade/2.6/libglade_2.6.4-1_win32.zip
    uncompress in /
* Download ActiveState perl and run the installer with default options (http://www.activestate.com , developer tools)
	Yes it is required despite MSYS perl is already installed.

* Download lastest linphone-deps from linphone downloads, misc directory:
    http://download.savannah.gnu.org/releases-noredirect/linphone/misc/)
    uncompress in /
* Download and install Inno Setup Compiler in its default path (required only if you run 'make setup.exe').

* HACKS:
	Move out /lib/libintl.la : it confuses libtool
		mv /lib/libintl.la /lib/libintl.la.bak
	Move out libstdc++.la in order to workaround a gcc-4.4.0 bug (or packaging bug):
		mv /mingw/lib/gcc/mingw32/4.4.0/libstdc++.la /mingw/lib/gcc/mingw32/4.4.0/libstdc++.la.bak

Get Linphone source code
************************

Install msys-git from (http://code.google.com/p/msysgit/)

It is recommended that you create a directory somewhere with a path without any spaces or ~ characters, for example
c:\sources\
Within msys-git bash, do
cd /c/sources
git clone git://git.savannah.nongnu.org/linphone.git


Building
********

WARNING: During the build, windows might slow down suddenly. Using ctl+alt+del to start the windows system monitor,
 you might see a process 'LVpSRV.exe' or something like this that eats 90% of cpu.
Kill it. Don't know what it is, but once killed, windows runs normally.

The following variables must be exported:

#use ActiveState perl instead of mingw perl
export PERL="/c/Perl/bin/perl"
export INTLTOOL_PERL="/c/Perl/bin/perl"
#add gnuwin32 tools to your path:
export PATH=$PATH:/c/Program\ Files/Gnuwin32/bin

for convenience the 'mingw-envsetup.sh' script in linphone sources does this, so you can just source it:
. ./mingw-envsetup.sh

#run autogen.sh after a git checkout or update
./autogen.sh
./configure --prefix=/opt/linphone --enable-shared --disable-static
make
#will install to /opt/linphone, required for compilation of plugins.
make install
#make a binary zip of linphone
make zip
#additionally you can make binary installer if you have Inno Setup 5 installed in its default path
make setup.exe

#build plugins
cd mediastreamer2/plugins/msx264
./autogen.sh
PKG_CONFIG_PATH=/opt/linphone/lib/pkgconfig ./configure --prefix=/opt/linphone --enable-shared --disable-static
#make a binary zip of this plugin
make zip
#or make an installer
make setup.exe

#the buddylookup plugin enables lookup of buddies in a remote database using xml-rpc over http/https.
cd coreapi/plugins/buddylookup
./autogen.sh
PKG_CONFIG_PATH=/opt/linphone/lib/pkgconfig ./configure --prefix=/opt/linphone --enable-shared --disable-static 
make
#make a binary zip of this plugin
make zip


******************************************************
*      Notes about linphone-deps generation          *
******************************************************

Linphone-deps is a collection of linphone dependencies, that are for some of them difficult
to find as windows binaries.
These notes are useful if you want to upgrade part of the software that is included in the
linphone-deps packages.

List of software included in linphone-deps:
libosip2  (compiled)
libeXosip2 (compiled)
libavcodec, libavutil, libavformat, libavdevice, libswscale (compiled, all these from ffmpeg)
libtheora (from the web)
libx264 (compiled from the version distributed from linphone's web site)
libogg (from the web)
libspeex, libspeexdsp (compiled, statically to workaround a dll-related crash)
libgnutls (from the web)
libgsm (from the web)
libxml2 (compiled)
libsoup (compiled)

Remarks:
For every package compiled that goes into linphone-deps, .la files (libtool files) must be removed to avoid libtool errors.
When running "make install DESTDIR=<somepath>", somepath must be absolute and should not contain any ~ or space.

- building ffmpeg 
  ./configure --enable-shared --disable-static --enable-memalign-hack --extra-cflags="-fno-common" --enable-gpl && make
  make install DESTDIR=/home/<myuser>/ffmpeg-install
  Copy to ~/ffmpeg-install/usr/local/* to linphone-deps/.
  Copy also all *.dll.a files from the build tree to lib/ directort of linphone-deps. These are the implibs necessary to link a program against the dlls.

- building libxml2: the binaries found on the internet are generated with MSVC++, and for obscure reason they are not suitable for building libsoup 
  (that requires libxml2).
  ./configure --enable-shared --disable-static && make && make install DESTDIR=/home/<myuser>/libxml2-install
  copy ~/libxml2-install/usr/local/* into linphone-deps/.

- building x264:
 
  * download yasm normal version windows executable from yasm project page:
  http://www.tortall.net/projects/yasm/wiki/Download
  copy it as /usr/local/bin/yasm.exe

  cd into x264/ dir then run:
  ./configure --enable-pic
  make
  make install DESTDIR=/home/<myuser>/x264-install
  then copy the content of ~/x264-install/usr/local/ into linphone-deps/.

- libgnutls (required for libsoup https support)
	- download binary zip from http://josefsson.org/gnutls4win.org
	- add to linphone-deps

- building libsoup (only required for buddylookup plugin)
	- download source from gnome ftp (warning: at the time of the writing only version 2.26.x can compile with the 
		glib version supplied in the gtk-bundle, 2.27 requires a new version of glib)
	- uncompress libgnutls zip in /
	- make sure you have libxml2 installed in /
	- apply a bugfix patch (fix gnutls support on windows, completely broken otherwise). The patch
		is in linphone-deps/src, apply it this way:
		cd libsoup-2.26.*
		cd libsoup
		patch -p0 < libsoup-gnutls-bugfix.patch
	- run:
		./configure --prefix=/usr --enable-shared --disable-static
		make
		make install
		make install DESTDIR=/home/<myuser>/libsoup-install
	- copy ~/libsoup-install/usr/* into linphone-deps/

Once you have everything in linphone-deps, remove .la files from lib:
	cd lib && rm -f *.la
