Index: trunk/qmake/Makefile.os2-g++
===================================================================
--- trunk/qmake/Makefile.os2-g++	(revision 8)
+++ trunk/qmake/Makefile.os2-g++	(revision 8)
@@ -0,0 +1,206 @@
+#
+# specific stuff for gnu make
+#
+CXX	    =	g++
+CFLAGS	    =	-c -o$@ -O -s -Zomf \
+		-I. -Igenerators -Igenerators\unix -Igenerators\win32 -Igenerators\os2 -Igenerators\mac -I..\include -I..\src\tools \
+		-I..\mkspecs\os2-g++ \
+		-DQT_NO_TEXTCODEC -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL -DQT_NO_COMPRESS -DHAVE_QCONFIG_CPP
+CXXFLAGS    =   $(CFLAGS)
+LFLAGS	    =   -s -Zomf -Zstack 0x2000 -Zlinker /PM:VIO -Zlinker /EXEPACK:2
+LIBS	    =   -lregistry.dll
+LINKQMAKE   =	g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS)
+ADDCLEAN    =
+
+
+#qmake code
+OBJS=project.obj main.obj makefile.obj unixmake.obj unixmake2.obj borland_bmake.obj mingw_make.obj gnumake.obj \
+    msvc_nmake.obj msvc_dsp.obj msvc_vcproj.obj option.obj winmakefile.obj projectgenerator.obj \
+    metrowerks_xml.obj pbuilder_pbx.obj msvc_objectmodel.obj property.obj meta.obj qtmd5.obj
+
+#qt code
+QTOBJS=qstring.obj qlocale.obj quuid.obj qtextstream.obj qiodevice.obj qglobal.obj qgdict.obj qcstring.obj qdatastream.obj \
+    qgarray.obj qbuffer.obj qglist.obj qptrcollection.obj qfile.obj qfile_pm.obj qregexp.obj qgvector.obj \
+    qgcache.obj qbitarray.obj qdir.obj qfileinfo_pm.obj qdir_pm.obj qfileinfo.obj qdatetime.obj \
+    qstringlist.obj qmap.obj qlibrary.obj qlibrary_pm.obj qconfig.obj qsettings.obj qsettings_pm.obj qunicodetables.obj
+
+
+
+..\bin\qmake.exe: qmake.exe
+	copy qmake.exe ..\bin\qmake.exe
+	-del qmake.exe >nul 2>&1
+
+qmake.exe: $(OBJS) $(QTOBJS)
+	$(LINKQMAKE)
+
+clean::
+	-del $(OBJS) $(QTOBJS) $(ADDCLEAN) >nul 2>&1
+
+distclean:: clean
+	-del qmake.exe >nul 2>&1
+
+.c.obj:
+	$(CXX) $(CFLAGS) $<
+
+.cpp.obj:
+	$(CXX) $(CXXFLAGS) $<
+
+qconfig.obj: ..\src\tools\qconfig.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qconfig.cpp
+
+qlibrary.obj: ..\src\tools\qlibrary.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qlibrary.cpp
+
+qlibrary_pm.obj: ..\src\tools\qlibrary_pm.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qlibrary_pm.cpp
+
+qtextstream.obj: ..\src\tools\qtextstream.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qtextstream.cpp
+
+qiodevice.obj: ..\src\tools\qiodevice.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qiodevice.cpp
+
+qglobal.obj: ..\src\tools\qglobal.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qglobal.cpp
+
+qgdict.obj: ..\src\tools\qgdict.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qgdict.cpp
+
+qcstring.obj: ..\src\tools\qcstring.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qcstring.cpp
+
+qstring.obj: ..\src\tools\qstring.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qstring.cpp
+
+qlocale.obj: ..\src\tools\qlocale.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qlocale.cpp
+
+quuid.obj: ..\src\tools\quuid.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\quuid.cpp
+
+qdatastream.obj: ..\src\tools\qdatastream.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qdatastream.cpp
+
+qgarray.obj: ..\src\tools\qgarray.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qgarray.cpp
+
+qbuffer.obj: ..\src\tools\qbuffer.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qbuffer.cpp
+
+qglist.obj: ..\src\tools\qglist.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qglist.cpp
+
+qptrcollection.obj: ..\src\tools\qptrcollection.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qptrcollection.cpp
+
+qfile.obj: ..\src\tools\qfile.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qfile.cpp
+
+qfile_pm.obj: ..\src\tools\qfile_pm.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qfile_pm.cpp
+
+qtextcodec.obj: ..\src\codecs\qtextcodec.cpp
+	$(CXX) $(CXXFLAGS) ..\src\codecs\qtextcodec.cpp
+
+qregexp.obj: ..\src\tools\qregexp.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qregexp.cpp
+
+qgvector.obj: ..\src\tools\qgvector.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qgvector.cpp
+
+qgcache.obj: ..\src\tools\qgcache.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qgcache.cpp
+
+qbitarray.obj: ..\src\tools\qbitarray.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qbitarray.cpp
+
+qdir.obj: ..\src\tools\qdir.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qdir.cpp
+
+qsettings.obj: ..\src\tools\qsettings.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qsettings.cpp
+
+qsettings_pm.obj: ..\src\tools\qsettings_pm.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qsettings_pm.cpp
+
+qfileinfo_pm.obj: ..\src\tools\qfileinfo_pm.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qfileinfo_pm.cpp
+
+qdir_pm.obj: ..\src\tools\qdir_pm.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qdir_pm.cpp
+
+qfileinfo.obj: ..\src\tools\qfileinfo.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qfileinfo.cpp
+
+qdatetime.obj: ..\src\tools\qdatetime.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qdatetime.cpp
+
+qstringlist.obj: ..\src\tools\qstringlist.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qstringlist.cpp
+
+qmap.obj: ..\src\tools\qmap.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qmap.cpp
+
+qunicodetables.obj: ..\src\tools\qunicodetables.cpp
+	$(CXX) $(CXXFLAGS) ..\src\tools\qunicodetables.cpp
+
+makefile.obj: generators\makefile.cpp
+	$(CXX) $(CXXFLAGS) generators\makefile.cpp
+
+unixmake.obj: generators\unix\unixmake.cpp
+	$(CXX) $(CXXFLAGS) generators\unix\unixmake.cpp
+
+unixmake2.obj: generators\unix\unixmake2.cpp
+	$(CXX) $(CXXFLAGS) generators\unix\unixmake2.cpp
+
+winmakefile.obj: generators/win32/winmakefile.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/winmakefile.cpp
+
+borland_bmake.obj: generators/win32/borland_bmake.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/borland_bmake.cpp
+
+mingw_make.obj: generators/win32/mingw_make.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/mingw_make.cpp
+
+gnumake.obj: generators/os2/gnumake.cpp
+	$(CXX) $(CXXFLAGS) generators/os2/gnumake.cpp
+
+msvc_nmake.obj: generators/win32/msvc_nmake.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/msvc_nmake.cpp
+
+msvc_dsp.obj: generators/win32/msvc_dsp.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/msvc_dsp.cpp
+
+msvc_vcproj.obj: generators/win32/msvc_vcproj.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/msvc_vcproj.cpp
+
+msvc_objectmodel.obj: generators/win32/msvc_objectmodel.cpp
+	$(CXX) $(CXXFLAGS) generators/win32/msvc_objectmodel.cpp
+
+qtmd5.obj: qtmd5.cpp
+	$(CXX) $(CXXFLAGS) qtmd5.cpp
+
+project.obj: project.cpp project.h option.h
+	$(CXX) $(CXXFLAGS) project.cpp
+
+meta.obj: meta.cpp project.h option.h
+	$(CXX) $(CXXFLAGS) meta.cpp
+
+property.obj: property.cpp property.h option.h
+	$(CXX) $(CXXFLAGS) property.cpp
+
+main.obj: main.cpp project.h
+	$(CXX) $(CXXFLAGS) main.cpp
+
+option.obj: option.cpp option.h
+	$(CXX) $(CXXFLAGS) option.cpp
+
+projectgenerator.obj: generators/projectgenerator.cpp
+	$(CXX) $(CXXFLAGS) generators/projectgenerator.cpp
+
+metrowerks_xml.obj: generators/mac/metrowerks_xml.cpp
+	$(CXX) $(CXXFLAGS) generators/mac/metrowerks_xml.cpp
+
+pbuilder_pbx.obj: generators/mac/pbuilder_pbx.cpp
+	$(CXX) $(CXXFLAGS) generators/mac/pbuilder_pbx.cpp
+
Index: trunk/qmake/generators/makefile.cpp
===================================================================
--- trunk/qmake/generators/makefile.cpp	(revision 7)
+++ trunk/qmake/generators/makefile.cpp	(revision 8)
@@ -61,6 +61,10 @@
 QString mkdir_p_asstring(const QString &dir)
 {
+    //@@TODO (dmik): OS/2 cannot create multiple subdirs in mkdir.
+    //@@TODO (dmik): fix it here? (mkdir a\b\c = mkdir a;a\b;a\b\c)
     QString ret =  "@$(CHK_DIR_EXISTS) \"" + dir + "\" ";
-    if(Option::target_mode == Option::TARG_WIN_MODE)
+    if(Option::target_mode == Option::TARG_WIN_MODE ||
+        Option::target_mode == Option::TARG_OS2_MODE
+    )
 	ret += "$(MKDIR)";
     else
@@ -447,5 +451,6 @@
 	    } else {
 		if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
-		   (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') ||
+		   ((Option::target_mode == Option::TARG_WIN_MODE ||
+                     Option::target_mode == Option::TARG_OS2_MODE) && inc[1] != ':') ||
 		   ((Option::target_mode == Option::TARG_UNIX_MODE ||
 		     Option::target_mode == Option::TARG_QNX6_MODE ||
@@ -667,5 +672,5 @@
 		    path = path.right(path.length() - 1);
 		}
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
 		bool driveExists = TRUE;
 		if ( !QDir::isRelativePath( path ) ) {
@@ -694,5 +699,5 @@
 			}
 		    }
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
 		}
 #endif
@@ -1884,5 +1889,5 @@
 			uninst.append("\n\t");
 		    uninst.append(
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
 		    QString("-$(DEL_FILE)")
 #else
@@ -1901,5 +1906,5 @@
 			uninst.append("\n\t");
 		    uninst.append(
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
 			QString("-$(DEL_FILE)")
 #else
@@ -2449,4 +2454,5 @@
 #include "borland_bmake.h"
 #include "mingw_make.h"
+#include "gnumake.h"
 #include "msvc_dsp.h"
 #include "msvc_vcproj.h"
@@ -2484,4 +2490,6 @@
     } else if(gen == "MINGW") {
 	mkfile = new MingwMakefileGenerator(proj);
+    } else if(gen == "GNUMAKE") {
+	mkfile = new GNUMakefileGenerator(proj);
     } else if(gen == "METROWERKS") {
 	mkfile = new MetrowerksMakefileGenerator(proj);
Index: trunk/qmake/generators/os2/gnumake.cpp
===================================================================
--- trunk/qmake/generators/os2/gnumake.cpp	(revision 8)
+++ trunk/qmake/generators/os2/gnumake.cpp	(revision 8)
@@ -0,0 +1,766 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of GNUMakefileGenerator class.
+**
+** Copyright (C) 1992-2003 Trolltech AS.  All rights reserved.
+** Copyright (C) 2004 Norman ASA.  Initial OS/2 Port.
+** Copyright (C) 2005 netlabs.org.  Further OS/2 Development.
+**
+** This file is part of qmake.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "gnumake.h"
+#include "option.h"
+#include <qregexp.h>
+#include <qdir.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+GNUMakefileGenerator::GNUMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
+{
+}
+
+bool
+GNUMakefileGenerator::findLibraries() // todo - pascal
+{
+    return TRUE;
+}
+
+bool
+GNUMakefileGenerator::writeMakefile(QTextStream &t)
+{
+    writeHeader(t);
+    if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
+	t << "all clean:" << "\n\t"
+	  << "@echo \"Some of the required modules ("
+	  << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
+	  << "@echo \"Skipped.\"" << endl << endl;
+	writeMakeQmake(t);
+	return TRUE;
+    }
+
+    if(project->first("TEMPLATE") == "app" ||
+       project->first("TEMPLATE") == "lib") {
+	writeGNUParts(t);
+	return MakefileGenerator::writeMakefile(t);
+    }
+    else if(project->first("TEMPLATE") == "subdirs") {
+	writeSubDirs(t);
+	return TRUE;
+    }
+    return FALSE;
+ }
+
+void
+GNUMakefileGenerator::writeGNUParts(QTextStream &t)
+{
+    t << "QMAKESPECDIR	=	" << specdir() << endl << endl;
+    
+    t << "####### Compiler, tools and options" << endl << endl;
+    t << "CC		=	" << var("QMAKE_CC") << endl;
+    t << "CXX		=	" << var("QMAKE_CXX") << endl;
+    t << "LEX		= " << var("QMAKE_LEX") << endl;
+    t << "YACC		= " << var("QMAKE_YACC") << endl;
+    t << "CFLAGS	=	" << var("QMAKE_CFLAGS") << " "
+      << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
+      <<  varGlue("DEFINES","-D"," -D","") << endl;
+    t << "CXXFLAGS	=	" << var("QMAKE_CXXFLAGS") << " "
+      << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
+      << varGlue("DEFINES","-D"," -D","") << endl;
+    t << "LEXFLAGS	=" << var("QMAKE_LEXFLAGS") << endl;
+    t << "YACCFLAGS	=" << var("QMAKE_YACCFLAGS") << endl;
+
+    t << "INCPATH	=	";
+    QStringList &incs = project->variables()["INCLUDEPATH"];
+    for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
+	QString inc = (*incit);
+//@@TODO (dmik): old, remove
+//	inc.replace(QRegExp("\\\\$"), "\\\\");
+	inc.replace(QRegExp("\\\\$"), "");
+	inc.replace(QRegExp("\""), "");
+	t << " " << var ("QMAKE_CFLAGS_INCDIR") << "\"" << inc << "\"";
+    }
+    t << " " << var ("QMAKE_CFLAGS_INCDIR") << "\"$(QMAKESPECDIR)\"" << endl;
+    if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
+	t << "LINK	=	" << var("QMAKE_LINK") << endl;
+	t << "LFLAGS	=	" << var("QMAKE_LFLAGS") << endl;
+	t << "LIBS	=	";
+//@@TODO (dmik): old, remove
+//	if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
+//	    t << varGlue("QMAKE_LIBDIR","-L\"","\" -L\"","\"") << " ";
+//	t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
+        QString flag = var ("QMAKE_LFLAGS_LIBDIR") + "\""; 
+	if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
+	    t << varGlue ("QMAKE_LIBDIR", flag, "\" " + flag, "\"") << " ";
+        flag = var ("QMAKE_LFLAGS_LIB");
+        t << varGlue ("QMAKE_LIBS", flag, " " + flag, "") << endl;
+    }
+    else {
+	t << "LIB	=	" << var("QMAKE_LIB") << endl;
+    }
+    t << "MOC		=	" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
+			      Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
+    t << "UIC		=	" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
+			      Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
+    t << "QMAKE		=	" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
+			      Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
+    t << "IDC		=	" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
+			      Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
+    t << "IDL		=	" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
+			      Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
+    t << "ZIP		=	" << var("QMAKE_ZIP") << endl;
+    t << "COPY_FILE	=       " << var("QMAKE_COPY") << endl;
+    t << "COPY_DIR	=       " << var("QMAKE_COPY") << endl;
+    t << "DEL_FILE	=       " << var("QMAKE_DEL_FILE") << endl;
+    t << "DEL_DIR	=       " << var("QMAKE_DEL_DIR") << endl;
+    t << "MOVE		=       " << var("QMAKE_MOVE") << endl;
+    t << "IF_FILE_EXISTS =	" << var("QMAKE_IF_FILE_EXISTS") << endl;
+    t << "CHK_DIR_EXISTS =	" << var("QMAKE_CHK_DIR_EXISTS") << endl;
+    t << "MKDIR		=	" << var("QMAKE_MKDIR") << endl;
+    t << endl;
+
+    t << "####### Output directory" << endl << endl;
+    if (! project->variables()["OBJECTS_DIR"].isEmpty())
+	t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
+    else
+	t << "OBJECTS_DIR = ." << endl;
+    if (! project->variables()["MOC_DIR"].isEmpty())
+	t << "MOC_DIR = " << var("MOC_DIR").replace(QRegExp("\\\\$"),"") << endl;
+    else
+	t << "MOC_DIR = ." << endl;
+    t << endl;
+
+    t << "####### Files" << endl << endl;
+    t << "HEADERS =	" << varList("HEADERS") << endl;
+    t << "SOURCES =	" << varList("SOURCES") << endl;
+    t << "OBJECTS =	" << varList("OBJECTS") << endl;
+    t << "FORMS =	" << varList("FORMS") << endl;
+    t << "UICDECLS =	" << varList("UICDECLS") << endl;
+    t << "UICIMPLS =	" << varList("UICIMPLS") << endl;
+    t << "SRCMOC	=	" << varList("SRCMOC") << endl;
+    t << "OBJMOC	=	" << varList("OBJMOC") << endl;
+    
+    QString extraCompilerDeps;
+    if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
+	t << "OBJCOMP = " << varList("OBJCOMP") << endl;
+	extraCompilerDeps += " $(OBJCOMP) ";
+	
+	QStringList &comps = project->variables()["QMAKE_EXTRA_COMPILERS"];
+	for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
+	    QStringList &vars = project->variables()[(*compit) + ".variables"];
+	    for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
+		QStringList vals = project->variables()[(*varit)];
+		if(!vals.isEmpty())
+		    t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
+	    }
+	}
+    }
+    
+    if ( project->isEmpty( "DEF_FILE" ) ) {
+        if ( project->isActiveConfig("dll") ) {
+            t << "DEF_FILE	=	$(basename $(TARGET)).def" << endl;
+            project->variables()["QMAKE_CLEAN"].append( "$(DEF_FILE)" );
+            if ( !project->isEmpty( "DEF_FILE_TEMPLATE" ) ) {
+                t << "DEF_FILE_TEMPLATE = " << var( "DEF_FILE_TEMPLATE" ) << endl;
+                project->variables()["QMAKE_GENDEF_DEPS"] += "$(DEF_FILE_TEMPLATE)";
+            }
+            if ( !project->isEmpty( "DEF_FILE_MAP" ) ) {
+                t << "DEF_FILE_MAP = " << var( "DEF_FILE_MAP" ) << endl;
+                project->variables()["QMAKE_GENDEF_DEPS"] += "$(DEF_FILE_MAP)";
+            }
+        }
+    } else {
+        if ( !project->isEmpty( "DEF_FILE_TEMPLATE" ) ) {
+            fprintf( stderr, "Both DEF_FILE and DEF_FILE_TEMPLATE are specified.\n" );
+            fprintf( stderr, "Please specify one of them, not both." );
+            exit( 666 );
+        }
+        t << "DEF_FILE	=	" << var( "DEF_FILE" ) << endl;
+    }
+    
+    if ( project->isActiveConfig("dll") && !project->isEmpty( "QMAKE_RUN_IMPLIB" ) ) {
+        t << "TARGET_IMPLIB	=	$(basename $(TARGET)).lib" << endl;
+        project->variables()["QMAKE_CLEAN"].append( "$(TARGET_IMPLIB)" );
+    }
+
+    t << "DIST	=	" << varList("DISTFILES") << endl;
+    t << "TARGET	=	";
+    if( !project->variables()[ "DESTDIR" ].isEmpty() )
+	t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
+    else
+	t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
+    t << endl;
+    t << endl;
+
+    t << "####### Implicit rules" << endl << endl;
+    t << ".SUFFIXES: .c " << Option::cpp_ext.join (" ") << endl << endl;
+    t << ".c" + Option::obj_ext + ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
+    for (QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
+        t << (*it) + Option::obj_ext + ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
+    }
+
+    t << "####### Build rules" << endl << endl;
+    t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
+    t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) ";
+    if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
+        t << "$(DEF_FILE) " << extraCompilerDeps << var("POST_TARGETDEPS");
+        if ( project->isEmpty( "QMAKE_RUN_LINK" ) )
+            t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(DEF_FILE) $(OBJECTS) $(OBJMOC) $(LIBS)";
+        else
+            t << "\n\t" << var( "QMAKE_RUN_LINK" );
+        if ( project->isActiveConfig("dll") && !project->isEmpty( "QMAKE_RUN_IMPLIB" ) )
+            t << "\n\t" << var( "QMAKE_RUN_IMPLIB" );
+    } else {
+        t << extraCompilerDeps << var("POST_TARGETDEPS");
+        if ( project->isEmpty( "QMAKE_RUN_LIB" ) )
+            t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)";
+        else
+            t << "\n\t" << var( "QMAKE_RUN_LIB" );
+    }
+    t << extraCompilerDeps;
+    if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
+	QStringList dlldirs = project->variables()["DLLDESTDIR"];
+	for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
+	    t << "\n\t" << "$(COPY_FILE) $(TARGET) " << *dlldir;
+	}
+    }
+    QString targetfilename = project->variables()["TARGET"].first();
+    if(project->isActiveConfig("activeqt")) {
+	QString version = project->variables()["VERSION"].first();
+	if ( version.isEmpty() )
+	    version = "1.0";
+
+	if ( project->isActiveConfig("dll")) {
+	    t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
+	    t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
+	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
+	    t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
+	} else {
+	    t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
+	    t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
+	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
+	    t << "\n\t" << "-$(TARGET) -regserver";
+	}
+    }
+    t << endl << endl;
+
+    if ( project->isEmpty( "DEF_FILE" ) && project->isActiveConfig("dll") ) {
+        t << "$(DEF_FILE): " << var( "QMAKE_GENDEF_DEPS" );
+        t << valGlue (QStringList::split (" ;; ", var ("QMAKE_RUN_GENDEF")),
+                "\n\t", "\n\t", "") << endl << endl;
+    }
+    
+    if(!project->variables()["RC_FILE"].isEmpty()) {
+	t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
+	  << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),Option::obj_ext) << " --include-dir=" << QFileInfo(var("RC_FILE")).dirPath() << endl << endl;
+    }
+	project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),Option::obj_ext);
+
+    t << "mocables: $(SRCMOC)" << endl << endl;
+
+    if ( !project->isEmpty( "OBJECTS_DIR" ) ) 
+        t << "$(OBJECTS_DIR):" << "\n\t"
+          << "@$(CHK_DIR_EXISTS) $(OBJECTS_DIR) $(MKDIR) $(OBJECTS_DIR)" << endl << endl;
+
+    if ( !project->isEmpty( "MOC_DIR" ) ) 
+        t << "$(MOC_DIR):" << "\n\t"
+          << "@$(CHK_DIR_EXISTS) $(MOC_DIR) $(MKDIR) $(MOC_DIR)" << endl << endl;
+
+    writeMakeQmake(t);
+
+    QStringList dist_files;
+    for(
+        QStringList::Iterator it = Option::mkfile::project_files.begin();
+        it != Option::mkfile::project_files.end(); ++it
+    ) {
+        dist_files << fileFixify(*it);
+    }
+//@@TODO (dmik): guess we don't need to zip this    
+//    if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
+//	dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
+    if(!project->isEmpty("TRANSLATIONS"))
+	dist_files << var("TRANSLATIONS");
+    if(!project->isEmpty("FORMS")) {
+	QStringList &forms = project->variables()["FORMS"];
+	for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
+	    QString ui_h = fileFixify((*formit) + Option::h_ext.first());
+	    if(QFile::exists(ui_h) )
+		dist_files << ui_h;
+	}
+    }
+    t << "dist:" << "\n\t"
+      << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "
+      << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;
+
+    t << "clean:"
+      << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << "\n\t-$(DEL_FILE) $(TARGET)"
+      << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
+      << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
+    if ( project->isActiveConfig("activeqt")) {
+	t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
+	t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
+    }
+    if(!project->isEmpty("IMAGES"))
+	t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
+
+    if ( !project->isEmpty( "QMAKE_QUIET_CLEAN" ) ) {
+        QStringList &delf = project->variables()["QMAKE_QUIET_CLEAN"];
+        for( QStringList::Iterator it = delf.begin(); it != delf.end(); ++it ) {
+            t << "\n\t-@$(IF_FILE_EXISTS) " << (*it) << " $(DEL_FILE) " << (*it);
+        }
+    }
+    
+    // user defined targets
+    QStringList::Iterator it;
+    QStringList &qut = project->variables()["QMAKE_EXTRA_TARGETS"];
+
+    for(it = qut.begin(); it != qut.end(); ++it) {
+	QString targ = var((*it) + ".target"),
+		 cmd = var((*it) + ".commands"),
+           extradeps = var((*it) + ".extradeps"),
+                deps;
+	if(targ.isEmpty())
+	    targ = (*it);
+	QStringList &deplist = project->variables()[(*it) + ".depends"];
+	for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
+	    QString dep = var((*dep_it) + ".target");
+	    if(dep.isEmpty())
+		dep = (*dep_it);
+	    deps += " " + dep;
+	}
+	t << "\n\n";
+        if ( !extradeps.isEmpty() ) {
+            t << valGlue( QStringList::split (" ;; ", extradeps),
+                           targ + ": ", "\n" + targ + ": ", "\n" );
+        }
+	t << targ << ":" << deps << "\n\t"
+	  << valGlue( QStringList::split (" ;; ", cmd), "", "\n\t", "" );
+    }
+
+    t << endl << endl;
+   
+    QStringList &quc = project->variables()["QMAKE_EXTRA_COMPILERS"];
+    for(it = quc.begin(); it != quc.end(); ++it) {
+	QString tmp_out = project->variables()[(*it) + ".output"].first();
+	QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
+	QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
+	QStringList &vars = project->variables()[(*it) + ".variables"];
+	if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
+	    continue;
+	QStringList &tmp = project->variables()[(*it) + ".input"];
+	for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
+	    QStringList &inputs = project->variables()[(*it2)];
+	    for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
+		QFileInfo fi(Option::fixPathToLocalOS((*input)));
+		QString in = Option::fixPathToTargetOS((*input), FALSE),
+		       out = tmp_out, cmd = tmp_cmd, deps;
+		out.replace("${QMAKE_FILE_BASE}", fi.baseName());
+		out.replace("${QMAKE_FILE_NAME}", fi.fileName());
+		cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
+		cmd.replace("${QMAKE_FILE_OUT}", out);
+		cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
+		for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
+		    cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
+		if(!tmp_dep.isEmpty()) {
+		    char buff[256];
+		    QString dep_cmd = tmp_dep;
+		    dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
+		    if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
+			while(!feof(proc)) {
+			    int read_in = fread(buff, 1, 255, proc);
+			    if(!read_in)
+				break;
+			    int l = 0;
+			    for(int i = 0; i < read_in; i++) {
+				if(buff[i] == '\n' || buff[i] == ' ') {
+				    deps += " " + QCString(buff+l, (i - l) + 1);
+				    l = i;
+				}
+			    }
+			}
+			fclose(proc);
+		    }
+		}
+		t << out << ": " << in << deps << "\n\t"
+		  << valGlue( QStringList::split( " ;; ", cmd ), "", "\n\t", "" )
+                  << endl << endl;
+	    }
+	}
+    }
+    t << endl;
+}
+
+
+void
+GNUMakefileGenerator::init()
+{
+    if(init_flag)
+	return;
+    init_flag = TRUE;
+
+    /* this should probably not be here, but I'm using it to wrap the .t files */
+    if(project->first("TEMPLATE") == "app")
+	project->variables()["QMAKE_APP_FLAG"].append("1");
+    else if(project->first("TEMPLATE") == "lib")
+	project->variables()["QMAKE_LIB_FLAG"].append("1");
+    else if(project->first("TEMPLATE") == "subdirs") {
+	MakefileGenerator::init();
+	if(project->variables()["MAKEFILE"].isEmpty())
+	    project->variables()["MAKEFILE"].append("Makefile");
+	if(project->variables()["QMAKE"].isEmpty())
+	    project->variables()["QMAKE"].append("qmake");
+	return;
+    }
+
+    bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
+    project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
+
+    // LIBS defined in Profile comes first for gcc
+    project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
+    
+    QString targetfilename = project->variables()["TARGET"].first();
+    QStringList &configs = project->variables()["CONFIG"];
+    
+    if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
+	project->variables()["DEFINES"].append("QT_DLL");
+    
+    if (project->isActiveConfig("qt_dll"))
+	if (configs.findIndex("qt") == -1)
+	    configs.append("qt");
+    
+    if ( project->isActiveConfig("qt") ) {
+	if ( project->isActiveConfig( "plugin" ) ) {
+	    project->variables()["CONFIG"].append("dll");
+	    if(project->isActiveConfig("qt"))
+		project->variables()["DEFINES"].append("QT_PLUGIN");
+	}
+	if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
+         ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
+           project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
+          (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
+	    project->variables()["QMAKE_QT_DLL"].append("1");
+	    if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
+		project->variables()["CONFIG"].append("dll");
+	}
+	if ( project->isActiveConfig("thread") )
+	    project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
+	if ( project->isActiveConfig("accessibility" ) )
+	    project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
+	if ( project->isActiveConfig("tablet") )
+	    project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
+    }
+    
+    if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
+	project->variables()["CONFIG"].remove("staticlib");
+	project->variables()["QMAKE_APP_OR_DLL"].append("1");
+    } else {
+	project->variables()["CONFIG"].append("staticlib");
+    }
+    
+    if ( project->isActiveConfig("warn_off") ) {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
+    } else if ( project->isActiveConfig("warn_on") ) {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
+    }
+    
+    if ( project->isActiveConfig("debug") ) {
+        if ( project->isActiveConfig("thread") ) {
+	    // use the DLL RT even here
+	    if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
+		project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
+		project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
+	    } else {
+		project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
+		project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
+	    }
+	}
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
+	project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
+    } else {
+	if ( project->isActiveConfig("thread") ) {
+	    if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
+		project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
+		project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
+	    } else {
+		project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
+		project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
+	    }
+	}
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
+	project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
+    }
+    
+    if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
+	project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
+    
+    if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
+	project->variables()["CONFIG"].append("windows");
+    
+    if ( project->isActiveConfig("qt") ) {
+	project->variables()["CONFIG"].append("moc");
+	project->variables()["INCLUDEPATH"] +=	project->variables()["QMAKE_INCDIR_QT"];
+	project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
+	if ( !project->isActiveConfig("debug") )
+	    project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
+	if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
+	    if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
+		project->variables()["DEFINES"].append("QT_MAKEDLL");
+		project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
+	    }
+	} else {
+
+	    if ( project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
+                if(project->isActiveConfig("thread"))
+                    project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
+                else
+                    project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
+            } else {
+//@@TODO (dmik): old, remove            
+//	    if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
+                if(project->isActiveConfig("thread"))
+                    project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD_DLL"];
+                else
+                    project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_DLL"];
+		int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
+		if ( hver == -1 )
+		    hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
+		if(hver != -1) {
+		    QString ver;
+//@@TODO (dmik): old, remove 
+//		    ver.sprintf("libqt%s" QTDLL_POSTFIX "%d.a", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
+		    ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
+		    QStringList &libs = project->variables()["QMAKE_LIBS"];
+//@@TODO (dmik): remove the comment below                    
+// @@@HGTODO maybe we must change the replace regexp if we understand what's going on
+		    for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
+//@@TODO (dmik): old, remove            
+//			(*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
+//			(*libit).replace(QRegExp("-lqt(-mt)?"), ver);
+			(*libit).replace(QRegExp("qt(-mt)?(\\.lib)?"), ver);
+		}
+	    }
+	    if ( project->isActiveConfig( "activeqt" ) ) {
+		project->variables().remove("QMAKE_LIBS_QT_ENTRY");
+		project->variables()["QMAKE_LIBS_QT_ENTRY"] = "-lqaxserver";
+		if ( project->isActiveConfig( "dll" ) ) {
+		   project->variables()["QMAKE_LIBS"]  += project->variables()["QMAKE_LIBS_QT_ENTRY"];
+		}
+	    }
+            if ( !project->isEmpty( "QMAKE_LIBS_QT_ENTRY" ) ) { 
+                if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
+                    project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
+                }
+                // QMAKE_LIBS_QT_ENTRY should be first on the link line as it needs qt
+                project->variables()["QMAKE_LIBS"].remove(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
+                project->variables()["QMAKE_LIBS"].prepend(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
+            }
+	}
+    }
+    
+    if ( project->isActiveConfig("opengl") ) {
+	project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
+	project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
+    }
+    
+    if ( project->isActiveConfig("dll") ) {
+	project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
+	project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
+	project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
+	project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
+	if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
+	    project->variables()["TARGET_EXT"].append(
+		QStringList::split('.',project->first("VERSION")).join("") + ".dll");
+	} else {
+	    project->variables()["TARGET_EXT"].append(".dll");
+	}
+    } else {
+	project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
+	project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
+	project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
+	project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
+	if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
+	    project->variables()["TARGET_EXT"].append(".exe");
+	} else {
+//@@TODO (dmik): old, guess to remove
+//	    project->variables()["TARGET_EXT"].append(".a");
+//	    project->variables()["QMAKE_LFLAGS"].append("-static");
+//	    if(project->variables()["TARGET"].first().left(3) != "lib")
+//		project->variables()["TARGET"].first().prepend("lib");
+//	}
+	    project->variables()["TARGET_EXT"].append(".lib");
+	}
+    }
+    
+    if ( project->isActiveConfig("windows") ) {
+	if ( project->isActiveConfig("console") ) {
+	    project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
+	    project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
+	    project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
+	    project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
+	} else {
+	    project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
+	}
+	project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
+    } else {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
+	project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
+	project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
+    }
+    
+    if ( project->isActiveConfig("exceptions") ) {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
+    } else {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
+    }
+    
+    if ( project->isActiveConfig("rtti") ) {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
+    } else {
+	project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
+	project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
+    }
+
+    if ( project->isActiveConfig("moc") )
+	setMocAware(TRUE);
+    
+    // add -L libs to libdir
+    QStringList &libs = project->variables()["QMAKE_LIBS"];
+    for ( QStringList::Iterator libit = libs.begin(); libit != libs.end();  ) {
+	if ( (*libit).startsWith( "-L" ) ) {
+	    project->variables()["QMAKE_LIBDIR"] += (*libit).mid(2);
+	    libit = libs.remove( libit );
+	} else {
+	    ++libit;
+	}
+    }
+
+    project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
+	"HEADERS SOURCES DEF_FILE DEF_FILE_TEMPLATE DEF_FILE_MAP RC_FILE TARGET "
+        "QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
+    QStringList &l = project->variables()["QMAKE_FILETAGS"];
+    QStringList::Iterator it;
+    for(it = l.begin(); it != l.end(); ++it) {
+	QStringList &gdmf = project->variables()[(*it)];
+	for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
+	    (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
+    }
+
+//@@TODO (dmik): old, remove    
+//    if ( project->isActiveConfig("dll") ) {
+//		QString destDir = "";
+//		if (!project->first("DESTDIR").isEmpty())
+//			destDir = project->first("DESTDIR") + "\\";
+//		project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") +
+//					  destDir + "lib" + project->first("TARGET") + ".a");
+//    }
+    
+//    if(!project->isActiveConfig("incremental"))
+//	project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
+
+    if ( !project->variables()["RC_FILE"].isEmpty()) {
+	if ( !project->variables()["RES_FILE"].isEmpty()) {
+	    fprintf( stderr, "Both RC_FILE and RES_FILE are specified.\n" );
+	    fprintf( stderr, "Please specify one of them, not both." );
+	    exit( 666 );
+	}
+	project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
+	project->variables()["RES_FILE"].first().replace(".rc",Option::obj_ext);
+	project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
+	project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
+    }
+    
+    if ( !project->variables()["RES_FILE"].isEmpty())
+	project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
+
+    MakefileGenerator::init();
+    
+    if ( !project->variables()["VERSION"].isEmpty()) {
+	QStringList l = QStringList::split('.', project->first("VERSION"));
+	project->variables()["VER_MAJ"].append(l[0]);
+	project->variables()["VER_MIN"].append(l[1]);
+    }
+
+//@@TODO (dmik): old, remove    
+//    if(project->isActiveConfig("dll")) {
+//	project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a");
+//    }
+    
+    QStringList &quc = project->variables()["QMAKE_EXTRA_COMPILERS"];
+    for(it = quc.begin(); it != quc.end(); ++it) {
+	QString tmp_out = project->variables()[(*it) + ".output"].first();
+	if(tmp_out.isEmpty())
+	    continue;
+	QStringList &tmp = project->variables()[(*it) + ".input"];
+	for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
+	    QStringList &inputs = project->variables()[(*it2)];
+	    for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
+		QFileInfo fi(Option::fixPathToLocalOS((*input)));
+		QString in = Option::fixPathToTargetOS((*input), FALSE),
+		       out = tmp_out;
+		out.replace("${QMAKE_FILE_BASE}", fi.baseName());
+		out.replace("${QMAKE_FILE_NAME}", fi.fileName());
+		if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
+		    project->variables()["OBJCOMP"] += out;
+	    }
+	}
+    }
+}
+
+void
+GNUMakefileGenerator::writeSubDirs(QTextStream &t)
+{
+    QString qs ;
+    QTextStream ts (&qs, IO_WriteOnly) ;
+    Win32MakefileGenerator::writeSubDirs( ts ) ;
+    QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ;
+    rx.setMinimal(TRUE);
+    int pos = 0 ;
+    while ( -1 != (pos = rx.search( qs, pos)))
+    {
+	QString qsMatch = rx.cap(2);
+	qsMatch.replace("\n\t"," && \\\n\t");
+	qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch );
+	pos += (rx.cap(1).length()+qsMatch.length());
+    }
+    t << qs ;
+}
Index: trunk/qmake/generators/os2/gnumake.h
===================================================================
--- trunk/qmake/generators/os2/gnumake.h	(revision 8)
+++ trunk/qmake/generators/os2/gnumake.h	(revision 8)
@@ -0,0 +1,63 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of GNUMakefileGenerator class.
+**
+** Copyright (C) 1992-2003 Trolltech AS.  All rights reserved.
+** Copyright (C) 2004 Norman ASA.  Initial OS/2 Port.
+** Copyright (C) 2005 netlabs.org.  Further OS/2 Development.
+**
+** This file is part of qmake.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef __GNUMAKE_H__
+#define __GNUMAKE_H__
+
+#include "winmakefile.h"
+
+class GNUMakefileGenerator : public Win32MakefileGenerator
+{
+    bool init_flag;
+    void writeGNUParts(QTextStream &);
+    void writeSubDirs(QTextStream &t) ;
+
+    bool writeMakefile(QTextStream &);
+    void init();
+    
+    virtual bool findLibraries();
+
+public:
+    GNUMakefileGenerator(QMakeProject *p);
+    ~GNUMakefileGenerator();
+
+};
+
+inline GNUMakefileGenerator::~GNUMakefileGenerator()
+{ }
+
+#endif /* __GNUMAKE_H__ */
Index: trunk/qmake/generators/unix/unixmake.cpp
===================================================================
--- trunk/qmake/generators/unix/unixmake.cpp	(revision 7)
+++ trunk/qmake/generators/unix/unixmake.cpp	(revision 8)
@@ -857,4 +857,5 @@
 	    for(QStringList::Iterator it = links.begin(); it != links.end(); it++) {
 		if(Option::target_mode == Option::TARG_WIN_MODE ||
+                   Option::target_mode == Option::TARG_OS2_MODE ||
 		   Option::target_mode == Option::TARG_MAC9_MODE) {
 		} else if(Option::target_mode == Option::TARG_UNIX_MODE ||
Index: trunk/qmake/generators/win32/msvc_nmake.cpp
===================================================================
--- trunk/qmake/generators/win32/msvc_nmake.cpp	(revision 7)
+++ trunk/qmake/generators/win32/msvc_nmake.cpp	(revision 8)
@@ -81,14 +81,19 @@
 {
     QStringList &aList = MakefileGenerator::findDependencies(file);
-    // Note: The QMAKE_IMAGE_COLLECTION file have all images
-    // as dependency, so don't add precompiled header then
-    if (file == project->first("QMAKE_IMAGE_COLLECTION"))
-	return aList;
-    for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
-	if(file.endsWith(*it)) {
-	    if(!aList.contains(precompH))
-		aList += precompH;
-	    break;
-	}
+    // [dmik] this method can be called from MakefileGenerator::init() before
+    // precompH is set in NmakeMakefileGenerator::init(), so we check it
+    // to avoid appending of NULL string to the list of dependencies
+    if (!precompH.isNull()) {
+        // Note: The QMAKE_IMAGE_COLLECTION file have all images
+        // as dependency, so don't add precompiled header then
+        if (file == project->first("QMAKE_IMAGE_COLLECTION"))
+            return aList;
+        for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
+            if(file.endsWith(*it)) {
+                if(!aList.contains(precompH))
+                    aList += precompH;
+                break;
+            }
+        }
     }
     return aList;
Index: trunk/qmake/main.cpp
===================================================================
--- trunk/qmake/main.cpp	(revision 7)
+++ trunk/qmake/main.cpp	(revision 8)
@@ -63,5 +63,5 @@
     QDir sunworkshop42workaround = QDir::current();
     QString oldpwd = sunworkshop42workaround.currentDirPath();
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_OS2) 
     if(!(oldpwd.length() == 3 && oldpwd[0].isLetter() && oldpwd.endsWith(":/") ) )
 #endif
Index: trunk/qmake/option.cpp
===================================================================
--- trunk/qmake/option.cpp	(revision 7)
+++ trunk/qmake/option.cpp	(revision 8)
@@ -73,4 +73,6 @@
 #if defined(Q_OS_WIN32)
 Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
+#elif defined(Q_OS_OS2)
+Option::TARG_MODE Option::target_mode = Option::TARG_OS2_MODE;
 #elif defined(Q_OS_MAC9)
 Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE;
@@ -148,4 +150,5 @@
 	    "\t-unix          Run in unix mode\n"
 	    "\t-win32         Run in win32 mode\n"
+	    "\t-os2           Run in OS/2 mode\n"
 	    "\t-macx          Run in Mac OS X mode\n"
 	    "\t-d             Increase debug level\n"
@@ -220,4 +223,6 @@
 	    } else if(opt == "win32") {
 		Option::target_mode = TARG_WIN_MODE;
+	    } else if(opt == "os2") {
+		Option::target_mode = TARG_OS2_MODE;
 	    } else if(opt == "d") {
 		Option::debug_level++;
@@ -393,6 +398,8 @@
 
     //defaults for globals
-    if(Option::target_mode == Option::TARG_WIN_MODE) {
-	Option::dir_sep = "\\";
+    if(Option::target_mode == Option::TARG_WIN_MODE ||
+        Option::target_mode == Option::TARG_OS2_MODE)
+    {
+        Option::dir_sep = "\\";
 	Option::obj_ext =  ".obj";
     } else {
@@ -485,5 +492,5 @@
     if(Option::target_mode == TARG_MAC9_MODE) 
 	tmp = tmp.replace('/', Option::dir_sep).replace('\\', Option::dir_sep);
-    else if(Option::target_mode == TARG_WIN_MODE) 
+    else if(Option::target_mode == TARG_WIN_MODE || Option::target_mode == TARG_OS2_MODE) 
 	tmp = tmp.replace('/', Option::dir_sep);
     else 
@@ -500,5 +507,5 @@
     if(canonical)
 	tmp = fixPath(tmp);
-#if defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32) || defined(Q_OS_OS2)
     return tmp.replace('/', '\\');
 #else
Index: trunk/qmake/option.h
===================================================================
--- trunk/qmake/option.h	(revision 7)
+++ trunk/qmake/option.h	(revision 8)
@@ -96,5 +96,5 @@
     static int warn_level;
     static QStringList before_user_vars, after_user_vars;
-    enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE };
+    enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE, TARG_OS2_MODE };
     static TARG_MODE target_mode;
     static QString user_template, user_template_prefix;
Index: trunk/qmake/project.cpp
===================================================================
--- trunk/qmake/project.cpp	(revision 7)
+++ trunk/qmake/project.cpp	(revision 8)
@@ -69,5 +69,5 @@
     const QString concat = QDir::separator() + QString("mkspecs");
     if(const char *qmakepath = getenv("QMAKEPATH")) {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
 	QStringList lst = QStringList::split(';', qmakepath);
 	for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) {
@@ -707,4 +707,6 @@
     else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32")
 	return TRUE;
+    else if(Option::target_mode == Option::TARG_OS2_MODE && x == "os2")
+	return TRUE;
 
 
@@ -897,5 +899,5 @@
 		QStringList feature_roots;
 		if(const char *mkspec_path = getenv("QMAKEFEATURES")) {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
 		    QStringList lst = QStringList::split(';', mkspec_path);
 		    for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
@@ -906,5 +908,5 @@
 		}
 		if(const char *qmakepath = getenv("QMAKEPATH")) {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
 		    QStringList lst = QStringList::split(';', qmakepath);
 		    for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) {
Index: trunk/qmake/property.cpp
===================================================================
--- trunk/qmake/property.cpp	(revision 7)
+++ trunk/qmake/property.cpp	(revision 8)
@@ -89,5 +89,7 @@
 #endif
     } else if(v == "QMAKE_MKSPECS") {
-	return qmake_mkspec_paths().join(Option::target_mode == Option::TARG_WIN_MODE ? ";" : ":");
+	return qmake_mkspec_paths().join(
+            (Option::target_mode == Option::TARG_WIN_MODE ||
+            Option::target_mode == Option::TARG_OS2_MODE) ? ";" : ":");
     } else if(v == "QMAKE_VERSION") {
 	return qmake_version();
