#!/bin/sh
#
# update the version numbers in the win32 projects

echo this script is broken, needs updating
exit

tmp=tmp.$$

# bzflag top-level dir
for root in . .. ../.. ; do
  if [ -r $root/configure.in ] ; then
    break
  fi
done

# get version number from config file
BZVERSION=`grep ^AM_INIT_AUTOMAKE configure.in | sed -e 's/.* //g' -e 's/)//g'`
eval `grep "^VERSIONNUM *= *" $root/configure.in | sed -e 's/ *//g'`

# config.h files
for file in \
  $root/win32/config.h \
  $root/src/platform/MacBZFlag-prefix.h \
  $root/src/platform/MacOSX/MacBZFlag-prefix.h \
  ; do
  if [ ! -w $file ]; then
    echo "$file not found or not writable."
  else
    sed -e "s/#define VERSION \".*/#define VERSION \"$BZVERSION\"/g" \
        -e "s/#define BZVERSION [0-9]*/#define BZVERSION $VERSIONNUM/g"< $file > $tmp
    cat $tmp > $file
  fi
done

# dsp and vcproj
# vcproj's are gone?
for file in \
  $root/win32/*.dsp \
  $root/src/platform/MacBZFlag-prefix.h \
  $root/src/platform/MacOSX/MacBZFlag-prefix.h \
  ; do
  if [ ! -w $file ]; then
    echo "$file not found or not writable."
  else
    sed -e "s/VERSION=[0-9]*/VERSION=$VERSIONNUM/g" \
        -e "s/VERSIONNUM=[0-9]*/VERSIONNUM=$BZVERSION/g"< $file > $tmp
    cat $tmp > $file
  fi
done

# update installer filename
file=$root/win32/installer.dsp
if [ ! -w $file ]; then
  echo "$file not found or not writable."
else
  sed -e "s/BZFlag[0-9][^\"]*\"/BZFlag$BZVERSION.exe\"/g" < $file > $tmp
  cat $tmp > $file
fi

# update rpm spec file
file=$root/package/rpm/spec
if [ ! -w $file ]; then
  echo "$file not found or not writable."
else
  sed -e "s/^%define version .*$/%define version $BZVERSION/g" < $file > $tmp
  cat $tmp > $file
fi

# update README
file=$root/README
if [ ! -w $file ]; then
  echo "$file not found or not writable."
else
  sed -e "s/BZFlag [0-9]*\.[0-9]*[a-z]*[0-9]*$/BZFlag $BZVERSION/g" < $file > $tmp
  cat $tmp > $file
fi

# update lsm
# FIXME something should add filesizes
file=$root/bzflag.lsm
if [ ! -w $file ]; then
  echo "$file not found or not writable."
else
  sed -e "s/^Version:.*$/Version:	$BZVERSION/g" < $file > $tmp
  cat $tmp > $file
fi

rm $tmp

# Local Variables: ***
# mode:sh ***
# tab-width: 8 ***
# sh-indentation: 2 ***
# sh-basic-offset: 2 ***
# indent-tabs-mode: t ***
# End: ***
# ex: shiftwidth=2 tabstop=8
