#!/bin/sh

TMP=/tmp
CWD=`pwd`

SRCDIR=../src

SUBDIRS=`find -type d | cut -f 2 -d "." | cut -f 2 -d "/" | uniq | xargs echo`

rm -f $TMP/filedirs.txt

find $SRCDIR -type f -name "*.cpp" | while read LINE; do
    echo "$LINE" >> $TMP/filedirs.txt
done

find $SRCDIR -type f -name "*.h" | while read LINE; do
    echo "$LINE" >> $TMP/filedirs.txt
done

find $SRCDIR -type f -name "*.ui" | while read LINE; do
    echo "$LINE" >> $TMP/filedirs.txt
done

FILES=`cat $TMP/filedirs.txt`

rm -f $TMP/filedirs.txt

echo "$FILES" | sort | uniq | while read LINE; do
    echo -n " \\
	$LINE" >> $TMP/filedirs.txt
done

SOURCES=`cat $TMP/filedirs.txt`

rm -f $TMP/filedirs.txt

rm -f $TMP/do_update_ts

for SUBDIR in $SUBDIRS ; do
    echo "#!/bin/sh

lupdate -verbose $SOURCES \\
    -ts $SUBDIR/alice.ts" > $TMP/do_update_ts

    chmod 777 $TMP/do_update_ts 

    $TMP/do_update_ts
done

#rm -f $TMP/do_update_ts
