#!/bin/bash

# Here we create the dummy config files ...
echo "#ifndef CONFIG_H" > qdvdauthor/CONFIG.h
echo "#define CONFIG_H" >> qdvdauthor/CONFIG.h
echo "#define PREFIX_DIRECTORY $PREFIX" >> qdvdauthor/CONFIG.h
echo "#endif // CONFIG_H" >> qdvdauthor/CONFIG.h

echo "#ifndef MEDIA_CONFIG_H" > qdvdauthor/qplayer/MEDIA_CONFIG.h
echo "#define MEDIA_CONFIG_H" >> qdvdauthor/qplayer/MEDIA_CONFIG.h
echo "#define XINE_SUPPORT $WITH_XINE_SUPPORT" >> qdvdauthor/qplayer/MEDIA_CONFIG.h 
echo "#define MPLAYER_SUPPORT $WITH_MPLAYER_SUPPORT" >> qdvdauthor/qplayer/MEDIA_CONFIG.h
echo "#define VLC_SUPPORT $WITH_VLC_SUPPORT" >> qdvdauthor/qplayer/MEDIA_CONFIG.h
echo "#endif // MEDIA_CONFIG_H" >> qdvdauthor/qplayer/MEDIA_CONFIG.h

# Next we set all *.ui filess back to Qt version 3.1
find . -name "*?.ui" | while read ui_file
do
	replace=`grep DOCTYPE $ui_file | grep -v 'version="3.1"'`
	# And if we found some other then version 3.1 we change it back ...
	if [ "" != "$replace" ];
	then
        	echo $ui_file = "$replace"
	        mv $ui_file $ui_file.old
        	cat $ui_file.old | sed s/"$replace"/'<!DOCTYPE UI><UI version="3.1" stdsetdef="1">'/ > $ui_file
		rm $ui_file.old
	fi;
done;

rm Makefile
cd bin
rm configurator
rm qdvdauthor
rm qslideshow
rm qplayer
rm qrender

# This script cleans all sub projects for a neat and compact directory.
cd ../configurator/; make clean 
rm Makefile
rm -r .ui .moc .obj core*

cd ../qdvdauthor/; make clean 
rm Makefile
rm i18n/*.qm
rm CONFIG.h
rm core*

cd tools; make clean
rm core*

cd ../qslideshow/; make clean
rm Makefile
rm core*

cd ../qplayer/; make clean
rm Makefile
rm MEDIA_CONFIG.h
rm core

cd ../qrender/; make clean
rm Makefile
rm core

cd ..
rm -r .ui .moc .obj
rm core*

cd ../manual; make clean
rm core*

cd ..
sourceFiles=`cat \`find . -name "*.cpp"\` | wc -l`
sourceHeader=`cat \`find . -name "*.h"\`  | wc -l`
echo "Source=$sourceFiles + Header=$sourceHeader  => LOC=$(( sourceFiles + sourceHeader ))"
echo


