#! /usr/local/bin/bash

if test -z "$1"; then
  echo "call: $0 <filename>"
  exit
fi

filelist=$1
dir=`dirname $0`
. $dir/get_paths

ml="`list_modules` l10n"

rm -f "$filelist"_* $filelist

: > $filelist

for mod in $ml; do
  dir=$BASEDIR/`get_path $mod`
  if test ! -d $dir; then
	echo "$mod does not exist in $PWD/../.."
  fi
  echo "$dir"
  find $dir/ -name "*.directory" -print >> $filelist
  find $dir/ -name "*.kdelnk" -print >> $filelist
  find $dir/ -name "*.desktop" -print >> $filelist
  find $dir/ -name "*.kimap" -print >> $filelist
  find $dir/ -name "*.themerc" -print >> $filelist
  find $dir/ -name "*.kcsrc" -print >> $filelist
  find $dir/ -name "*.setdlg" -print >> $filelist
  find $dir/ -name "index.theme" -print >> $filelist
  find $dir/ -name "eventsrc" -print >> $filelist
  find $dir/ -name "*.protocol" -print >> $filelist
done
find $BASEDIR/`get_path kdebase`/konqueror -name .svn -prune , -name "directory.*" -type f >> $filelist
find $BASEDIR/`get_path kdebase`/kdesktop -name .svn -prune , -name "directory.*" -type f >> $filelist 
find $BASEDIR/`get_path kdebase`/drkonqi -name "*rc" -print >> $filelist
find $BASEDIR/`get_path kdelibs`/kimgio -name \*.kimgio -print >> $filelist
find $BASEDIR/`get_path kdemultimedia`/noatun -name \*.plugin -print >> $filelist
find $BASEDIR/`get_path kdeaddons`/noatun-plugins -name \*.plugin -print >> $filelist
find $BASEDIR/`get_path kdebase`/khotkeys -name \*.khotkeys -print >> $filelist
find $BASEDIR/`get_path kdebase`/kwin -name \*.kwinrules -print >> $filelist
dir=`get_path kdegames`
cat $BASEDIR/$dir/kolf/courses.list >> $filelist
find $BASEDIR/`get_path kdetoys`/amor/data -name \*rc -print >> $filelist
find $BASEDIR/`get_path kdelibs`/kdeprint -name \*.print -print >> $filelist
find $BASEDIR/`get_path kdebase` -name \*.kksrc -print >> $filelist
find $BASEDIR/`get_path kdenetwork`/kopete -name \*.plugin -print >> $filelist
find $BASEDIR/`get_path kdevelop` -name \*.kdevtemplate -print >> $filelist

# Extract .directory files in template directories of KOffice
find $BASEDIR/`get_path koffice` -name .directory|fgrep templates >> $filelist

sort -o $filelist -u $filelist

for mod in $ml; do 
    subfile="$filelist"_$mod
    grep $BASEDIR/`get_path $mod`/ $filelist > $subfile
done
