why you just can't have a look in sources of qmake?
IMHO, that's what you need and more.