#!/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, F                                     **/"
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/F; then 
  mkdir $DISLIN/F 
  echo "The directory  "${DISLIN}"/F  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/F

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

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/examples; then 
  mkdir $DISLIN/examples
  echo "The directory  "${DISLIN}"/examples  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/examples

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

cp -p linux_F_rh9/examples/*.f90 ${DISLIN}/examples/F
chmod u=rw,g=r,o=r ${DISLIN}/examples/F/*
echo "exampls/*.F      is copied to  "${DISLIN}"/examples/F"

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 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 README ${DISLIN}/README.F
chmod u=rw ${DISLIN}/README.F
echo "README.F         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 linux_F_rh9/lib/*        ${DISLIN}/lib
echo "linux_F/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_F_rh9/bin/*        ${DISLIN}/bin
echo "linux_F/bin   is copied to  "${DISLIN}/"bin"
   
chmod u=rwx,g=x,o=x ${DISLIN}/bin/*
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin/Flink
cp -p $DISLIN/bin/Flink $DISLIN/bin/f90link

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

cp -p linux_F_rh9/dislin.f90 ${DISLIN}/F
chmod u=rw  ${DISLIN}/F/dislin.f90
cp -p linux_F_rh9/dislin_d.f90 ${DISLIN}/F/real64/dislin.f90
chmod u=rw  ${DISLIN}/F/real64/dislin.f90
echo "dislin.f90       is copied to  "${DISLIN}

ln -s -f ${DISLIN}/lib/dislin-9.0.a    $DISLIN/libdislin.a
ln -s -f ${DISLIN}/lib/dislin_d-9.0.a  $DISLIN/libdislin_d.a

ln -s -f ${DISLIN}/lib/dislin-9.0.so   $DISLIN/libdislin.so.9
ln -s -f ${DISLIN}/libdislin.so.9      $DISLIN/libdislin.so
ln -s -f ${DISLIN}/lib/dislin_d-9.0.so $DISLIN/libdislin_d.so.9
ln -s -f ${DISLIN}/libdislin_d.so.9    $DISLIN/libdislin_d.so

ln -s -f ${DISLIN}/lib/dislin-9.0.so   $DISLIN/libdislin.so.8
ln -s -f ${DISLIN}/lib/dislin_d-9.0.so $DISLIN/libdislin_d.so.8

echo "links were created in       "${DISLIN}
