#!/bin/sh

MAKEFILES=`(find . -name Makefile -print ; echo ./Makefile) | sort | uniq -u`;

QTDIR=`( cd ../.. ; pwd )`

for a in $MAKEFILES ; do
    M=`dirname $a`/Makefile
    N=${M}.new
    cat > $N <<EOF
####### This section is automatically generated from
#######    `pwd`/Makefile

INCDIR	=	${QTDIR}/include
CFLAGS	=	${CFLAGS}
LFLAGS	=	-L`pwd`/lib ${LFLAGS}
CC	=	${CC}
MOC	=	`pwd`/bin/moc

####### End of automatically generated section
#
EOF
    sed -ne '/# *\$Source.*\$/,$ p' < $M >> $N
    rm -f $M
    mv $N $M
    echo edited $M
done

