#!/bin/sh
echo ""
echo "     /*****************************************************************/"
echo "     /**                       I N S T A L L                         **/"
echo "     /**                                                             **/"
echo "     /** This program installs the graphics software DISLIN. The va- **/"
echo "     /** riable  DISLIN must be set to  the directory  where  DISLIN **/"
echo "     /** should be installed:                                        **/"
echo "     /** For example:  DISLIN=/usr/local/dislin                      **/"
echo "     /**               export DISLIN                                 **/"
echo "     /**                                                             **/"
echo "     /** Date   : 15.11.2005                                         **/"
echo "     /** Version: 9.0 / Linux, Absoft F77 + F90 8.2,9.0              **/"
echo "     /*****************************************************************/"
echo ""

if test $DISLIN ; then
  echo "Installation of DISLIN in directory "${DISLIN}
  echo ""
else
  echo "The environment DISLIN is not defined!"
  exit 0
fi 

if test ! -d $DISLIN; then 
  mkdir $DISLIN 
  echo "The directory  "${DISLIN}"      is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}

if test ! -d $DISLIN/map; then 
  mkdir $DISLIN/map 
  echo "The directory  "${DISLIN}"/map  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/map

if test ! -d $DISLIN/man; then 
  mkdir $DISLIN/man 
  echo "The directory  "${DISLIN}"/man  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/man

if test ! -d $DISLIN/hlp; then 
  mkdir $DISLIN/hlp 
  echo "The directory  "${DISLIN}"/hlp  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/hlp

if test ! -d $DISLIN/fonts; then 
  mkdir $DISLIN/fonts 
  echo "The directory  "${DISLIN}"/fonts  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/fonts

if test ! -d $DISLIN/bin; then 
  mkdir $DISLIN/bin 
  echo "The directory  "${DISLIN}"/bin  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin

if test ! -d $DISLIN/lib; then 
  mkdir $DISLIN/lib 
  echo "The directory  "${DISLIN}"/lib  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/lib

if test ! -d $DISLIN/real64; then 
  mkdir $DISLIN/real64 
  echo "The directory  "${DISLIN}"/real64  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/real64

if test ! -d $DISLIN/examples; then 
  mkdir $DISLIN/examples
  echo "The directory  "${DISLIN}"/examples  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/examples

cp -p man/*.txt ${DISLIN}/man
echo "man/*         is copied to  "${DISLIN}"/man"
chmod u=rw,g=r,o=r ${DISLIN}/man/*

cp -p hlp/*.txt ${DISLIN}/hlp
echo "hlp/*         is copied to  "${DISLIN}"/hlp"
chmod u=rw,g=r,o=r ${DISLIN}/hlp/*

cp -p fonts/*.bdf ${DISLIN}/fonts
echo "fonts/*       is copied to  "${DISLIN}"/fonts"
chmod u=rw,g=r,o=r ${DISLIN}/fonts/*

cp -p linux_af90_rh9/bin/*      ${DISLIN}/bin
echo "linux_af90/bin  is copied to  "${DISLIN}"/bin"
   
chmod u=rwx,g=x,o=x ${DISLIN}/bin/*
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin/disdrv
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin/af77link
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin/af90link
cp -p $DISLIN/bin/af77link ${DISLIN}/bin/dlink
cp -p $DISLIN/bin/af90link ${DISLIN}/bin/f90link

cp -p linux_af90_rh9/lib/*        ${DISLIN}/lib
echo "linux_af90/lib  is copied to  "${DISLIN}"/lib"
   
chmod u=rw,g=r,o=r ${DISLIN}/lib/*.a
chmod u=rwx,g=rx,o=rx ${DISLIN}/lib/*.so

cp -p linux_af90_rh9/DISLIN.mod    ${DISLIN}
cp -p linux_af90_rh9/DISLIN_d.mod  ${DISLIN}/real64/DISLIN.mod
echo "DISLIN.mod    is copied to  "${DISLIN}
chmod u=rw,g=r,o=r ${DISLIN}/DISLIN.mod
chmod u=rw,g=r,o=r ${DISLIN}/real64/DISLIN.mod

cp -p linux_af90_rh9/dislin.f90    ${DISLIN}
cp -p linux_af90_rh9/dislin_d.f90    ${DISLIN}/real64/dislin.f90
chmod u=rw,g=r,o=r ${DISLIN}/dislin.f90
chmod u=rw,g=r,o=r ${DISLIN}/real64/dislin.f90
echo "dislin.f90    is copied to  "${DISLIN}

if test ! -f $DISLIN/device.dat ; then  
  cp -p device.dat ${DISLIN}
  chmod u=rw,g=r,o=r ${DISLIN}/device.dat
  echo "device.dat    is copied to  "${DISLIN}
fi

if test ! -f $DISLIN/dislin.log ; then  
  cp -p dislin.log ${DISLIN}
  chmod u=rw,g=rw,o=rw ${DISLIN}/dislin.log
  echo "dislin.log    is copied to  "${DISLIN}
fi

cp -p map/* ${DISLIN}/map
chmod u=rw,g=r,o=r ${DISLIN}/map/*
echo "map/*         is copied to  "${DISLIN}"/map"

cp -p README ${DISLIN}/README.AF
chmod u=rw ${DISLIN}/README.AF
echo "README.AF     is copied to  "${DISLIN}

cp -p DISLIN ${DISLIN}
chmod u=rw,g=r,o=r ${DISLIN}/DISLIN
echo "DISLIN        is copied to  "${DISLIN}

cp -p examples/exa_f77.f  ${DISLIN}/examples/exa_f77.f
cp -p examples/exa_f90.f90 ${DISLIN}/examples/exa_f90.f90
cp -p examples/map_f77.f  ${DISLIN}/examples/map_f77.f
cp -p examples/map_f90.f90 ${DISLIN}/examples/map_f90.f90
echo "examples/*    is copied to  "${DISLIN}
chmod u=rw,g=r,o=r ${DISLIN}/examples/*

ln -s -f ${DISLIN}/lib/disaf77-9.0.a    $DISLIN/libdisaf77.a
ln -s -f ${DISLIN}/lib/disaf90-9.0.a    $DISLIN/libdisaf90.a
ln -s -f ${DISLIN}/lib/disaf77_d-9.0.a  $DISLIN/libdisaf77_d.a
ln -s -f ${DISLIN}/lib/disaf90_d-9.0.a  $DISLIN/libdisaf90_d.a

ln -s -f ${DISLIN}/lib/disaf77-9.0.so   $DISLIN/libdisaf77.so.9
ln -s -f ${DISLIN}/libdisaf77.so.9      $DISLIN/libdisaf77.so
ln -s -f ${DISLIN}/lib/disaf90-9.0.so   $DISLIN/libdisaf90.so.9
ln -s -f ${DISLIN}/libdisaf90.so.9      $DISLIN/libdisaf90.so

ln -s -f ${DISLIN}/lib/disaf77_d-9.0.so $DISLIN/libdisaf77_d.so.9
ln -s -f ${DISLIN}/libdisaf77_d.so.9    $DISLIN/libdisaf77_d.so
ln -s -f ${DISLIN}/lib/disaf90_d-9.0.so $DISLIN/libdisaf90_d.so.9
ln -s -f ${DISLIN}/libdisaf90_d.so.9    $DISLIN/libdisaf90_d.so

ln -s -f ${DISLIN}/lib/disaf77-9.0.so   $DISLIN/libdisaf77.so.8
ln -s -f ${DISLIN}/lib/disaf90-9.0.so   $DISLIN/libdisaf90.so.8
ln -s -f ${DISLIN}/lib/disaf77_d-9.0.so $DISLIN/libdisaf77_d.so.8
ln -s -f ${DISLIN}/lib/disaf90_d-9.0.so $DISLIN/libdisaf90_d.so.8
echo "links were created in       "${DISLIN}
