This file explains how to compile and install the CLAM libraries and 
applications from the source tarballs. Alternatively, CLAM website
provides already compiled packages for several platforms.

 1. Install CLAM dependencies

 This step is different for each architecture (Linux, Windows, MacOSX).
 Such platform dependant steps at detailed at the end of this file.
   
 2. Compile CLAM libraries from the source

 Checkout the subversion repository
 $ svn co http://iua-share.upf.edu/svn/clam/trunk 

 Or download the CLAM tarball (stable release or cvs snapshot) from the 
 web: [http://clam.iua.upf.es/download.html] 
 
 Change directory to CLAM/
 NEW! (April 4th) build directory is now CLAM/ instead of CLAM/scons/libs

 The simplest way to build and install the libraries is issuing :

        $ scons configure
        $ scons
        $ sudo scons install
 
 This will compile all the libraries with default options, and install
 them to the default dirs ( /usr/local/lib/ and /usr/local/include/ )

 Troubleshooting: in some scenarios, the first scons command ends with error
 and is necessary to re-run scons a second time.
 
 Tip: use "scons -j3" to take advantadge of multi-threading if you machine is a dual-core.

 To install clam in a non system-wide place (usefull when developing) use 
 scons configure with these options: (you must create the destination dir before)

	$ scons configure prefix=~/local
 
 Then export LD_LIBRARY_PATH=~/local/lib before running the apps with these libs.
 (Probably you also want to add this export line into your .bashrc)
 
 To see all available build options run:

        $ scons --help

 Note that scons saves the last used options in the options.cache file. 
 These options will be used by default in further "scons" commands.

 If you plan to use your CLAM build for performance-sensitive applications consult the
 tips below (4. Tips for increasing performance).
 
 MacOSX specific: the equivalent to LD_LIBRARY_PATH in mac is DYLD_LIBRARY_PATH.
   
 ** Warning about compiler Errors: ** 
 Because scons copies all sources in CLAM/scons/libs/ you must be aware that the 
 paths given by the g++ error log are NOT the original sources. For example, if scons 
 returns: "scons/libs/core/src/Processing.cxx:56: error: ..." you should not edit this 
 file but the one in src/ (searchable by  $ find  src/ -name "Processing.cxx")

 3. Compile CLAM applications.

 Applications can be download from the CLAM website in separate tarballs.
 If you are using svn they are folders at the CLAM trunk.
 Go to the root of the application source tree and issue: (maybe changing the prefix)

        $ scons prefix=/usr/local clam_prefix=/usr/local

 For further building options do :

        $ scons --help


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



2.1 Install CLAM dependencies on Linux

 Debian/Ubuntu
 (do "sudo apt-get install <packages>")

 * Packages to compile clam libs:
 build-essential scons ladspa-sdk libxerces27-dev libfftw3-dev libjack-dev libmad0-dev libogg-dev libsndfile1-dev libvorbis-dev libid3-3.8.3-dev libasound2-dev portaudio19-dev 

 ** to pass the tests: libcppunit-dev 

 * Qt4 packages to compile NetworkEditor and Annotator:
 qt4-dev-tools libqt4-dev libqt4-opengl-dev (the last, from revision 11755)

NOTE about Qt version: 
from CLAM svn revision 11755 support to qt4.3 is discontinued and qt4.4 is required.
If you are a Ubuntu 8.04 (Hardy) user you can enable the hardy-backports repository

* Qt3 packages to compile SMSTools and Voice2MIDI:
 libqt3-headers libqt3-mt-dev 

 
 Redhat / Fedora Core packages list (tested with FC5)
   gcc-c++ scons fftw2-devel fltk-devel libvorbis-devel libogg-devel qt-devel
   qt-designer libxml++-devel alsa-lib-devel libsndfile-devel ladspa-devel 
   id3lib-devel libXi-devel 
   Unofficial Pakages:
   libmad-devel (lvn5) jack-audio-connection-kit-devel (rhfc5.ccrma)
   qt4-devel, qt4 



2.2 Install CLAM dependencies on Mac OSX

Build instructions for CLAM in Mac OSX are currently in this wiki:

http://iua-share.upf.edu/wikis/clam/index.php/Devel/Mac_OSX_build



2.3 Install CLAM dependencies on Windows

See instructions on the wiki for native compilation with MinGW 
or cross compilation from Linux

 http://www.clam.iua.upf.edu/wikis/clam/index.php/Devel/Windows_MinGW_build
 http://www.clam.iua.upf.edu/wikis/clam/index.php/Devel/Windows_MinGW_cross_compile

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
 
 3. Tips for increasing performance

 If you plan to use CLAM in performance-sensitive applications it's a good idea to
 compile with the release flag set, as this tells the compiler to use optimizations:
 	
	$ scons configure release=1

 Also if you use the fourier transform a lot in CLAM, try using the fast fftw3 
 implementation:

 	$ scons configure with-fftw3=1

 Of course you can do both:

 	$ scons configure release=1 with-fftw3=1
 
 If you decide to use the fftw3 library you can further improve the fft performance
 by precomputing wisdom. The fftw3 tries to optimize the algorithms it uses for your
 system, this takes a long time at first but allows the transforms to be later 
 computed much faster. To calculate the wisdom for the transforms most often used in
 CLAM issue these commands (you need the fftw3 package):

 	$ fftw-wisdom -v -x -o wisdom rof32768 cif32768

 And then move the resulting wisdom file to the default system wisdom location (you
 need root access for this):

 	$ sudo mv wisdom /etc/fftw/

 Don't worry if the file /etc/fftw/wisdom already exists - you do not lose any
 information previously stored in it, because fftw-wisdom reads this file first and
 includes it in the new wisdom file it generates.

 Generating fftw wisdom has been tested under linux, for using wisdom on other 
 operating systems consult your fftw3 user documentation.
