#!/bin/sh

fatal() {
    echo $1
    exit 1
}

topdir=${TMPDIR:-/var/tmp}

target=$topdir/ical22

if test -d $target ; then 
   echo 'remove $target? (y/n)'
   read rep
   if test $rep != 'y' ; then 
      exit 1
   fi
   rm -rf $target
   test -d $target && fatal "Could not remove $target"
fi

mkdir $target || exit 1



tclfiles=" \
actions.tcl \
alarm.tcl \
apptlist.tcl \
canvsup.tcl \
dateeditor.tcl \
dayview.tcl \
dg_alarms.tcl \
dg_item.tcl \
dg_key.tcl \
dg_monthr.tcl \
dg_print.tcl \
dg_range.tcl \
dg_wdays.tcl \
help.tcl \
ical_x.tcl \
ical_text.tcl \
io.tcl \
itemlist.tcl \
itemwindow.tcl \
link.tcl \
listing.tcl \
notelist.tcl \
parse.tcl \
pref.tcl \
print.tcl \
support.tcl \
timerange.tcl \
trigger.tcl \
contrib/iconwindow.tcl \
contrib/timeofday.tcl \
contrib/weeknumber.tcl \
tcllib/canvas.tcl \
tcllib/tests/bug.tcl \
tcllib/tests/ctest.tcl \
tcllib/tests/error.tcl \
tcllib/tests/file.tcl \
tcllib/tests/num.tcl \
tcllib/tests/string.tcl \
tcllib/tests/yn.tcl \
tcllib/tests/ync.tcl \
tcllib/class.tcl \
tcllib/dg_bug.tcl \
tcllib/dg_error.tcl \
tcllib/dg_file.tcl \
tcllib/dg_num.tcl \
tcllib/dg_string.tcl \
tcllib/dg_yn.tcl \
tcllib/dg_ync.tcl \
tcllib/filesel.tcl \
tcllib/hooks.tcl \
tcllib/key.tcl \
tcllib/label.tcl \
tcllib/menus.tcl \
tcllib/ruler.tcl \
tcllib/support.tcl \
tcllib/textwin.tcl \
tclIndex \
tcllib/tclIndex"

tar cf - $tclfiles | (cd $target ; tar xf -)

cp -p Release/ical83.exe $target

(cd $topdir; rm -f ical22.zip ; zip -r ical22.zip ical22)
