Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

borland_bmake.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** 
00003 **
00004 ** NmakeMakefileGenerator of BorlandMakefileGenerator class.
00005 **
00006 ** Copyright (C) 1992-2003 Trolltech AS.  All rights reserved.
00007 **
00008 ** This file is part of qmake.
00009 **
00010 ** This file may be distributed under the terms of the Q Public License
00011 ** as defined by Trolltech AS of Norway and appearing in the file
00012 ** LICENSE.QPL included in the packaging of this file.
00013 **
00014 ** This file may be distributed and/or modified under the terms of the
00015 ** GNU General Public License version 2 as published by the Free Software
00016 ** Foundation and appearing in the file LICENSE.GPL included in the
00017 ** packaging of this file.
00018 **
00019 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00020 ** file in accordance with the Qt Commercial License Agreement provided
00021 ** with the Software.
00022 **
00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 **
00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00027 **   information about Qt Commercial License Agreements.
00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00030 **
00031 ** Contact info@trolltech.com if any conditions of this licensing are
00032 ** not clear to you.
00033 **
00034 **********************************************************************/
00035 
00036 #include "borland_bmake.h"
00037 #include "option.h"
00038 #include <qdir.h>
00039 #include <qregexp.h>
00040 #include <time.h>
00041 #include <stdlib.h>
00042 
00043 
00044 BorlandMakefileGenerator::BorlandMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
00045 {
00046 
00047 }
00048 
00049 bool
00050 BorlandMakefileGenerator::writeMakefile(QTextStream &t)
00051 {
00052     writeHeader(t);
00053     if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
00054         t << "all clean:" << "\n\t"
00055           << "@echo \"Some of the required modules ("
00056           << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
00057           << "@echo \"Skipped.\"" << endl << endl;
00058         return TRUE;
00059     }
00060 
00061     if(project->first("TEMPLATE") == "app" ||
00062        project->first("TEMPLATE") == "lib") {
00063         writeBorlandParts(t);
00064         return MakefileGenerator::writeMakefile(t);
00065     }
00066     else if(project->first("TEMPLATE") == "subdirs") {
00067         writeSubDirs(t);
00068         return TRUE;
00069     }
00070     return FALSE;
00071 }
00072 
00073 void
00074 BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
00075 {
00076     t << "!if !$d(BCB)" << endl;
00077     t << "BCB = $(MAKEDIR)\\.." << endl;
00078     t << "!endif" << endl << endl;
00079     t << "####### Compiler, tools and options" << endl << endl;
00080     t << "CC    =       " << var("QMAKE_CC") << endl;
00081     t << "CXX   =       " << var("QMAKE_CXX") << endl;
00082     t << "LEX     = " << var("QMAKE_LEX") << endl;
00083     t << "YACC    = " << var("QMAKE_YACC") << endl;
00084     t << "CFLAGS        =       " << var("QMAKE_CFLAGS") << " "
00085       << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
00086       <<  varGlue("DEFINES","-D"," -D","") << endl;
00087     t << "CXXFLAGS=     " << var("QMAKE_CXXFLAGS") << " "
00088       << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
00089       << varGlue("DEFINES","-D"," -D","") << endl;
00090     t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
00091     t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
00092 
00093     t << "INCPATH       =       ";
00094     QStringList &incs = project->variables()["INCLUDEPATH"];
00095     for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
00096         QString inc = (*incit);
00097         inc.replace(QRegExp("\\\\*$"), "");
00098         inc.replace("\"", "");
00099         t << " -I\"" << inc << "\"";
00100     }
00101     t << " -I\"" << specdir() << "\""
00102       << endl;
00103 
00104     if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
00105         t << "LINK      =       " << var("QMAKE_LINK") << endl;
00106         t << "LFLAGS    =       ";
00107         if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
00108             t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";
00109         t << var("QMAKE_LFLAGS") << endl;
00110         t << "LIBS      =       " << var("QMAKE_LIBS") << endl;
00111     }
00112     else {
00113         t << "LIB       =       " << var("QMAKE_LIB") << endl;
00114     }
00115     t << "MOC   =       " << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
00116                               Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
00117     t << "UIC   =       " << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
00118                               Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
00119     t << "QMAKE =       " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
00120                               Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
00121     t << "IDC           =       " << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
00122                               Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
00123     t << "IDL           =       " << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
00124                               Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
00125     t << "ZIP   =       " << var("QMAKE_ZIP") << endl;
00126     t << "DEF_FILE =    " << varList("DEF_FILE") << endl;
00127     t << "RES_FILE =    " << varList("RES_FILE") << endl;
00128     t << "COPY_FILE  =       " << var("QMAKE_COPY") << endl;
00129     t << "COPY_DIR  =       " << var("QMAKE_COPY") << endl;
00130     t << "DEL_FILE   =       " << var("QMAKE_DEL_FILE") << endl;
00131     t << "DEL_DIR    =       " << var("QMAKE_DEL_DIR") << endl;
00132     t << "MOVE  =       " << var("QMAKE_MOVE") << endl;
00133     t << "CHK_DIR_EXISTS =      " << var("QMAKE_CHK_DIR_EXISTS") << endl;
00134     t << "MKDIR         =       " << var("QMAKE_MKDIR") << endl;
00135     t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
00136     t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
00137     t << endl;
00138 
00139     t << "####### Files" << endl << endl;
00140     t << "HEADERS =     " << varList("HEADERS") << endl;
00141     t << "SOURCES =     " << varList("SOURCES") << endl;
00142     t << "OBJECTS =     " << varList("OBJECTS") << endl;
00143     t << "FORMS =       " << varList("FORMS") << endl;
00144     t << "UICDECLS =    " << varList("UICDECLS") << endl;
00145     t << "UICIMPLS =    " << varList("UICIMPLS") << endl;
00146     t << "SRCMOC        =       " << varList("SRCMOC") << endl;
00147     t << "OBJMOC        =       " << varList("OBJMOC") << endl;
00148 
00149     QString extraCompilerDeps;
00150     if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
00151         t << "OBJCOMP = " << varList("OBJCOMP") << endl;
00152         extraCompilerDeps += " $(OBJCOMP) ";
00153 
00154         QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
00155         for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
00156             QStringList &vars = project->variables()[(*compit) + ".variables"];
00157             for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
00158                 QStringList vals = project->variables()[(*varit)];
00159                 if(!vals.isEmpty())
00160                     t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
00161             }
00162         }
00163     }
00164 
00165     t << "DIST  =       " << varList("DISTFILES") << endl;
00166     t << "TARGET        =       "
00167       << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
00168       << endl;
00169     t << endl;
00170 
00171     t << "####### Implicit rules" << endl << endl;
00172     t << ".SUFFIXES: .c";
00173     QStringList::Iterator cppit;
00174     for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
00175         t << " " << (*cppit);
00176     t << endl << endl;
00177     for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
00178         t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
00179     t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
00180 
00181     t << "####### Build rules" << endl << endl;
00182     t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << " $(TARGET)" << endl << endl;
00183     t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
00184       << extraCompilerDeps << var("POST_TARGETDEPS");
00185     if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
00186         t << "\n\t" << "$(LINK) @&&|" << "\n\t"
00187           << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
00188     } else {
00189         t << "\n\t-$(DEL_FILE) $(TARGET)"
00190           << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
00191           << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
00192           << project->variables()["OBJMOC"].join(" \\\n+");
00193     }
00194     t << extraCompilerDeps;
00195     t << endl << "|" << endl;
00196 
00197     if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
00198         t << "\t" <<var("QMAKE_POST_LINK") << endl;
00199 
00200     if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
00201         QStringList dlldirs = project->variables()["DLLDESTDIR"];
00202         for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
00203             t << "\n\t" << "-$(COPY_FILE) \"$(TARGET)\" " << *dlldir;
00204         }
00205     }
00206     QString targetfilename = project->variables()["TARGET"].first();
00207     if(project->isActiveConfig("activeqt")) {
00208         QString version = project->variables()["VERSION"].first();
00209         if ( version.isEmpty() )
00210             version = "1.0";
00211 
00212         if ( project->isActiveConfig("dll")) {
00213             t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
00214             t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
00215             t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
00216             t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
00217         } else {
00218             t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
00219             t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
00220             t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
00221             t << "\n\t" << ("-$(TARGET) -regserver");
00222         }
00223     }
00224     t << endl << endl;
00225 
00226     if(!project->variables()["RC_FILE"].isEmpty()) {
00227         t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
00228           << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
00229     }
00230     t << "mocables: $(SRCMOC)" << endl
00231       << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl;
00232 
00233     writeMakeQmake(t);
00234 
00235     QStringList dist_files = Option::mkfile::project_files;
00236     if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
00237         dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
00238     if(!project->isEmpty("TRANSLATIONS"))
00239         dist_files << var("TRANSLATIONS");
00240     if(!project->isEmpty("FORMS")) {
00241         QStringList &forms = project->variables()["FORMS"];
00242         for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
00243             QString ui_h = fileFixify((*formit) + Option::h_ext.first());
00244             if(QFile::exists(ui_h) )
00245                 dist_files << ui_h;
00246         }
00247     }
00248     t << "dist:" << "\n\t"
00249       << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "
00250       << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;
00251 
00252     t << "uiclean:";
00253     QString uiclean = varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
00254     if ( uiclean.isEmpty() ) {
00255         // Borland make does not like an empty command section
00256         uiclean = "\n\t@cd .";
00257     }
00258     t << uiclean << endl;
00259 
00260     t << "mocclean:";
00261     QString mocclean = varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
00262     if ( mocclean.isEmpty() ) {
00263         // Borland make does not like an empty command section
00264         mocclean = "\n\t@cd .";
00265     }
00266     t << mocclean << endl;
00267 
00268     t << "clean: uiclean mocclean"
00269       << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
00270       << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
00271       << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
00272     if ( project->isActiveConfig("activeqt")) {
00273         t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
00274         t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
00275     }
00276     if(!project->isEmpty("IMAGES"))
00277         t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
00278     t << endl;
00279 
00280     // user defined targets
00281     QStringList::Iterator it;
00282     QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
00283     for(it = qut.begin(); it != qut.end(); ++it) {
00284         QString targ = var((*it) + ".target"),
00285                  cmd = var((*it) + ".commands"), deps;
00286         if(targ.isEmpty())
00287             targ = (*it);
00288         QStringList &deplist = project->variables()[(*it) + ".depends"];
00289         for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
00290             QString dep = var((*dep_it) + ".target");
00291             if(dep.isEmpty())
00292                 dep = (*dep_it);
00293             deps += " " + dep;
00294         }
00295         if(!project->variables()["QMAKE_NOFORCE"].isEmpty() &&
00296            project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
00297             deps += QString(" ") + "FORCE";
00298         t << "\n\n" << targ << ":" << deps << "\n\t"
00299           << cmd;
00300     }
00301 
00302     t << endl << endl;
00303 
00304     QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
00305     for(it = quc.begin(); it != quc.end(); ++it) {
00306         QString tmp_out = project->variables()[(*it) + ".output"].first();
00307         QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
00308         QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
00309         QStringList &vars = project->variables()[(*it) + ".variables"];
00310         if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
00311             continue;
00312         QStringList &tmp = project->variables()[(*it) + ".input"];
00313         for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
00314             QStringList &inputs = project->variables()[(*it2)];
00315             for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
00316                 QFileInfo fi(Option::fixPathToLocalOS((*input)));
00317                 QString in = Option::fixPathToTargetOS((*input), FALSE),
00318                        out = tmp_out, cmd = tmp_cmd, deps;
00319                 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
00320                 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
00321                 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
00322                 cmd.replace("${QMAKE_FILE_OUT}", out);
00323                 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
00324                 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
00325                     cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
00326                 if(!tmp_dep.isEmpty()) {
00327                     char buff[256];
00328                     QString dep_cmd = tmp_dep;
00329                     dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
00330                     if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
00331                         while(!feof(proc)) {
00332                             int read_in = int(fread(buff, 1, 255, proc));
00333                             if(!read_in)
00334                                 break;
00335                             int l = 0;
00336                             for(int i = 0; i < read_in; i++) {
00337                                 if(buff[i] == '\n' || buff[i] == ' ') {
00338                                     deps += " " + QCString(buff+l, (i - l) + 1);
00339                                     l = i;
00340                                 }
00341                             }
00342                         }
00343                         fclose(proc);
00344                     }
00345                 }
00346                 t << out << ": " << in << deps << "\n\t"
00347                   << cmd << endl << endl;
00348             }
00349         }
00350     }
00351     t << endl;
00352 
00353     t << "distclean: clean"
00354       << "\n\t-$(DEL_FILE) $(TARGET)"
00355       << endl << endl;
00356 }
00357 
00358 void
00359 BorlandMakefileGenerator::init()
00360 {
00361     if(init_flag)
00362         return;
00363     init_flag = TRUE;
00364 
00365     project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
00366 
00367     /* this should probably not be here, but I'm using it to wrap the .t files */
00368     if(project->first("TEMPLATE") == "app")
00369         project->variables()["QMAKE_APP_FLAG"].append("1");
00370     else if(project->first("TEMPLATE") == "lib")
00371         project->variables()["QMAKE_LIB_FLAG"].append("1");
00372     else if(project->first("TEMPLATE") == "subdirs") {
00373         MakefileGenerator::init();
00374         if(project->variables()["MAKEFILE"].isEmpty())
00375             project->variables()["MAKEFILE"].append("Makefile");
00376         if(project->variables()["QMAKE"].isEmpty())
00377             project->variables()["QMAKE"].append("qmake");
00378         return;
00379     }
00380 
00381     if(project->isEmpty("QMAKE_INSTALL_FILE"))
00382         project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)");
00383     if(project->isEmpty("QMAKE_INSTALL_DIR"))
00384         project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)");
00385 
00386     bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qtmt"QTDLL_POSTFIX);
00387     QStringList &configs = project->variables()["CONFIG"];
00388     if (project->isActiveConfig("shared"))
00389         project->variables()["DEFINES"].append("QT_DLL");
00390     if (project->isActiveConfig("qt_dll"))
00391         if(configs.findIndex("qt") == -1) configs.append("qt");
00392     if ( project->isActiveConfig("qtopia") ) {
00393         if(configs.findIndex("qtopialib") == -1)
00394             configs.append("qtopialib");
00395         if(configs.findIndex("qtopiainc") == -1)
00396             configs.append("qtopiainc");
00397     }
00398     if ( project->isActiveConfig("qt") ) {
00399         if ( project->isActiveConfig("plugin") ) {
00400             project->variables()["CONFIG"].append("dll");
00401             project->variables()["DEFINES"].append("QT_PLUGIN");
00402         }
00403         if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
00404              ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
00405                project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
00406               (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
00407             project->variables()["QMAKE_QT_DLL"].append("1");
00408             if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
00409                 project->variables()["CONFIG"].append("dll");
00410         }
00411     }
00412     if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
00413         project->variables()["CONFIG"].remove("staticlib");
00414         project->variables()["QMAKE_APP_OR_DLL"].append("1");
00415     } else {
00416         project->variables()["CONFIG"].append("staticlib");
00417     }
00418     if ( project->isActiveConfig("warn_off") ) {
00419         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
00420         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
00421     } else if ( project->isActiveConfig("warn_on") ) {
00422         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
00423         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
00424     }
00425     if(project->isActiveConfig("qt")) {
00426         if ( project->isActiveConfig("thread") )
00427             project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
00428         if ( project->isActiveConfig("accessibility" ) )
00429             project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
00430         if ( project->isActiveConfig("tablet") )
00431             project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
00432     }
00433 
00434     if ( project->isActiveConfig("debug") ) {
00435         if ( project->isActiveConfig("thread") ) {
00436             if ( project->isActiveConfig("dll") ) {
00437                 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
00438                 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
00439             } else {
00440                 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
00441                 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
00442             }
00443         }
00444         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
00445         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
00446         project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
00447     } else {
00448         if ( project->isActiveConfig("thread") ) {
00449             if ( project->isActiveConfig("dll") ) {
00450                 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
00451                 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
00452             } else {
00453                 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
00454                 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
00455             }
00456         }
00457         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
00458         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
00459         project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
00460     }
00461 
00462     if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) {
00463         project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
00464     }
00465     if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
00466         project->variables()["CONFIG"].append("windows");
00467     }
00468     if ( project->isActiveConfig("qtopiainc") )
00469         project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
00470     if ( project->isActiveConfig("qtopialib") ) {
00471         if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
00472             project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"];
00473         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
00474     }
00475     if ( project->isActiveConfig("qt") ) {
00476         project->variables()["CONFIG"].append("moc");
00477         project->variables()["INCLUDEPATH"] +=  project->variables()["QMAKE_INCDIR_QT"];
00478         project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
00479         if ( !project->isActiveConfig("debug") )
00480             project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
00481         if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
00482             if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
00483                 project->variables()["DEFINES"].append("QT_MAKEDLL");
00484                 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
00485             }
00486         } else {
00487             if(project->isActiveConfig("thread"))
00488                 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
00489             else
00490                 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
00491             if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
00492                 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
00493                 if ( hver == -1 )
00494                     hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qtmt");
00495                 if(hver != -1) {
00496                     QString ver;
00497                     ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver);
00498                     QStringList &libs = project->variables()["QMAKE_LIBS"];
00499                     for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
00500                         (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver);
00501                 }
00502             }
00503             if ( project->isActiveConfig( "activeqt" ) ) {
00504                 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
00505                 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
00506                 if ( project->isActiveConfig( "dll" ) )
00507                     project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
00508             }
00509             if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
00510                 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
00511             }
00512         }
00513     }
00514     if ( project->isActiveConfig("opengl") ) {
00515         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
00516         project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
00517     }
00518     if ( project->isActiveConfig("dll") ) {
00519         project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
00520         project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
00521         project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
00522         project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
00523         if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
00524             project->variables()["TARGET_EXT"].append(
00525                 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
00526         } else {
00527             project->variables()["TARGET_EXT"].append(".dll");
00528         }
00529     } else {
00530         project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
00531         project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
00532         project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
00533         project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
00534         if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
00535             project->variables()["TARGET_EXT"].append(".exe");
00536         } else {
00537             project->variables()["TARGET_EXT"].append(".lib");
00538         }
00539     }
00540     if ( project->isActiveConfig("windows") ) {
00541         if ( project->isActiveConfig("console") ) {
00542             project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
00543             project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
00544             project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
00545             project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
00546         } else {
00547             project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
00548         }
00549         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
00550     } else {
00551         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
00552         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
00553         project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
00554         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
00555     }
00556     if ( project->isActiveConfig("stl") ) {
00557         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
00558         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
00559     } else {
00560         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
00561         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
00562     }
00563     if ( project->isActiveConfig("exceptions") ) {
00564         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
00565         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
00566     } else {
00567         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
00568         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
00569     }
00570     if ( project->isActiveConfig("rtti") ) {
00571         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
00572         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
00573     } else {
00574         project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
00575         project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
00576     }
00577 
00578     if ( project->isActiveConfig("thread") ) {
00579         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"];
00580     } else {
00581         project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"];
00582     }
00583     if ( project->isActiveConfig("moc") ) {
00584         setMocAware(TRUE);
00585     }
00586     project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
00587     // Update -lname to name.lib, and -Ldir to
00588     QStringList &libList = project->variables()["QMAKE_LIBS"];
00589     for( QStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) {
00590         QString s = *stIt;
00591         if( s.startsWith( "-l" ) ) {
00592             stIt = libList.remove( stIt );
00593             stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" );
00594         } else if( s.startsWith( "-L" ) ) {
00595             stIt = libList.remove( stIt );
00596             project->variables()["QMAKE_LIBDIR"].append(QDir::convertSeparators(s.mid( 2 )));
00597         } else {
00598             stIt++;
00599         }
00600     }
00601     project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
00602         "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
00603     QStringList &l = project->variables()["QMAKE_FILETAGS"];
00604     QStringList::Iterator it;
00605     for(it = l.begin(); it != l.end(); ++it) {
00606         QStringList &gdmf = project->variables()[(*it)];
00607         for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
00608             (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
00609     }
00610 
00611     if ( !project->variables()["RC_FILE"].isEmpty()) {
00612         if ( !project->variables()["RES_FILE"].isEmpty()) {
00613             fprintf(stderr, "Both .rc and .res file specified.\n");
00614             fprintf(stderr, "Please specify one of them, not both.");
00615             exit(666);
00616         }
00617         project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
00618         project->variables()["RES_FILE"].first().replace(".rc",".res");
00619         project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
00620         project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
00621     }
00622     MakefileGenerator::init();
00623     if ( !project->variables()["VERSION"].isEmpty()) {
00624         QStringList l = QStringList::split('.', project->first("VERSION"));
00625         project->variables()["VER_MAJ"].append(l[0]);
00626         project->variables()["VER_MIN"].append(l[1]);
00627     }
00628 
00629     if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
00630         // bcc does not generate a .tds file for static libs
00631         QString tdsPostfix;
00632         if ( !project->variables()["VERSION"].isEmpty() ) {
00633             tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("")
00634                 + ".tds";
00635         } else {
00636             tdsPostfix = ".tds";
00637         }
00638         project->variables()["QMAKE_CLEAN"].append(
00639                 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
00640     }
00641 
00642     QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
00643     for(it = quc.begin(); it != quc.end(); ++it) {
00644         QString tmp_out = project->variables()[(*it) + ".output"].first();
00645         if(tmp_out.isEmpty())
00646             continue;
00647         QStringList &tmp = project->variables()[(*it) + ".input"];
00648         for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
00649             QStringList &inputs = project->variables()[(*it2)];
00650             for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
00651                 QFileInfo fi(Option::fixPathToLocalOS((*input)));
00652                 QString in = Option::fixPathToTargetOS((*input), FALSE),
00653                     out = tmp_out;
00654                 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
00655                 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
00656                 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
00657                     project->variables()["OBJCOMP"] += out;
00658             }
00659         }
00660     }
00661 }

Generated on Sat Nov 5 16:18:20 2005 for OPIE by  doxygen 1.4.2