#!/bin/sh
# script to generate the MPlayer HTML documentation from the XML sources,
# convert the manual page to text and HTML versions
# and generate the codecs status table
# Do not generate the program automatically, it is a security risk.
# Instead, use a version that we compiled ourselves manually.
make codecs2html
/codecs2html || cleanup 1
#codecs2html > /dev/null 2>&1 || cleanup 1
mkdir -p $DSTDIR || cleanup 1
mv $DOCSDIR/codecs-status.html $DSTDIR
nice -10 make doc || cleanup 1
rm -rf $DSTDIR/HTML
mv $DOCSDIR/HTML $DSTDIR
rm -rf $DSTDIR/tech
mv $DOCSDIR/tech $DSTDIR
# groff does not set the encoding in generated HTML ...
cat <<EOF > $TEMPDIR/encoding.sed
6i\\
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
EOF
# Convert man pages with legacy encodings
fixencoding ru KOI8-R
fixencoding hu ISO8859-2
fixencoding pl ISO8859-2
for lang in en de es fr it; do
fixencoding $lang ISO8859-1
done
cd $DOCSDIR/man/
for lang in $DOCSDIR/man/*; do
cd $lang
groff -m man -Thtml mplayer.1 > mplayer.1.html || cleanup 1
groff -m man -Tutf8 -rLL=78n mplayer.1 | col -bxp > mplayer.1.txt
sed -i -f $TEMPDIR/encoding.sed mplayer.1.html
cd ..
done