#! /bin/sh

# broken 

encoding=$1 

echo
rm -r ../dos/* 2>/dev/null
mkdir ../dos ../dos/cfg ../dos/doc
echo -n Preparing source files...
for i in $2 ; do cat $i |todos >../dos/$i 
	echo -n "$i "  
done;
echo ...done.
cd ../arch/unix
echo
echo -n 'Copying various ascii files... '
for i in $3; do cat $i |todos > ../dos/$i
	echo -n "$i "
done;
mv ../dos/config.dos ../dos/config.h
echo ...done.
cd ../doc
echo
echo -n 'Converting documentation... '
for i in * */* ; do if [ -d $i ]; then mkdir ../dos/doc/$i ; fi; done
for i in * */* ; do if [ -f $i ]; then cstocs il2 $encoding $i |todos > ../dos/doc/$i
	echo -n "$i "
fi; done
echo ...done.
cd ../cfg
echo
echo -n 'Converting configuration '
for i in * */* ; do if [ -d $i ]; then mkdir ../dos/cfg/$i ; fi; done
echo -n 'and data files...'
for i in inv/{*,*/*,*/*/*,*/*/*/*}; do
	cp $i ../dos/cfg/$i
	echo -n "$i "
done
echo -n .....
for i in {cfg/,lng/,prosody/}{*,*/*,*/*/*,*/*/*/*,../*} inv/*/*.ini; do
	if [ -f $i ]; then
		cstocs il2 $encoding $i |todos > ../dos/cfg/$i
		echo -n "$i "
	fi
done
mv -f ../arch/win/epos.ini ../dos/cfg/cfg/epos.ini

echo ...done.
echo Packing.
cd ../src
echo

eposversion=ep`../arch/unix/makever dos`

cd ..
ln -s dos $eposversion
zip -rmq dos/$eposversion.zip $eposversion/*
rm $eposversion
cd src
rm -r ../dos/doc ../dos/cfg &>/dev/null && echo && \
	echo Now you can copy ../dos/*zip to DOS. See also README.dos
echo 
