#!/bin/csh -f
#
# SETUP_csc: Creates softlinks for EASYPVM-files under include,lib/PVM_ARCH & bin
#
unalias *
unsetenv PVM_ARCH

set debug=$1

if ( ! $?PVM_ROOT_DIR ) then
   setenv PVM_ROOT_DIR  /appl/compiler/pvm3      # Modify this if necessary
endif

set INCDIR=/usr/local/include                        # Modify this if necessary
set LIBDIR=/usr/local/lib                            # Modify this if necessary
set BINDIR=/usr/local/bin                            # Modify this if necessary

set ROOTDIR=${PVM_ROOT_DIR}/easypvm3

set PVM_ARCH=`${ROOTDIR}/lib/pvmgetarch`

if ( "$PVM_ARCH" == "" ) then
  echo "$0: Cannot set PVM_ARCH"
endif

set libs=`ls ${ROOTDIR}/lib/${PVM_ARCH}/lib*.a`

set bins="`ls ${ROOTDIR}/lib/${PVM_ARCH}/pvm*`"
set bins="$bins `ls ${ROOTDIR}/bin/pvm*`"
set bins="$bins ${ROOTDIR}/lib/pvmgetarch"

set incs="${ROOTDIR}/include/easy.h ${ROOTDIR}/include/feasy.h"

echo "LIBs:"

foreach LIB ( $libs )
   set FILE=${LIBDIR}/`basename $LIB`
   echo "  Linking  $FILE --> $LIB"
   if ( ! -f $FILE ) then
     if ( "$debug" != "-d" ) then
       ln -s $LIB $FILE
     endif
   else
     echo "  Link already exist"
   endif
   ls -ld $FILE
end

echo "BINs:"

foreach BIN ( $bins )
   set FILE=${BINDIR}/`basename $BIN`
   echo "  Linking  $FILE --> $BIN"
   if ( ! -f $FILE ) then
     if ( "$debug" != "-d" ) then
       ln -s $BIN $FILE
     endif
   else
     echo "  Link already exist"
   endif
   ls -ld $FILE
end

echo "INCLUDEs:"

foreach INC ( $incs )
   set FILE=${INCDIR}/`basename $INC`
   echo "  Linking  $FILE --> $INC"
   if ( ! -f $FILE ) then
     if ( "$debug" != "-d" ) then
       ln -s $INC $FILE
     endif
   else
     echo "  Link already exist"
   endif
   ls -ld $FILE
end


exit 0

