#! /bin/sh

if [ -z "$QTDIR" ]
then
    echo "*******************************************************************************"
    echo " QTDIR is not set. This package requires a correctly set up"
    echo " qt. To get qt visit http://www.trolltech.com"
    echo "*******************************************************************************"
    exit -1
fi

QMAKE_TEST=`which qmake`
if [ ! -f "$QMAKE_TEST" ]
then
    echo "*******************************************************************************"
    echo " The qmake utility was not found. This package requires a correctly"
    echo " set up qmake. To get qmake visit http://www.trolltech.com or install"
    echo " a qt development package from your distribution
    echo "*******************************************************************************"
    exit -1
fi

if [ ! -f "$QTDIR/bin/uic" ]
then
    echo "*******************************************************************************"
    echo " The uic utility was not found. This package requires a correctly"
    echo " set up uic. To get uic visit http://www.trolltech.com or install"
    echo " a qt development package from your distribution
    echo "*******************************************************************************"
    exit -1
fi

echo "Creating Makefiles..." 


qmake QtDMM.pro -o Makefile 
cd src
qmake src.pro -o Makefile
cd ..

echo "Testing libraries & tools ..."

echo "#include <qglobal.h>" > qttest.cpp
echo "#include <stdio.h>" >> qttest.cpp
echo "int main(int argc, char **argv) { fprintf( stderr, \"Found Qt Version %s: \", QT_VERSION_STR );" >> qttest.cpp
echo "if (QT_VERSION >= 300) return 0; else return -1; }" >> qttest.cpp
g++ -I$QTDIR/include qttest.cpp
if ./a.out
then
echo "OK"
rm qttest.cpp 2>/dev/null
rm a.out 2>/dev/null
else
echo "Please upgrade your Qt installation"
rm qttest.cpp 2>/dev/null
rm a.out 2>/dev/null
exit -1
fi

if [ ! -f "$QTDIR/bin/moc" ]
then
    echo "*******************************************************************************"
    echo " The moc meta object compiler was not found. This package requires a"
    echo " correctly set up Qt. To get Qt, see http://www.trolltech.com"
    echo "*******************************************************************************"
    exit -1
fi

echo ""
echo "*******************************************************************************"
echo "Type make to compile QtDMM. After that you'll"
echo "find the binary in the bin directory."
echo ""
echo "Enjoy it! -- Matthias Toussaint <qtdmm@mtoussaint.de>"
echo "*******************************************************************************"



