#! /bin/bash
# Install dependencies
sudo apt-get -y install libsdl1.2debian libsdl1.2-dev libsdl-ttf2.0-dev libsdl-image1.2-dev libexpat1-dev zlib1g-dev gcc make openjdk-6-jdk
# Download and compile XPilot NG
wget http://xpilot-ai.org/downloads/xpilot-ng-4.7.3.tar.gz
tar xfz xpilot-ng-4.7.3.tar.gz
rm xpilot-ng-4.7.3.tar.gz
mv xpilot-ng-4.7.3 xpilot-ai
cd xpilot-ai
./configure --prefix=$PWD --silent
make --silent
make install --silent
# Download and compile AI code
cd src/client/x11
wget http://xpilot-ai.org/downloads/AI.c
wget http://xpilot-ai.org/downloads/AI.java
wget http://xpilot-ai.org/downloads/doAI.sh
chmod +x doAI.sh
./doAI.sh
# Create an .xpilotrc (if not present)
if [ ! -a ~/.xpilotrc ]
  then
    echo "" > ~/.xpilotrc
fi


