#!/bin/bash
PHP_VERSION=${1-5.5.3}
PHP_ARCHIVE=php-$PHP_VERSION.tar.bz2
PHP_SOURCE=http://www.php.net/get/$PHP_ARCHIVE/from/www.php.net/mirror

# don't run the install process if we are in use mode
if [ ! $BASHINATE_USE ]; then
  # if we don't have the latest node version, then install
  log "Checking php version $PHP_VERSION installed";
  if [ ! -e $BASHINATE_INSTALL/php/$PHP_VERSION ]
  then
    log "Installing php version $PHP_VERSION"
    require packages gcc libmysqlclient-dev libxml2-dev

    fetchSource $PHP_SOURCE tar $PHP_ARCHIVE
    cd $BASHINATE_SOURCE/php-$PHP_VERSION

    # configure 
    log "- configuring"
    ./configure --prefix=$BASHINATE_INSTALL/php/$PHP_VERSION --enable-bcmath --with-mysql ||
      abort "!!! Unable to configure php build"

    # # make and install
    log "- compiling and installing"
    make && make install ||
      abort "!!! Unable to make php $PHP_VERSION"
  fi
fi

# linkBinaries rust/$PHP_VERSION/bin rust rustc rustdoc rusti rustpkg