#!/bin/tcsh -f

if(! -f configure) then
  echo "run this script from the root directory of CVS working directory"
  echo "which is where the 'conigure' script resides"
  exit 1
endif

if( "$1" == "") then
  echo "usage : $0 <version> <name extension> <options to configure ...>"
  exit
endif

set dir_name="dar$2-$1-i386-windows"
set build_dir=`pwd`/$dir_name
echo "install directory is $build_dir"
if( -e $build_dir) then
   echo "cannot create $build_dir file exists"
   exit 1
endif
mkdir $build_dir
make clean distclean || echo "ignoring error, tree already clean"
setenv CXXFLAGS -O
./configure --prefix=$build_dir $3 $4 $5 $6 $7 $8 $9
make
make install-strip
mv $build_dir/bin/* $build_dir/lib/*.so.*.*.* $build_dir
cp /bin/cygwin1.dll /bin/cygz.dll /bin/cygbz2-1.dll /bin/cygiconv-2.dll /bin/cygintl-3.dll /usr/bin/cygintl-8.dll $build_dir
cp -R doc $build_dir
foreach fichier (README TODO INSTALL ChangeLog THANKS COPYING)
   cp $fichier "$build_dir/`basename $fichier`.txt"
   misc/todos "$build_dir/`basename $fichier`.txt"
end
rm -rf $build_dir/man $build_dir/bin $build_dir/lib $build_dir/include
rm -rf $build_dir/share
zip -9 -r "$dir_name".zip $dir_name
rm -rf $build_dir
