#!/bin/sh

cd lib

echo "SPOVNET: preparing ..."
rm -rf ./boost*
rm -rf ./gmp*
rm -rf ./log*

echo "SPOVNET: downloading libraries needed by SpoVNet ..."
wget http://www.tm.uka.de/~mayer/spovnet/spovnet_libs_v2.tar.gz

echo "SPOVNET: unpacking libraries ..."
tar xfz ./spovnet_libs_v2.tar.gz
rm ./spovnet_libs_v2.tar.gz

echo "SPOVNET: start building libraries ..."

echo "SPOVNET: building boost ..."
cd boost_1_35_0
mkdir build
./configure --prefix=$PWD/build --with-libraries=thread,serialization,filesystem,system
make -j2
make install
cd build/lib
ln ./libboost_thread-*-1_35.so.1.35.0 ./libboost_thread.so
ln ./libboost_serialization-*-1_35.so.1.35.0 ./libboost_serialization.so
ln ./libboost_filesystem-*-1_35.so.1.35.0 ./libboost_filesystem.so
ln ./libboost_system-*-1_35.so.1.35.0 ./libboost_system.so
cd ..
cd ..
cd ..
echo "SPOVNET: building boost done!"

echo "SPOVNET: building gmp ..."
cd gmp_4_2_2
mkdir build
./configure --prefix=$PWD/build 
make -j2
make install
cd ..
echo "SPOVNET: building gmp done!"

echo "SPOVNET: building log4cxx ..."
cd log4cxx_0_10_0
mkdir build
./configure --prefix=$PWD/build 
make -j2
make install
cd ..
echo "SPOVNET: building log4cxx done!"

echo "Built all libraries needed by SpoVNet!";
cd ..
