#!/bin/sh

# 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
RRDTOOL_PREFIX=/usr/local/rrdtool
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 Graphviz and Webfonts and supporting libraries

# libpng-1.2.4.tar.bz2
# zlib-1.1.4.tar.gz

echo building zlib
tar zxf $JFFNMS_FILE_CACHE/zlib*

cd $BUILDDIR/zlib*

./configure --prefix=/usr/local

make

make install

cd $BUILDDIR
echo building gd

tar zxf $JFFNMS_FILE_CACHE/gd*
cd $BUILDDIR/gd*
make

# isntalls to /usr/local
make install

cd $BUILDDIR
bunzip2 -c  $JFFNMS_FILE_CACHE/libpng* | tar -x
cd $BUILDDIR/libpng*


rm -f *akfile

cp scripts/makefile.linux Makefile.old

# Change Path to the zlibs
 sed -e s+^ZLIBLIB.*+ZLIBLIB=/usr/local/lib+ < Makefile.old > Makefile.$$
 sed -e s+^ZLIBINC.*+ZLIBINC=/usr/local/include+ < Makefile.$$ > Makefile

make
make install


echo Building Graphviz
cd $BUILDDIR

tar zxf $JFFNMS_FILE_CACHE/graphviz*

cd $BUILDDIR/graphviz*

./configure --prefix=/usr/local \
		--with-zlibdir=/usr/local/lib \
		--with-zlibincludedir=/usr/local/include \
		--with-pngincludedir=/usr/local/include \
		--with-pnglibdir=/usr/local/lib



make
make install


echo Building NMAP

cd $BUILDDIR

tar zxf $JFFNMS_FILE_CACHE/nmap*

cd $BUILDDIR/nmap*

./configure --prefix=/usr/local
make
make install


echo BUILDING RRDTOOL

cd $BUILDDIR
tar zxf $JFFNMS_FILE_CACHE/rrdtool*

cd $BUILDDIR/rrdtool*

./configure --enable-shared --prefix=$RRDTOOL_PREFIX

make
make install

