#!/bin/sh
# building PHP


# Installation of JFFNMS

TMPDIR=/tmp
BUILDDIR=$TMPDIR/jffnms.build-$$
JFFNMS_FILE_CACHE=/usr/src/jffnms
MYSQL_PREFIX=/usr/local/mysql
APACHE_PREFIX=/usr/local/apache

PROFILE_D=/etc/profile.d
MYSQL_PATH_SH=$PROFILE_D/mysql.sh
APACHE_PATH_SH=$PROFILE_D/apache.sh

mkdir $BUILDDIR
cd $BUILDDIR


echo BUILDING RRDTOOL

cd $BUILDDIR
tar zxf $JFFNMS_FILE_CACHE/rrdtool*

cd $BUILDDIR/rrdtool*

./configure --enable-shared --prefix=/usr/local

make
make install

echo Building SNMP
cd $BUILDDIR

tar zxf $JFFNMS_FILE_CACHE/ucd-snmp*
cd ucd-snmp*
./configure --prefix=/usr/local --enable-shared
make
make install

echo Building PHP4
# build php first with apache then without

cd $BUILDDIR
bunzip2 -c $JFFNMS_FILE_CACHE/php-4* | tar x
tar xzf $JFFNMS_FILE_CACHE/php4-rrdtool*
tar xzf $JFFNMS_FILE_CACHE/ucd-snmp*

cd php-4*
PHP_DIR=`pwd`

# add rrdtool
mkdir $PHP_DIR/ext/rrdtool
cd $BUILDIR
cd php4-rrdtool*
cp config.m4 rrdtool.c php_rrdtool.h Makefile.in $PHP_DIR/ext/rrdtool/
cd $PHP_DIR

# remove configure and rebuild it to give us --with-rrdtool opiton
rm -f configure
./buildconf

# configure and build w/ apache (libphp4.so)
./configure \
--prefix=/usr/local \
--disable-debug \
--enable-inline-optimization \
--with-apxs=$APACHE_PREFIX/bin/apxs \
--with-regex=system \
--with-ttf \
--with-zlib \
--enable-sockets \
--enable-track-vars \
--with-mysql=/usr/local/mysql \
--enable-shared=rrdtool \
--with-rrdtool=/usr/local/rrdtool \
--with-snmp=/usr/local \
--with-readline \
--with-openssl

make
make install

# Build without apache (php binary)
./configure \
--prefix=/usr/local \
--disable-debug \
--enable-inline-optimization \
--with-regex=system \
--with-ttf \
--with-zlib \
--enable-sockets \
--enable-track-vars \
--with-mysql=/usr/local/mysql \
--enable-shared=rrdtool \
--with-rrdtool=/usr/local/rrdtool \
--with-snmp=/usr/local \
--with-readline \
--with-openssl

make
make install


# now add the type statements to the httpd.conf
