#!/bin/csh
#  Script d'installation PEIDA 
#  Version preliminaire - Reza 27/11/97 +cmv

if( "$1" == "-h" ) then
  echo "install_peida <-s repertoire source> <-d repertoire destination>"
  echo "              [-m nom_machine-compilateur]"
  if($?DPCDEVREP) then
    echo " - defaut repertoire source: $DPCDEVREP"
  else
    echo "   pas de defaut donnez explicitement le repertoire source"
  endif
  if($?DPCBASEREP) then
    echo " - defaut repertoire destination: $DPCBASEREP"
  else
    echo "   pas de defaut donnez explicitement le repertoire destination"
  endif
  echo " - possibilites nom_machine-compilateur"
  echo "    [AIX-xlC AIX-g++ HP-UX-aCC HP-UX-g++ OSF1-cxx OSF1-g++  Linux-g++ ...]"
  if($?EROSCXX) then
    echo "    defaut: `uname`-$EROSCXX"
  else
    echo "    pas de defaut donnez explicitement nom_machine-compilateur"
  endif
  exit -1
endif

unset srcdir
unset dstdir
unset macomp

while( $#argv > 1 )
  if( "$1" == "-s" ) then
    set srcdir = $2
  endif
  if( "$1" == "-d" ) then
    set dstdir = $2
  endif
  if( "$1" == "-m" ) then
    set macomp = $2
  endif
  shift
  shift
end

if( ! $?srcdir && $?DPCDEVREP ) then
  echo "defaut srcdir set to DPCDEVREP"
  set srcdir = $DPCDEVREP
endif
if( ! $?dstdir && $?DPCBASEREP ) then
  echo "defaut dstdir set to DPCBASEREP"
  set dstdir = $DPCBASEREP
endif
if( ! $?macomp && $?EROSCXX ) then
  echo "defaut macomp set to uname-EROSCXX"
  set macomp = `uname`-$EROSCXX
endif

if( ! $?srcdir || ! $?dstdir || ! $?macomp ) then
  echo "precisez ce que vous voulez:"
  echo srcdir=$?srcdir dstdir=$?dstdir macomp=$?macomp
  exit -1
else
  set SRC = $srcdir/$macomp
  set DST = $dstdir/$macomp
  echo "************** PEIDA_Install script : ****************** "
  echo "copie de $srcdir"
  echo "      vers $dstdir pour $macomp"
  echo "      pour $macomp"
  # echo "SRC= $SRC , DST= $DST"
  echo "********************************************************"
endif

#set DO = echo
set DO =

# d'abord les includes
#foreach d ( Include Include/tnt Include/CInc Include/SystCxx Include/Syst )
foreach d ( Include Include/tnt Include/CInc Include/Syst )
  echo "PEIDA_Install: Installing $d ... "
  if( ! -e $srcdir/$d ) then
    echo "rep. inexistant: $SRC/$d"
  else if( ! -e $dstdir/$d ) then
    echo "rep. inexistant: $DST/$d"
  else
    cd $srcdir/$d
    $DO cp * $dstdir/$d/.
    $DO chmod -R a+r $dstdir/$d/
  endif
end

# puis le reste
foreach d ( Libs ShLibs Exec )
  echo "PEIDA_Install: Installing $d ... "
  if( ! -e $SRC/$d ) then
    echo "rep. inexistant: $SRC/$d"
  else if( ! -e $DST/$d ) then
    echo "rep. inexistant: $DST/$d"
  else
    if( "$d" == "Exec" ) then
      foreach f ( tobjio tspm tspm2 piapp )
        if( -e $SRC/$d/$f ) then
          $DO cp $SRC/$d/$f $DST/$d/.
        endif
      end
      $DO chmod -R a+x $DST/$d/
    else
      cd $SRC/$d/.
      $DO cp * $DST/$d/.
    endif
    $DO chmod -R a+r $DST/$d/
  endif
end

echo 'PEIDA_Install complete'

exit 0
