#!/bin/sh
# vim: set noexpandtab:

set -e

if [ `pwd | grep -e '.*\/debian$'`  ]; then
    echo "$0: you must run this script from the root of the freedict source."
    exit 127
fi

## variables
FILES='COPYING AUTHORS README INSTALL ChangeLog'
LANGLIST=`cat debian/dictionarylist`


for lang in $LANGLIST
do
    echo 'Generating docs for '$lang
    docsfile=debian/dict-freedict-$lang.docs
    for f in $FILES
    do
        if [ -f $lang/$f ]
        then
        	#
            if [ `stat -c %s "$lang/$f"` -eq 0 ]
            then
                echo "adding $lang/$f to debian/$docsfile."
                echo "$lang/$f" > $docsfile
            fi
        else
            echo "Skipping $lang/$f, is empty."
        fi
    done
done
