#!/bin/csh

######################################################################
# This is a shell script that will build and install PGPLOT for you on 
# a Linux/g77 system.  You can inspect the commands to see what it does,
# to guide you for other systems.
# 
# pgplot needs a dedicated "installation directory", which is set to 
# "/usr/local/pgplot".  You'll need to set your PGPLOT_DIR environment
# variable to use it.
#
# -CED 2-Nov-2004

rm -rf pgplot
tar xvfz pgplot-5.2.2-cd4
cd pgplot-5.2.2-cd4
cp drivers.list drivers.list.orig
echo "\!###################" > drivers.list
echo "\!## Edit this file to make sure the correct drivers are NOT commented out." >> drivers.list
echo "\!## (delete the leading '!' on all drivers you want active)">> drivers.list
echo "\!## " >> drivers.list
echo "\!## Some drivers require external modules. See the PGPLOT documentation" >> drivers.list
echo "\!## for details." >> drivers.list
echo "\!####################" >> drivers.list
cat drivers.list.orig | perl -pe 's/^\!(\s*(GIDRIV|PNDRIV|PPDRIV|PSDRIV|WDDRIV|XWDRIV))/ $1/' >> drivers.list;
./makemake `pwd` linux g77_gcc
ln -s /usr/include/png.h .
ln -s /usr/include/pngconf.h .
ln -s /usr/include/zlib.h .
ln -s /usr/include/zconf.h .
make
make cpg
rm -rf /usr/local/pgplot
mkdir /usr/local/pgplot
cp -p libpgplot.a libcpgplot.a drivers.list grfont.dat rgb.txt pgxwin_server pgplot.doc pgdemo* /usr/local/pgplot
rm -f /usr/local/lib/libpgplot.a /usr/local/lib/libpgplot.so /usr/local/lib/libcpgplot.a
ln -s /usr/local/pgplot/libpgplot.a /usr/local/lib
ln -s /usr/local/pgplot/libcpgplot.a /usr/local/lib
cp -p cpgplot.h /usr/local/include

/sbin/ldconfig
cd ..

