#!/bin/bash

if [[ "$(whoami)" != "root" ]]; then
	echo "Please run this script as root";
	exit 1;
fi

#unpack the sdk
echo " unpacking sdk (very long)... please wait"
if [[ -e /tmp/sdk.tar.gz ]]; then
	cd /var
	tar xf /tmp/sdk.tar.gz
	rm -f /tmp/sdk.tar.gz
fi
#install private headers
echo ""
echo " installing private headers"
apt-get -y --force-yes install --reinstall com.philippe.iphoneheaders

#download and install libgcc
echo ""
echo " downloading and installing libgcc"
wget  http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb -O/tmp/libgcc_4.2-20080410-1-6_iphoneos-arm.deb
if [[ -e /tmp/libgcc_4.2-20080410-1-6_iphoneos-arm.deb ]]; then
	dpkg -i /tmp/libgcc_4.2-20080410-1-6_iphoneos-arm.deb
fi

#install iphone-gcc
echo ""
echo " installing iphone-gcc and make"
apt-get -y --force-yes install iphone-gcc make