#! /bin/sh
#
# Author      : Olivier.Sirol@lip6.fr
# Date        : dec 1998
# Description : 
#
# (C) Czo 1998,99
# This code is released under GPL
# $Id: multibuild,v 1.9 2002/02/26 11:24:55 czo Exp $
#

#set +x
#set -x

# I made this script to build alliance on multiple architectures
# Modify it to suit you site


#WKSOSLIST="Linux Solaris"
#WKSLIST="bip beny"

WKSOSLIST="Linux"
WKSLIST="bip"


TMPFILE=/tmp/albuild.$$
TMPD=tmp$$

STARTDIR=`pwd`
cd ../..
ALLIANCEDIR=`pwd`

echo "Removing old source mirror and archi..."
mkdir $TMPD
mv -f sce-* $TMPD 
mv -f archi $TMPD
rm -fr $TMPD &
if [ $? -ne 0 ] ; then echo "Error, exiting" ; exit 4 ; fi


echo "Updating CVS sources..."
CVSROOT=/users/outil/alliance/cvsroot
cvs update -d -P 
if [ $? -ne 0 ] ; then echo "Error, exiting" ; exit 4 ; fi

echo "Creating source mirror..."
for WKS in $WKSOSLIST
do
 mkdir -p "sce-$WKS"
 cd "sce-$WKS"; lndir ../sources . ; cd ..
if [ $? -ne 0 ] ; then echo "Error, exiting" ; exit 4 ; fi
done

# # I build NT binaries on an NT machine but BSD/Samba 
# # file server, this avoids unix/cygwin soft links problems.
# echo "Copying sources for Cygwin ..."
# mkdir -p "archi/Cygwin/bin"
# mkdir -p "archi/Cygwin/include"
# mkdir -p "archi/Cygwin/lib"
# cp -r sources sce-Cygwin
# cp -r share/* archi/Cygwin
# if [ $? -ne 0 ] ; then echo "Error, exiting" ; exit 4 ; fi

echo "loging onto each OS, cd sce-XXX, then run ./build"

cd $ALLIANCEDIR

for WKS in $WKSLIST

do
ssh -n $WKS "cd $ALLIANCEDIR/sce-\$MACHINE; ./build"  2>&1 | tee $TMPFILE
grep "###########       O K        #############" $TMPFILE
if [ $? -ne 0 ] ; then echo "Error, sce-$MACHINE, exiting" ; exit 4 ; fi

done

echo "done..."
echo "###########   O K pour tout le monde   #############"

