#!/bin/csh -f
set master=$PWD
echo Setting up CCP4 in directory $master
echo Remember to execute the following command in each new csh:
echo   source $master/ccp4/include/ccp4.setup

wget ftp://ftp.ccp4.ac.uk/ccp4/5.0.2/packed/ccp4-5.0.2.tar.gz 

gunzip -c ./ccp4-5.0.2.tar.gz | tar -xf - 

cat <<eof > $master/ccp4-5.0.2/x-windows/Mosflm/big_cell.csh
#!/bin/csh
cd mosflm
foreach I ( control.f mosflm_all_ip_inc.for unoptimizable.f )
if (-e \$I) then
echo Redimensioning NREFLS \$I
sed s/"PARAMETER (NREFLS=100000)"/"PARAMETER (NREFLS=1000000)"/ \$I > tmp1
mv tmp1 \$I
endif
end
/bin/rm -f tmp1
eof
chmod u+x $master/ccp4-5.0.2/x-windows/Mosflm/big_cell.csh

cd $master/ccp4-5.0.2/x-windows/Mosflm
Q315.csh
big_cell.csh

cd $master

ln -s ccp4-5.0.2 ccp4

cat $master/ccp4/include/ccp4.setup-dist |\
  sed -e "s?setenv CCP4_MASTER[ \t]*/xtal?setenv CCP4_MASTER        ${master}?" |\
  sed -e 's?setenv CCP4I_TCLTK /usr/local/bin?setenv CCP4I_TCLTK $CCP4/tcltkblt/bin?' |\
  sed -e 's?set ccp4_first_in_path = 0?set ccp4_first_in_path = 1?' \
  > $master/ccp4/include/ccp4.setup

source $master/ccp4/include/ccp4.setup

cd $master
wget ftp://ftp.ccp4.ac.uk/tcltk/TclTk-8.3/Linux_shared_tcltkblt.tar.gz

cd $CCP4
mkdir tcltkblt; cd tcltkblt
gzip -dc $master/Linux_shared_tcltkblt.tar.gz | tar xf -

cd $CCP4
#now to compile your own:
./configure linux --with-shared-libs --with-x
echo compiling...
make > make.log
echo installing...
make install >> make.log
echo Done installing CCP4.
echo Remember to execute the following command in each new csh:
echo   source $master/ccp4/include/ccp4.setup
