#!/bin/sh
# Build script for php
# Use this for configure, make and make install for the php version 5.
# Change the version and the CFLAGS for your own system/hardware.
# Change the path settings for your OS installation.

APACHE_PREFIX=/usr/local/apache2
PHP_VER=5.2.3
PHP_PREFIX=/usr/local/php-$PHP_VER

echo "Installation tool for PHP-$PHP_VER"
echo "Configuring PHP-$PHP_VER ..."
sleep 3

cd php-$PHP_VER

CFLAGS='-O3 -march=i686 -mtune=i686' ./configure --prefix=$PHP_PREFIX \
	--with-apxs2=$APACHE_PREFIX/bin/apxs \
	--with-config-file-path=/usr/local/etc \
	--with-pear=$PHP_PREFIX/lib/pear \
	--disable-debug \
	--with-zlib=/usr \
	--with-bcmath \
	--with-bz2 \
	--with-gd \
	    --enable-gd-native-ttf \
	    --with-freetype-dir=/usr/include/freetype2/freetype \
	    --with-zlib-dir=/usr/include \
	    --with-jpeg-dir=/usr/include \
	    --with-png-dir=/usr/include \
	    --with-tiff-dir=/usr/include \
	    --with-ttf-dir=/usr/include \
	--enable-ftp \
	--enable-calendar \
	--enable-mailparse \
	--enable-mbstring \
	--enable-mbregex \
	--enable-memory-limit \
	--enable-sockets \
	--enable-sysvsem \
	--enable-sysvmsg \
	--enable-sysvshm \
	--with-mime-magic \
	--enable-dba=shared \
	    --with-gdbm=/usr \
	    --with-db4=/usr \
	    --with-inifile \
	    --with-flatfile \
	--with-mysql=/usr/local/mysql \
	--with-mysqli=/usr/local/mysql/bin/mysql_config \
	--with-pgsql=/usr/local/postgresql \
	--with-gettext \
	--with-openssl=/usr \
	--with-curl=/usr \
	--enable-dbase=shared \
	--enable-exif \
	--enable-memory-limit \
	--enable-zend-multibyte \
	--with-ldap=/usr \
	    --with-ldap-sasl=/usr \
	--with-mhash=/usr \
	--with-mcrypt=/usr \
	--enable-pdo \
	    --with-pdo-mysql=/usr/local/mysql \
	    --with-pdo-pgsql=/usr/local/postgresql \
	    --with-pdo-sqlite=/usr \
	--with-snmp=/usr \
	    --with-openssl-dir=/usr/include \
	--enable-soap \
	    --with-libxml-dir=/usr/include \
	--with-sqlite=/usr \
	    --enable-sqlite-utf8 \
	--enable-wddx \
	--enable-xml \
	    --with-libxml-dir=/usr \
	--with-xsl=/usr \
	--enable-zip
	

sleep 5
echo "   "
echo "Building PHP-$PHP_VER ..."
echo "   "
make -j4

# If you don't run as sudo/root leave the comments.

#sleep 5
#echo "   "
#echo "Installing PHP-$PHP_VER ..."
#echo "   "
#make install
#ln -sf $PHP_PREFIX /usr/local/php
