#!/bin/sh
#/*************************************************************************/
#/* Program Database Toolkit (PDT)                                        */
#/* Copyright (C) 1998-2008                                               */
#/* University of Oregon, Department of Computer and Information Science  */
#/* Forschungszentrum Juelich, Zentralinstitut fuer Angewandte Mathematik */
#/* Los Alamos National Laboratory, Advanced Computing Laboratory         */
#/*************************************************************************/

unpack=no
platforms="alpha apple Windows hitachi hp9000s700 linux rs6000 sgi32 sgin32 sgi64 solaris2 t3e crayx1 ppc64 ia64 sun386i x86_64 mips"

for arg in "$@"
do 
  case $arg in 
  -u)
     unpack=yes
     shift
     ;;

  -platform=*)
     platforms=`echo $arg | sed -e 's/-platform=//'`
     shift
     ;;

  *) 
   echo "ERROR: Command line switch \`$arg' not recognized"
   echo "Usage: $0 [-u] [-platform=<arch>]"
   exit 1
   ;;
  esac
done

for i in $platforms
do
  if [ $unpack = yes ]
  then      
    if [ -f ${i}/bin/edgcpfe.gz ]
    then
      echo "Unpacking $i/bin ..."
      gunzip $i/bin/*.gz
    fi

    if [ -f ${i}/bin/gfortran/gfortran.gz ] ; then
	echo "Unpacking $i/bin/gfortran ..."
	gunzip $i/bin/gfortran/*.gz
    fi
  else 
    if [ -f ${i}/bin/edgcpfe ]
    then 
      echo "Packing $i/bin ..."
      gzip $i/bin/edgcpfe $i/bin/taucpdisp $i/bin/f90fe $i/bin/pdtf90disp 
    fi
    if [ -f ${i}/bin/pdtflint ]
    then
      gzip $i/bin/pdtflint
    fi
    if [ -f ${i}/bin/pdtflint.exe ]
    then
      gzip $i/bin/*.exe
    fi

    if [ -f ${i}/bin/gfortran/gfortran ] ; then
	echo "packing $i/bin/gfortran ..."
	gzip $i/bin/gfortran/*
    fi
  fi
done

if [ ! -h bgp ]
then
  ln -s ppc64 bgp
fi

if [ ! -h bgl ]
then
  ln -s ppc64 bgl
fi

if [ ! -h xt3 ]
then
  ln -s x86_64 xt3
fi

if [ ! -h craycnl ]
then
  ln -s x86_64 craycnl
fi

