#!/bin/csh -f # # Installs PGPLOT # # Arguments: # # 1) the name of the tar.gz file (give full path) # # 2) the name of the directory containing the lib and include sub-directories # for linking to PGPLOT (must have write permission). These will contain links # to libraries and include files stored in the pgplot directory (next argument) # # 3) the name of the directory which will contain the grfont.dat, rgb.txt, libpgplot.a # etc files and be pointed at by PGPLOT_DIR # # 4) name of fortran compiler. choices: 'g77', 'gfortran' or 'g95' # # This script include several workarounds for problems with PGPLOT installation # including: # # 1) copes with gcc & gfortran or gcc & g95 # 2) allows compilation of the PNG drivers # 3) allows the html to be generated # 4) creates a shareable that is OK with python pgplot for g95 # # Search for 'EDIT NEXT LINE FOR DRIVERS' if you want different drivers if($#argv != 4) then echo "usage: installation_directory pgplot_dir compiler" exit 1 endif set tarfile = $1 set install_dir = $2 set pgplot_dir = $3 set FC = $4 if($FC != "gfortran" && $FC != "g77" && $FC != "g95" ) then echo "Can only have 'gfortran', 'g77' or 'g95'" exit 1 endif which $FC > /dev/null if( $status ) then echo "Compiler = $FC was not recognised; is it in the path or even installed?" exit 1 endif if( !(-d $install_dir) ) then echo "'installation directory' = $install_dir is not a directory" exit 1 endif if( !(-w $install_dir) ) then echo "unable to write to installation directory = $install_dir" exit 1 endif if( ! (-e ${install_dir}/lib) ) then mkdir ${install_dir}/lib endif if( ! (-e ${install_dir}/include) ) then mkdir ${install_dir}/include endif if( ! (-e $tarfile) ) then echo "Failed to find tar file = $tarfile" exit 1 endif if( !(-e $pgplot_dir) ) then mkdir $pgplot_dir endif if( !(-d $pgplot_dir) ) then echo "'pgplot_dir' = $pgplot_dir is not a directory" exit 1 endif if( !(-w $pgplot_dir) ) then echo "unable to write to pgplot_dir = $pgplot_dir" exit 1 endif set verbose # unpack in /tmp cd /tmp tar xvfz $tarfile echo "Unpacked tar file = $tarfile" cd $pgplot_dir # this line defines which drivers get uncommented. PNG, PostScript and Xwindows. # (the gif drivers does not seem to work with 'gfortran') # # EDIT NEXT LINE FOR DRIVERS #sed -e 's/^! PN/ PN/' -e 's/^! PS/ PS/' -e 's/^! XW/ XW/' /tmp/pgplot/drivers.list > drivers.list sed -e 's/^! PS/ PS/' -e 's/^! XW/ XW/' /tmp/pgplot/drivers.list > drivers.list # Get the compiler options right echo "FC = $FC" if($FC == "gfortran") then cp /tmp/pgplot/sys_linux/g77_gcc.conf local.conf sed -e 's/FCOMPL=.*/FCOMPL="gfortran"/' \ -e 's/FFLAGC=.*/FFLAGC="-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O"/' \ local.conf > local.conf.new mv local.conf.new local.conf set config = "" else if ($FC == "g95") then # a few fixes including a difficult one need for ppgplt in python to work cp /tmp/pgplot/sys_linux/g77_gcc.conf local.conf set file=`g95 -print-file-name=libf95.a` set dir=`dirname $file` sed -e 's/FCOMPL=.*/FCOMPL="g95"/' -e 's/FFLAGC=.*/FFLAGC="-Wall -fPIC -O"/' -e 's/FFLAGD=.*/FFLAGD="-Wall"/' \ -e 's%SHARED_LIB_LIBS.*%SHARED_LIB_LIBS="-L'$dir' -lf95"%' local.conf > local.conf.new mv local.conf.new local.conf set config = "" else if($FC == "g77") then set config = "g77_gcc" endif # make the makefile /tmp/pgplot/makemake /tmp/pgplot linux $config # fix up the png driver problem sed -e 's/^pndriv.o.*png.*//' makefile > makefile.new mv makefile.new makefile # Compile make || exit 1 # Now the C binding make cpg || exit 1 # now the html, with another workaround sed -e 's|^\#\!.*|\#\!/usr/bin/perl|' /tmp/pgplot/makehtml > /tmp/pgplot/makehtml.new mv /tmp/pgplot/makehtml.new /tmp/pgplot/makehtml chmod +x /tmp/pgplot/makehtml make pgplot.html make clean # Makes links to the files cd $install_dir/lib rm libpgplot.so libpgplot.a libcpgplot.a ln -sf $pgplot_dir/libpgplot.so ln -sf $pgplot_dir/libpgplot.a ln -sf $pgplot_dir/libcpgplot.a cd $install_dir/include ln -sf $pgplot_dir/cpgplot.h exit