#!/bin/bash
# author: Sebastian Blumenthal
# date: 06.08.2009
#
# This scripts automatically downloads the patched (for gcc 4.3) Approximated Nearest 
# Neighbourhood (ANN) library and installs it into the defeat location /usr/local/lib/ANN. 
# The headers are installed at /usr/local/include/ANN. Source code is planted at 
# /usr/local/src/ann_1.1.1
# Feel free to change the script to your own needs. 
#
# NOTE: Tested with UBUNTU 9.04 + gcc 4.3
# ---- 

echo "Starting to install patched ANN library (version 1.1.1) for gcc 4.3"

#automatically download patched library (might be skipped if lib is already downloaded)
wget http://www.sebastianblumenthal.de/downloads/ann_1.1.1_fixed_gcc4.3.tar.gz
 
# copy src
sudo cp ann_1.1.1_fixed_gcc4.3.tar.gz /usr/local/src/ /usr/local/src/
cd /usr/local/src/
sudo tar -xvf ann_1.1.1_fixed_gcc4.3.tar.gz
cd ann_1.1.1

# compile code
sudo make linux-g++

# copy lib and headers
sudo mkdir /usr/local/lib/ANN
sudo cp /usr/local/src/ann_1.1.1/lib/libANN.a /usr/local/lib/ANN
sudo cp -r /usr/local/src/ann_1.1.1/include/ANN/ /usr/local/include

echo "Done."

