Я писал скрипт для WHS. В unix-е обошелся средствами qmake
contains( MAKEFILE_GENERATOR, MSVC.NET|MSBUILD ): {
#message($$basename(_FILE_):$$_LINE_ "=== msvc build detected!")
LIBS += Advapi32.lib
DEFINES += WINNT
QT_BUILDER = msvc
win32-msvc2005 : QT_BUILDER_VER=2005
else:win32-msvc2008: QT_BUILDER_VER=2008
else:win32-msvc2010: QT_BUILDER_VER=2010
else:win32-msvc2012: QT_BUILDER_VER=2012
else: QT_BUILDER_VER=xxxx
QMAKE_SH =
} else: {
contains( MAKEFILE_GENERATOR, MINGW ): {
#message($$basename(_FILE_):$$_LINE_ "=== mingw build detected!")
QT_BUILDER = mingw
!isEmpty(QMAKE_SH) {
#отлично! Есть шелл в Windows
MGW_MAJ = $$system(echo | gcc -dM -E - | grep __GNUC__ | cut -d\" \" -f 3)
MGW_MIN = $$system(echo | gcc -dM -E - | grep __GNUC_MINOR__ | cut -d\" \" -f 3)
MGW_PTH = $$system(echo | gcc -dM -E - | grep __GNUC_PATCHLEVEL__ | cut -d\" \" -f 3)
QT_BUILDER_VER = $$sprintf(%1.%2.%3, $$MGW_MAJ, $$MGW_MIN, $$MGW_PTH)
} else : {
# Шелла нет, использовать скрипт
QT_BUILDER_VER = $$system(cscript.exe /nologo $$PWD\\tools\\get.gcc.ver.vbs)
}
} else: {
#message($$basename(_FILE_):$$_LINE_ "=== GCC build detected!")
MGW_MAJ = $$system(echo | gcc -dM -E - | grep __GNUC__ | cut -d\" \" -f 3)
MGW_MIN = $$system(echo | gcc -dM -E - | grep __GNUC_MINOR__ | cut -d\" \" -f 3)
MGW_PTH = $$system(echo | gcc -dM -E - | grep __GNUC_PATCHLEVEL__ | cut -d\" \" -f 3)
QT_BUILDER_VER = $$sprintf(%1.%2.%3, $$MGW_MAJ, $$MGW_MIN, $$MGW_PTH)
QT_BUILDER = gcc
}
}
QT_BUILDER_VER_SHORT=$$replace(QT_BUILDER_VER, '\\.', "")
QT_VERSION = $$[QT_VERSION]
QT_VERSION_SHORT = $$replace(QT_VERSION, '\\.',)
!build_pass:message($$basename(_FILE_):$$_LINE_ SVN_REV=$$QT_BUILDER)
!build_pass:message($$basename(_FILE_):$$_LINE_ SVN_REV=$$QT_BUILDER_VER)