#!/bin/sh

export PATH=$PATH:/usr/bin


#./configure --python=2.4 --without-clamav --without-dspam
#make doc
./configure
make libclamav/libclamav.so pydspam/pydspam.so
python doc/gendoc.py doc
make clean

for mp in doc/*.[18]; do
  man2html $mp | tail -n +3 > `echo $mp | sed 's/\.[0-9]$/.html/'`
done

if [ "$1" = "home" ]; then
  TARGET='home.salstar.sk:sh/sagator'
  shift
elif [ "$1" = "work" ]; then
  TARGET='salstar.sk:sh/sagator'
  shift
else
  TARGET='ftp:public_html/pub/antivir/sagator'
  EXTRA_EXCLUDE="--exclude=rsync"
fi

rsync -v \
 --archive \
 --recursive \
 --links \
 --perms \
 --times \
 --delete \
 -e 'ssh' \
 --exclude='DEADJOE' \
 --exclude='root/tmp/*' \
 --exclude='config/sgconf.py' \
 --exclude='*.pyc' --exclude='*.pyo' \
 --exclude='*~' \
 --exclude='.svn' --exclude='CVS*' \
 --exclude='*.o' --exclude='*.so' \
 $EXTRA_EXCLUDE \
 . "$TARGET"

#if [ ! "$1" = "noco" ]; then
#  cvs commit -m "$1" | grep -v '^\?.*\.pyc$'
#fi
