#!/bin/sh

# Copyright (C) 1998-2009 Yves Renard
#
# This file is a part of GETFEM++
#
# Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
# under  the  terms  of the  GNU  Lesser General Public License as published
# by  the  Free Software Foundation;  either version 2.1 of the License,  or
# (at your option) any later version.
# This program  is  distributed  in  the  hope  that it will be useful,  but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
# You  should  have received a copy of the GNU Lesser General Public License
# along  with  this program;  if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.



if test $# -lt 3; then
 echo usage : test_dist getfem++-1.6 machine compiler login
 echo " faire  : getfem++-1.7 telline.cict.fr aCC mip"
 echo "         : getfem++-1.7 calmip.cict.fr CC"
 echo "         : getfem++-1.7 superdec cxx"
 echo "         : getfem++-1.7 superdec g++"
 echo "         : getfem++-1.7 gmmlinux2 g++-2.95"
 echo "         : getfem++-1.7 gmmlinux2 g++-3.0"
 echo "         : getfem++-1.7 gmmlinux2 g++-3.2"
 echo "         : getfem++-1.7 gmmlinux2 icc   "
 exit 0
fi


if test $# -lt 4; then 
  u=$(whoami)
else
  u=$4
fi

echo login name: $u


scp $1.tar.gz $u@$2:
ssh $u@$2 "/bin/sh -c 'PATH=/usr/bin:/usr/bsd:/usr/local/bin:/opt/aCC/bin:$PATH && export PATH && CXX=$3 && export CXX && mkdir -p temp_dist/$2/$3 && chmod -R u+rw temp_dist/$2/$3 && rm -rf temp_dist/$2/$3 && mkdir -p temp_dist/$2/$3 && cd temp_dist/$2/$3 && gunzip -c ../../../$1.tar.gz | tar xvf - && cd $1 && ./configure && (which gmake; if test \$? -ne 0; then make distcheck; else gmake distcheck; fi) && cd .. && chmod -R u+rw $1 && rm -fr $1 && touch $1.ok'"
