Revision 1 (by moose, 2006/03/06 10:00:33) Initial Import
QT4DIR="$(getoptval --with-qt-dir)"
QT4DIR?=${QTDIR}
if "${QT4DIR}"="" echo Could not detect Qt4 install directory.

QT4INCDIR="$(getoptval --with-qt-include-dir)"
QT4INCDIR?=${QT4DIR}/include/qt4
if "${QT4INCDIR}"="/include/qt4" echo Could not detect Qt4 include directory.

QT4LIBDIR="$(getoptval --with-qt-lib-dir)"
QT4LIBDIR?=${QT4DIR}/lib/qt4
if "${QT4LIBDIR}"="/lib/qt4" echo Could not detect Qt4 library directory.

QT4BINDIR="$(getoptval --with-qt-bin-dir)"
QT4BINDIR?=${QT4DIR}/bin
if "${QT4BINDIR}"="/bin" echo Could not detect Qt4 program directory.

if "${QT4DIR}"="" exit -1
if "${QT4INCDIR}"="/include/qt4" exit -1
if "${QT4LIBDIR}"="/lib/qt4" exit -1
if "${QT4BINDIR}"="/bin" exit -1

do ifnot "${QT4DIR}"=""
	put checking for Qt ${QT_MAJOR}.${QT_MIN_MINOR}...
	writefile tmp.cpp '/* safe to delete */'
	do ifret 0
		appendfile tmp.cpp \#include 
		appendfile tmp.cpp \#include 
		appendfile tmp.cpp \#include 
		appendfile tmp.cpp int main(int argc, char **argv) {
		appendfile tmp.cpp "	int qmajor = QT_VERSION >> 16, qminor = (char)(QT_VERSION >> 8), major = ${QT_MAJOR}, minor = ${QT_MIN_MINOR};"
		appendfile tmp.cpp '	FILE *fh = fopen("qt_version", "wt");'
		appendfile tmp.cpp '	fprintf(fh, "QT_VERSION='%s'\\nQT_MINOR=%i", QT_VERSION_STR, qminor); fclose(fh);'
		appendfile tmp.cpp '	if(major != qmajor) return -1;'
		appendfile tmp.cpp '	if(minor > qminor) return -1;'
		appendfile tmp.cpp '	return 0;'
		appendfile tmp.cpp }
		@!call ${CXX} -s -O2 -I${QT4INCDIR}/Qt -I${QT4INCDIR} -L${QT4LIBDIR} tmp.cpp ${OUT_OPT}tmp${EXE_EXT} #${QUIET}
		do ifret 0
			# empty 
			@!call ./tmp${EXE_EXT}
			do ifret 0
				invoke qt_version
				echo " ${QT_VERSION}"
				# echo ""
				# nothing?
			else
				echo Failed to find a suitable Qt lib :(
				echo set QTDIR, or pass --with-qt-dir=.
				exit -1
			done

			@call rm tmp tmp.cpp
		else
			echo " Failed to compile test program."
			echo " set QTDIR, or pass --with-qt-dir=."
			exit -1
		done
		
	done
else
	echo Qt4 path not specified, set QTDIR, or pass --with-qt-dir=.
done

${APPEND_CONFIG} \# Qt4 Config
${APPEND_CONFIG} QT_VERSION=${QT_VERSION}
${APPEND_CONFIG} QT_MINOR=${QT_MINOR}
${APPEND_CONFIG} QT4DIR=${QT4DIR}
${APPEND_CONFIG} QT4INCDIR=${QT4INCDIR}
${APPEND_CONFIG} QT4LIBDIR=${QT4LIBDIR}
${APPEND_CONFIG} QT4BINDIR=${QT4BINDIR}
${APPEND_CONFIG}