# (c) 2007 uberdose.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

READLINE=5.2
RUBY_BASE=1.8
RUBY=1.8.6
RUBY_GEMS=0.9.2
SVN=1.4.3
MYSQL_INSTALLATION=/usr/local
FAST_MYSQL_BASE=2.7

curl -O ftp://ftp.gnu.org/gnu/readline/readline-$READLINE.tar.gz
tar xzvf readline-$READLINE.tar.gz
cd readline-$READLINE
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O ftp://ftp.ruby-lang.org/pub/ruby/$RUBY_BASE/ruby-$RUBY.tar.gz
tar xzvf ruby-$RUBY.tar.gz
cd ruby-$RUBY
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local --enable-shared
make
sudo make install
sudo make install-doc
cd ..

curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-$RUBY_GEMS.tgz
tar xzvf rubygems-$RUBY_GEMS.tgz
cd rubygems-$RUBY_GEMS
sudo /usr/local/bin/ruby setup.rb
cd ..

sudo gem install rails --include-dependencies
sudo gem install mongrel --include-dependencies
sudo gem install capistrano --include-dependencies
sudo gem install termios --include-dependencies
sudo gem install mysql -- --with-mysql-dir=$MYSQL_INSTALLATION/mysql
sudo install_name_tool -change $MYSQL_INSTALLATION/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

# comment in if you want svn
#curl -O http://subversion.tigris.org/downloads/subversion-$SVN.tar.gz
#curl -O http://subversion.tigris.org/downloads/subversion-deps-$SVN.tar.gz
#tar xzvf subversion-$SVN.tar.gz
#tar xzvf subversion-deps-$SVN.tar.gz
#cd subversion-$SVN
#./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib
#make
#sudo make install
#cd ..


