From 5042e3cf0d3514552769e441f5aad590c8eaf967 Mon Sep 17 00:00:00 2001 From: kergoth Date: Fri, 01 Nov 2002 00:10:42 +0000 Subject: Adding qmake in preperation for new build system --- (limited to 'qmake/generators') diff --git a/qmake/generators/mac/metrowerks_xml.cpp b/qmake/generators/mac/metrowerks_xml.cpp new file mode 100644 index 0000000..125749d --- a/dev/null +++ b/qmake/generators/mac/metrowerks_xml.cpp @@ -0,0 +1,822 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "metrowerks_xml.h" +#include "option.h" +#include +#include +#include +#include +#include +#ifdef Q_OS_MAC +#include +#include +#include +#endif + + +MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +MetrowerksMakefileGenerator::writeMakefile(QTextStream &t) +{ + if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { + /* for now just dump, I need to generated an empty xml or something.. */ + fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", + var("QMAKE_FAILED_REQUIREMENTS").latin1()); + return TRUE; + } + + if(project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib") { + return writeMakeParts(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeHeader(t); + qDebug("Not supported!"); + return TRUE; + } + return FALSE; +} + +bool +MetrowerksMakefileGenerator::writeMakeParts(QTextStream &t) +{ + //..grrr.. libs! + QStringList extra_objs; + bool do_libs = TRUE; + if(project->first("TEMPLATE") == "app") + extra_objs += project->variables()["QMAKE_CRT_OBJECTS"]; + else if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) + do_libs = FALSE; + if(do_libs) + extra_objs += project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator val_it = extra_objs.begin(); + val_it != extra_objs.end(); ++val_it) { + if((*val_it).startsWith("-L")) { + QString dir((*val_it).right((*val_it).length() - 2)); + fixEnvVariables(dir); + if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && + project->variables()["INCLUDEPATH"].findIndex(dir) == -1) + project->variables()["INCLUDEPATH"].append(dir); + } else if((*val_it).startsWith("-l")) { + QString lib("lib" + (*val_it).right((*val_it).length() - 2) + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + if(project->variables()["LIBRARIES"].findIndex(lib) == -1) + project->variables()["LIBRARIES"].append(lib); + } else + if((*val_it) == "-framework") { + ++val_it; + if(val_it == extra_objs.end()) + break; + QString frmwrk = (*val_it) + ".framework"; + if(project->variables()["FRAMEWORKS"].findIndex(frmwrk) == -1) + project->variables()["FRAMEWORKS"].append(frmwrk); + } else if((*val_it).left(1) != "-") { + QString lib=(*val_it); + int s = lib.findRev('/'); + if(s != -1) { + QString dir = lib.left(s); + lib = lib.right(lib.length() - s - 1); + fixEnvVariables(dir); + if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 && + project->variables()["INCLUDEPATH"].findIndex(dir) == -1) + project->variables()["INCLUDEPATH"].append(dir); + } + project->variables()["LIBRARIES"].append(lib); + } + } + //let metrowerks find the files & set the files to the type I expect + QDict seen(293); + QString paths[] = { QString("SRCMOC"), QString("FORMS"), QString("UICDECLS"), + QString("UICIMPLS"), QString("SOURCES"),QString("HEADERS"), + QString::null }; + for(int y = 0; paths[y] != QString::null; y++) { + QStringList &l = project->variables()[paths[y]]; + for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { + //establish file types + seen.insert((*val_it), (void *)1); + createFork((*val_it)); //the file itself + QStringList &d = findDependencies((*val_it)); //depends + for(QStringList::Iterator dep_it = d.begin(); dep_it != d.end(); ++dep_it) { + if(!seen.find((*dep_it))) { + seen.insert((*dep_it), (void *)1); + createFork((*dep_it)); + } + } + //now chop it + int s = (*val_it).findRev('/'); + if(s != -1) { + QString dir = (*val_it).left(s); + (*val_it) = (*val_it).right((*val_it).length() - s - 1); + QString tmpd=dir, tmpv; + if(fixifyToMacPath(tmpd, tmpv)) { + bool add_in = TRUE; + QString deps[] = { QString("DEPENDPATH"), + QString("INCLUDEPATH"), QString::null }, + dd, dv; + for(int yy = 0; deps[yy] != QString::null; yy++) { + QStringList &l2 = project->variables()[deps[yy]]; + for(QStringList::Iterator val_it2 = l2.begin(); + val_it2 != l2.end(); ++val_it2) { + QString dd= (*val_it2), dv; + if(!fixifyToMacPath(dd, dv)) + continue; + if(dd == tmpd && tmpv == dv) { + add_in = FALSE; + break; + } + } + } + if(add_in) + project->variables()["INCLUDEPATH"].append(dir); + } + } + } + } + //need a defines file + if(!project->isEmpty("DEFINES")) { + QString pre_pref = project->first("TARGET_STEM"); + if(project->first("TEMPLATE") == "lib") + pre_pref += project->isActiveConfig("staticlib") ? "_static" : "_shared"; + project->variables()["CODEWARRIOR_PREFIX_HEADER"].append(pre_pref + "_prefix.h"); + } + + QString xmlfile = findTemplate(project->first("QMAKE_XML_TEMPLATE")); + QFile file(xmlfile); + if(!file.open(IO_ReadOnly )) { + fprintf(stderr, "Cannot open XML file: %s\n", + project->first("QMAKE_XML_TEMPLATE").latin1()); + return FALSE; + } + QTextStream xml(&file); + createFork(Option::output.name()); + + int rep; + QString line; + while ( !xml.eof() ) { + line = xml.readLine(); + while((rep = line.find(QRegExp("\\$\\$[!a-zA-Z0-9_-]*"))) != -1) { + QString torep = line.mid(rep, line.find(QRegExp("[^\\$!a-zA-Z0-9_-]"), rep) - rep); + QString variable = torep.right(torep.length()-2); + + t << line.left(rep); //output the left side + line = line.right(line.length() - (rep + torep.length())); //now past the variable + if(variable == "CODEWARRIOR_HEADERS" || variable == "CODEWARRIOR_SOURCES" || + variable == "CODEWARRIOR_LIBRARIES" || variable == "CODEWARRIOR_QPREPROCESS" || + variable == "CODEWARRIOR_QPREPROCESSOUT") { + QString outcmd=variable.right(variable.length() - variable.findRev('_') - 1); + QStringList args; + if(outcmd == "QPREPROCESS") + args << "UICS" << "MOCS"; + else if(outcmd == "QPREPROCESSOUT") + args << "SRCMOC" << "UICIMPLS" << "UICDELCS"; + else + args << outcmd; + for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { + QString arg = (*arit); + QString kind = "Text"; + if(arg == "LIBRARIES") + kind = "Library"; + if(!project->variables()[arg].isEmpty()) { + QStringList &list = project->variables()[arg]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString flag; + if(project->isActiveConfig("debug")) { + bool debug = TRUE; + if(outcmd == "QPREPROCESS") { + debug = FALSE; + } else { + for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { + if((*it).endsWith((*hit))) { + debug = FALSE; + break; + } + } + } + if(debug) + flag = "Debug"; + } + t << "\t\t\t\t" << endl + << "\t\t\t\t\tName" << endl + << "\t\t\t\t\t" << (*it) << "" << endl + << "\t\t\t\t\tMacOS" << endl + << "\t\t\t\t\t" << kind << "" << endl + << "\t\t\t\t\t" << flag << "" << endl + << "\t\t\t\t" << endl; + } + } + } + } else if(variable == "CODEWARRIOR_SOURCES_LINKORDER" || + variable == "CODEWARRIOR_HEADERS_LINKORDER" || + variable == "CODEWARRIOR_LIBRARIES_LINKORDER" || + variable == "CODEWARRIOR_QPREPROCESS_LINKORDER" || + variable == "CODEWARRIOR_QPREPROCESSOUT_LINKORDER") { + QString outcmd=variable.mid(variable.find('_')+1, + variable.findRev('_')-(variable.find('_')+1)); + QStringList args; + if(outcmd == "QPREPROCESS") + args << "UICS" << "MOCS"; + else if(outcmd == "QPREPROCESSOUT") + args << "SRCMOC" << "UICIMPLS" << "UICDELCS"; + else + args << outcmd; + for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { + QString arg = (*arit); + if(!project->variables()[arg].isEmpty()) { + QStringList &list = project->variables()[arg]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + t << "\t\t\t\t" << endl + << "\t\t\t\t\tName" << endl + << "\t\t\t\t\t" << (*it) << "" << endl + << "\t\t\t\t\tMacOS" << endl + << "\t\t\t\t" << endl; + } + } + } + } else if(variable == "CODEWARRIOR_HEADERS_GROUP" || + variable == "CODEWARRIOR_SOURCES_GROUP" || + variable == "CODEWARRIOR_LIBRARIES_GROUP" || + variable == "CODEWARRIOR_QPREPROCESS_GROUP" || + variable == "CODEWARRIOR_QPREPROCESSOUT_GROUP") { + QString outcmd = variable.mid(variable.find('_')+1, + variable.findRev('_')-(variable.find('_')+1)); + QStringList args; + if(outcmd == "QPREPROCESS") + args << "UICS" << "MOCS"; + else if(outcmd == "QPREPROCESSOUT") + args << "SRCMOC" << "UICIMPLS" << "UICDELCS"; + else + args << outcmd; + for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { + QString arg = (*arit); + if(!project->variables()[arg].isEmpty()) { + QStringList &list = project->variables()[arg]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + t << "\t\t\t\t" << endl + << "\t\t\t\t\t" << var("TARGET_STEM") << "" + << endl + << "\t\t\t\t\tName" << endl + << "\t\t\t\t\t" << (*it) << "" << endl + << "\t\t\t\t\tMacOS" << endl + << "\t\t\t\t" << endl; + } + } + } + } else if(variable == "CODEWARRIOR_FRAMEWORKS") { + if(!project->isEmpty("FRAMEWORKS")) { + QStringList &list = project->variables()["FRAMEWORKS"]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + t << "\t\t\t\t" << endl + << "\t\t\t\t\t" << endl + << "\t\t\t\t\t\tName" << endl + << "\t\t\t\t\t\t" << (*it) << "" << endl + << "\t\t\t\t\t\tMacOS" << endl + << "\t\t\t\t\t" << endl + << "\t\t\t\t" << endl; + } + } + } else if(variable == "CODEWARRIOR_DEPENDPATH" || variable == "CODEWARRIOR_INCLUDEPATH" || + variable == "CODEWARRIOR_FRAMEWORKPATH") { + QString arg=variable.right(variable.length()-variable.find('_')-1); + QStringList list; + if(arg == "INCLUDEPATH") { + list = project->variables()[arg]; + list << Option::mkfile::qmakespec; + list << QDir::current().currentDirPath(); + + QStringList &l = project->variables()["QMAKE_LIBS_PATH"]; + for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { + QString p = (*val_it), v; + if(!fixifyToMacPath(p, v)) + continue; + + t << "\t\t\t\t\t" << endl + << "\t\t\t\t\t\tSearchPath" << endl + << "\t\t\t\t\t\t\tPath" + << "" << p << "" << endl + << "\t\t\t\t\t\t\tPathFormatMacOS" << endl + << "\t\t\t\t\t\t\tPathRootCodeWarrior" << endl + << "\t\t\t\t\t\t" << endl + << "\t\t\t\t\t\tRecursivetrue" << endl + << "\t\t\t\t\t\tHostFlagsAll" << endl + << "\t\t\t\t\t" << endl; + } + } else if(variable == "DEPENDPATH") { + QStringList &l = project->variables()[arg]; + for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) + { + //apparently tmake used colon separation... + QStringList damn = QStringList::split(':', (*val_it)); + if(!damn.isEmpty()) + list += damn; + else + list.append((*val_it)); + } + } else { + list = project->variables()[arg]; + } + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString p = (*it), v, recursive = "false", framework = "false"; + if(p.startsWith("recursive--")) { + p = p.right(p.length() - 11); + recursive = "true"; + } + if(!fixifyToMacPath(p, v)) + continue; + if(arg == "FRAMEWORKPATH") + framework = "true"; + + t << "\t\t\t\t\t" << endl + << "\t\t\t\t\t\tSearchPath" << endl + << "\t\t\t\t\t\t\tPath" + << "" << p << "" << endl + << "\t\t\t\t\t\t\tPathFormatMacOS" << endl + << "\t\t\t\t\t\t\tPathRoot" << v << "" << endl + << "\t\t\t\t\t\t" << endl + << "\t\t\t\t\t\tRecursive" << recursive << "" << endl + << "\t\t\t\t\t\tFrameworkPath" << framework << "" << endl + << "\t\t\t\t\t\tHostFlagsAll" << endl + << "\t\t\t\t\t" << endl; + } + } else if(variable == "CODEWARRIOR_WARNING" || variable == "!CODEWARRIOR_WARNING") { + bool b = ((!project->isActiveConfig("warn_off")) && + project->isActiveConfig("warn_on")); + if(variable.startsWith("!")) + b = !b; + t << (int)b; + } else if(variable == "CODEWARRIOR_TEMPLATE") { + if(project->first("TEMPLATE") == "app" ) { + t << "Executable"; + } else if(project->first("TEMPLATE") == "lib") { + if(project->isActiveConfig("staticlib")) + t << "Library"; + else + t << "SharedLibrary"; + } + } else if(variable == "CODEWARRIOR_OUTPUT_DIR") { + QString outdir = "{Project}/", volume; + if(!project->isEmpty("DESTDIR")) + outdir = project->first("DESTDIR"); + if(project->first("TEMPLATE") == "app" && !project->isActiveConfig("console")) + outdir += var("TARGET") + ".app/Contents/MacOS/"; + if(fixifyToMacPath(outdir, volume, FALSE)) { + t << "\t\t\tPath" << outdir << "" + << endl + << "\t\t\tPathFormatMacOS" << endl + << "\t\t\tPathRoot" << volume << "" + << endl; + } + } else if(variable == "CODEWARRIOR_PACKAGER_PANEL") { + if(project->first("TEMPLATE") == "app" && !project->isActiveConfig("console")) { + QString outdir = "{Project}/", volume; + if(!project->isEmpty("DESTDIR")) + outdir = project->first("DESTDIR"); + outdir += var("TARGET") + ".app"; + if(fixifyToMacPath(outdir, volume, FALSE)) { + t << "\t\tMWMacOSPackager_UsePackager" + << "1" << "\n" + << "\t\tMWMacOSPackager_FolderToPackage" << "\n" + << "\t\t\tPath" << outdir + << "" << "\n" + << "\t\t\tPathFormatMacOS" + << "\n" + << "\t\t\tPathRoot" << volume + << "" << "\n" + << "\t\t" << "\n" + << "\t\tMWMacOSPackager_CreateClassicAlias" + << "0" << "\n" + << "\t\tMWMacOSPackager_ClassicAliasMethod" + << "UseTargetOutput" << "\n" + << "\t\tMWMacOSPackager_ClassicAliasPath" + << "" << "\n" + << "\t\tMWMacOSPackager_CreatePkgInfo" + << "1" << "\n" + << "\t\tMWMacOSPackager_PkgCreatorType" + << "CUTE" << "\n" + << "\t\tMWMacOSPackager_PkgFileType" + << "APPL" << endl; + } + } + } else if(variable == "CODEWARRIOR_FILETYPE") { + if(project->first("TEMPLATE") == "lib") + t << "MYDL"; + else + t << "MEXE"; + } else if(variable == "CODEWARRIOR_QTDIR") { + t << getenv("QTDIR"); + } else if(variable == "CODEWARRIOR_CACHEMODDATES") { + t << "true"; + } else { + t << var(variable); + } + } + t << line << endl; + } + t << endl; + file.close(); + + if(mocAware()) { + QString mocs = project->first("MOCS"); + QFile mocfile(mocs); + if(!mocfile.open(IO_WriteOnly)) { + fprintf(stderr, "Cannot open MOCS file: %s\n", mocs.latin1()); + } else { + createFork(mocs); + QTextStream mocs(&mocfile); + QStringList &list = project->variables()["SRCMOC"]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString src = findMocSource((*it)); + if(src.findRev('/') != -1) + src = src.right(src.length() - src.findRev('/') - 1); + mocs << src << endl; + } + mocfile.close(); + } + } + + if(!project->isEmpty("FORMS")) { + QString uics = project->first("UICS"); + QFile uicfile(uics); + if(!uicfile.open(IO_WriteOnly)) { + fprintf(stderr, "Cannot open UICS file: %s\n", uics.latin1()); + } else { + createFork(uics); + QTextStream uics(&uicfile); + QStringList &list = project->variables()["FORMS"]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString ui = (*it); + if(ui.findRev('/') != -1) + ui = ui.right(ui.length() - ui.findRev('/') - 1); + uics << ui << endl; + } + uicfile.close(); + } + } + + if(!project->isEmpty("CODEWARRIOR_PREFIX_HEADER")) { + QFile prefixfile(project->first("CODEWARRIOR_PREFIX_HEADER")); + if(!prefixfile.open(IO_WriteOnly)) { + fprintf(stderr, "Cannot open PREFIX file: %s\n", prefixfile.name().latin1()); + } else { + createFork(project->first("CODEWARRIOR_PREFIX_HEADER")); + QTextStream prefix(&prefixfile); + QStringList &list = project->variables()["DEFINES"]; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + if((*it).find('=') != -1) { + int x = (*it).find('='); + prefix << "#define " << (*it).left(x) << " " << (*it).right((*it).length() - x - 1) << endl; + } else { + prefix << "#define " << (*it) << endl; + } + } + prefixfile.close(); + } + } + return TRUE; +} + + + +void +MetrowerksMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + if ( project->isEmpty("QMAKE_XML_TEMPLATE") ) + project->variables()["QMAKE_XML_TEMPLATE"].append("mwerkstmpl.xml"); + + QStringList &configs = project->variables()["CONFIG"]; + if(project->isActiveConfig("qt")) { + if(configs.findIndex("moc")) configs.append("moc"); + if ( !( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || + (project->first("TARGET") == "qt-mt") ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if(configs.findIndex("moc")) + configs.append("moc"); + if ( !project->isActiveConfig("debug") ) + project->variables()["DEFINES"].append("QT_NO_DEBUG"); + } + + //version handling + if(project->variables()["VERSION"].isEmpty()) + project->variables()["VERSION"].append("1.0." + + (project->isEmpty("VER_PAT") ? QString("0") : + project->first("VER_PAT")) ); + QStringList ver = QStringList::split('.', project->first("VERSION")); + ver << "0" << "0"; //make sure there are three + project->variables()["VER_MAJ"].append(ver[0]); + project->variables()["VER_MIN"].append(ver[1]); + project->variables()["VER_PAT"].append(ver[2]); + + if( !project->isEmpty("LIBS") ) + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + if( project->variables()["QMAKE_EXTENSION_SHLIB"].isEmpty() ) + project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dylib" ); + + if ( project->isActiveConfig("moc") ) { + QString mocfile = project->first("TARGET"); + if(project->first("TEMPLATE") == "lib") + mocfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; + project->variables()["MOCS"].append(mocfile + ".mocs"); + setMocAware(TRUE); + } + if(!project->isEmpty("FORMS")) { + QString uicfile = project->first("TARGET"); + if(project->first("TEMPLATE") == "lib") + uicfile += project->isActiveConfig("staticlib") ? "_static" : "_shared"; + project->variables()["UICS"].append(uicfile + ".uics"); + } + if(project->isEmpty("DESTDIR")) + project->variables()["DESTDIR"].append(QDir::currentDirPath()); + MakefileGenerator::init(); + + if ( project->isActiveConfig("opengl") ) { + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; + if ( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") || + (project->first("TARGET") == "qt-mt") ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + } + + if(project->isActiveConfig("qt")) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + if(project->isEmpty("FRAMEWORKPATH")) + project->variables()["FRAMEWORKPATH"].append("/System/Library/Frameworks/"); + + //set the target up + project->variables()["TARGET_STEM"] = project->variables()["TARGET"]; + if(project->first("TEMPLATE") == "lib") { + if(project->isActiveConfig("staticlib")) + project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + ".lib"; + else + project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB"); + + project->variables()["CODEWARRIOR_VERSION"].append(project->first("VER_MAJ") + + project->first("VER_MIN") + + project->first("VER_PAT")); + } else { + project->variables()["CODEWARRIOR_VERSION"].append("0"); + if(project->isEmpty("QMAKE_ENTRYPOINT")) + project->variables()["QMAKE_ENTRYPOINT"].append("start"); + project->variables()["CODEWARRIOR_ENTRYPOINT"].append( + project->first("QMAKE_ENTRYPOINT")); + } +} + + +QString +MetrowerksMakefileGenerator::findTemplate(QString file) +{ + QString ret; + if(!QFile::exists(ret = file) && + !QFile::exists((ret = Option::mkfile::qmakespec + QDir::separator() + file)) && + !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/mac-mwerks/" + file)) && + !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) + return ""; + return ret; +} + +bool +MetrowerksMakefileGenerator::createFork(const QString &f) +{ +#if defined(Q_OS_MACX) + FSRef fref; + FSSpec fileSpec; + if(QFile::exists(f)) { + mode_t perms = 0; + { + struct stat s; + stat(f.latin1(), &s); + if(!(s.st_mode & S_IWUSR)) { + perms = s.st_mode; + chmod(f.latin1(), perms | S_IWUSR); + } + } + FILE *o = fopen(f.latin1(), "a"); + if(!o) + return FALSE; + if(FSPathMakeRef((const UInt8 *)f.latin1(), &fref, NULL) == noErr) { + if(FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL) == noErr) + FSpCreateResFile(&fileSpec, 'CUTE', 'TEXT', smSystemScript); + else + qDebug("bogus %d", __LINE__); + } else + qDebug("bogus %d", __LINE__); + fclose(o); + if(perms) + chmod(f.latin1(), perms); + } +#else + Q_UNUSED(f) +#endif + return TRUE; +} + +bool +MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool ) +{ + v = "Absolute"; + if(p.find(':') != -1) //guess its macish already + return TRUE; + + static QString st_volume; + if(st_volume.isEmpty()) { + st_volume = var("QMAKE_VOLUMENAME"); +#ifdef Q_OS_MAC + if(st_volume.isEmpty()) { + uchar foo[512]; + HVolumeParam pb; + memset(&pb, '\0', sizeof(pb)); + pb.ioVRefNum = 0; + pb.ioNamePtr = foo; + if(PBHGetVInfoSync((HParmBlkPtr)&pb) == noErr) { + int len = foo[0]; + memcpy(foo,foo+1, len); + foo[len] = '\0'; + st_volume = (char *)foo; + } + } +#endif + } + QString volume = st_volume; + + fixEnvVariables(p); + if(p.startsWith("\"") && p.endsWith("\"")) + p = p.mid(1, p.length() - 2); + if(p.isEmpty()) + return FALSE; + if(!p.endsWith("/")) + p += "/"; + if(QDir::isRelativePath(p)) { + if(p.startsWith("{")) { + int eoc = p.find('}'); + if(eoc == -1) + return FALSE; + volume = p.mid(1, eoc - 1); + p = p.right(p.length() - eoc - 1); + } else { + QFileInfo fi(p); + if(fi.convertToAbs()) //strange + return FALSE; + p = fi.filePath(); + } + } + p = QDir::cleanDirPath(p); + if(!volume.isEmpty()) + v = volume; + p.replace("/", ":"); + if(p.right(1) != ":") + p += ':'; + return TRUE; +} + +void +MetrowerksMakefileGenerator::processPrlFiles() +{ + QPtrList libdirs; + libdirs.setAutoDelete(TRUE); + const QString lflags[] = { "QMAKE_LIBS", QString::null }; + for(int i = 0; !lflags[i].isNull(); i++) { + for(bool ret = FALSE; TRUE; ret = FALSE) { + QStringList l_out; + QStringList &l = project->variables()[lflags[i]]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + QString opt = (*it); + if(opt.startsWith("-")) { + if(opt.startsWith("-L")) { + QString r = opt.right(opt.length() - 2), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace( "\"", ""), + l.replace( "\"", ""))); + } else if(opt.left(2) == "-l") { + QString lib = opt.right(opt.length() - 2), prl; + for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { + prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; + if(processPrlFile(prl)) { + if(prl.startsWith(mdd->local_dir)) + prl.replace(0, mdd->local_dir.length(), mdd->real_dir); + QRegExp reg("^.*lib(" + lib + "[^.]*)\\." + + project->first("QMAKE_EXTENSION_SHLIB") + "$"); + if(reg.exactMatch(prl)) + prl = "-l" + reg.cap(1); + opt = prl; + ret = TRUE; + break; + } + } + } else if(opt == "-framework") { + l_out.append(opt); + ++it; + opt = (*it); + QString prl = "/System/Library/Frameworks/" + opt + + ".framework/" + opt + Option::prl_ext; + if(processPrlFile(prl)) + ret = TRUE; + } + if(!opt.isEmpty()) + l_out.append(opt); + } else { + if(processPrlFile(opt)) + ret = TRUE; + if(!opt.isEmpty()) + l_out.append(opt); + } + } + if(ret) + l = l_out; + else + break; + } + } +} + +void +MetrowerksMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) +{ + if(var == "QMAKE_PRL_LIBS") { + QStringList &out = project->variables()["QMAKE_LIBS"]; + for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + bool append = TRUE; + if((*it).startsWith("-")) { + if((*it).startsWith("-l") || (*it).startsWith("-L")) { + append = out.findIndex((*it)) == -1; + } else if((*it).startsWith("-framework")) { + ++it; + for(QStringList::ConstIterator outit = out.begin(); + outit != out.end(); ++it) { + if((*outit) == "-framework") { + ++outit; + if((*outit) == (*it)) { + append = FALSE; + break; + } + } + } + } + } else if(QFile::exists((*it))) { + append = out.findIndex((*it)); + } + if(append) + out.append((*it)); + } + } else { + MakefileGenerator::processPrlVariable(var, l); + } +} + + +bool +MetrowerksMakefileGenerator::openOutput(QFile &file) const +{ + QString outdir; + if(!file.name().isEmpty()) { + QFileInfo fi(file); + if(fi.isDir()) + outdir = file.name() + QDir::separator(); + } + if(!outdir.isEmpty() || file.name().isEmpty()) + file.setName(outdir + project->first("TARGET") + ".xml"); + return MakefileGenerator::openOutput(file); +} diff --git a/qmake/generators/mac/metrowerks_xml.h b/qmake/generators/mac/metrowerks_xml.h new file mode 100644 index 0000000..ae3cfae --- a/dev/null +++ b/qmake/generators/mac/metrowerks_xml.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __METROWERKSMAKE_H__ +#define __METROWERKSMAKE_H__ + +#include "makefile.h" + +class MetrowerksMakefileGenerator : public MakefileGenerator +{ + bool createFork(const QString &f); + bool fixifyToMacPath(QString &c, QString &v, bool exists=TRUE); + + bool init_flag; + + bool writeMakeParts(QTextStream &); + bool writeSubDirs(QTextStream &); + + bool writeMakefile(QTextStream &); + QString findTemplate(QString file); + void init(); +public: + MetrowerksMakefileGenerator(QMakeProject *p); + ~MetrowerksMakefileGenerator(); + + bool openOutput(QFile &file) const; +protected: + virtual void processPrlFiles(); + virtual void processPrlVariable(const QString &var, const QStringList &l); + virtual bool doDepends() const { return FALSE; } //never necesary +}; + +inline MetrowerksMakefileGenerator::~MetrowerksMakefileGenerator() +{ } + +#endif /* __METROWERKSMAKE_H__ */ diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp new file mode 100644 index 0000000..8525058 --- a/dev/null +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -0,0 +1,983 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "pbuilder_pbx.h" +#include "option.h" +#include +#include +#include +#include +#include +#ifdef Q_OS_UNIX +# include +# include +#endif + +// Note: this is fairly hacky, but it does the job... + + +ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p) +{ + +} + +bool +ProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t) +{ + if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { + /* for now just dump, I need to generated an empty xml or something.. */ + fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", + var("QMAKE_FAILED_REQUIREMENTS").latin1()); + return TRUE; + } + + project->variables()["MAKEFILE"].clear(); + project->variables()["MAKEFILE"].append("Makefile"); + if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib") { + return writeMakeParts(t); + } else if(project->first("TEMPLATE") == "subdirs") { + writeSubdirs(t, FALSE); + return TRUE; + } + return FALSE; +} + +bool +ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) +{ + int i; + QStringList tmp; + bool did_preprocess = FALSE; + + //HEADER + t << "// !$*UTF8*$!" << "\n" + << "{" << "\n" + << "\t" << "archiveVersion = 1;" << "\n" + << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n" + << "\t" << "objectVersion = " << pbuilderVersion() << ";" << "\n" + << "\t" << "objects = {" << endl; + + //MAKE QMAKE equivlant + if(!project->isActiveConfig("no_autoqmake") && project->projectFile() != "(stdin)") { + QString mkfile = pbx_dir + Option::dir_sep + "qt_makeqmake.mak"; + QFile mkf(mkfile); + if(mkf.open(IO_WriteOnly | IO_Translate)) { + debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1()); + QTextStream mkt(&mkf); + writeHeader(mkt); + mkt << "QMAKE = " << + (project->isEmpty("QMAKE_QMAKE") ? QString("$(QTDIR)/bin/qmake") : + var("QMAKE_QMAKE")) << endl; + writeMakeQmake(mkt); + mkf.close(); + } + QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE"); + mkfile = fileFixify(mkfile, QDir::currentDirPath()); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); + t << "\t\t" << phase_key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" + << "\t\t\t" << "files = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "generatedFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n" + << "\t\t\t" << "name = \"Qt Qmake\";" << "\n" + << "\t\t\t" << "neededFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "shellPath = /bin/sh;" << "\n" + << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() << + " -f " << mkfile << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + + //DUMP SOURCES + QMap groups; + QString srcs[] = { "SOURCES", "SRCMOC", "UICIMPLS", QString::null }; + for(i = 0; !srcs[i].isNull(); i++) { + tmp = project->variables()[srcs[i]]; + QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]]; + for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) { + QString file = fileFixify((*it)); + if(file.endsWith(Option::moc_ext)) + continue; + bool in_root = TRUE; + QString src_key = keyFor(file); + if(!project->isActiveConfig("flat")) { + QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE); + if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) { + QString last_grp("QMAKE_PBX_" + srcs[i] + "_HEIR_GROUP"); + QStringList dirs = QStringList::split(Option::dir_sep, flat_file); + dirs.pop_back(); //remove the file portion as it will be added via src_key + for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { + QString new_grp(last_grp + Option::dir_sep + (*dir_it)), + new_grp_key(keyFor(new_grp)), last_grp_key(keyFor(last_grp)); + if(dir_it == dirs.begin()) { + if(!groups.contains(new_grp)) + project->variables()["QMAKE_PBX_" + srcs[i]].append(new_grp_key); + } else { + groups[last_grp] += new_grp_key; + } + last_grp = new_grp; + } + groups[last_grp] += src_key; + in_root = FALSE; + } + } + if(in_root) + src_list.append(src_key); + //source reference + t << "\t\t" << src_key << " = {" << "\n" + << "\t\t\t" << "isa = PBXFileReference;" << "\n" + << "\t\t\t" << "path = \"" << file << "\";" << "\n" + << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n" + << "\t\t" << "};" << "\n"; + //build reference + QString obj_key = file + ".o"; + obj_key = keyFor(obj_key); + t << "\t\t" << obj_key << " = {" << "\n" + << "\t\t\t" << "fileRef = " << src_key << ";" << "\n" + << "\t\t\t" << "isa = PBXBuildFile;" << "\n" + << "\t\t\t" << "settings = {" << "\n" + << "\t\t\t\t" << "ATTRIBUTES = (" << "\n" + << "\t\t\t\t" << ");" << "\n" + << "\t\t\t" << "};" << "\n" + << "\t\t" << "};" << "\n"; + project->variables()["QMAKE_PBX_OBJ"].append(obj_key); + } + if(!src_list.isEmpty()) { + QString grp; + if(srcs[i] == "SOURCES") { + if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon + QString icns_file = keyFor("ICNS_FILE"); + src_list.append(icns_file); + t << "\t\t" << icns_file << " = {" << "\n" + << "\t\t\t" << "isa = PBXFileReference;" << "\n" + << "\t\t\t" << "path = \"" << project->first("RC_FILE") << "\";" << "\n" + << "\t\t\t" << "refType = " << reftypeForFile(project->first("RC_FILE")) << ";" << "\n" + << "\t\t" << "};" << "\n"; + t << "\t\t" << keyFor("ICNS_FILE_REFERENCE") << " = {" << "\n" + << "\t\t\t" << "fileRef = " << icns_file << ";" << "\n" + << "\t\t\t" << "isa = PBXBuildFile;" << "\n" + << "\t\t\t" << "settings = {" << "\n" + << "\t\t\t" << "};" << "\n" + << "\t\t" << "};" << "\n"; + } + grp = "Sources"; + } else if(srcs[i] == "SRCMOC") { + grp = "Mocables"; + } else if(srcs[i] == "UICIMPLS") { + grp = "UICables"; + } + QString grp_key = keyFor(grp); + project->variables()["QMAKE_PBX_GROUPS"].append(grp_key); + t << "\t\t" << grp_key << " = {" << "\n" + << "\t\t\t" << "children = (" << "\n" + << varGlue("QMAKE_PBX_" + srcs[i], "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXGroup;" << "\n" + << "\t\t\t" << "name = " << grp << ";" << "\n" + << "\t\t\t" << "refType = 4;" << "\n" + << "\t\t" << "};" << "\n"; + } + } + for(QMap::Iterator grp_it = groups.begin(); + grp_it != groups.end(); ++grp_it) { + t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n" + << "\t\t\t" << "isa = PBXGroup;" << "\n" + << "\t\t\t" << "children = (" << "\n" + << valGlue(grp_it.data(), "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n" + << "\t\t\t" << "refType = 4;" << "\n" + << "\t\t" << "};" << "\n"; + } + + //PREPROCESS BUILDPHASE (just a makefile) + if(!project->isEmpty("UICIMPLS") || !project->isEmpty("SRCMOC") || + !project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) { + QString mkfile = pbx_dir + Option::dir_sep + "qt_preprocess.mak"; + QFile mkf(mkfile); + if(mkf.open(IO_WriteOnly | IO_Translate)) { + did_preprocess = TRUE; + debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1()); + QTextStream mkt(&mkf); + writeHeader(mkt); + mkt << "MOC = " << var("QMAKE_MOC") << endl; + mkt << "UIC = " << var("QMAKE_UIC") << endl; + mkt << "LEX = " << var("QMAKE_LEX") << endl; + mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; + mkt << "YACC = " << var("QMAKE_YACC") << endl; + mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << endl; + mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl; + mkt << "FORMS = " << varList("UICIMPLS") << endl; + mkt << "MOCS = " << varList("SRCMOC") << endl; + mkt << "PARSERS ="; + if(!project->isEmpty("YACCSOURCES")) { + QStringList &yaccs = project->variables()["YACCSOURCES"]; + for(QStringList::Iterator yit = yaccs.begin(); yit != yaccs.end(); ++yit) { + QFileInfo fi((*yit)); + mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE) + << Option::yacc_mod << Option::cpp_ext.first(); + } + } + if(!project->isEmpty("LEXSOURCES")) { + QStringList &lexs = project->variables()["LEXSOURCES"]; + for(QStringList::Iterator lit = lexs.begin(); lit != lexs.end(); ++lit) { + QFileInfo fi((*lit)); + mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE) + << Option::lex_mod << Option::cpp_ext.first(); + } + } + mkt << "\n"; + mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS)" << endl; + mkt << "preprocess_clean: mocclean uiclean parser_clean" << endl << endl; + mkt << "mocclean:" << "\n"; + if(!project->isEmpty("SRCMOC")) + mkt << "\t-rm -f $(MOCS)" << "\n"; + mkt << "uiclean:" << "\n"; + if(!project->isEmpty("UICIMPLS")) + mkt << "\t-rm -f $(FORMS)" << "\n"; + mkt << "parser_clean:" << "\n"; + if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) + mkt << "\t-rm -f $(PARSERS)" << "\n"; + writeUicSrc(mkt, "FORMS"); + writeMocSrc(mkt, "HEADERS"); + writeMocSrc(mkt, "SOURCES"); + writeMocSrc(mkt, "UICDECLS"); + writeYaccSrc(mkt, "YACCSOURCES"); + writeLexSrc(mkt, "LEXSOURCES"); + mkf.close(); + } + QString target_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET"); + mkfile = fileFixify(mkfile, QDir::currentDirPath()); + t << "\t\t" << target_key << " = {" << "\n" + << "\t\t\t" << "buildArgumentsString = \"-f " << mkfile << "\";" << "\n" + << "\t\t\t" << "buildPhases = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "buildSettings = {" << "\n" + << "\t\t\t" << "};" << "\n" + << "\t\t\t" << "buildToolPath = \"/usr/bin/gnumake\";"<< "\n" + << "\t\t\t" << "buildWorkingDirectory = \"" << QDir::currentDirPath() << "\";" << "\n" + << "\t\t\t" << "dependencies = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXLegacyTarget;" << "\n" + << "\t\t\t" << "name = QtPreprocessors;" << "\n" + << "\t\t\t" << "productName = QtPreprocessors;" << "\n" + << "\t\t\t" << "settingsToExpand = 6;" << "\n" + << "\t\t\t" << "settingsToPassInEnvironment = 287;" << "\n" + << "\t\t\t" << "settingsToPassOnCommandLine = 280;" << "\n" + << "\t\t\t" << "shouldsUseHeadermap = 0;" << "\n" + << "\t\t" << "};" << "\n"; + + QString target_depend_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET_DEPEND"); + project->variables()["QMAKE_PBX_TARGETDEPENDS"].append(target_depend_key); + t << "\t\t" << target_depend_key << " = {" << "\n" + << "\t\t\t" << "isa = PBXTargetDependency;" << "\n" + << "\t\t\t" << "target = " << target_key << ";" << "\n" + << "\t\t" << "};" << "\n"; + } + //SOURCE BUILDPHASE + if(!project->isEmpty("QMAKE_PBX_OBJ")) { + QString grp = "Build Sources", key = keyFor(grp); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" + << "\t\t\t" << "files = (" << "\n" + << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXSourcesBuildPhase;" << "\n" + << "\t\t\t" << "name = \"" << grp << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + + if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES + QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"]; + QString libs[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; + for(i = 0; !libs[i].isNull(); i++) { + tmp = project->variables()[libs[i]]; + for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) { + bool remove = FALSE; + QString library, name, opt = (*it).stripWhiteSpace(); + if(opt.startsWith("-L")) { + QString r = opt.right(opt.length() - 2); + fixEnvVariables(r); + libdirs.append(r); + } else if(opt.startsWith("-l")) { + name = opt.right(opt.length() - 2); + QString lib("lib" + name); + for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) { + if(project->isActiveConfig("link_prl")) { + /* This isn't real nice, but it is real usefull. This looks in a prl + for what the library will ultimately be called so we can stick it + in the ProjectFile. If the prl format ever changes (not likely) then + this will not really work. However, more concerning is that it will + encode the version number in the Project file which might be a bad + things in days to come? --Sam + */ + QString prl_file = (*lit) + Option::dir_sep + lib + Option::prl_ext; + if(QFile::exists(prl_file)) { + QMakeProject proj; + if(proj.read(prl_file, QDir::currentDirPath())) { + if(!proj.isEmpty("QMAKE_PRL_TARGET")) { + library = (*lit) + Option::dir_sep + proj.first("QMAKE_PRL_TARGET"); + debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)", + opt.latin1(), prl_file.latin1(), library.latin1()); + remove = TRUE; + } + } + + } + } + if(!remove) { + QString extns[] = { ".dylib", ".so", ".a", QString::null }; + for(int n = 0; !remove && !extns[n].isNull(); n++) { + QString tmp = (*lit) + Option::dir_sep + lib + extns[n]; + if(QFile::exists(tmp)) { + library = tmp; + debug_msg(1, "pbuilder: Found library (%s) via %s", + opt.latin1(), library.latin1()); + remove = TRUE; + } + } + } + } + } else if(opt == "-framework") { + ++it; + if(it == tmp.end()) + break; + QStringList &fdirs = project->variables()["QMAKE_FRAMEWORKDIR"]; + if(fdirs.isEmpty()) + fdirs.append("/System/Library/Frameworks/"); + for(QStringList::Iterator fit = fdirs.begin(); fit != fdirs.end(); ++fit) { + if(QFile::exists((*fit) + QDir::separator() + (*it) + ".framework")) { + --it; + it = tmp.remove(it); + remove = TRUE; + library = (*fit) + Option::dir_sep + (*it) + ".framework"; + break; + } + } + } else if(opt.left(1) != "-") { + remove = TRUE; + library = opt; + } + if(!library.isEmpty()) { + if(name.isEmpty()) { + int slsh = library.findRev(Option::dir_sep); + if(slsh != -1) + name = library.right(library.length() - slsh - 1); + } + library = fileFixify(library); + QString key = keyFor(library); + bool is_frmwrk = (library.endsWith(".framework")); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "isa = " << (is_frmwrk ? "PBXFrameworkReference" : "PBXFileReference") << ";" << "\n" + << "\t\t\t" << "name = \"" << name << "\";" << "\n" + << "\t\t\t" << "path = \"" << library << "\";" << "\n" + << "\t\t\t" << "refType = " << reftypeForFile(library) << ";" << "\n" + << "\t\t" << "};" << "\n"; + project->variables()["QMAKE_PBX_LIBRARIES"].append(key); + QString obj_key = library + ".o"; + obj_key = keyFor(obj_key); + t << "\t\t" << obj_key << " = {" << "\n" + << "\t\t\t" << "fileRef = " << key << ";" << "\n" + << "\t\t\t" << "isa = PBXBuildFile;" << "\n" + << "\t\t\t" << "settings = {" << "\n" + << "\t\t\t" << "};" << "\n" + << "\t\t" << "};" << "\n"; + project->variables()["QMAKE_PBX_BUILD_LIBRARIES"].append(obj_key); + } + if(remove) + it = tmp.remove(it); + else + ++it; + } + project->variables()[libs[i]] = tmp; + } + } + //SUBLIBS BUILDPHASE (just another makefile) + if(!project->isEmpty("SUBLIBS")) { + QString mkfile = pbx_dir + Option::dir_sep + "qt_sublibs.mak"; + QFile mkf(mkfile); + if(mkf.open(IO_WriteOnly | IO_Translate)) { + debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1()); + QTextStream mkt(&mkf); + writeHeader(mkt); + mkt << "SUBLIBS= "; + tmp = project->variables()["SUBLIBS"]; + QStringList::Iterator it; + for(it = tmp.begin(); it != tmp.end(); ++it) + t << "tmp/lib" << (*it) << ".a "; + t << endl << endl; + mkt << "sublibs: $(SUBLIBS)" << endl << endl; + tmp = project->variables()["SUBLIBS"]; + for(it = tmp.begin(); it != tmp.end(); ++it) + t << "tmp/lib" << (*it) << ".a" << ":\n\t" + << var(QString("MAKELIB") + (*it)) << endl << endl; + mkf.close(); + } + QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE"); + mkfile = fileFixify(mkfile, QDir::currentDirPath()); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); + t << "\t\t" << phase_key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" + << "\t\t\t" << "files = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "generatedFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n" + << "\t\t\t" << "name = \"Qt Sublibs\";" << "\n" + << "\t\t\t" << "neededFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "shellPath = /bin/sh;" << "\n" + << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() << + " -f " << mkfile << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + //LIBRARY BUILDPHASE + if(!project->isEmpty("QMAKE_PBX_LIBRARIES")) { + tmp = project->variables()["QMAKE_PBX_LIBRARIES"]; + if(!tmp.isEmpty()) { + QString grp("External Frameworks and Libraries"), key = keyFor(grp); + project->variables()["QMAKE_PBX_GROUPS"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "children = (" << "\n" + << varGlue("QMAKE_PBX_LIBRARIES", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXGroup;" << "\n" + << "\t\t\t" << "name = \"" << grp << "\"" << ";" << "\n" + << "\t\t\t" << "path = \"\";" << "\n" + << "\t\t\t" << "refType = 4;" << "\n" + << "\t\t" << "};" << "\n"; + } + } + { + QString grp("Frameworks & Libraries"), key = keyFor(grp); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" + << "\t\t\t" << "files = (" << "\n" + << varGlue("QMAKE_PBX_BUILD_LIBRARIES", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXFrameworksBuildPhase;" << "\n" + << "\t\t\t" << "name = \"" << grp << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console") && + project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES + QString grp("Bundle Resources"), key = keyFor(grp); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" + << "\t\t\t" << "files = (" << "\n" + << (!project->isEmpty("RC_FILE") ? keyFor("ICNS_FILE_REFERENCE") : QString("")) + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXResourcesBuildPhase;" << "\n" + << "\t\t\t" << "name = \"" << grp << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + + //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER + //PRODUCTS + { + QString grp("Products"), key = keyFor(grp); + project->variables()["QMAKE_PBX_GROUPS"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "children = (" << "\n" + << "\t\t\t\t" << keyFor("QMAKE_PBX_REFERENCE") << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXGroup;" << "\n" + << "\t\t\t" << "name = Products;" << "\n" + << "\t\t\t" << "refType = 4;" << "\n" + << "\t\t" << "};" << "\n"; + } + { //INSTALL BUILDPHASE (sh script) + QString targ = project->first("TARGET"); + if(project->first("TEMPLATE") == "app" || + (project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") && + project->isActiveConfig("frameworklib"))) + targ = project->first("QMAKE_ORIG_TARGET"); + int slsh = targ.findRev(Option::dir_sep); + if(slsh != -1) + targ = targ.right(targ.length() - slsh - 1); + fixEnvVariables(targ); + QStringList links; + if(project->first("TEMPLATE") == "app") { + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) + targ += ".app"; + } else if(!project->isActiveConfig("staticlib") && + !project->isActiveConfig("frameworklib")) { + QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null }; + for(int n = 0; !li[n].isNull(); n++) { + QString t = project->first(li[n]); + slsh = t.findRev(Option::dir_sep); + if(slsh != -1) + t = t.right(t.length() - slsh); + fixEnvVariables(t); + links << t; + } + } + QString script = pbx_dir + Option::dir_sep + "qt_install.sh"; + QFile shf(script); + if(shf.open(IO_WriteOnly | IO_Translate)) { + debug_msg(1, "pbuilder: Creating file: %s", script.latin1()); + QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags; + if(project->first("TEMPLATE") == "app") { + targ = project->first("TARGET"); + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { + targ += ".app"; + cpflags += "-r "; + } + } else if(!project->isActiveConfig("frameworklib")) { + if(project->isActiveConfig("staticlib")) + targ = project->first("TARGET"); + else + targ = project->first("TARGET_"); + int slsh = targ.findRev(Option::dir_sep); + if(slsh != -1) + targ = targ.right(targ.length() - slsh - 1); + } + QTextStream sht(&shf); + QString dstdir = project->first("DESTDIR"); + fixEnvVariables(dstdir); + + sht << "#!/bin/sh" << endl; + //copy the actual target + sht << "OUT_TARG=\"" << targ << "\"\n" + << "[ -z \"$BUILD_ROOT\" ] || OUT_TARG=\"${BUILD_ROOT}/${OUT_TARG}\"" << endl; + sht << "[ \"$OUT_TARG\" = \"" + << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || " + << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || " + << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << endl; + //rename as a framework + if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib")) + sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl; + //create all the version symlinks (just to be like unixmake) + for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) { + if(targ != (*it)) + sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << (*it) << "\"" << endl; + } + shf.close(); +#ifdef Q_OS_UNIX + chmod(script.latin1(), S_IRWXU | S_IRWXG); +#endif + QString phase_key = keyFor("QMAKE_PBX_INSTALL_BUILDPHASE"); + script = fileFixify(script, QDir::currentDirPath()); + project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); + t << "\t\t" << phase_key << " = {" << "\n" + << "\t\t\t" << "buildActionMask = 8;" << "\n" //only on install! + << "\t\t\t" << "files = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "generatedFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n" + << "\t\t\t" << "name = \"Qt Install\";" << "\n" + << "\t\t\t" << "neededFileNames = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "shellPath = /bin/sh;" << "\n" + << "\t\t\t" << "shellScript = \"" << script << "\";" << "\n" + << "\t\t" << "};" << "\n"; + } + } + //ROOT_GROUP + t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n" + << "\t\t\t" << "children = (" << "\n" + << varGlue("QMAKE_PBX_GROUPS", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXGroup;" << "\n" + << "\t\t\t" << "name = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n" + << "\t\t\t" << "path = \"\";" << "\n" + << "\t\t\t" << "refType = 4;" << "\n" + << "\t\t" << "};" << "\n"; + //REFERENCE + t << "\t\t" << keyFor("QMAKE_PBX_REFERENCE") << " = {" << "\n"; + if(project->first("TEMPLATE") == "app") { + QString targ = project->first("QMAKE_ORIG_TARGET"); + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { + targ += ".app"; + t << "\t\t\t" << "isa = PBXApplicationReference;" << "\n"; + } else { + t << "\t\t\t" << "isa = PBXExecutableFileReference;" << "\n"; + } + QString app = (!project->isEmpty("DESTDIR") ? project->first("DESTDIR") + project->first("QMAKE_ORIG_TARGET") : + QDir::currentDirPath()) + Option::dir_sep + targ; + t << "\t\t\t" << "name = " << targ << ";" << "\n" + << "\t\t\t" << "path = \"" << targ << "\";" << "\n" + << "\t\t\t" << "refType = " << reftypeForFile(app) << ";" << "\n"; + } else { + QString lib = project->first("QMAKE_ORIG_TARGET"); + if(project->isActiveConfig("staticlib")) { + lib = project->first("TARGET"); + } else if(!project->isActiveConfig("frameworklib")) { + if(project->isActiveConfig("plugin")) + lib = project->first("TARGET"); + else + lib = project->first("TARGET_"); + } + int slsh = lib.findRev(Option::dir_sep); + if(slsh != -1) + lib = lib.right(lib.length() - slsh - 1); + t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n" + << "\t\t\t" << "path = " << lib << ";\n" + << "\t\t\t" << "refType = " << reftypeForFile(lib) << ";" << "\n"; + } + t << "\t\t" << "};" << "\n"; + //TARGET + t << "\t\t" << keyFor("QMAKE_PBX_TARGET") << " = {" << "\n" + << "\t\t\t" << "buildPhases = (" << "\n" + << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "buildSettings = {" << "\n" + << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n" + << "\t\t\t\t" << "HEADER_SEARCH_PATHS = \"" << fixEnvsList("INCLUDEPATH") << " " << fixEnvs(specdir()) << "\";" << "\n" + << "\t\t\t\t" << "LIBRARY_SEARCH_PATHS = \"" << var("QMAKE_PBX_LIBPATHS") << "\";" << "\n" + << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n" + << "\t\t\t\t" << "OTHER_CFLAGS = \"" << + fixEnvsList("QMAKE_CFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << + varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" + << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n" + << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n" + << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" << + fixEnvsList("QMAKE_CXXFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << + varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" + << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n" + << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n" + << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n"; +#if 1 + t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n"; +#endif + if(!project->isActiveConfig("staticlib")) + t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " << + fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") << + " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n"; + if(!project->isEmpty("DESTDIR")) + t << "\t\t\t\t" << "INSTALL_PATH = \"" << project->first("DESTDIR") << "\";" << "\n"; + if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0") + t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VERSION") << "\";" << "\n"; + if(!project->isEmpty("OBJECTS_DIR")) + t << "\t\t\t\t" << "OBJECT_FILE_DIR = \"" << project->first("OBJECTS_DIR") << "\";" << "\n"; + if(project->first("TEMPLATE") == "app") { + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) + t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n"; + t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; + } else { + QString lib = project->first("QMAKE_ORIG_TARGET"); + if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) { + t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n"; + lib = project->first("TARGET"); + } else { + t << "\t\t\t\t" << "LIBRARY_STYLE = DYNAMIC;" << "\n"; + if(!project->isActiveConfig("frameworklib")) { + if(project->isActiveConfig("plugin")) + lib = project->first("TARGET"); + else + lib = project->first("TARGET_"); + } + } + int slsh = lib.findRev(Option::dir_sep); + if(slsh != -1) + lib = lib.right(lib.length() - slsh - 1); + t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n"; + } + tmp = project->variables()["QMAKE_PBX_VARS"]; + for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) + t << "\t\t\t\t" << (*it) << " = \"" << getenv((*it)) << "\";" << "\n"; + t << "\t\t\t" << "};" << "\n" + << "\t\t\t" << "conditionalBuildSettings = {" << "\n" + << "\t\t\t" << "};" << "\n" + << "\t\t\t" << "dependencies = (" << "\n" + << varGlue("QMAKE_PBX_TARGETDEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_REFERENCE") << ";" << "\n" + << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n"; + if(project->first("TEMPLATE") == "app") { + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { + t << "\t\t\t" << "isa = PBXApplicationTarget;" << "\n" + << "\t\t\t" << "productSettingsXML = " << "\"" << "" << "\n" + << "\t\t\t\t" << "" << "\n" + << "\t\t\t\t" << "" << "\n" + << "\t\t\t\t" << "" << "\n" + << "\t\t\t\t\t" << "CFBundleDevelopmentRegion" << "\n" + << "\t\t\t\t\t" << "English" << "\n" + << "\t\t\t\t\t" << "CFBundleExecutable" << "\n" + << "\t\t\t\t\t" << "" << project->first("QMAKE_ORIG_TARGET") << "" << "\n" + << "\t\t\t\t\t" << "CFBundleIconFile" << "\n" + << "\t\t\t\t\t" << "" << var("RC_FILE").section(Option::dir_sep, -1) << "" << "\n" + << "\t\t\t\t\t" << "CFBundleInfoDictionaryVersion" << "\n" + << "\t\t\t\t\t" << "6.0" << "\n" + << "\t\t\t\t\t" << "CFBundlePackageType" << "\n" + << "\t\t\t\t\t" << "APPL" << "\n" + << "\t\t\t\t\t" << "CFBundleSignature" << "\n" + << "\t\t\t\t\t" << "????" << "\n" + << "\t\t\t\t\t" << "CFBundleVersion" << "\n" + << "\t\t\t\t\t" << "0.1" << "\n" + << "\t\t\t\t\t" << "CSResourcesFileMapped" << "\n" + << "\t\t\t\t\t" << "" << "\n" + << "\t\t\t\t" << "" << "\n" + << "\t\t\t\t" << "" << "\";" << "\n"; + } else { + t << "\t\t\t" << "isa = PBXToolTarget;" << "\n"; + } + t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n" + << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; + } else { + QString lib = project->first("QMAKE_ORIG_TARGET"); + if(!project->isActiveConfig("frameworklib")) + lib.prepend("lib"); + t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n" + << "\t\t\t" << "name = \"" << lib << "\";" << "\n" + << "\t\t\t" << "productName = " << lib << ";" << "\n"; + } + if(!project->isEmpty("DESTDIR")) + t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n"; + t << "\t\t" << "};" << "\n"; + //DEBUG/RELEASE + for(i = 0; i < 2; i++) { + bool as_release = !i; + if(project->isActiveConfig("debug")) + as_release = i; + QString key = "QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"); + key = keyFor(key); + project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key); + t << "\t\t" << key << " = {" << "\n" + << "\t\t\t" << "buildRules = (" << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "buildSettings = {" << "\n" + << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n"; + if(as_release) + t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n"; + t << "\t\t\t" << "};" << "\n" + << "\t\t\t" << "isa = PBXBuildStyle;" << "\n" + << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n" + << "\t\t" << "};" << "\n"; + } + //ROOT + t << "\t\t" << keyFor("QMAKE_PBX_ROOT") << " = {" << "\n" + << "\t\t\t" << "buildStyles = (" << "\n" + << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n") + << "\t\t\t" << ");" << "\n" + << "\t\t\t" << "isa = PBXProject;" << "\n" + << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n" + << "\t\t\t" << "targets = (" << "\n" + << "\t\t\t\t" << keyFor("QMAKE_PBX_TARGET") << "\n" + << "\t\t\t" << ");" << "\n" + << "\t\t" << "};" << "\n"; + + //FOOTER + t << "\t" << "};" << "\n" + << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n" + << "}" << endl; + + QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"), + QDir::currentDirPath()); + QFile mkwrapf(mkwrap); + if(mkwrapf.open(IO_WriteOnly | IO_Translate)) { + debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1()); + QTextStream mkwrapt(&mkwrapf); + writeHeader(mkwrapt); + const char *cleans = "uiclean mocclean preprocess_clean "; + mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n" + << "all:" << "\n\t" + << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild") << "\n" + << "install: all" << "\n\t" + << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild install") << "\n" + << "distclean clean: preprocess_clean" << "\n\t" + << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild clean") << "\n" + << (!did_preprocess ? cleans : "") << ":" << "\n"; + if(did_preprocess) + mkwrapt << cleans << ":" << "\n\t" + << "make -f " + << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl; + } + return TRUE; +} + +QString +ProjectBuilderMakefileGenerator::fixEnvs(QString file) +{ + QRegExp reg_var("\\$\\((.*)\\)"); + for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) { + if(project->variables()["QMAKE_PBX_VARS"].findIndex(reg_var.cap(1)) == -1) + project->variables()["QMAKE_PBX_VARS"].append(reg_var.cap(1)); + rep += reg_var.matchedLength(); + } + return file; +} + +QString +ProjectBuilderMakefileGenerator::fixEnvsList(QString where) +{ + QString ret; + const QStringList &l = project->variables()[where]; + for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + fixEnvs((*it)); + if(!ret.isEmpty()) + ret += " "; + ret += (*it); + } + return ret; +} + +QString +ProjectBuilderMakefileGenerator::keyFor(QString block) +{ +#if 0 //This make this code much easier to debug.. + return block; +#endif + + QString ret; + if(!keys.contains(block)) { +#if 0 + static unsigned int r = 0; + ret.sprintf("%024x", ++r); +#else //not really necesary, but makes it look more interesting.. + static struct { unsigned int a1, a2, a3; } r = { 0, 0, 0 }; + if(!r.a1 && !r.a2 && !r.a3) { + r.a1 = rand(); + r.a2 = rand(); + r.a3 = rand(); + } + switch(rand() % 3) { + case 0: ++r.a1; break; + case 1: ++r.a2; break; + case 2: ++r.a3; break; + } + ret.sprintf("%08x%08x%08x", r.a1, r.a2, r.a3); +#endif + ret = ret.upper(); + keys.insert(block, ret); + } else { + ret = keys[block]; + } + return ret; +} + +bool +ProjectBuilderMakefileGenerator::openOutput(QFile &file) const +{ + if(project->first("TEMPLATE") != "subdirs") { + QFileInfo fi(file); + if(fi.extension() != "pbxproj" || file.name().isEmpty()) { + QString output = file.name(); + if(fi.isDir()) + output += QDir::separator(); + if(fi.extension() != "pbproj") { + if(file.name().isEmpty() || fi.isDir()) + output += project->first("TARGET"); + output += QString(".pbproj") + QDir::separator(); + } else if(output[(int)output.length() - 1] != QDir::separator()) { + output += QDir::separator(); + } + output += QString("project.pbxproj"); + file.setName(output); + } + bool ret = UnixMakefileGenerator::openOutput(file); + ((ProjectBuilderMakefileGenerator*)this)->pbx_dir = Option::output_dir.section(Option::dir_sep, 0, -1); + Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2); + return ret; + } + return UnixMakefileGenerator::openOutput(file); +} + +/* This function is such a hack it is almost pointless, but it + eliminates the warning message from ProjectBuilder that the project + file is for an older version. I guess this could be used someday if + the format of the output is dependant upon the version of + ProjectBuilder as well. +*/ +int +ProjectBuilderMakefileGenerator::pbuilderVersion() const +{ + QString ret; + if(project->isEmpty("QMAKE_PBUILDER_VERSION")) { + QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST"); + if(version_plist.isEmpty()) + version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist"; + else + version_plist = version_plist.replace(QRegExp("\""), ""); + QFile version_file(version_plist); + if(version_file.open(IO_ReadOnly)) { + debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1()); + QTextStream plist(&version_file); + + bool in_dict = FALSE; + QString current_key; + QRegExp keyreg("^(.*)$"), stringreg("^(.*)$"); + while(!plist.eof()) { + QString line = plist.readLine().stripWhiteSpace(); + if(line == "") + in_dict = TRUE; + else if(line == "") + in_dict = FALSE; + else if(in_dict) { + if(keyreg.exactMatch(line)) + current_key = keyreg.cap(1); + else if(current_key == "CFBundleShortVersionString" && stringreg.exactMatch(line)) + version = stringreg.cap(1); + } + } + version_file.close(); + } else debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); + if(version.startsWith("2.0")) + ret = "38"; + else if(version == "1.1") + ret = "34"; + } else { + ret = project->first("QMAKE_PBUILDER_VERSION"); + } + if(!ret.isEmpty()) { + bool ok; + int int_ret = ret.toInt(&ok); + if(ok) { + debug_msg(1, "pbuilder: version.plist: Got version: %d", int_ret); + return int_ret; + } + } + debug_msg(1, "pbuilder: version.plist: Fallback to default version"); + return 34; //my fallback +} + +QString +ProjectBuilderMakefileGenerator::reftypeForFile(QString where) +{ + if(QDir::isRelativePath(where)) + return "4"; //relative + return "0"; //absolute +} diff --git a/qmake/generators/mac/pbuilder_pbx.h b/qmake/generators/mac/pbuilder_pbx.h new file mode 100644 index 0000000..ec2e1be --- a/dev/null +++ b/qmake/generators/mac/pbuilder_pbx.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __PBUILDERMAKE_H__ +#define __PBUILDERMAKE_H__ + +#include "unixmake.h" + +class ProjectBuilderMakefileGenerator : public UnixMakefileGenerator +{ + QString pbx_dir; + int pbuilderVersion() const; + bool writeMakeParts(QTextStream &); + bool writeMakefile(QTextStream &); + + QMap keys; + QString keyFor(QString file); + QString fixEnvs(QString file); + QString fixEnvsList(QString where); + QString reftypeForFile(QString file); + +public: + ProjectBuilderMakefileGenerator(QMakeProject *p); + ~ProjectBuilderMakefileGenerator(); + + virtual bool openOutput(QFile &) const; +protected: + virtual bool doDepends() const { return FALSE; } //never necesary +}; + +inline ProjectBuilderMakefileGenerator::~ProjectBuilderMakefileGenerator() +{ } + + +#endif /* __PBUILDERMAKE_H__ */ diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp new file mode 100644 index 0000000..7df95b2 --- a/dev/null +++ b/qmake/generators/unix/unixmake.cpp @@ -0,0 +1,520 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "unixmake.h" +#include "option.h" +#include +#include +#include +#include +#include + + +void +UnixMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ + return; + + QStringList &configs = project->variables()["CONFIG"]; + /* 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->isEmpty("MAKEFILE")) + project->variables()["MAKEFILE"].append("Makefile"); + if(project->isEmpty("QMAKE")) + project->variables()["QMAKE"].append("qmake"); + if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) + project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); + return; /* subdirs is done */ + } + + if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { + QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); + if ( os == "cygwin" ) { + project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" ); + } else { + project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); + } + } + if( project->isEmpty("QMAKE_COPY_FILE") ) + project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); + if( project->isEmpty("QMAKE_COPY_DIR") ) + project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); + //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET + if(!project->isEmpty("TARGET")) { + QString targ = project->first("TARGET"); + int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); + if(slsh != -1) { + if(project->isEmpty("DESTDIR")) + project->values("DESTDIR").append(""); + else if(project->first("DESTDIR").right(1) != Option::dir_sep) + project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep; + project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1); + project->variables()["TARGET"] = targ.mid(slsh+1); + } + } + + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || + project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); + bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || + (!project->isEmpty("QMAKE_LIB_FLAG") && + project->isActiveConfig("dll")) || is_qt; + if(!project->isActiveConfig("global_init_link_order")) + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || + (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { + if(configs.findIndex("dll") == -1) configs.append("dll"); + } else if ( !project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll") ) { + configs.remove("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") ) { + 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 { + 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->isEmpty("QMAKE_INCREMENTAL")) + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_INCREMENTAL"]; + else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && + !project->variables()["QMAKE_LIB_FLAG"].isEmpty() && + project->isActiveConfig("dll")) + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"]; + if(!project->isEmpty("QMAKE_INCDIR")) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; + if(!project->isEmpty("QMAKE_LIBDIR")) { + if ( !project->isEmpty("QMAKE_RPATH") ) + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), + " " + var("QMAKE_RPATH"), ""); + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); + } + if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { + if(configs.findIndex("x11lib") == -1) + configs.append("x11lib"); + if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) + configs.append("x11inc"); + } + if ( project->isActiveConfig("x11") ) { + if(configs.findIndex("x11lib") == -1) + configs.append("x11lib"); + if(configs.findIndex("x11inc") == -1) + configs.append("x11inc"); + } + if ( project->isActiveConfig("qt") ) { + 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(configs.findIndex("moc")) configs.append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + if ( !project->isActiveConfig("debug") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); + if ( !is_qt ) { + if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { + if ( !project->isEmpty("QMAKE_RPATH") ) + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), + " " + var("QMAKE_RPATH"), ""); + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); + } + if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + } + } + if ( project->isActiveConfig("thread") ) { + if(project->isActiveConfig("qt")) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); + if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; + if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"]; + if(!project->isEmpty("QMAKE_LFLAGS_THREAD")) + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"]; + } + if ( project->isActiveConfig("opengl") ) { + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; + if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); + if ( is_qt ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + } + if(project->isActiveConfig("global_init_link_order")) + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + if ( project->isActiveConfig("x11sm") ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"]; + if ( project->isActiveConfig("dylib") ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"]; + if ( project->isActiveConfig("x11inc") ) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; + if ( project->isActiveConfig("x11lib") ) { + if(!project->isEmpty("QMAKE_LIBDIR_X11")) + project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; + } + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + if ( project->isEmpty("QMAKE_RUN_CC") ) + project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); + if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) + project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); + if ( project->isEmpty("QMAKE_RUN_CXX") ) + project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); + if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) + project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); + project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); + if ( !project->isEmpty("PRECOMPH") ) { + initOutPaths(); // Need to fix MOC_DIR since we do this before init() + QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); + project->variables()["SOURCES"].prepend(allmoc); + project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; + project->variables()["HEADERS"].clear(); + } + if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) + include_deps = TRUE; //do not generate deps + + MakefileGenerator::init(); + if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { + if(!project->isEmpty("QMAKE_APP_FLAG")) { + if(project->isEmpty("DESTDIR")) + project->values("DESTDIR").append(""); + project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() + + ".app/Contents/MacOS/"; + project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo"); + project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO"); + + QString plist = specdir() + QDir::separator() + "Info.plist." + + project->first("TEMPLATE"); + if(QFile::exists(Option::fixPathToLocalOS(plist))) { + project->variables()["QMAKE_INFO_PLIST"].append(plist); + project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") + + "../Info.plist"); + project->variables()["ALL_DEPS"] += project->first("QMAKE_INFO_PLIST_OUT"); + if(!project->isEmpty("RC_FILE")) + project->variables()["ALL_DEPS"] += project->first("DESTDIR") + + "../Resources/application.icns"; + } + } + } + + if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) + project->variables()["DISTFILES"] += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"]; + project->variables()["DISTFILES"] += Option::mkfile::project_files; + + init2(); + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_LIBDIR_FLAGS" << "QMAKE_LIBS"; + if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) { + bool ok; + int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok); + QStringList ar_sublibs, objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"]; + if(ok && max_files > 5 && max_files < (int)objs.count()) { + int obj_cnt = 0, lib_cnt = 0; + QString lib; + for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { + if((++obj_cnt) >= max_files) { + if(lib_cnt) { + lib.sprintf("lib%s-tmp%d.a", project->first("QMAKE_ORIG_TARGET").latin1(), lib_cnt); + ar_sublibs << lib; + obj_cnt = 0; + } + lib_cnt++; + } + } + } + if(!ar_sublibs.isEmpty()) { + project->variables()["QMAKE_AR_SUBLIBS"] = ar_sublibs; + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS"; + } + } +} + +QStringList +UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &list2) +{ + QStringList ret; + for(QStringList::ConstIterator it = list1.begin(); it != list1.end(); ++it) { + bool unique = TRUE; + if((*it).startsWith("-")) { + if((*it).startsWith("-l") || (*it).startsWith("-L")) { + unique = list2.findIndex((*it)) == -1; + } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) { + int as_one = TRUE; + QString framework_in; + if((*it).length() > 11) { + framework_in = (*it).mid(11); + } else { + if(it != list1.end()) { + ++it; + as_one = FALSE; + framework_in = (*it); + } + } + if(!framework_in.isEmpty()) { + for(QStringList::ConstIterator outit = list2.begin(); outit != list2.end(); ++outit) { + if((*outit).startsWith("-framework")) { + QString framework_out; + if((*outit).length() > 11) { + framework_out = (*outit).mid(11); + } else { + if(it != list2.end()) { + ++outit; + framework_out = (*outit); + } + } + if(framework_out == framework_in) { + unique = FALSE; + break; + } + } + } + if(unique) { + unique = FALSE; //because I'm about to just insert it myself + if(as_one) { + ret.append("-framework " + framework_in); + } else { + ret.append("-framework"); + ret.append(framework_in); + } + } + } + } else { + unique = (list2.findIndex((*it)) == -1); + } + } else if(QFile::exists((*it))) { + unique = (list2.findIndex((*it)) == -1); + } + if(unique) + ret.append((*it)); + } + return ret; +} + + +void +UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) +{ + if(var == "QMAKE_PRL_LIBS") + project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); + else + MakefileGenerator::processPrlVariable(var, l); +} + +void +UnixMakefileGenerator::processPrlFiles() +{ + QDict processed; + QPtrList libdirs; + libdirs.setAutoDelete(TRUE); + const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; + for(int i = 0; !lflags[i].isNull(); i++) { + for(bool ret = FALSE; TRUE; ret = FALSE) { + QStringList l_out; + QStringList &l = project->variables()[lflags[i]]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); + QString opt = (*it).stripWhiteSpace();; + if(opt.startsWith("-")) { + if(opt.startsWith("-L")) { + QString r = opt.right(opt.length() - 2), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } else if(opt.startsWith("-l") && !processed[opt]) { + QString lib = opt.right(opt.length() - 2), prl; + for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { + prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; + if(processPrlFile(prl)) { + if(prl.startsWith(mdd->local_dir)) + prl.replace(0, mdd->local_dir.length(), mdd->real_dir); + QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$"); + if(reg.exactMatch(prl)) + prl = "-l" + reg.cap(1); + opt = prl; + processed.insert(opt, (void*)1); + ret = TRUE; + break; + } + } + } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) { + if(opt.length() > 11) { + opt = opt.mid(11); + } else { + ++it; + opt = (*it); + } + QString prl = "/System/Library/Frameworks/" + opt + + ".framework/" + opt + Option::prl_ext; + if(processPrlFile(prl)) + ret = TRUE; + l_out.append("-framework"); + } + if(!opt.isEmpty()) + l_out.append(opt); + l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); + } else { + if(!processed[opt] && processPrlFile(opt)) { + processed.insert(opt, (void*)1); + ret = TRUE; + } + if(!opt.isEmpty()) + l_out.append(opt); + l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); + } + } + if(ret && l != l_out) + l = l_out; + else + break; + } + } +} + +QString +UnixMakefileGenerator::defaultInstall(const QString &t) +{ + if(t != "target" || project->first("TEMPLATE") == "subdirs") + return QString(); + + bool resource = FALSE; + QStringList &uninst = project->variables()[t + ".uninstall"]; + QString ret, destdir=fileFixify(project->first("DESTDIR")); + QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE); + if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) + destdir += Option::dir_sep; + targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE); + if(targetdir.right(1) != Option::dir_sep) + targetdir += Option::dir_sep; + + QStringList links; + QString target="$(TARGET)"; + if(project->first("TEMPLATE") == "app") { + target = "$(QMAKE_TARGET)"; + if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { + destdir += "../../../"; + target += ".app"; + resource = TRUE; + } + } else if(project->first("TEMPLATE") == "lib") { + if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { + QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); + int slsh = dst_prl.findRev('/'); + if(slsh != -1) + dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); + dst_prl = targetdir + dst_prl; + ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl; + if(!uninst.isEmpty()) + uninst.append("\n\t"); + uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); + } + QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); + if ( os != "cygwin" ) { + if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { + if ( os == "hpux" ) { + links << "$(TARGET0)"; + } else { + links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; + } + } + } + } + QString src_targ = target; + if(!destdir.isEmpty()) + src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); + QString dst_targ = fileFixify(targetdir + target); + if(!ret.isEmpty()) + ret += "\n\t"; + ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + + src_targ + "\" \"" + dst_targ + "\""; + if(!project->isEmpty("QMAKE_STRIP")) { + ret += "\n\t-" + var("QMAKE_STRIP"); + if(resource) + ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)"; + else + ret += " \"" + dst_targ + "\""; + } + if(!uninst.isEmpty()) + uninst.append("\n\t"); + if(resource) + uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\""); + else + uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); + if(!links.isEmpty()) { + for(QStringList::Iterator it = links.begin(); it != links.end(); it++) { + if(Option::target_mode == Option::TARG_WIN_MODE || + Option::target_mode == Option::TARG_MAC9_MODE) { + } else if(Option::target_mode == Option::TARG_UNIX_MODE || + Option::target_mode == Option::TARG_MACX_MODE) { + QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); + int lslash = link.findRev(Option::dir_sep); + if(lslash != -1) + link = link.right(link.length() - (lslash + 1)); + QString dst_link = fileFixify(targetdir + link); + ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; + if(!uninst.isEmpty()) + uninst.append("\n\t"); + uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); + } + } + } + return ret; +} + + diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h new file mode 100644 index 0000000..e889dcc --- a/dev/null +++ b/qmake/generators/unix/unixmake.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __UNIXMAKE_H__ +#define __UNIXMAKE_H__ + +#include "makefile.h" + +class UnixMakefileGenerator : public MakefileGenerator +{ + bool init_flag, include_deps; + bool writeMakefile(QTextStream &); + QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2); + +public: + UnixMakefileGenerator(QMakeProject *p); + ~UnixMakefileGenerator(); + +protected: + virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); } + virtual QString defaultInstall(const QString &); + virtual void processPrlVariable(const QString &, const QStringList &); + virtual void processPrlFiles(); + + virtual void init(); + + void writeMakeParts(QTextStream &); + void writeSubdirs(QTextStream &, bool=TRUE); + +private: + void init2(); +}; + +inline UnixMakefileGenerator::~UnixMakefileGenerator() +{ } + + +#endif /* __UNIXMAKE_H__ */ diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp new file mode 100644 index 0000000..1797b98 --- a/dev/null +++ b/qmake/generators/unix/unixmake2.cpp @@ -0,0 +1,1048 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "unixmake.h" +#include "option.h" +#include +#include +#include +#include + + +UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE) +{ + +} + +bool +UnixMakefileGenerator::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->variables()["TEMPLATE"].first() == "app" || + project->variables()["TEMPLATE"].first() == "lib") { + writeMakeParts(t); + return MakefileGenerator::writeMakefile(t); + } else if(project->variables()["TEMPLATE"].first() == "subdirs") { + writeSubdirs(t); + return TRUE; + } + return FALSE; +} + +void +UnixMakefileGenerator::writeMakeParts(QTextStream &t) +{ + QString deps = fileFixify(Option::output.name()), prl; + bool do_incremental = (project->isActiveConfig("incremental") && + !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && + (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || + !project->isActiveConfig("staticlib"))), + src_incremental=FALSE, moc_incremental=FALSE; + QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); + + t << "####### Compiler, tools and options" << endl << endl; + t << "CC = "; + if (project->isActiveConfig("thread") && + ! project->variables()["QMAKE_CC_THREAD"].isEmpty()) + t << var("QMAKE_CC_THREAD") << endl; + else + t << var("QMAKE_CC") << endl; + + t << "CXX = "; + if (project->isActiveConfig("thread") && + ! project->variables()["QMAKE_CXX_THREAD"].isEmpty()) + t << var("QMAKE_CXX_THREAD") << endl; + else + t << 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 = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl; + + if(!project->isActiveConfig("staticlib")) { + t << "LINK = "; + if (project->isActiveConfig("thread") && + ! project->variables()["QMAKE_LINK_THREAD"].isEmpty()) + t << var("QMAKE_LINK_THREAD") << endl; + else + t << var("QMAKE_LINK") << endl; + + t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; + t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; + } + + t << "AR = " << var("QMAKE_AR") << endl; + t << "RANLIB = " << var("QMAKE_RANLIB") << endl; + t << "MOC = " << var("QMAKE_MOC") << endl; + t << "UIC = " << var("QMAKE_UIC") << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "TAR = " << var("QMAKE_TAR") << endl; + t << "GZIP = " << var("QMAKE_GZIP") << endl; + t << "COPY = " << var("QMAKE_COPY") << endl; + t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; + t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; + t << "MOVE = " << var("QMAKE_MOVE") << endl; + t << endl; + + t << "####### Output directory" << endl << endl; + if (! project->variables()["OBJECTS_DIR"].isEmpty()) + t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; + else + t << "OBJECTS_DIR = ./" << endl; + t << endl; + + /* files */ + t << "####### Files" << endl << endl; + t << "HEADERS = " << varList("HEADERS") << endl; + t << "SOURCES = " << varList("SOURCES") << endl; + if(do_incremental) { + QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; + t << "OBJECTS = "; + for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { + bool increment = FALSE; + for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { + if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { + increment = TRUE; + incrs_out.append((*objit)); + break; + } + } + if(!increment) + t << "\\\n\t\t" << (*objit); + } + if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! + t << incrs_out.join(" \\\n\t\t") << endl; + } else if(!incrs_out.count()) { + t << endl; + } else { + src_incremental = TRUE; + t << endl; + t << "INCREMENTAL_OBJECTS = " << incrs_out.join(" \\\n\t\t") << endl; + } + } else { + t << "OBJECTS = " << varList("OBJECTS") << endl; + } + t << "FORMS = " << varList("FORMS") << endl; + t << "UICDECLS = " << varList("UICDECLS") << endl; + t << "UICIMPLS = " << varList("UICIMPLS") << endl; + QString srcMoc = varList("SRCMOC"), objMoc = varList("OBJMOC"); + t << "SRCMOC = " << srcMoc << endl; + if(do_incremental) { + QStringList &objs = project->variables()["OBJMOC"], + &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; + t << "OBJMOC = "; + for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { + bool increment = FALSE; + for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { + if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { + increment = TRUE; + incrs_out.append((*objit)); + break; + } + } + if(!increment) + t << "\\\n\t\t" << (*objit); + } + if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! + t << incrs_out.join(" \\\n\t\t") << endl; + } else if(!incrs_out.count()) { + t << endl; + } else { + moc_incremental = TRUE; + t << endl; + t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl; + } + } else { + t << "OBJMOC = " << objMoc << endl; + } + if(do_incremental && !moc_incremental && !src_incremental) + do_incremental = FALSE; + t << "DIST = " << varList("DISTFILES") << endl; + t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; + t << "DESTDIR = " << var("DESTDIR") << endl; + t << "TARGET = " << var("TARGET") << endl; + if(project->isActiveConfig("plugin") ) { + t << "TARGETD = " << var("TARGET") << endl; + } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) { + t << "TARGETA = " << var("TARGETA") << endl; + if (os == "hpux") { + t << "TARGETD = " << var("TARGET_x") << endl; + t << "TARGET0 = " << var("TARGET_") << endl; + } + else { + t << "TARGETD = " << var("TARGET_x.y.z") << endl; + t << "TARGET0 = " << var("TARGET_") << endl; + t << "TARGET1 = " << var("TARGET_x") << endl; + t << "TARGET2 = " << var("TARGET_x.y") << endl; + } + } + t << endl; + + // blasted incldues + QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; + QStringList::Iterator it; + for( it = qeui.begin(); it != qeui.end(); ++it) + t << "include " << (*it) << endl; + + /* rules */ + t << "first: all" << endl; + t << "####### Implicit rules" << endl << endl; + t << ".SUFFIXES: .c"; + QStringList::Iterator cppit; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << " " << (*cppit); + t << endl << endl; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + + if(include_deps) { + QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; + cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); + if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) + cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; + cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); + QString odir; + if(!project->variables()["OBJECTS_DIR"].isEmpty()) + odir = project->first("OBJECTS_DIR"); + t << "###### Dependancies" << endl << endl; + t << odir << ".deps/%.d: %.cpp\n\t" + << "@echo Creating depend for $<" << "\n\t" + << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" + << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; + + t << odir << ".deps/%.d: %.c\n\t" + << "@echo Creating depend for $<" << "\n\t" + << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" + << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; + + + QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; + for(int x = 0; !src[x].isNull(); x++) { + QStringList &l = project->variables()[src[x]]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + if(!(*it).isEmpty()) { + QString d_file; + if((*it).endsWith(".c")) { + d_file = (*it).left((*it).length() - 2); + } else { + for(QStringList::Iterator cppit = Option::cpp_ext.begin(); + cppit != Option::cpp_ext.end(); ++cppit) { + if((*it).endsWith((*cppit))) { + d_file = (*it).left((*it).length() - (*cppit).length()); + break; + } + } + } + if(!d_file.isEmpty()) { + d_file = odir + ".deps/" + d_file + ".d"; + QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$")); + if(!deps.isEmpty()) + t << d_file << ": " << deps.join(" ") << endl; + t << "-include " << d_file << endl; + } + } + } + } + } + + t << "####### Build rules" << endl << endl; + if(!project->variables()["SUBLIBS"].isEmpty()) { + QString libdir = "tmp/"; + if(!project->isEmpty("SUBLIBS_DIR")) + libdir = project->first("SUBLIBS_DIR"); + t << "SUBLIBS= "; + QStringList &l = project->variables()["SUBLIBS"]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) + t << libdir << "lib" << (*it) << ".a "; + t << endl << endl; + } + if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) { + QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"]; + QStringList::Iterator it; + for(it = l.begin(); it != l.end(); ++it) { + QMakeProject proj; + if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) { + QString dir; + int slsh = (*it).findRev(Option::dir_sep); + if(slsh != -1) + dir = (*it).left(slsh + 1); + QString targ = dir + proj.first("QMAKE_PRL_TARGET"); + deps += " " + targ; + t << targ << ":" << "\n\t" + << "@echo \"Creating '" << targ << "'\"" << "\n\t" + << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";" + << "$(MAKE) )" << endl; + } + } + } + if(!project->variables()["QMAKE_APP_FLAG"].isEmpty()) { + QString destdir = project->first("DESTDIR"); + if(do_incremental) { + //incremental target + QString incr_target = var("TARGET") + "_incremental"; + if(incr_target.find(Option::dir_sep) != -1) + incr_target = incr_target.right(incr_target.length() - + (incr_target.findRev(Option::dir_sep) + 1)); + QString incr_deps, incr_objs; + if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { + QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; + //actual target + t << incr_target_dir << ": $(OBJECTS)" << "\n\t" + << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl; + //communicated below + deps.prepend(incr_target_dir + " "); + incr_deps = "$(UICDECLS) $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC) $(OBJMOC)"; + if(!incr_objs.isEmpty()) + incr_objs += " "; + incr_objs += incr_target_dir; + } else { + //actual target + QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + + project->variables()["QMAKE_EXTENSION_SHLIB"].first(); + QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; + if(project->isActiveConfig("debug")) + incr_lflags += var("QMAKE_LFLAGS_DEBUG"); + else + incr_lflags += var("QMAKE_LFLAGS_RELEASE"); + t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; + if(!destdir.isEmpty()) + t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << + " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; + //communicated below + if(!destdir.isEmpty()) { + if(!incr_objs.isEmpty()) + incr_objs += " "; + incr_objs += "-L" + destdir; + } else { + if(!incr_objs.isEmpty()) + incr_objs += " "; + incr_objs += "-L" + QDir::currentDirPath(); + } + if(!incr_objs.isEmpty()) + incr_objs += " "; + incr_objs += " -l" + incr_target; + deps.prepend(incr_target_dir + " "); + incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; + } + t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" + << endl << endl; + + //real target + t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t"; + if(!destdir.isEmpty()) + t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + if(!project->isEmpty("QMAKE_PRE_LINK")) + t << var("QMAKE_PRE_LINK") << "\n\t"; + t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK"); + t << endl << endl; + } else { + t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" + << endl << endl; + + t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t"; + if(!destdir.isEmpty()) + t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + if(!project->isEmpty("QMAKE_PRE_LINK")) + t << var("QMAKE_PRE_LINK") << "\n\t"; + t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK"); + t << endl << endl; + } + } else if(!project->isActiveConfig("staticlib")) { + QString destdir = project->first("DESTDIR"), incr_deps; + if(do_incremental) { + QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first(); + QString incr_target = var("QMAKE_ORIG_TARGET").replace( + QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental"; + if(incr_target.find(Option::dir_sep) != -1) + incr_target = incr_target.right(incr_target.length() - + (incr_target.findRev(Option::dir_sep) + 1)); + + if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { + QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; + //actual target + const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; + t << incr_target_dir << ": " << link_deps << "\n\t" + << "ld -r -o " << incr_target_dir << " " << link_deps << endl; + //communicated below + QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; + cmd.first().replace("$(OBJECTS) $(OBJMOC)", + "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"); //ick + cmd.append(incr_target_dir); + deps.prepend(incr_target_dir + " "); + incr_deps = "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; + } else { + //actual target + QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + s_ext; + QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; + if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL")) + incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " "; + if(project->isActiveConfig("debug")) + incr_lflags += var("QMAKE_LFLAGS_DEBUG"); + else + incr_lflags += var("QMAKE_LFLAGS_RELEASE"); + t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; + if(!destdir.isEmpty()) + t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << + " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; + //communicated below + QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; + if(!destdir.isEmpty()) + cmd.append(" -L" + destdir); + cmd.append(" -l" + incr_target); + deps.prepend(incr_target_dir + " "); + incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; + } + + t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","") + << " " << var("DESTDIR_TARGET") << endl << endl; + + //real target + t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " << + var("TARGETDEPS"); + } else { + t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << + var("DESTDIR_TARGET") << endl << endl; + t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << + var("TARGETDEPS"); + } + if(!destdir.isEmpty()) + t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir; + if(!project->isEmpty("QMAKE_PRE_LINK")) + t << "\n\t" << var("QMAKE_PRE_LINK"); + + if(project->isActiveConfig("plugin")) { + t << "\n\t" + << "-$(DEL_FILE) $(TARGET)" << "\n\t" + << var("QMAKE_LINK_SHLIB_CMD"); + if(!destdir.isEmpty()) + t << "\n\t" + << "-$(MOVE) $(TARGET) " << var("DESTDIR"); + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t"; + t << endl << endl; + } else if ( os == "hpux" ) { + t << "\n\t" + << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t" + << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; + t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)"); + if(!destdir.isEmpty()) + t << "\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" + << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR"); + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK"); + t << endl << endl; + } else { + t << "\n\t" + << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t" + << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; + t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t" + << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t" + << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)"); + if(!destdir.isEmpty()) + t << "\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t" + << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t" + << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR"); + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK"); + t << endl << endl; + } + t << endl << endl; + + if (! project->isActiveConfig("plugin")) { + t << "staticlib: $(TARGETA)" << endl << endl; + t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)"; + if(do_incremental) + t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; + t << var("TARGETDEPS") << "\n\t" + << "-$(DEL_FILE) $(TARGETA) " << "\n\t" + << var("QMAKE_AR_CMD"); + if(do_incremental) + t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; + if(!project->isEmpty("QMAKE_RANLIB")) + t << "\n\t" << "$(RANLIB) $(TARGETA)"; + t << endl << endl; + } + } else { + t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) " + << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n" + << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; + if(project->isEmpty("QMAKE_AR_SUBLIBS")) { + t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t"; + if(!project->isEmpty("DESTDIR")) { + QString destdir = project->first("DESTDIR"); + t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + } + t << "-$(DEL_FILE) $(TARGET)" << "\n\t" + << var("QMAKE_AR_CMD") << "\n"; + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\t" << var("QMAKE_POST_LINK") << "\n"; + if(!project->isEmpty("QMAKE_RANLIB")) + t << "\t" << "$(RANLIB) $(TARGET)" << "\n"; + if(!project->isEmpty("DESTDIR")) + t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n" + << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; + } else { + int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); + QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], + libs = project->variables()["QMAKE_AR_SUBLIBS"]; + libs.prepend("$(TARGET)"); + for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); + libit != libs.end(); ++libit) { + QStringList build; + for(cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) + build << (*objit); + QString ar; + if((*libit) == "$(TARGET)") { + t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) " + << valList(build) << "\n\t"; + ar = project->variables()["QMAKE_AR_CMD"].first(); + ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", + build.join(" ")); + } else { + t << (*libit) << ": " << valList(build) << "\n\t"; + ar = "$(AR) " + (*libit) + " " + build.join(" "); + } + if(!project->isEmpty("DESTDIR")) { + QString destdir = project->first("DESTDIR"); + t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + } + t << "-$(DEL_FILE) " << (*libit) << "\n\t" + << ar << "\n"; + if(!project->isEmpty("QMAKE_POST_LINK")) + t << "\t" << var("QMAKE_POST_LINK") << "\n"; + if(!project->isEmpty("QMAKE_RANLIB")) + t << "\t" << "$(RANLIB) " << (*libit) << "\n"; + if(!project->isEmpty("DESTDIR")) + t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" + << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; + } + } + t << endl << endl; + } + + t << "mocables: $(SRCMOC)" << endl << endl; + + if(!project->isActiveConfig("no_mocdepend")) { + //this is an implicity depend on moc, so it will be built if necesary, however + //moc itself shouldn't have this dependancy - this is a little kludgy but it is + //better than the alternative for now. + QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); + fixEnvVariables(target); + fixEnvVariables(moc); + if(target != moc) + t << "$(MOC): \n\t" + << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; + } + + writeMakeQmake(t); + + if(!project->first("QMAKE_PKGINFO").isEmpty()) { + QString pkginfo = project->first("QMAKE_PKGINFO"); + QString destdir = project->first("DESTDIR"); + t << pkginfo << ": " << "\n\t"; + if(!destdir.isEmpty()) + t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + t << "@$(DEL_FILE) " << pkginfo << "\n\t" + << "@echo \"APPL????\" >" << pkginfo << endl; + } + if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { + QString info_plist = project->first("QMAKE_INFO_PLIST"), + info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); + QString destdir = project->first("DESTDIR"); + t << info_plist_out << ": " << "\n\t"; + if(!destdir.isEmpty()) + t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; + t << "@$(DEL_FILE) " << info_plist_out << "\n\t" + << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl; + if(!project->first("RC_FILE").isEmpty()) { + QString dir = destdir + "../Resources/"; + t << dir << "application.icns:" << "\n\t" + << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" + << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl; + } + } + + QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") : + project->first("QMAKE_DISTDIR"); + QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") : + project->first("OBJECTS_DIR")) + ddir); + t << "dist: " << "\n\t" + << "@mkdir -p " << ddir_c << " && " + << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; + if(!project->isEmpty("TRANSLATIONS")) + t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; + if(!project->isEmpty("FORMS")) { + QStringList &forms = project->variables()["FORMS"], ui_headers; + for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { + QString ui_h = fileFixify((*formit) + Option::h_ext.first()); + if(QFile::exists(ui_h) ) + ui_headers << ui_h; + } + if(!ui_headers.isEmpty()) + t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && "; + } + t << "( cd `dirname " << ddir_c << "` && " + << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && " + << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && " + << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && " + << "$(DEL_DIR) " << ddir_c + << endl << endl; + + QString clean_targets; + if(mocAware()) { + t << "mocclean:" << "\n"; + if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { + if(!objMoc.isEmpty()) + t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; + if(!srcMoc.isEmpty()) + t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n'; + if(moc_incremental) + t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; + clean_targets += " mocclean"; + } + t << endl; + } + t << "uiclean:" << "\n"; + if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) { + t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n"; + clean_targets += " uiclean"; + } + t << endl; + + if(do_incremental) { + t << "incrclean:" << "\n"; + if(src_incremental) + t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n"; + if(moc_incremental) + t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; + t << endl; + } + + t << "clean:" << clean_targets << "\n\t"; + if(!project->isEmpty("OBJECTS")) + t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; + if(src_incremental) + t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; + t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") + << "-$(DEL_FILE) *~ core *.core" << "\n" + << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; + t << "####### Sub-libraries" << endl << endl; + if ( !project->variables()["SUBLIBS"].isEmpty() ) { + QString libdir = "tmp/"; + if(!project->isEmpty("SUBLIBS_DIR")) + libdir = project->first("SUBLIBS_DIR"); + QStringList &l = project->variables()["SUBLIBS"]; + for(it = l.begin(); it != l.end(); ++it) + t << libdir << "lib" << (*it) << ".a" << ":\n\t" + << var(QString("MAKELIB") + (*it)) << endl << endl; + } + + QString destdir = project->first("DESTDIR"); + if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) + destdir += Option::dir_sep; + t << "distclean: " << "clean\n\t" + << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; + if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && + !project->isActiveConfig("plugin")) + t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " + << destdir << "$(TARGET2) $(TARGETA)" << "\n"; + t << endl << endl; + + if ( !project->isEmpty("PRECOMPH") ) { + QString outdir = project->first("MOC_DIR"); + QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); + t << "###### Combined headers" << endl << endl; + //XXX + t << outdir << "allmoc.cpp: " << qt_dot_h << " " + << varList("HEADERS_ORIG") << "\n\t" + << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" + << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " + << outdir << "allmoc.cpp" << "\n\t" + << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" + << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" + << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" + << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; + } + + // blasted user defined targets + QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; + for(it = qut.begin(); it != qut.end(); ++it) { + QString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), 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 << targ << ":" << deps << "\n\t" + << cmd << endl << endl; + } + t <<"FORCE:" << endl << endl; +} + +struct SubDir +{ + QString directory, profile, target, makefile; +}; + +void +UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct) +{ + QPtrList subdirs; + { + QStringList subdirs_in = project->variables()["SUBDIRS"]; + for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { + QString file = (*it); + fileFixify(file); + SubDir *sd = new SubDir; + subdirs.append(sd); + sd->makefile = "$(MAKEFILE)"; + if((*it).right(4) == ".pro") { + int slsh = file.findRev(Option::dir_sep); + if(slsh != -1) { + sd->directory = file.left(slsh+1); + sd->profile = file.mid(slsh+1); + } else { + sd->profile = file; + } + } else { + sd->directory = file; + } + while(sd->directory.right(1) == Option::dir_sep) + sd->directory = sd->directory.left(sd->directory.length() - 1); + if(!sd->profile.isEmpty()) { + QString basename = sd->directory; + int new_slsh = basename.findRev(Option::dir_sep); + if(new_slsh != -1) + basename = basename.mid(new_slsh+1); + if(sd->profile != basename + ".pro") + sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro + } + sd->target = "sub-" + (*it); + sd->target.replace('/', '-'); + sd->target.replace('.', '_'); + } + } + QPtrListIterator it(subdirs); + + QString ofile = Option::output.name(); + if(ofile.findRev(Option::dir_sep) != -1) + ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1); + t << "MAKEFILE = " << var("MAKEFILE") << endl; + t << "QMAKE = " << var("QMAKE") << endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + t << "SUBTARGETS = "; // subdirectory targets are sub-directory + for( it.toFirst(); it.current(); ++it) + t << " \\\n\t\t" << it.current()->target; + t << endl << endl; + t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl; + + // generate target rules + for( it.toFirst(); it.current(); ++it) { + bool have_dir = !(*it)->directory.isEmpty(); + QString mkfile = (*it)->makefile, out; + if(have_dir) + mkfile.prepend((*it)->directory + Option::dir_sep); + if(direct || (*it)->makefile != "$(MAKEFILE)") + out = " -o " + (*it)->makefile; + //qmake it + t << mkfile << ": " << "\n\t"; + if(have_dir) + t << "cd " << (*it)->directory << " && "; + t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; + //actually compile + t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; + if(have_dir) + t << "cd " << (*it)->directory << " && "; + t << "$(MAKE) -f " << (*it)->makefile << endl << endl; + } + + if (project->isActiveConfig("ordered")) { // generate dependencies + for( it.toFirst(); it.current(); ) { + QString tar = it.current()->target; + ++it; + if (it.current()) + t << it.current()->target << ": " << tar << endl; + } + t << endl; + } + + writeMakeQmake(t); + + if(project->isEmpty("SUBDIRS")) { + t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl; + } else { + t << "all: $(SUBTARGETS)" << endl; + t << "qmake_all:"; + for( it.toFirst(); it.current(); ++it) { + t << " "; + if(!(*it)->directory.isEmpty()) + t << (*it)->directory << Option::dir_sep; + t << (*it)->makefile; + } + for( it.toFirst(); it.current(); ++it) { + t << "\n\t ( "; + if(!(*it)->directory.isEmpty()) + t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; + t << "grep \"^qmake_all:\" " << (*it)->makefile + << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; + } + t << endl; + t << "clean uninstall install uiclean mocclean: qmake_all FORCE"; + for( it.toFirst(); it.current(); ++it) { + t << "\n\t ( "; + if(!(*it)->directory.isEmpty()) + t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; + t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; + } + t << endl; + t << "distclean: qmake_all FORCE"; + for( it.toFirst(); it.current(); ++it) { + t << "\n\t ( "; + if(!(*it)->directory.isEmpty()) + t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; + t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true"; + } + t << endl << endl; + } + t <<"FORCE:" << endl << endl; +} + +void UnixMakefileGenerator::init2() +{ + //version handling + if(project->variables()["VERSION"].isEmpty()) + project->variables()["VERSION"].append("1.0." + + (project->isEmpty("VER_PAT") ? QString("0") : + project->first("VER_PAT")) ); + QStringList l = QStringList::split('.', project->first("VERSION")); + l << "0" << "0"; //make sure there are three + project->variables()["VER_MAJ"].append(l[0]); + project->variables()["VER_MIN"].append(l[1]); + project->variables()["VER_PAT"].append(l[2]); + + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { +#if 0 + if ( project->isActiveConfig("dll") ) { + project->variables()["TARGET"] += project->variables()["TARGET.so"]; + if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty()) + project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; + if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) + project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET"); + } +#endif + project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); + } else if ( project->isActiveConfig("staticlib") ) { + project->variables()["TARGET"].first().prepend("lib"); + project->variables()["TARGET"].first() += ".a"; + if(project->variables()["QMAKE_AR_CMD"].isEmpty()) + project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); + } else { + project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); + if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) + project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); + else + project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); + QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); + if( project->isActiveConfig("plugin") ) { + project->variables()["TARGET_x.y.z"].append("lib" + + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); + if(project->isActiveConfig("lib_version_first")) + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + else + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + + "." + project->first("VER_MAJ")); + + project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; + if(project->isActiveConfig("qt")) + project->variables()["DEFINES"].append("QT_PLUGIN"); + } else if ( os == "hpux" ) { + project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl"); + if(project->isActiveConfig("lib_version_first")) + project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." + + project->first("TARGET")); + else + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ")); + project->variables()["TARGET"] = project->variables()["TARGET_x"]; + } else if ( os == "aix" ) { + project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a"); + if(project->isActiveConfig("lib_version_first")) { + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + + "." + project->first("VER_MIN") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + "." + + project->first("VER_MIN") + "." + + project->first("VER_PAT") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + } else { + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + + "." + project->first("VER_MAJ")); + project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + + "." + project->first("VER_MAJ") + + "." + project->first("VER_MIN")); + project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + "." + + project->first("VER_MAJ") + "." + + project->first("VER_MIN") + "." + + project->first("VER_PAT")); + } + project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; + } else { + project->variables()["TARGET_"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + if(project->isActiveConfig("lib_version_first")) { + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + + "." + project->first("VER_MIN") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + + project->first("VER_MAJ") + "." + + project->first("VER_MIN") + "." + + project->first("VER_PAT") + "." + + project->variables()["QMAKE_EXTENSION_SHLIB"].first()); + } else { + project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + + "." + project->first("VER_MAJ")); + project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + + project->first("QMAKE_EXTENSION_SHLIB") + + "." + project->first("VER_MAJ") + + "." + project->first("VER_MIN")); + project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + + "." + + project->variables()[ + "QMAKE_EXTENSION_SHLIB"].first() + "." + + project->first("VER_MAJ") + "." + + project->first("VER_MIN") + "." + + project->first("VER_PAT")); + } + project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; + } + if(project->isEmpty("QMAKE_LN_SHLIB")) + project->variables()["QMAKE_LN_SHLIB"].append("ln -s"); + project->variables()["DESTDIR_TARGET"].append("$(TARGET)"); + if ( !project->variables()["DESTDIR"].isEmpty() ) + project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR")); + if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty() && !project->variables()["TARGET_x"].isEmpty() ) + project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x"); + if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) + project->variables()["QMAKE_LINK_SHLIB_CMD"].append( + "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); + } + if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) + project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; + } else if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; + if ( project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; + if( !project->isActiveConfig("plugin_no_soname") ) + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; + } else { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; + } + QString destdir = project->first("DESTDIR"); + if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) { + QString rpath_destdir = destdir; + if(QDir::isRelativePath(rpath_destdir)) { + QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir)); + if(fi.convertToAbs()) //strange, shouldn't really happen + rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); + else + rpath_destdir = fi.filePath(); + } else { + rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); + } + project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir; + } + } +} diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp new file mode 100644 index 0000000..ae7b47b --- a/dev/null +++ b/qmake/generators/win32/borland_bmake.cpp @@ -0,0 +1,477 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "borland_bmake.h" +#include "option.h" +#include +#include +#include +#include + + +BorlandMakefileGenerator::BorlandMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +BorlandMakefileGenerator::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; + return TRUE; + } + + if(project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib") { + writeBorlandParts(t); + return MakefileGenerator::writeMakefile(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +void +BorlandMakefileGenerator::writeBorlandParts(QTextStream &t) +{ + t << "!if !$d(BCB)" << endl; + t << "BCB = $(MAKEDIR)\\.." << endl; + t << "!endif" << 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); + inc.replace(QRegExp("\\\\*$"), ""); + inc.replace("\"", ""); + t << " -I\"" << inc << "\""; + } + t << " -I\"" << specdir() << "\"" + << endl; + + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "LINK = " << var("QMAKE_LINK") << endl; + t << "LFLAGS = "; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + t << varGlue("QMAKE_LIBDIR","-L",";","") << " "; + t << var("QMAKE_LFLAGS") << endl; + t << "LIBS = " << var("QMAKE_LIBS") << 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 << "DEF_FILE = " << varList("DEF_FILE") << endl; + t << "RES_FILE = " << varList("RES_FILE") << 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 << 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; + t << "DIST = " << varList("DISTFILES") << endl; + t << "TARGET = " + << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")) + << endl; + t << endl; + + t << "####### Implicit rules" << endl << endl; + t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; + t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + + t << "####### Build rules" << endl << endl; + t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl; + t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "\n\t" << "$(LINK) @&&|" << "\n\t" + << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)"; + } else { + t << "\n\t-del $(TARGET)" + << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+" + << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+" + << project->variables()["OBJMOC"].join(" \\\n+"); + } + t << endl << "|" << endl; + 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 $(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 tmp\\" + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); + } else { + t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); + t << "\n\t" << ("-$(TARGET) -regserver"); + } + } + t << endl << endl; + + if(!project->variables()["RC_FILE"].isEmpty()) { + t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" + << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; + } + t << "mocables: $(SRCMOC)" << endl << endl; + + writeMakeQmake(t); + + t << "dist:" << "\n\t" + << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" + << endl << endl; + + t << "clean:\n" + << varGlue("OBJECTS","\t-del ","\n\t-del ","") + << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") + << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") + << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") + << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") + << "\n\t-del $(TARGET)" + << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") + << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); + if ( project->isActiveConfig("activeqt")) { + t << ("\n\t-del tmp\\" + targetfilename + ".*"); + t << "\n\t-del tmp\\dump.*"; + } + if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) + t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); + + // blasted user defined targets + QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { + QString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), 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" << targ << ":" << deps << "\n\t" + << cmd; + } + + t << endl << endl; +} + +void +BorlandMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + /* 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") == "qtmt"QTDLL_POSTFIX); + QStringList &configs = project->variables()["CONFIG"]; + if (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"); + 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("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("qt")) { + 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("debug") ) { + if ( project->isActiveConfig("thread") ) { + if ( project->isActiveConfig("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->isActiveConfig("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->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + 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; + ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver); + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + 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 { + 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("thread") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"]; + } else { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"]; + } + if ( project->isActiveConfig("moc") ) { + setMocAware(TRUE); + } + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + QStringList &l = project->variables()["QMAKE_FILETAGS"]; + for(QStringList::Iterator 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); + } + + if ( !project->variables()["RC_FILE"].isEmpty()) { + if ( !project->variables()["RES_FILE"].isEmpty()) { + fprintf(stderr, "Both .rc and .res file 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",".res"); + project->variables()["TARGETDEPS"] += 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]); + } + + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + // bcc does not generate a .tds file for static libs + QString tdsPostfix; + if ( !project->variables()["VERSION"].isEmpty() ) { + tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("") + + ".tds"; + } else { + tdsPostfix = ".tds"; + } + project->variables()["QMAKE_CLEAN"].append( + project->first("DESTDIR") + project->first("TARGET") + tdsPostfix ); + } +} + diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h new file mode 100644 index 0000000..90f8229 --- a/dev/null +++ b/qmake/generators/win32/borland_bmake.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __BORLANDMAKE_H__ +#define __BORLANDMAKE_H__ + +#include "winmakefile.h" + +class BorlandMakefileGenerator : public Win32MakefileGenerator +{ + bool init_flag; + void writeBorlandParts(QTextStream &); + + bool writeMakefile(QTextStream &); + void init(); + +public: + BorlandMakefileGenerator(QMakeProject *p); + ~BorlandMakefileGenerator(); +}; + +inline BorlandMakefileGenerator::~BorlandMakefileGenerator() +{ } + + +#endif /* __BORLANDMAKE_H__ */ diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp new file mode 100644 index 0000000..8b08c78 --- a/dev/null +++ b/qmake/generators/win32/msvc_dsp.cpp @@ -0,0 +1,955 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "msvc_dsp.h" +#include "option.h" +#include +#include +#include +#include + +DspMakefileGenerator::DspMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +DspMakefileGenerator::writeMakefile(QTextStream &t) +{ + if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { + /* for now just dump, I need to generated an empty dsp or something.. */ + fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", + var("QMAKE_FAILED_REQUIREMENTS").latin1()); + return TRUE; + } + + if(project->first("TEMPLATE") == "vcapp" || + project->first("TEMPLATE") == "vclib") { + return writeDspParts(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeHeader(t); + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +bool +DspMakefileGenerator::writeDspParts(QTextStream &t) +{ + QString dspfile; + if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) { + dspfile = project->first("DSP_TEMPLATE"); + } else { + dspfile = project->first("MSVCDSP_TEMPLATE"); + } + QString dspfile_loc = findTemplate(dspfile); + + QFile file(dspfile_loc); + if(!file.open(IO_ReadOnly)) { + fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1()); + return FALSE; + } + QTextStream dsp(&file); + + int rep; + QString line; + while ( !dsp.eof() ) { + line = dsp.readLine(); + while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) { + QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep); + QString variable = torep.right(torep.length()-2); + + t << line.left(rep); //output the left side + line = line.right(line.length() - (rep + torep.length())); //now past the variable + if(variable == "MSVCDSP_SOURCES") { + if(project->variables()["SOURCES"].isEmpty()) + continue; + + QString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; + + QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"]; + if(!project->isActiveConfig("flat")) + list.sort(); + QStringList::Iterator it; + for( it = list.begin(); it != list.end(); ++it) { + beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { + QString base = (*it); + base.replace(QRegExp("\\..*$"), "").upper(); + base.replace(QRegExp("[^a-zA-Z]"), "_"); + + QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" + "\t" + mocpath + findMocSource((*it)) + " -o " + + (*it) + "\n\n" "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" + << build << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } + endGroups(t); + } else if(variable == "MSVCDSP_IMAGES") { + if(project->variables()["IMAGES"].isEmpty()) + continue; + t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl; + t << "# End Source File" << endl; + } else if(variable == "MSVCDSP_HEADERS") { + if(project->variables()["HEADERS"].isEmpty()) + continue; + + QStringList list = project->variables()["HEADERS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl; + if ( project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) { + QString base = (*it); + base.replace(QRegExp("\\..*$"), "").upper(); + base.replace(QRegExp("[^a-zA-Z]"), "_"); + + QString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; + + QString build = "\n\n# Begin Custom Build - Moc'ing " + (*it) + + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + findMocDestination((*it)) + + "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" + "\t" + mocpath + (*it) + " -o " + + findMocDestination((*it)) + "\n\n" "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" + << build << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") { + if(project->variables()["FORMS"].isEmpty()) + continue; + + QString uiSourcesDir; + QString uiHeadersDir; + if(!project->variables()["UI_DIR"].isEmpty()) { + uiSourcesDir = project->first("UI_DIR"); + uiHeadersDir = project->first("UI_DIR"); + } else { + if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) + uiSourcesDir = project->first("UI_SOURCES_DIR"); + else + uiSourcesDir = ""; + if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) + uiHeadersDir = project->first("UI_HEADERS_DIR"); + else + uiHeadersDir = ""; + } + + QStringList list = project->variables()["FORMS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h"; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString base = (*it); + int dot = base.findRev("."); + base.replace( dot, base.length() - dot, ext ); + QString fname = base; + + int lbs = fname.findRev( "\\" ); + QString fpath; + if ( lbs != -1 ) + fpath = fname.left( lbs + 1 ); + fname = fname.right( fname.length() - lbs - 1 ); + + if ( ext == ".cpp" && !uiSourcesDir.isEmpty() ) + fname.prepend(uiSourcesDir); + else if ( ext == ".h" && !uiHeadersDir.isEmpty() ) + fname.prepend(uiHeadersDir); + else + fname = base; +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname + << "\n# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_TRANSLATIONS" ) { + if(project->variables()["TRANSLATIONS"].isEmpty()) + continue; + + t << "# Begin Group \"Translations\"\n"; + t << "# Prop Default_Filter \"ts\"\n"; + + QStringList list = project->variables()["TRANSLATIONS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString sify = *it; + sify.replace('/', '\\' ); + QString base = (*it); + base.replace(QRegExp("\\..*$"), "").upper(); + base.replace(QRegExp("[^a-zA-Z]"), "_"); + +// beginGroupForFile(sify, t); + t << "# Begin Source File\n\nSOURCE=" << sify << endl; + t << "\n# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) { + if ( project->variables()["SRCMOC"].isEmpty()) + continue; + + QString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; + + QStringList list = project->variables()["SRCMOC"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { + QString base = (*it); + base.replace(QRegExp("\\..*$"), "").upper(); + base.replace(QRegExp("[^a-zA-Z]"), "_"); + + QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" + "\t" + mocpath + findMocSource((*it)) + " -o " + + (*it) + "\n\n" "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" + << build << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_PICTURES") { + if(project->variables()["IMAGES"].isEmpty()) + continue; + + t << "# Begin Group \"Images\"\n" + << "# Prop Default_Filter \"png jpeg bmp xpm\"\n"; + + QStringList list = project->variables()["IMAGES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + QStringList::Iterator it; + + // dump the image list to a file UIC can read. + QFile f( "images.tmp" ); + f.open( IO_WriteOnly ); + QTextStream ts( &f ); + for( it = list.begin(); it != list.end(); ++it ) + ts << " " << *it; + f.close(); + + // create an output step for images not more than once + bool imagesBuildDone = FALSE; + for( it = list.begin(); it != list.end(); ++it ) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + + QString base = (*it); + QString uicpath = var("QMAKE_UIC"); + uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; + + if ( !imagesBuildDone ) { + imagesBuildDone = TRUE; + QString build = "\n\n# Begin Custom Build - Creating image collection...\n" + "InputPath=.\\" + base + "\n\n"; + + build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"; + build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o " + + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n"; + build.append("# End Custom Build\n\n"); + + t << "USERDEP_" << base << "="; + QStringList::Iterator it2 = list.begin(); + while ( it2 != list.end() ) { + t << "\"" << (*it2) << "\""; + it2++; + if ( it2 != list.end() ) + t << "\\\n"; + } + t << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build + << "!ENDIF \n\n" << endl; + } + + t << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_FORMS") { + if(project->variables()["FORMS"].isEmpty()) + continue; + + t << "# Begin Group \"Forms\"\n" + << "# Prop Default_Filter \"ui\"\n"; + + QString uicpath = var("QMAKE_UIC"); + uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; + QString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; + + QStringList list = project->variables()["FORMS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString base = (*it); +// beginGroupForFile(base, t); + t << "# Begin Source File\n\nSOURCE=" << base << endl; + + QString fname = base; + fname.replace(".ui", ""); + int lbs = fname.findRev( "\\" ); + QString fpath; + if ( lbs != -1 ) + fpath = fname.left( lbs + 1 ); + fname = fname.right( fname.length() - lbs - 1 ); + + QString mocFile; + if(!project->variables()["MOC_DIR"].isEmpty()) + mocFile = project->first("MOC_DIR"); + else + mocFile = fpath; + + QString uiSourcesDir; + QString uiHeadersDir; + if(!project->variables()["UI_DIR"].isEmpty()) { + uiSourcesDir = project->first("UI_DIR"); + uiHeadersDir = project->first("UI_DIR"); + } else { + if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) + uiSourcesDir = project->first("UI_SOURCES_DIR"); + else + uiSourcesDir = fpath; + if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) + uiHeadersDir = project->first("UI_HEADERS_DIR"); + else + uiHeadersDir = fpath; + } + + t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl; + + QString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n" + "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + + " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + + " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" + "\t" + mocpath + uiHeadersDir + fname + ".h -o " + mocFile + "moc_" + fname + ".cpp \\\n"; + + build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n" + "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n" + "\"" + mocFile + "moc_" + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n"); + + build.append("# End Custom Build\n\n"); + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build + << "!ENDIF \n\n" << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_LEXSOURCES") { + if(project->variables()["LEXSOURCES"].isEmpty()) + continue; + + t << "# Begin Group \"Lexables\"\n" + << "# Prop Default_Filter \"l\"\n"; + + QString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " "; + + QStringList list = project->variables()["LEXSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString fname = (*it); +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname << endl; + fname.replace(".l", Option::lex_mod + Option::cpp_ext.first()); + + QString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n" + "InputPath=.\\" + (*it) + "\n\n" + "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t" + lexpath + (*it) + "\\\n" + "\tdel " + fname + "\\\n" + "\tcopy lex.yy.c " + fname + "\n\n" + + "# End Custom Build\n\n"; + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build + << "!ENDIF \n\n" << build + + << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_YACCSOURCES") { + if(project->variables()["YACCSOURCES"].isEmpty()) + continue; + + t << "# Begin Group \"Yaccables\"\n" + << "# Prop Default_Filter \"y\"\n"; + + QString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " "; + + QStringList list = project->variables()["YACCSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + QString fname = (*it); +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname << endl; + fname.replace(".y", Option::yacc_mod); + + QString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n" + "InputPath=.\\" + (*it) + "\n\n" + "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t" + yaccpath + (*it) + "\\\n" + "\tdel " + fname + Option::h_ext.first() + "\\\n" + "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" + + "\tdel " + fname + Option::cpp_ext.first() + "\\\n" + "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" + + "# End Custom Build\n\n"; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build + << "!ENDIF \n\n" + << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if( variable == "MSVCDSP_CONFIGMODE" ) { + if( project->isActiveConfig( "debug" ) ) + t << "Debug"; + else + t << "Release"; + } else if( variable == "MSVCDSP_IDLSOURCES" ) { + QStringList list = project->variables()["MSVCDSP_IDLSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + t << "# Begin Source File" << endl << endl; + t << "SOURCE=" << (*it) << endl; + t << "# PROP Exclude_From_Build 1" << endl; + t << "# End Source File" << endl << endl; + } + } + else + t << var(variable); + } + t << line << endl; + } + t << endl; + file.close(); + return TRUE; +} + + + +void +DspMakefileGenerator::init() +{ + if(init_flag) + return; + QStringList::Iterator it; + init_flag = TRUE; + + /* this should probably not be here, but I'm using it to wrap the .t files */ + if(project->first("TEMPLATE") == "vcapp" ) + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "vclib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + if ( project->variables()["QMAKESPEC"].isEmpty() ) + project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); + + bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + QStringList &configs = project->variables()["CONFIG"]; + if (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"); + 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("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("qt") || project->isActiveConfig("opengl") ) { + project->variables()["CONFIG"].append("windows"); + } + if ( !project->variables()["VERSION"].isEmpty() ) { + QString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + QString major = version.left( firstDot ); + QString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); + } + + 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 ( 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"].append("/base:\"0x39D00000\""); + } + } else { + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + 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; + ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + + if ( project->isActiveConfig("debug") ) { + if ( !project->first("OBJECTS_DIR").isEmpty() ) + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); + else + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; + project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; + if ( !project->first("DESTDIR").isEmpty() ) + project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); + else + project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; + project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; + } else { + if ( !project->first("OBJECTS_DIR").isEmpty() ) + project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; + if ( !project->first("DESTDIR").isEmpty() ) + project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); + else + project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; + project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; + } + + 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("thread") ) { + if(project->isActiveConfig("qt")) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); + if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" + || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; + project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; + } else { + // YES we want to use the DLL even in a static build + project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; + project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; + } + if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt + && project->first("TARGET") != "qtmain" ) + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); + } + + if(project->isActiveConfig("qt")) { + 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") ) { + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + QString ver_xyz(project->first("VERSION")); + ver_xyz.replace(".", ""); + project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } else { + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) + project->variables()["TARGET_EXT"].append(".exe"); + else + project->variables()["TARGET_EXT"].append(".lib"); + } + + project->variables()["MSVCDSP_VER"] = "6.00"; + project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI"; + + if(!project->isActiveConfig("incremental")) { + project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); + if ( is_qt ) + project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /Zi"; + } + + QString msvcdsp_project; + if ( project->variables()["TARGET"].count() ) + msvcdsp_project = project->variables()["TARGET"].first(); + + QString targetfilename = project->variables()["TARGET"].first(); + project->variables()["TARGET"].first() += project->first("TARGET_EXT"); + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + QStringList &l = project->variables()["QMAKE_FILETAGS"]; + 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); + } + + MakefileGenerator::init(); + if ( msvcdsp_project.isEmpty() ) + msvcdsp_project = Option::output.name(); + + msvcdsp_project = msvcdsp_project.right( msvcdsp_project.length() - msvcdsp_project.findRev( "\\" ) - 1 ); + msvcdsp_project = msvcdsp_project.left( msvcdsp_project.findRev( "." ) ); + msvcdsp_project.replace("-", ""); + + project->variables()["MSVCDSP_PROJECT"].append(msvcdsp_project); + QStringList &proj = project->variables()["MSVCDSP_PROJECT"]; + + for(it = proj.begin(); it != proj.end(); ++it) + (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); + + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["MSVCDSP_TEMPLATE"].append("win32app" + project->first( "DSP_EXTENSION" ) ); + if ( project->isActiveConfig("console") ) { + project->variables()["MSVCDSP_CONSOLE"].append("Console"); + project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE"); + project->variables()["MSVCDSP_DSPTYPE"].append("0x0103"); + project->variables()["MSVCDSP_SUBSYSTEM"].append("console"); + } else { + project->variables()["MSVCDSP_CONSOLE"].clear(); + project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); + project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); + project->variables()["MSVCDSP_SUBSYSTEM"].append("windows"); + } + } else { + if ( project->isActiveConfig("dll") ) { + project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); + } else { + project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); + } + } + + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + + project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); + project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; + project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); + project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); + + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { + QString lib = (*libit); + lib.replace(QRegExp("\""), ""); + project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); + } + + QStringList &incs = project->variables()["INCLUDEPATH"]; + for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + QString inc = (*incit); + inc.replace("\"", ""); + project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); + } + + project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); + if ( project->isActiveConfig("qt") ) { + project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); + } else { + project->variables()["MSVCDSP_RELDEFS"].clear(); + } + + QString dest; + if ( !project->variables()["DESTDIR"].isEmpty() ) { + project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); + Option::fixPathToTargetOS(project->first("TARGET")); + dest = project->first("TARGET"); + if ( project->first("TARGET").startsWith("$(QTDIR)") ) + dest.replace( "$(QTDIR)", getenv("QTDIR") ); + project->variables()["MSVCDSP_TARGET"].append( + QString("/out:\"") + dest + "\""); + if ( project->isActiveConfig("dll") ) { + QString imp = dest; + imp.replace(".dll", ".lib"); + project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\""); + } + } + if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { + QStringList dlldirs = project->variables()["DLLDESTDIR"]; + QString copydll = "# Begin Special Build Tool\n" + "TargetPath=" + dest + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" + "PostBuild_Cmds="; + + for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; + } + + copydll += "\n# End Special Build Tool"; + project->variables()["MSVCDSP_COPY_DLL_REL"].append( copydll ); + project->variables()["MSVCDSP_COPY_DLL_DBG"].append( copydll ); + } + if ( project->isActiveConfig("activeqt") ) { + QString idl = project->variables()["QMAKE_IDL"].first(); + QString idc = project->variables()["QMAKE_IDC"].first(); + QString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); + project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); + project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); + if ( project->isActiveConfig( "dll" ) ) { + QString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveQt server...\n" + "PostBuild_Cmds=" + + idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + + "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" + "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + "\t" + idc + " %1 /regserver\n" + "# End Special Build Tool"; + + QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCDSP_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCDSP_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } else { + QString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveQt server...\n" + "PostBuild_Cmds=" + "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + + "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" + "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + "\t%1 -regserver\n" + "# End Special Build Tool"; + + QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCDSP_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCDSP_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } + + } + if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { + project->variables()["SOURCES"] += project->variables()["RC_FILE"]; + } + QStringList &list = project->variables()["FORMS"]; + for( it = list.begin(); it != list.end(); ++it ) { + if ( QFile::exists( *it + ".h" ) ) + project->variables()["SOURCES"].append( *it + ".h" ); + } + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; +} + + +QString +DspMakefileGenerator::findTemplate(QString file) +{ + QString ret; + if(!QFile::exists((ret = file)) && + !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && + !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) && + !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) + return ""; + return ret; +} + + +void +DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) +{ + if(var == "QMAKE_PRL_DEFINES") { + QStringList &out = project->variables()["MSVCDSP_DEFINES"]; + for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + if(out.findIndex((*it)) == -1) + out.append((" /D \"" + *it + "\"")); + } + } else { + MakefileGenerator::processPrlVariable(var, l); + } +} + + +int +DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t, + QString filter) +{ + if(project->isActiveConfig("flat")) + return 0; + + fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE); + file = file.section(Option::dir_sep, 0, -2); + if(file.right(Option::dir_sep.length()) != Option::dir_sep) + file += Option::dir_sep; + if(file == currentGroup) + return 0; + + if(file.isEmpty() || !QDir::isRelativePath(file)) { + endGroups(t); + return 0; + } + if(file.startsWith(currentGroup)) + file = file.mid(currentGroup.length()); + else + endGroups(t); + int lvl = file.contains(Option::dir_sep), old_lvl = currentGroup.contains(Option::dir_sep); + if(lvl > old_lvl) { + QStringList dirs = QStringList::split(Option::dir_sep, file); + for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { + t << "# Begin Group \"" << (*dir_it) << "\"\n" + << "# Prop Default_Filter \"" << filter << "\"\n"; + } + } else { + for(int x = old_lvl - lvl; x; x--) + t << "\n# End Group\n"; + } + currentGroup = file; + return lvl - old_lvl; +} + + +int +DspMakefileGenerator::endGroups(QTextStream &t) +{ + if(project->isActiveConfig("flat")) + return 0; + else if(currentGroup.isEmpty()) + return 0; + + QStringList dirs = QStringList::split(Option::dir_sep, currentGroup); + for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) { + t << "\n# End Group\n"; + } + currentGroup = ""; + return dirs.count(); +} + +bool +DspMakefileGenerator::openOutput(QFile &file) const +{ + QString outdir; + if(!file.name().isEmpty()) { + QFileInfo fi(file); + if(fi.isDir()) + outdir = file.name() + QDir::separator(); + } + if(!outdir.isEmpty() || file.name().isEmpty()) + file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION")); + if(QDir::isRelativePath(file.name())) { + QString ofile; + ofile = file.name(); + int slashfind = ofile.findRev('\\'); + if (slashfind == -1) { + ofile = ofile.replace(QRegExp("-"), "_"); + } else { + int hypenfind = ofile.find('-', slashfind); + while (hypenfind != -1 && slashfind < hypenfind) { + ofile = ofile.replace(hypenfind, 1, "_"); + hypenfind = ofile.find('-', hypenfind + 1); + } + } + file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile)); + } + return Win32MakefileGenerator::openOutput(file); +} diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h new file mode 100644 index 0000000..a7fc3e7 --- a/dev/null +++ b/qmake/generators/win32/msvc_dsp.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __DSPMAKE_H__ +#define __DSPMAKE_H__ + +#include "winmakefile.h" +#include + +class DspMakefileGenerator : public Win32MakefileGenerator +{ + QString currentGroup; + int beginGroupForFile(QString file, QTextStream &, const QString filter=""); + int endGroups(QTextStream &); + + bool init_flag; + bool writeDspParts(QTextStream &); + + bool writeMakefile(QTextStream &); + QString findTemplate(QString file); + void init(); + +public: + DspMakefileGenerator(QMakeProject *p); + ~DspMakefileGenerator(); + + bool openOutput(QFile &file) const; + +protected: + virtual void processPrlVariable(const QString &, const QStringList &); + virtual bool findLibraries(); +}; + +inline DspMakefileGenerator::~DspMakefileGenerator() +{ } + +inline bool DspMakefileGenerator::findLibraries() +{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } + +#endif /* __DSPMAKE_H__ */ diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp new file mode 100644 index 0000000..9cc9a69 --- a/dev/null +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -0,0 +1,488 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "msvc_nmake.h" +#include "option.h" +#include +#include +#include +#include + + +NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +NmakeMakefileGenerator::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") { + writeNmakeParts(t); + return MakefileGenerator::writeMakefile(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +void +NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) +{ + 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); + inc.replace(QRegExp("\\\\$"), "\\\\"); + inc.replace("\"", ""); + t << " -I\"" << inc << "\""; + } + t << " -I\"" << specdir() << "\"" + << endl; + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "LINK = " << var("QMAKE_LINK") << endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS"); + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""); + t << endl; + t << "LIBS = "; + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { + QString lib = (*libit); + lib.replace(QRegExp("\\\\$"), "\\\\"); + lib.replace(QRegExp("\""), ""); + t << " \"" << lib << "\""; + } + t << 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 << 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; + 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: .cpp .cxx .cc .c" << endl << endl; + t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + + t << "####### Build rules" << endl << endl; + t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; + t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " + << "$(OBJECTS) $(OBJMOC) $(LIBS)"; + } else { + t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " + << "$(OBJECTS) $(OBJMOC)"; + } + t << endl << "<<" << endl; + 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 $(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 tmp\\" + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); + } else { + t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); + t << "\n\t" << "-$(TARGET) -regserver"; + } + } + t << endl << endl; + + if(!project->variables()["RC_FILE"].isEmpty()) { + t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" + << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; + } + + t << "mocables: $(SRCMOC)" << endl << endl; + + writeMakeQmake(t); + + t << "dist:" << "\n\t" + << "$(ZIP) " << var("PROJECT") << ".zip " + << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; + + t << "clean:" + << varGlue("OBJECTS","\n\t-del ","\n\t-del ","") + << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") + << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") + << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") + << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") + << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") + << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); + if ( project->isActiveConfig("activeqt")) { + t << ("\n\t-del tmp\\" + targetfilename + ".*"); + t << "\n\t-del tmp\\dump.*"; + } + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); + + // blasted user defined targets + QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { + QString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), 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" << targ << ":" << deps << "\n\t" + << cmd; + } + + t << endl << endl; +} + + +void +NmakeMakefileGenerator::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"]; + + 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->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL") + && !is_qt && project->first("TARGET") != "qtmain") { + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); + } + + 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->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + 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; + ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + 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 { + 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("moc") ) + setMocAware(TRUE); + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + QStringList &l = project->variables()["QMAKE_FILETAGS"]; + for(QStringList::Iterator 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); + } + + if ( !project->variables()["DEF_FILE"].isEmpty() ) + project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); + if(!project->isActiveConfig("incremental")) + project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); + + if ( !project->variables()["VERSION"].isEmpty() ) { + QString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + QString major = version.left( firstDot ); + QString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); + } + if ( !project->variables()["RC_FILE"].isEmpty()) { + if ( !project->variables()["RES_FILE"].isEmpty()) { + fprintf(stderr, "Both .rc and .res file 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",".res"); + project->variables()["TARGETDEPS"] += 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]); + } + if(project->isActiveConfig("dll")) { + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib"); + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp"); + } + if(project->isActiveConfig("debug")) { + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb"); + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk"); + project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); + } +} diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h new file mode 100644 index 0000000..d3e170f --- a/dev/null +++ b/qmake/generators/win32/msvc_nmake.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __NMAKEMAKE_H__ +#define __NMAKEMAKE_H__ + +#include "winmakefile.h" + +class NmakeMakefileGenerator : public Win32MakefileGenerator +{ + bool init_flag; + void writeNmakeParts(QTextStream &); + + bool writeMakefile(QTextStream &); + void init(); + +public: + NmakeMakefileGenerator(QMakeProject *p); + ~NmakeMakefileGenerator(); + +}; + +inline NmakeMakefileGenerator::~NmakeMakefileGenerator() +{ } + +#endif /* __NMAKEMAKE_H__ */ diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp new file mode 100644 index 0000000..c2b9e30 --- a/dev/null +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -0,0 +1,1955 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Copyright (C) 2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "msvc_objectmodel.h" +#include "msvc_vcproj.h" +#include +#include +#include + +#if defined(Q_OS_WIN32) +#include +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID +{ + ulong Data1; + ushort Data2; + ushort Data3; + uchar Data4[8]; +} GUID; +#endif +#endif + +// XML Tags --------------------------------------------------------- +const char* _xmlInit = ""; +const char* _begConfiguration = "\n\t\t"; +return strm; +} + +bool VCCLCompilerTool::parseOption( const char* option ) +{ + // skip index 0 ('/' or '-') + char first = option[1]; + char second = option[2]; + char third = option[3]; + char fourth = option[4]; + + switch ( first ) { + case '?': + case 'h': + qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" ); + return FALSE; + case '@': + qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" ); + return FALSE; + case 'l': + qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" ); + return FALSE; + + case 'A': + if ( second != 'I' ) + return FALSE; + AdditionalUsingDirectories += option+2; + break; + case 'C': + KeepComments = _True; + break; + case 'D': + PreprocessorDefinitions += option+1; + break; + case 'E': + if ( second == 'H' ) { + if ( third == 'a' || third == 'c' || third == 's' ) { + // ExceptionHandling must be false, or it will override + // with an /EHsc option + ExceptionHandling = _False; + AdditionalOptions += option; + break; + } + return FALSE; + } + GeneratePreprocessedFile = preprocessYes; + break; + case 'F': + if ( second <= '9' && second >= '0' ) { + AdditionalOptions += option; + break; + } else { + switch ( second ) { + case 'A': + if ( third == 'c' ) { + AssemblerOutput = asmListingAsmMachine; + if ( fourth == 's' ) + AssemblerOutput = asmListingAsmMachineSrc; + } else if ( third == 's' ) { + AssemblerOutput = asmListingAsmSrc; + } else { + AssemblerOutput = asmListingAssemblyOnly; + } + break; + case 'a': + AssemblerListingLocation = option+3; + break; + case 'I': + ForcedIncludeFiles += option+3; + break; + case 'R': + BrowseInformation = brAllInfo; + BrowseInformationFile = option+3; + break; + case 'r': + BrowseInformation = brNoLocalSymbols; + BrowseInformationFile = option+3; + break; + case 'U': + ForcedUsingFiles += option+3; + break; + case 'd': + ProgramDataBaseFileName = option+3; + break; + case 'e': + OutputFile = option+3; + break; + case 'm': + AdditionalOptions += option; + break; + case 'o': + ObjectFile = option+3; + break; + case 'p': + PrecompiledHeaderFile = option+3; + break; + case 'x': + ExpandAttributedSource = _True; + break; + default: + return FALSE; + } + } + break; + case 'G': + switch ( second ) { + case '3': + case '4': + qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" ); + return FALSE; + case '5': + OptimizeForProcessor = procOptimizePentium; + break; + case '6': + case 'B': + OptimizeForProcessor = procOptimizePentiumProAndAbove; + break; + case 'A': + OptimizeForWindowsApplication = _True; + break; + case 'F': + StringPooling = _True; + break; + case 'H': + AdditionalOptions += option; + break; + case 'L': + WholeProgramOptimization = _True; + if ( third == '-' ) + WholeProgramOptimization = _False; + break; + case 'R': + RuntimeTypeInfo = _True; + if ( third == '-' ) + RuntimeTypeInfo = _False; + break; + case 'S': + BufferSecurityCheck = _True; + break; + case 'T': + EnableFiberSafeOptimizations = _True; + break; + case 'X': + case 'Z': + case 'e': + case 'h': + AdditionalOptions += option; + break; + case 'd': + CallingConvention = callConventionCDecl; + break; + case 'f': + StringPooling = _True; + AdditionalOptions += option; + break; + case 'm': + MinimalRebuild = _True; + if ( third == '-' ) + MinimalRebuild = _False; + break; + case 'r': + CallingConvention = callConventionFastCall; + break; + case 's': + // Warning: following [num] is not used, + // were should we put it? + BufferSecurityCheck = _True; + break; + case 'y': + EnableFunctionLevelLinking = _True; + break; + case 'z': + CallingConvention = callConventionStdCall; + break; + default: + return FALSE; + } + break; + case 'H': + AdditionalOptions += option; + break; + case 'I': + AdditionalIncludeDirectories += option+2; + break; + case 'L': + if ( second == 'D' ) { + AdditionalOptions += option; + break; + } + return FALSE; + case 'M': + if ( second == 'D' ) { + RuntimeLibrary = rtMultiThreadedDLL; + if ( third == 'd' ) + RuntimeLibrary = rtMultiThreadedDebugDLL; + break; + } else if ( second == 'L' ) { + RuntimeLibrary = rtSingleThreaded; + if ( third == 'd' ) + RuntimeLibrary = rtSingleThreadedDebug; + break; + } else if ( second == 'T' ) { + RuntimeLibrary = rtMultiThreaded; + if ( third == 'd' ) + RuntimeLibrary = rtMultiThreadedDebug; + break; + } + return FALSE; + case 'O': + switch ( second ) { + case '1': + Optimization = optimizeMinSpace; + break; + case '2': + Optimization = optimizeMaxSpeed; + break; + case 'a': + AdditionalOptions += option; + break; + case 'b': + if ( third == '0' ) + InlineFunctionExpansion = expandDisable; + else if ( third == '1' ) + InlineFunctionExpansion = expandOnlyInline; + else if ( third == '2' ) + InlineFunctionExpansion = expandAnySuitable; + else + return FALSE; + break; + case 'd': + Optimization = optimizeDisabled; + break; + case 'g': + GlobalOptimizations = _True; + break; + case 'i': + EnableIntrinsicFunctions = _True; + break; + case 'p': + ImproveFloatingPointConsistency = _True; + if ( third == '-' ) + ImproveFloatingPointConsistency = _False; + break; + case 's': + FavorSizeOrSpeed = favorSize; + break; + case 't': + FavorSizeOrSpeed = favorSpeed; + break; + case 'w': + AdditionalOptions += option; + break; + case 'x': + Optimization = optimizeFull; + break; + case 'y': + OmitFramePointers = _True; + if ( third == '-' ) + OmitFramePointers = _False; + break; + default: + return FALSE; + } + break; + case 'P': + GeneratePreprocessedFile = preprocessYes; + break; + case 'Q': + if ( second == 'I' ) { + AdditionalOptions += option; + break; + } + return FALSE; + case 'R': + if ( second == 'T' && third == 'C' ) { + if ( fourth == '1' ) + BasicRuntimeChecks = runtimeBasicCheckAll; + else if ( fourth == 'c' ) + SmallerTypeCheck = _True; + else if ( fourth == 's' ) + BasicRuntimeChecks = runtimeCheckStackFrame; + else if ( fourth == 'u' ) + BasicRuntimeChecks = runtimeCheckUninitVariables; + else + return FALSE; + } + break; + case 'T': + if ( second == 'C' ) { + CompileAs = compileAsC; + } else if ( second == 'P' ) { + CompileAs = compileAsCPlusPlus; + } else { + qWarning( "Generator: Options '/Tp' and '/Tc' are not supported by qmake" ); + return FALSE; + } + break; + case 'U': + UndefinePreprocessorDefinitions += option+2; + break; + case 'V': + AdditionalOptions += option; + break; + case 'W': + switch ( second ) { + case 'a': + case '4': + WarningLevel = warningLevel_4; + break; + case '3': + WarningLevel = warningLevel_3; + break; + case '2': + WarningLevel = warningLevel_2; + break; + case '1': + WarningLevel = warningLevel_1; + break; + case '0': + WarningLevel = warningLevel_0; + break; + case 'L': + AdditionalOptions += option; + break; + case 'X': + WarnAsError = _True; + break; + case 'p': + if ( third == '6' && fourth == '4' ) { + Detect64BitPortabilityProblems = _True; + break; + } + // Fallthrough + default: + return FALSE; + } + break; + case 'X': + IgnoreStandardIncludePath = _True; + break; + case 'Y': + switch ( second ) { + case '\0': + case '-': + AdditionalOptions += option; + break; + case 'X': + UsePrecompiledHeader = pchGenerateAuto; + PrecompiledHeaderFile = option+3; + break; + case 'c': + UsePrecompiledHeader = pchCreateUsingSpecific; + PrecompiledHeaderFile = option+3; + break; + case 'd': + case 'l': + AdditionalOptions =+ option; + break; + case 'u': + UsePrecompiledHeader = pchUseUsingSpecific; + PrecompiledHeaderFile = option+3; + break; + default: + return FALSE; + } + break; + case 'Z': + switch ( second ) { + case '7': + DebugInformationFormat = debugOldStyleInfo; + break; + case 'I': + DebugInformationFormat = debugEditAndContinue; + break; + case 'd': + DebugInformationFormat = debugLineInfoOnly; + break; + case 'i': + DebugInformationFormat = debugEnabled; + break; + case 'l': + DebugInformationFormat = debugEditAndContinue; + break; + case 'a': + DisableLanguageExtensions = _True; + break; + case 'e': + DisableLanguageExtensions = _False; + break; + case 'c': + if ( third == ':' ) { + if ( fourth == 'f' ) + ForceConformanceInForLoopScope = _True; + else if ( fourth == 'w' ) + TreatWChar_tAsBuiltInType = _True; + else + return FALSE; + } else { + return FALSE; + } + break; + case 'g': + case 'm': + case 's': + AdditionalOptions += option; + break; + case 'p': + switch ( third ) + { + case '\0': + case '1': + StructMemberAlignment = alignSingleByte; + if ( fourth == '6' ) + StructMemberAlignment = alignSixteenBytes; + break; + case '2': + StructMemberAlignment = alignTwoBytes; + break; + case '4': + StructMemberAlignment = alignFourBytes; + break; + case '8': + StructMemberAlignment = alignEightBytes; + break; + default: + return FALSE; + } + break; + default: + return FALSE; + } + break; + case 'c': + if ( second == '\0' ) { + CompileOnly = _True; + } else if ( second == 'l' ) { + if ( *(option+5) == 'n' ) { + CompileAsManaged = managedAssembly; + TurnOffAssemblyGeneration = _True; + } else { + CompileAsManaged = managedAssembly; + } + } else { + return FALSE; + } + break; + case 'd': + if ( second != 'r' ) + return FALSE; + CompileAsManaged = managedAssembly; + break; + case 'n': + if ( second == 'o' && third == 'B' && fourth == 'o' ) { + AdditionalOptions += "/noBool"; + break; + } + if ( second == 'o' && third == 'l' && fourth == 'o' ) { + SuppressStartupBanner = _True; + break; + } + return FALSE; + case 's': + if ( second == 'h' && third == 'o' && fourth == 'w' ) { + ShowIncludes = _True; + break; + } + return FALSE; + case 'u': + UndefineAllPreprocessorDefinitions = _True; + break; + case 'v': + if ( second == 'd' || second == 'm' ) { + AdditionalOptions += option; + break; + } + return FALSE; + case 'w': + switch ( second ) { + case '\0': + WarningLevel = warningLevel_0; + break; + case 'd': + DisableSpecificWarnings += option+3; + break; + default: + AdditionalOptions += option; + } + break; + default: + return FALSE; + } + return TRUE; +} + +// VCLinkerTool ----------------------------------------------------- +VCLinkerTool::VCLinkerTool() + : EnableCOMDATFolding( optFoldingDefault ), + GenerateDebugInformation( unset ), + GenerateMapFile( unset ), + HeapCommitSize( -1 ), + HeapReserveSize( -1 ), + IgnoreAllDefaultLibraries( unset ), + IgnoreEmbeddedIDL( unset ), + IgnoreImportLibrary( unset ), + LargeAddressAware( addrAwareDefault ), + LinkDLL( unset ), + LinkIncremental( linkIncrementalYes ), + LinkTimeCodeGeneration( unset ), + MapExports( unset ), + MapLines( unset ), + OptimizeForWindows98( optWin98Default ), + OptimizeReferences( optReferencesDefault ), + RegisterOutput( unset ), + ResourceOnlyDLL( unset ), + SetChecksum( unset ), + ShowProgress( linkProgressNotSet ), + StackCommitSize( -1 ), + StackReserveSize( -1 ), + SubSystem( subSystemNotSet ), + SupportUnloadOfDelayLoadedDLL( unset ), + SuppressStartupBanner( unset ), + SwapRunFromCD( unset ), + SwapRunFromNet( unset ), + TargetMachine( machineNotSet ), + TerminalServerAware( termSvrAwareDefault ), + TurnOffAssemblyGeneration( unset ), + TypeLibraryResourceID( 0 ) +{ +} + +QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool ) +{ + strm << _begTool3; + strm << _VCLinkerToolName; + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " ); + strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); + strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly ); + strm << SPair( _BaseAddress, tool.BaseAddress ); + strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs ); + if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding ); + strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol ); + strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); + strm << SPair( _FunctionOrder, tool.FunctionOrder ); + strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation ); + strm << TPair( _GenerateMapFile, tool.GenerateMapFile ); + if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize ); + if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize ); + strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); + strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); + strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL ); + strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary ); + strm << SPair( _ImportLibrary, tool.ImportLibrary ); + if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware ); + strm << TPair( _LinkDLL, tool.LinkDLL ); + if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental ); + strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration ); + strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile ); + strm << TPair( _MapExports, tool.MapExports ); + strm << SPair( _MapFileName, tool.MapFileName ); + strm << TPair( _MapLines, tool.MapLines ); + strm << SPair( _MergedIDLBaseFileName, tool.MergedIDLBaseFileName ); + strm << SPair( _MergeSections, tool.MergeSections ); + strm << SPair( _MidlCommandFile, tool.MidlCommandFile ); + strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); + if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 ); + if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences ); + strm << SPair( _OutputFile, tool.OutputFile ); + strm << SPair( _ProgramDatabaseFile, tool.ProgramDatabaseFile ); + strm << TPair( _RegisterOutput, tool.RegisterOutput ); + strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL ); + strm << TPair( _SetChecksum, tool.SetChecksum ); + if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); + if ( tool.StackCommitSize != -1 ) strm << LPair( _StackCommitSize, tool.StackCommitSize ); + if ( tool.StackReserveSize != -1 ) strm << LPair( _StackReserveSize, tool.StackReserveSize ); + strm << SPair( _StripPrivateSymbols, tool.StripPrivateSymbols ); + strm << EPair( _SubSystem, tool.SubSystem ); + strm << TPair( _SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD ); + strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet ); + if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine ); + if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware ); + strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); + strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile ); + if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID ); + strm << SPair( _Version4, tool.Version ); + strm << "/>"; + return strm; +} + +// Hashing routine to do fast option lookups ---- +// Slightly rewritten to stop on ':' ',' and '\0' +// Original routine in qtranslator.cpp ---------- +static uint elfHash( const char* name ) +{ + const uchar *k; + uint h = 0; + uint g; + + if ( name ) { + k = (const uchar *) name; + while ( (*k) && + (*k)!= ':' && + (*k)!=',' && + (*k)!=' ' ) { + h = ( h << 4 ) + *k++; + if ( (g = (h & 0xf0000000)) != 0 ) + h ^= g >> 24; + h &= ~g; + } + } + if ( !h ) + h = 1; + return h; +} +static void displayHash( const char* str ) +{ + printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str ); +} + +bool VCLinkerTool::parseOption( const char* option ) +{ +#if 0 + // Main options + displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" ); + displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" ); + displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" ); + displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" ); + displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" ); + displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" ); + displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" ); + displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" ); + displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" ); + displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" ); + displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" ); + displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" ); + displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" ); + displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" ); + displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" ); + displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" ); + displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" ); + displayHash( "/VXD" ); displayHash( "/WS " ); +#endif +#if 0 + // Sub options + displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" ); + displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" ); + displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" ); + displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" ); + displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" ); + displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" ); + displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" ); +#endif + + switch ( elfHash(option) ) { + case 0x3360dbe: // /ALIGN[:number] + case 0x1485c34: // /ALLOWBIND[:NO] + case 0x6b21972: // /DEFAULTLIB:library + case 0x396ea92: // /DRIVER[:UPONLY | :WDM] + case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] + case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] + case 0x33aec94: // /FIXED[:NO] + case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] + case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] + case 0x0348992: // /STUB:filename + case 0x0034bc4: // /VXD + case 0x0034c50: // /WS + AdditionalOptions += option; + break; + case 0x679c075: // /ASSEMBLYMODULE:filename + AddModuleNamesToAssembly += option+15; + break; + case 0x062d065: // /ASSEMBLYRESOURCE:filename + LinkToManagedResourceFile = option+18; + break; + case 0x0336675: // /BASE:{address | @filename,key} + // Do we need to do a manual lookup when '@filename,key'? + // Seems BaseAddress only can contain the location... + // We don't use it in Qt, so keep it simple for now + BaseAddress = option+6; + break; + case 0x3389797: // /DEBUG + GenerateDebugInformation = _True; + break; + case 0x0033896: // /DEF:filename + ModuleDefinitionFile = option+5; + break; + case 0x338a069: // /DELAY:{UNLOAD | NOBIND} + // MS documentation does not specify what to do with + // this option, so we'll put it in AdditionalOptions + AdditionalOptions += option; + break; + case 0x06f4bf4: // /DELAYLOAD:dllname + DelayLoadDLLs += option+11; + break; + // case 0x003390c: // /DLL + // This option is not used for vcproj files + // break; + case 0x33a3979: // /ENTRY:function + EntryPointSymbol = option+7; + break; + case 0x033c960: // /HEAP:reserve[,commit] + { + QStringList both = QStringList::split( ",", option+6 ); + HeapReserveSize = both[0].toLong(); + if ( both.count() == 2 ) + HeapCommitSize = both[1].toLong(); + } + break; + case 0x3d91494: // /IDLOUT:[path\]filename + MergedIDLBaseFileName = option+8; + break; + case 0x345a04c: // /IGNOREIDL + IgnoreEmbeddedIDL = _True; + break; + case 0x3e250e2: // /IMPLIB:filename + ImportLibrary = option+8; + break; + case 0xe281ab5: // /INCLUDE:symbol + ForceSymbolReferences += option+9; + break; + case 0xb28103c: // /INCREMENTAL[:no] + if ( *(option+12) == ':' && + *(option+13) == 'n' ) + LinkIncremental = linkIncrementalNo; + else + LinkIncremental = linkIncrementalYes; + break; + case 0x26e4675: // /LARGEADDRESSAWARE[:no] + if ( *(option+18) == ':' && + *(option+19) == 'n' ) + LargeAddressAware = addrAwareNoLarge; + else + LargeAddressAware = addrAwareLarge; + break; + case 0x0d745c8: // /LIBPATH:dir + AdditionalLibraryDirectories += option+9; + break; + case 0x0341877: // /LTCG[:NOSTATUS|:STATUS] + config->WholeProgramOptimization = _True; + LinkTimeCodeGeneration = _True; + if ( *(option+5) == ':' && + *(option+6) == 'S' ) + ShowProgress = linkProgressAll; + break; + case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE} + switch ( elfHash(option+9) ) { + // Very limited documentation on all options but X86, + // so we put the others in AdditionalOptions... + case 0x0046063: // AM33 + case 0x000466d: // ARM + case 0x0004795: // CEE + case 0x004d494: // IA64 + case 0x0050672: // M32R + case 0x0051e53: // MIPS + case 0x51e5646: // MIPS16 + case 0x1e57b05: // MIPSFPU + case 0x57b09a6: // MIPSFPU16 + case 0x5852738: // MIPSR41XX + case 0x0005543: // PPC + case 0x00057b3: // SH3 + case 0x00057b4: // SH4 + case 0x00057b5: // SH5 + case 0x058da12: // THUMB + case 0x96d8435: // TRICORE + AdditionalOptions += option; + break; + case 0x0005bb6: // X86 + TargetMachine = machineX86; + break; + default: + return FALSE; + } + break; + case 0x0034160: // /MAP[:filename] + GenerateMapFile = _True; + MapFileName = option+5; + break; + case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES} + if ( *(option+9) == 'E' ) + MapExports = _True; + else if ( *(option+9) == 'L' ) + MapLines = _True; + break; + case 0x341a6b5: // /MERGE:from=to + MergeSections = option+7; + break; + case 0x0341d8c: // /MIDL:@file + MidlCommandFile = option+7; + break; + case 0x84e2679: // /NOASSEMBLY + TurnOffAssemblyGeneration = _True; + break; + case 0x2b21942: // /NODEFAULTLIB[:library] + if ( *(option+13) == '\0' ) + IgnoreAllDefaultLibraries = _True; + else + IgnoreDefaultLibraryNames += option+14; + break; + case 0x33a3a39: // /NOENTRY + ResourceOnlyDLL = _True; + break; + case 0x434138f: // /NOLOGO + SuppressStartupBanner = _True; + break; + case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98} + { + char third = *(option+7); + switch ( third ) { + case 'F': // REF + if ( *(option+5) == 'R' ) { + OptimizeReferences = optReferences; + } else { // ICF[=iterations] + EnableCOMDATFolding = optFolding; + // [=iterations] case is not documented + } + break; + case 'R': // NOREF + OptimizeReferences = optNoReferences; + break; + case 'I': // NOICF + EnableCOMDATFolding = optNoFolding; + break; + case 'N': // WIN98 + OptimizeForWindows98 = optWin98Yes; + break; + case 'W': // NOWIN98 + OptimizeForWindows98 = optWin98No; + break; + default: + return FALSE; + } + } + break; + case 0x34468a2: // /ORDER:@filename + FunctionOrder = option+8; + break; + case 0x00344a4: // /OUT:filename + OutputFile = option+5; + break; + case 0x0034482: // /PDB:filename + ProgramDatabaseFile = option+5; + break; + case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name + StripPrivateSymbols = option+13; + break; + case 0x6a09535: // /RELEASE + SetChecksum = _True; + break; + case 0x348857b: // /STACK:reserve[,commit] + { + QStringList both = QStringList::split( ",", option+7 ); + StackReserveSize = both[0].toLong(); + if ( both.count() == 2 ) + StackCommitSize = both[1].toLong(); + } + break; + case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]] + { + // Split up in subsystem, and version number + QStringList both = QStringList::split( ",", option+11 ); + switch ( elfHash(both[0].latin1()) ) { + case 0x8438445: // CONSOLE + SubSystem = subSystemConsole; + break; + case 0xbe29493: // WINDOWS + SubSystem = subSystemWindows; + break; + // The following are undocumented, so add them to AdditionalOptions + case 0x240949e: // EFI_APPLICATION + case 0xe617652: // EFI_BOOT_SERVICE_DRIVER + case 0x9af477d: // EFI_ROM + case 0xd34df42: // EFI_RUNTIME_DRIVER + case 0x5268ea5: // NATIVE + case 0x05547e8: // POSIX + case 0x2949c95: // WINDOWSCE + AdditionalOptions += option; + break; + default: + return FALSE; + } + } + break; + case 0x8b654de: // /SWAPRUN:{NET | CD} + if ( *(option+9) == 'N' ) + SwapRunFromNet = _True; + else if ( *(option+9) == 'C' ) + SwapRunFromCD = _True; + else + return FALSE; + break; + case 0x34906d4: // /TLBID:id + TypeLibraryResourceID = QString( option+7 ).toLong(); + break; + case 0x4907494: // /TLBOUT:[path\]filename + TypeLibraryFile = option+8; + break; + case 0x976b525: // /TSAWARE[:NO] + if ( *(option+8) == ':' ) + TerminalServerAware = termSvrAwareNo; + else + TerminalServerAware = termSvrAwareYes; + break; + case 0xaa67735: // /VERBOSE[:lib] + if ( *(option+9) == ':' ) { + ShowProgress = linkProgressLibs; + AdditionalOptions += option; + } else { + ShowProgress = linkProgressAll; + } + break; + case 0xaa77f7e: // /VERSION:major[.minor] + Version = option+9; + break; + default: + return FALSE; + } + return TRUE; +} + +// VCMIDLTool ------------------------------------------------------- +VCMIDLTool::VCMIDLTool() + : DefaultCharType( midlCharUnsigned ), + EnableErrorChecks( midlDisableAll ), + ErrorCheckAllocations( unset ), + ErrorCheckBounds( unset ), + ErrorCheckEnumRange( unset ), + ErrorCheckRefPointers( unset ), + ErrorCheckStubData( unset ), + GenerateStublessProxies( unset ), + GenerateTypeLibrary( unset ), + IgnoreStandardIncludePath( unset ), + MkTypLibCompatible( unset ), + StructMemberAlignment( midlAlignNotSet ), + SuppressStartupBanner( unset ), + TargetEnvironment( midlTargetNotSet ), + ValidateParameters( unset ), + WarnAsError( unset ), + WarningLevel( midlWarningLevel_0 ) +{ +} + +QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool ) +{ + strm << _begTool3; + strm << _VCMIDLToolName; + strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); + strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions ); + strm << EPair( _DefaultCharType, tool.DefaultCharType ); + strm << SPair( _DLLDataFileName, tool.DLLDataFileName ); + strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks ); + strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations ); + strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds ); + strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange ); + strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers ); + strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData ); + strm << XPair( _FullIncludePath, tool.FullIncludePath ); + strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies ); + strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary ); + strm << SPair( _HeaderFileName, tool.HeaderFileName ); + strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); + strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName ); + strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible ); + strm << SPair( _OutputDirectory4, tool.OutputDirectory ); + strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); + strm << SPair( _ProxyFileName, tool.ProxyFileName ); + strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors ); + if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment ); + strm << SPair( _TypeLibraryName, tool.TypeLibraryName ); + strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); + strm << TPair( _ValidateParameters, tool.ValidateParameters ); + strm << TPair( _WarnAsError, tool.WarnAsError ); + strm << EPair( _WarningLevel, tool.WarningLevel ); + strm << "/>"; + return strm; +} + +bool VCMIDLTool::parseOption( const char* option ) +{ +#if 0 + displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" ); + displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" ); + displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" ); + displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" ); + displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" ); + displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" ); + displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" ); + displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" ); + displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" ); + displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" ); + displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" ); + displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" ); + displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" ); + displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" ); + displayHash( "/msc_ver " ); displayHash( "/newtlb" ); displayHash( "/no_cpp" ); + displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" ); + displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" ); + displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" ); + displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" ); + displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" ); + displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" ); + displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" ); + displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" ); + displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" ); + displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" ); + displayHash( "/win32" ); displayHash( "/win64" ); +#endif + int offset = 0; + switch( elfHash(option) ) { + case 0x0000334: // /D name[=def] + PreprocessorDefinitions += option+3; + break; + case 0x0000339: // /I directory-list + AdditionalIncludeDirectories += option+3; + break; + case 0x0345f96: // /Oicf + case 0x00345f6: // /Oif + GenerateStublessProxies = _True; + break; + case 0x0000345: // /U name + UndefinePreprocessorDefinitions += option+3; + break; + case 0x00034c8: // /WX + WarnAsError = _True; + break; + case 0x3582fde: // /align {N} + offset = 3; // Fallthrough + case 0x0003510: // /Zp {N} + switch ( *(option+offset+4) ) { + case '1': + StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes; + break; + case '2': + StructMemberAlignment = midlAlignTwoBytes; + break; + case '4': + StructMemberAlignment = midlAlignFourBytes; + break; + case '8': + StructMemberAlignment = midlAlignEightBytes; + break; + default: + return FALSE; + } + break; + case 0x0359e82: // /char {ascii7|signed|unsigned} + switch( *(option+6) ) { + case 'a': + DefaultCharType = midlCharAscii7; + break; + case 's': + DefaultCharType = midlCharSigned; + break; + case 'u': + DefaultCharType = midlCharUnsigned; + break; + default: + return FALSE; + } + break; + case 0xa766524: // /cpp_opt options + CPreprocessOptions += option+9; + break; + case 0xb32abf1: // /dlldata filename + DLLDataFileName = option + 9; + break; + case 0x0035c56: // /env {win32|win64} + TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32; + break; + case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data} + EnableErrorChecks = midlEnableCustom; + switch ( *(option+7) ) { + case 'a': + if ( *(option+10) == '\0' ) + EnableErrorChecks = midlEnableAll; + else + ErrorCheckAllocations = _True; + break; + case 'b': + ErrorCheckBounds = _True; + break; + case 'e': + ErrorCheckEnumRange = _True; + break; + case 'n': + EnableErrorChecks = midlDisableAll; + break; + case 'r': + break; + ErrorCheckRefPointers = _True; + case 's': + break; + ErrorCheckStubData = _True; + default: + return FALSE; + } + break; + case 0x5eb7af2: // /header filename + offset = 5; + case 0x0000358: // /h filename + HeaderFileName = option + offset + 3; + break; + case 0x0035ff4: // /iid filename + InterfaceIdentifierFileName = option+5; + break; + case 0x64b7933: // /mktyplib203 + MkTypLibCompatible = _True; + break; + case 0x8e0b0a2: // /no_def_idir + IgnoreStandardIncludePath = _True; + break; + case 0x65635ef: // /nologo + SuppressStartupBanner = _True; + break; + case 0x3656b22: // /notlb + GenerateTypeLibrary = _True; + break; + case 0x000035f: // /o filename + RedirectOutputAndErrors = option+3; + break; + case 0x00366c4: // /out directory + OutputDirectory = option+5; + break; + case 0x36796f9: // /proxy filename + ProxyFileName = option+7; + break; + case 0x6959c94: // /robust + ValidateParameters = _True; + break; + case 0x6a88df4: // /target {system} + if ( *(option+11) == '6' ) + TargetEnvironment = midlTargetWin64; + else + TargetEnvironment = midlTargetWin32; + break; + case 0x0036b22: // /tlb filename + TypeLibraryName = option+5; + break; + case 0x36e0162: // /win32 + TargetEnvironment = midlTargetWin32; + break; + case 0x36e0194: // /win64 + TargetEnvironment = midlTargetWin64; + break; + case 0x0003459: // /Oi + case 0x00345f3: // /Oic + case 0x0003463: // /Os + case 0x0003513: // /Zs + case 0x0035796: // /acf filename + case 0x5b1cb97: // /app_config + case 0x3595cf4: // /c_ext + case 0x5a2fc64: // /client {none|stub} + case 0xa64d3dd: // /confirm + case 0xa765b64: // /cpp_cmd cmd_line + case 0x35aabb2: // /cstub filename + case 0x03629f4: // /lcid + case 0x6495cc4: // /ms_ext + case 0x96c7a1e: // /ms_union + case 0x4996fa2: // /msc_ver + case 0x64ceb12: // /newtlb + case 0x6555a40: // /no_cpp + case 0xf64d6a6: // /no_default_epv + case 0x6dd9384: // /no_format_opt + case 0x556dbee: // /no_warn + case 0x3655a70: // /nocpp + case 0x2b455a3: // /oldnames + case 0x662bb12: // /oldtlb + case 0x0036696: // /osf + case 0x036679b: // /pack {N} + case 0x678bd38: // /prefix {all|client|server|switch} + case 0x96b702c: // /protocol {all|dce|ndr64} + case 0x3696aa3: // /rpcss + case 0x698ca60: // /savePP + case 0x69c9cf2: // /server {none|stub} + case 0x36aabb2: // /sstub filename + case 0xce9b12b: // /syntax_check + case 0xc9b5f16: // /use_epv + AdditionalOptions += option; + break; + default: + // /W{0|1|2|3|4} case + if ( *(option+1) == 'W' ) { + switch ( *(option+2) ) { + case '0': + WarningLevel = midlWarningLevel_0; + break; + case '1': + WarningLevel = midlWarningLevel_1; + break; + case '2': + WarningLevel = midlWarningLevel_2; + break; + case '3': + WarningLevel = midlWarningLevel_3; + break; + case '4': + WarningLevel = midlWarningLevel_4; + break; + default: + return FALSE; + } + } + break; + } + return TRUE; +} + +// VCLibrarianTool -------------------------------------------------- +VCLibrarianTool::VCLibrarianTool() + : IgnoreAllDefaultLibraries( unset ), + SuppressStartupBanner( _True ) +{ +} + +QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, QString( "VCLibrarianTool" ) ); + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies ); + strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); + strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions ); + strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); + strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); + strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); + strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); + strm << SPair( _OutputFile, tool.OutputFile ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + strm << "/>"; + return strm; +} + +// VCCustomBuildTool ------------------------------------------------ +VCCustomBuildTool::VCCustomBuildTool() +{ + ToolName = "VCCustomBuildTool"; +} + +QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, tool.ToolName ); + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" ); + strm << SPair( _CommandLine4, tool.CommandLine ); + strm << SPair( _Description4, tool.Description ); + strm << SPair( _Outputs4, tool.Outputs ); + strm << SPair( _ToolPath, tool.ToolPath ); + strm << "/>"; + return strm; +} + +// VCResourceCompilerTool ------------------------------------------- +VCResourceCompilerTool::VCResourceCompilerTool() + : Culture( rcUseDefault ), + IgnoreStandardIncludePath( unset ), + ShowProgress( linkProgressNotSet ) +{ + PreprocessorDefinitions = "NDEBUG"; +} + +QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool ) +{ + strm << _begTool3; + strm << _VCResourceCompilerToolName; + strm << SPair( _ToolPath, tool.ToolPath ); + strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); + if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture ); + strm << XPair( _FullIncludePath, tool.FullIncludePath ); + strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); + strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); + strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName ); + if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); + strm << "/>"; + return strm; +} + +// VCEventTool ------------------------------------------------- +QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, tool.ToolName ); + strm << SPair( _ToolPath, tool.ToolPath ); + strm << SPair( _CommandLine4, tool.CommandLine ); + strm << SPair( _Description4, tool.Description ); + strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild ); + strm << "/>"; + return strm; +} + +// VCPostBuildEventTool --------------------------------------------- +VCPostBuildEventTool::VCPostBuildEventTool() +{ + ToolName = "VCPostBuildEventTool"; +} + +// VCPreBuildEventTool ---------------------------------------------- +VCPreBuildEventTool::VCPreBuildEventTool() +{ + ToolName = "VCPreBuildEventTool"; +} + +// VCPreLinkEventTool ----------------------------------------------- +VCPreLinkEventTool::VCPreLinkEventTool() +{ + ToolName = "VCPreLinkEventTool"; +} + +// VCConfiguration -------------------------------------------------- + +VCConfiguration::VCConfiguration() + : ATLMinimizesCRunTimeLibraryUsage( unset ), + BuildBrowserInformation( unset ), + CharacterSet( charSetNotSet ), + ConfigurationType( typeApplication ), + RegisterOutput( unset ), + UseOfATL( useATLNotSet ), + UseOfMfc( useMfcStdWin ), + WholeProgramOptimization( unset ) +{ + compiler.config = this; + linker.config = this; + idl.config = this; +} + +QTextStream &operator<<( QTextStream &strm, const VCConfiguration &tool ) +{ + strm << _begConfiguration; + strm << SPair( _Name3, tool.Name ); + strm << SPair( _OutputDirectory3, tool.OutputDirectory ); + strm << TPair( _ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage ); + strm << TPair( _BuildBrowserInformation, tool.BuildBrowserInformation ); + if ( tool.CharacterSet != charSetNotSet) strm << EPair( _CharacterSet, tool.CharacterSet ); + strm << EPair( _ConfigurationType, tool.ConfigurationType ); + strm << SPair( _DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean ); + strm << SPair( _ImportLibrary, tool.ImportLibrary ); + strm << SPair( _IntermediateDirectory, tool.IntermediateDirectory ); + strm << SPair( _PrimaryOutput, tool.PrimaryOutput ); + strm << SPair( _ProgramDatabase, tool.ProgramDatabase ); + strm << TPair( _RegisterOutput, tool.RegisterOutput ); + if ( tool.UseOfATL != useATLNotSet) strm << EPair( _UseOfATL, tool.UseOfATL ); + strm << EPair( _UseOfMfc, tool.UseOfMfc ); + strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); + strm << ">"; + strm << tool.compiler; + strm << tool.custom; + if ( tool.ConfigurationType == typeStaticLibrary ) + strm << tool.librarian; + else + strm << tool.linker; + strm << tool.idl; + strm << tool.postBuild; + strm << tool.preBuild; + strm << tool.preLink; + strm << tool.resource; + strm << _endConfiguration; + return strm; +} +// VCFilter --------------------------------------------------------- +VCFilter::VCFilter() + : ParseFiles( unset ) +{ +} + +void VCFilter::generateMOC( QTextStream &strm, QString str ) const +{ + QString mocOutput = Project->findMocDestination( str ); + QString mocApp = Project->var( "QMAKE_MOC" ); + + if( mocOutput.isEmpty() ) { + // In specialcases we DO moc .cpp files + // when the result is an .moc file + if ( !str.endsWith(".moc") ) + return; + mocOutput = str; + str = Project->findMocSource( mocOutput ); + } + + strm << _begFileConfiguration; + strm << _Name5; + strm << Config->Name; + strm << "\">"; + strm << _begTool5; + strm << _VCCustomBuildTool; + strm << _Description6; + strm << "Moc'ing " << str << "...\""; + strm << _CommandLine6; + strm << mocApp; + strm << " " << str << " -o " << mocOutput << "\""; + strm << _AdditionalDependencies6; + strm << mocApp << "\""; + strm << _Outputs6; + strm << mocOutput << "\""; + strm << "/>"; + strm << _endFileConfiguration; +} + +void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const +{ + QString uicApp = Project->var("QMAKE_UIC"); + QString mocApp = Project->var( "QMAKE_MOC" ); + QString fname = str.section( '\\', -1 ); + QString mocDir = Project->var( "MOC_DIR" ); + int dot = fname.findRev( '.' ); + if( dot != -1 ) + fname.truncate( dot ); + + int slash = str.findRev( '\\' ); + QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\"); + + strm << _begFileConfiguration; + strm << _Name5; + strm << Config->Name; + strm << "\">"; + strm << _begTool5; + strm << _VCCustomBuildTool; + strm << _Description6; + strm << "Uic'ing " << str << "...\""; + strm << _CommandLine6; + strm << uicApp << " " << str << " -o " << pname << fname << ".h && "; // Create .h from .ui file + strm << uicApp << " " << str << " -i " << fname << ".h -o " << pname << fname << ".cpp && "; // Create .cpp from .ui file + strm << mocApp << " " << pname << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\""; + strm << _AdditionalDependencies6; + strm << mocApp << ";" << uicApp << "\""; + strm << _Outputs6; + strm << pname << fname << ".h;" << pname << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\""; + strm << "/>"; + strm << _endFileConfiguration; +} + +QTextStream &operator<<( QTextStream &strm, const VCFilter &tool ) +{ + if ( tool.Files.count() == 0 ) + return strm; + + strm << _begFilter; + strm << SPair( _Name3, tool.Name ); + strm << TPair( _ParseFiles, tool.ParseFiles ); + strm << SPair( _Filter, tool.Filter ); + strm << ">"; + for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) { + strm << _begFile; + strm << SPair( _RelativePath, *it ); + strm << ">"; + if ( tool.CustomBuild == moc ) + tool.generateMOC( strm, *it ); + else if ( tool.CustomBuild == uic ) + tool.generateUIC( strm, *it ); + strm << _endFile; + } + + strm << _endFilter; + return strm; +} + +// VCProject -------------------------------------------------------- +VCProject::VCProject() +{ + QUuid uniqueId; +#if defined(Q_WS_WIN32) + GUID guid; + HRESULT h = CoCreateGuid( &guid ); + if ( h == S_OK ) + uniqueId = QUuid( guid ); + ProjectGUID = uniqueId.toString(); +#else + // Qt doesn't support GUID on other platforms yet + ProjectGUID = ""; +#endif +} + +QTextStream &operator<<( QTextStream &strm, const VCProject &tool ) +{ + strm << _xmlInit; + strm << _begVisualStudioProject; + strm << _ProjectType; + strm << SPair( _Version1, tool.Version ); + strm << SPair( _Name1, tool.Name ); + strm << SPair( _ProjectGUID, tool.ProjectGUID ); + strm << SPair( _SccProjectName, tool.SccProjectName ); + strm << SPair( _SccLocalPath, tool.SccLocalPath ); + strm << ">"; + strm << _begPlatforms; + strm << _begPlatform; + strm << SPair( _Name3, tool.PlatformName ); + strm << "/>"; + strm << _endPlatforms; + strm << _begConfigurations; + strm << tool.Configuration; + strm << _endConfigurations; + strm << _begFiles; + strm << tool.SourceFiles; + strm << tool.HeaderFiles; + strm << tool.MOCFiles; + strm << tool.UICFiles; + strm << tool.FormFiles; + strm << tool.TranslationFiles; + strm << tool.LexYaccFiles; + strm << tool.ResourceFiles; + strm << _endFiles; + strm << _begGlobals; + strm << _endGlobals; + strm << _endVisualStudioProject; + return strm; +} diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h new file mode 100644 index 0000000..2d09280 --- a/dev/null +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -0,0 +1,775 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Copyright (C) 2002 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __MSVC_OBJECTMODEL_H__ +#define __MSVC_OBJECTMODEL_H__ + +#include "project.h" +#include +#include + +/* + This Object model is of course VERY simplyfied, + and does not actually follow the original MSVC + object model. However, it fulfilles the basic + needs for qmake +*/ + +/* + If a triState value is 'unset' then the + corresponding property is not in the output, + forcing the tool to utilize default values. + False/True values will be in the output... +*/ +enum customBuildCheck { + none, + moc, + uic, + lexyacc +}; +enum triState { + unset = -1, + _False = 0, + _True = 1 +}; +enum addressAwarenessType { + addrAwareDefault, + addrAwareNoLarge, + addrAwareLarge +}; +enum asmListingOption { + asmListingNone, + asmListingAssemblyOnly, + asmListingAsmMachineSrc, + asmListingAsmMachine, + asmListingAsmSrc +}; +enum basicRuntimeCheckOption { + runtimeBasicCheckNone, + runtimeCheckStackFrame, + runtimeCheckUninitVariables, + runtimeBasicCheckAll +}; +enum browseInfoOption { + brInfoNone, + brAllInfo, + brNoLocalSymbols +}; +enum callingConventionOption { + callConventionDefault = -1, + callConventionCDecl, + callConventionFastCall, + callConventionStdCall +}; +enum charSet { + charSetNotSet, + charSetUnicode, + charSetMBCS +}; +enum compileAsManagedOptions { + managedDefault = -1, + managedAssembly = 2 +}; +enum CompileAsOptions{ + compileAsDefault, + compileAsC, + compileAsCPlusPlus +}; +enum ConfigurationTypes { + typeUnknown = 0, + typeApplication = 1, + typeDynamicLibrary = 2, + typeStaticLibrary = 4, + typeGeneric = 10 +}; +enum debugOption { + debugDisabled, + debugOldStyleInfo, + debugLineInfoOnly, + debugEnabled, + debugEditAndContinue +}; +enum eAppProtectionOption { + eAppProtectUnchanged, + eAppProtectLow, + eAppProtectMedium, + eAppProtectHigh +}; +enum enumResourceLangID { + rcUseDefault = 0, + rcAfrikaans = 1078, + rcAlbanian = 1052, + rcArabicAlgeria = 5121, + rcArabicBahrain = 15361, + rcArabicEgypt = 3073, + rcArabicIraq = 2049, + rcArabicJordan = 11265, + rcArabicKuwait = 13313, + rcArabicLebanon = 12289, + rcArabicLibya = 4097, + rcArabicMorocco = 6145, + rcArabicOman = 8193, + rcArabicQatar = 16385, + rcArabicSaudi = 1025, + rcArabicSyria = 10241, + rcArabicTunisia = 7169, + rcArabicUnitedArabEmirates = 14337, + rcArabicYemen = 9217, + rcBasque = 1069, + rcBulgarian = 1026, + rcByelorussian = 1059, + rcCatalan = 1027, + rcChineseHongKong = 3076, + rcChinesePRC = 2052, + rcChineseSingapore = 4100, + rcChineseTaiwan = 1028, + rcCroatian = 1050, + rcCzech = 1029, + rcDanish = 1030, + rcDutchBelgium = 2067, + rcDutchStandard = 1043, + rcEnglishAustralia = 3081, + rcEnglishBritain = 2057, + rcEnglishCanada = 4105, + RcEnglishCaribbean = 9225, + rcEnglishIreland = 6153, + rcEnglishJamaica = 8201, + rcEnglishNewZealand = 5129, + rcEnglishSouthAfrica = 7177, + rcEnglishUS = 1033, + rcEstonian = 1061, + rcFarsi = 1065, + rcFinnish = 1035, + rcFrenchBelgium = 2060, + rcFrenchCanada = 3084, + rcFrenchLuxembourg = 5132, + rcFrenchStandard = 1036, + rcFrenchSwitzerland = 4108, + rcGermanAustria = 3079, + rcGermanLichtenstein = 5127, + rcGermanLuxembourg = 4103, + rcGermanStandard = 1031, + rcGermanSwitzerland = 2055, + rcGreek = 1032, + rcHebrew = 1037, + rcHungarian = 1038, + rcIcelandic = 1039, + rcIndonesian = 1057, + rcItalianStandard = 1040, + rcItalianSwitzerland = 2064, + rcJapanese = 1041, + rcKorean = 1042, + rcKoreanJohab = 2066, + rcLatvian = 1062, + rcLithuanian = 1063, + rcNorwegianBokmal = 1044, + rcNorwegianNynorsk = 2068, + rcPolish = 1045, + rcPortugueseBrazilian = 1046, + rcPortugueseStandard = 2070, + rcRomanian = 1048, + rcRussian = 1049, + rcSerbian = 2074, + rcSlovak = 1051, + rcSpanishArgentina = 11274, + rcSpanishBolivia = 16394, + rcSpanishChile = 13322, + rcSpanishColombia = 9226, + rcSpanishCostaRica = 5130, + rcSpanishDominicanRepublic = 7178, + rcSpanishEcuador = 12298, + rcSpanishGuatemala = 4106, + rcSpanishMexico = 2058, + rcSpanishModern = 3082, + rcSpanishPanama = 6154, + rcSpanishParaguay = 15370, + rcSpanishPeru = 10250, + rcSpanishTraditional = 1034, + rcSpanishUruguay = 14346, + rcSpanishVenezuela = 8202, + rcSwedish = 1053, + rcThai = 1054, + rcTurkish = 1055, + rcUkrainian = 1058, + rcUrdu = 1056 +}; +enum enumSccEvent { + eProjectInScc, + ePreDirtyNotification +}; +enum favorSizeOrSpeedOption { + favorNone, + favorSpeed, + favorSize +}; +enum genProxyLanguage { + genProxyNative, + genProxyManaged +}; +enum inlineExpansionOption { + expandDisable, + expandOnlyInline, + expandAnySuitable +}; +enum linkIncrementalType { + linkIncrementalDefault, + linkIncrementalNo, + linkIncrementalYes +}; +enum linkProgressOption { + linkProgressNotSet, + linkProgressAll, + linkProgressLibs +}; +enum machineTypeOption { + machineNotSet, + machineX86 +}; +enum midlCharOption { + midlCharUnsigned, + midlCharSigned, + midlCharAscii7 +}; +enum midlErrorCheckOption { + midlEnableCustom, + midlDisableAll, + midlEnableAll +}; +enum midlStructMemberAlignOption { + midlAlignNotSet, + midlAlignSingleByte, + midlAlignTwoBytes, + midlAlignFourBytes, + midlAlignEightBytes, + midlAlignSixteenBytes +}; +enum midlTargetEnvironment { + midlTargetNotSet, + midlTargetWin32, + midlTargetWin64 +}; +enum midlWarningLevelOption { + midlWarningLevel_0, + midlWarningLevel_1, + midlWarningLevel_2, + midlWarningLevel_3, + midlWarningLevel_4 +}; +enum optFoldingType { + optFoldingDefault, + optNoFolding, + optFolding +}; +enum optimizeOption { + optimizeDisabled, + optimizeMinSpace, + optimizeMaxSpeed, + optimizeFull, + optimizeCustom +}; +enum optRefType { + optReferencesDefault, + optNoReferences, + optReferences +}; +enum optWin98Type { + optWin98Default, + optWin98No, + optWin98Yes +}; +enum pchOption { + pchNone, + pchCreateUsingSpecific, + pchGenerateAuto, + pchUseUsingSpecific +}; +enum preprocessOption { + preprocessNo, + preprocessYes, + preprocessNoLineNumbers +}; +enum ProcessorOptimizeOption { + procOptimizeBlended, + procOptimizePentium, + procOptimizePentiumProAndAbove +}; +enum RemoteDebuggerType { + DbgLocal, + DbgRemote, + DbgRemoteTCPIP +}; +enum runtimeLibraryOption { + rtMultiThreaded, + rtMultiThreadedDebug, + rtMultiThreadedDLL, + rtMultiThreadedDebugDLL, + rtSingleThreaded, + rtSingleThreadedDebug +}; +enum structMemberAlignOption { + alignNotSet, + alignSingleByte, + alignTwoBytes, + alignFourBytes, + alignEightBytes, + alignSixteenBytes +}; +enum subSystemOption { + subSystemNotSet, + subSystemConsole, + subSystemWindows +}; +enum termSvrAwarenessType { + termSvrAwareDefault, + termSvrAwareNo, + termSvrAwareYes +}; +enum toolSetType { + toolSetUtility, + toolSetMakefile, + toolSetLinker, + toolSetLibrarian, + toolSetAll +}; +enum TypeOfDebugger { + DbgNativeOnly, + DbgManagedOnly, + DbgMixed, + DbgAuto +}; +enum useOfATL { + useATLNotSet, + useATLStatic, + useATLDynamic +}; +enum useOfMfc { + useMfcStdWin, + useMfcStatic, + useMfcDynamic +}; +enum warningLevelOption { + warningLevel_0, + warningLevel_1, + warningLevel_2, + warningLevel_3, + warningLevel_4 +}; + +class VCToolBase { +protected: + // Functions + VCToolBase(){}; + ~VCToolBase(){}; + virtual bool parseOption( const char* option ) = 0; +public: + bool parseOptions( QStringList& options ) { + bool result = TRUE; + for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()) && result; it++ ) + result = parseOption( (*it).latin1() ); + return result; + } +}; + +class VCConfiguration; +class VCProject; + +class VCCLCompilerTool : public VCToolBase +{ +public: + // Functions + VCCLCompilerTool(); + ~VCCLCompilerTool(){}; + virtual bool parseOption( const char* option ); + + // Variables + QStringList AdditionalIncludeDirectories; + QStringList AdditionalOptions; + QStringList AdditionalUsingDirectories; + QString AssemblerListingLocation; + asmListingOption AssemblerOutput; + basicRuntimeCheckOption BasicRuntimeChecks; + browseInfoOption BrowseInformation; + QString BrowseInformationFile; + triState BufferSecurityCheck; + callingConventionOption CallingConvention; + CompileAsOptions CompileAs; + compileAsManagedOptions CompileAsManaged; + triState CompileOnly; + debugOption DebugInformationFormat; + triState DefaultCharIsUnsigned; + triState Detect64BitPortabilityProblems; + triState DisableLanguageExtensions; + QStringList DisableSpecificWarnings; + triState EnableFiberSafeOptimizations; + triState EnableFunctionLevelLinking; + triState EnableIntrinsicFunctions; + triState ExceptionHandling; + triState ExpandAttributedSource; + favorSizeOrSpeedOption FavorSizeOrSpeed; + triState ForceConformanceInForLoopScope; + QStringList ForcedIncludeFiles; + QStringList ForcedUsingFiles; + preprocessOption GeneratePreprocessedFile; + triState GlobalOptimizations; + triState IgnoreStandardIncludePath; + triState ImproveFloatingPointConsistency; + inlineExpansionOption InlineFunctionExpansion; + triState KeepComments; + triState MinimalRebuild; + QString ObjectFile; + triState OmitFramePointers; + optimizeOption Optimization; + ProcessorOptimizeOption OptimizeForProcessor; + triState OptimizeForWindowsApplication; + QString OutputFile; + QString PrecompiledHeaderFile; + QString PrecompiledHeaderThrough; + QStringList PreprocessorDefinitions; + QString ProgramDataBaseFileName; + runtimeLibraryOption RuntimeLibrary; + triState RuntimeTypeInfo; + triState ShowIncludes; + triState SmallerTypeCheck; + triState StringPooling; + structMemberAlignOption StructMemberAlignment; + triState SuppressStartupBanner; + triState TreatWChar_tAsBuiltInType; + triState TurnOffAssemblyGeneration; + triState UndefineAllPreprocessorDefinitions; + QStringList UndefinePreprocessorDefinitions; + pchOption UsePrecompiledHeader; + triState WarnAsError; + warningLevelOption WarningLevel; + triState WholeProgramOptimization; + VCConfiguration* config; +}; + +class VCLinkerTool : public VCToolBase +{ +public: + // Functions + VCLinkerTool(); + ~VCLinkerTool(){}; + virtual bool parseOption( const char* option ); + + // Variables + QStringList AdditionalDependencies; + QStringList AdditionalLibraryDirectories; + QStringList AdditionalOptions; + QStringList AddModuleNamesToAssembly; + QString BaseAddress; + QStringList DelayLoadDLLs; + optFoldingType EnableCOMDATFolding; + QString EntryPointSymbol; + QStringList ForceSymbolReferences; + QString FunctionOrder; + triState GenerateDebugInformation; + triState GenerateMapFile; + long HeapCommitSize; + long HeapReserveSize; + triState IgnoreAllDefaultLibraries; + QStringList IgnoreDefaultLibraryNames; + triState IgnoreEmbeddedIDL; + triState IgnoreImportLibrary; + QString ImportLibrary; + addressAwarenessType LargeAddressAware; + triState LinkDLL; + linkIncrementalType LinkIncremental; + triState LinkTimeCodeGeneration; + QString LinkToManagedResourceFile; + triState MapExports; + QString MapFileName; + triState MapLines; + QString MergedIDLBaseFileName; + QString MergeSections; // Should be list? + QString MidlCommandFile; + QString ModuleDefinitionFile; // Should be list? + optWin98Type OptimizeForWindows98; + optRefType OptimizeReferences; + QString OutputFile; + QString ProgramDatabaseFile; + triState RegisterOutput; + triState ResourceOnlyDLL; + triState SetChecksum; + linkProgressOption ShowProgress; + long StackCommitSize; + long StackReserveSize; + QString StripPrivateSymbols; // Should be list? + subSystemOption SubSystem; + triState SupportUnloadOfDelayLoadedDLL; + triState SuppressStartupBanner; + triState SwapRunFromCD; + triState SwapRunFromNet; + machineTypeOption TargetMachine; + termSvrAwarenessType TerminalServerAware; + triState TurnOffAssemblyGeneration; + QString TypeLibraryFile; + long TypeLibraryResourceID; + QString Version; + VCConfiguration* config; +}; + +class VCMIDLTool : public VCToolBase +{ +public: + // Functions + VCMIDLTool(); + ~VCMIDLTool(){}; + virtual bool parseOption( const char* option ); + + // Variables + QStringList AdditionalIncludeDirectories; + QStringList AdditionalOptions; + QStringList CPreprocessOptions; + midlCharOption DefaultCharType; + QString DLLDataFileName; // Should be list? + midlErrorCheckOption EnableErrorChecks; + triState ErrorCheckAllocations; + triState ErrorCheckBounds; + triState ErrorCheckEnumRange; + triState ErrorCheckRefPointers; + triState ErrorCheckStubData; + QStringList FullIncludePath; + triState GenerateStublessProxies; + triState GenerateTypeLibrary; + QString HeaderFileName; + triState IgnoreStandardIncludePath; + QString InterfaceIdentifierFileName; + triState MkTypLibCompatible; + QString OutputDirectory; + QStringList PreprocessorDefinitions; + QString ProxyFileName; + QString RedirectOutputAndErrors; + midlStructMemberAlignOption StructMemberAlignment; + triState SuppressStartupBanner; + midlTargetEnvironment TargetEnvironment; + QString TypeLibraryName; + QStringList UndefinePreprocessorDefinitions; + triState ValidateParameters; + triState WarnAsError; + midlWarningLevelOption WarningLevel; + VCConfiguration* config; +}; + +class VCLibrarianTool : public VCToolBase +{ +public: + // Functions + VCLibrarianTool(); + ~VCLibrarianTool(){}; + virtual bool parseOption( const char* option ){ return FALSE; }; + + // Variables + QStringList AdditionalDependencies; + QStringList AdditionalLibraryDirectories; + QStringList AdditionalOptions; + QStringList ExportNamedFunctions; + QStringList ForceSymbolReferences; + triState IgnoreAllDefaultLibraries; + QStringList IgnoreDefaultLibraryNames; + QString ModuleDefinitionFile; + QString OutputFile; + triState SuppressStartupBanner; +}; + +class VCCustomBuildTool : public VCToolBase +{ +public: + // Functions + VCCustomBuildTool(); + ~VCCustomBuildTool(){}; + virtual bool parseOption( const char* option ){ return FALSE; }; + + // Variables + QStringList AdditionalDependencies; + QString CommandLine; + QString Description; + QString Outputs; + QString ToolName; + QString ToolPath; +}; + +class VCResourceCompilerTool : public VCToolBase +{ +public: + // Functions + VCResourceCompilerTool(); + ~VCResourceCompilerTool(){}; + virtual bool parseOption( const char* option ){ return FALSE; }; + + // Variables + QStringList AdditionalIncludeDirectories; + QStringList AdditionalOptions; + enumResourceLangID Culture; + QStringList FullIncludePath; + triState IgnoreStandardIncludePath; + QStringList PreprocessorDefinitions; + QString ResourceOutputFileName; + linkProgressOption ShowProgress; + QString ToolPath; +}; + +class VCEventTool : public VCToolBase +{ +protected: + // Functions + VCEventTool() : ExcludedFromBuild( unset ){}; + ~VCEventTool(){}; + virtual bool parseOption( const char* option ){ return FALSE; }; + +public: + // Variables + QString CommandLine; + QString Description; + triState ExcludedFromBuild; + QString ToolName; + QString ToolPath; +}; + +class VCPostBuildEventTool : public VCEventTool +{ +public: + VCPostBuildEventTool(); + ~VCPostBuildEventTool(){}; +}; + +class VCPreBuildEventTool : public VCEventTool +{ +public: + VCPreBuildEventTool(); + ~VCPreBuildEventTool(){}; +}; + +class VCPreLinkEventTool : public VCEventTool +{ +public: + VCPreLinkEventTool(); + ~VCPreLinkEventTool(){}; +}; + +class VCConfiguration +{ +public: + // Functions + VCConfiguration(); + ~VCConfiguration(){}; + + // Variables + triState ATLMinimizesCRunTimeLibraryUsage; + triState BuildBrowserInformation; + charSet CharacterSet; + ConfigurationTypes ConfigurationType; + QString DeleteExtensionsOnClean; + QString ImportLibrary; + QString IntermediateDirectory; + QString Name; + QString OutputDirectory; + QString PrimaryOutput; + QString ProgramDatabase; + triState RegisterOutput; + useOfATL UseOfATL; + useOfMfc UseOfMfc; + triState WholeProgramOptimization; + + // XML sub-parts + VCCLCompilerTool compiler; + VCLinkerTool linker; + VCLibrarianTool librarian; + VCCustomBuildTool custom; + VCMIDLTool idl; + VCPostBuildEventTool postBuild; + VCPreBuildEventTool preBuild; + VCPreLinkEventTool preLink; + VCResourceCompilerTool resource; +}; + +class VcprojGenerator; +class VCFilter +{ +public: + // Functions + VCFilter(); + ~VCFilter(){}; + void generateMOC( QTextStream &strm, QString str ) const; + void generateUIC( QTextStream &strm, const QString& str ) const; + + // Variables + QString Name; + QString Filter; + triState ParseFiles; + QStringList Files; + VcprojGenerator* Project; + VCConfiguration* Config; + customBuildCheck CustomBuild; +}; + +class VCProject +{ +public: + // Functions + VCProject(); + ~VCProject(){}; + + // Variables + QString Name; + QString Version; + QString ProjectGUID; + QString SccProjectName; + QString SccLocalPath; + QString PlatformName; + + // XML sub-parts + VCConfiguration Configuration; + VCFilter SourceFiles; + VCFilter HeaderFiles; + VCFilter MOCFiles; + VCFilter UICFiles; + VCFilter FormFiles; + VCFilter TranslationFiles; + VCFilter LexYaccFiles; + VCFilter ResourceFiles; +}; + +QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & ); +QTextStream &operator<<( QTextStream &, const VCLinkerTool & ); +QTextStream &operator<<( QTextStream &, const VCMIDLTool & ); +QTextStream &operator<<( QTextStream &, const VCCustomBuildTool & ); +QTextStream &operator<<( QTextStream &, const VCLibrarianTool & ); +QTextStream &operator<<( QTextStream &, const VCResourceCompilerTool & ); +QTextStream &operator<<( QTextStream &, const VCEventTool & ); +QTextStream &operator<<( QTextStream &, const VCConfiguration & ); +QTextStream &operator<<( QTextStream &, const VCFilter & ); +QTextStream &operator<<( QTextStream &, const VCProject & ); + +#endif //__MSVC_OBJECTMODEL_H__ diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp new file mode 100644 index 0000000..a2bb6e9 --- a/dev/null +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -0,0 +1,1050 @@ +/**************************************************************************** +** $Id$ +** +** Definition of VcprojGenerator class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "msvc_vcproj.h" +#include "option.h" +#include +#include +#include + +#if defined(Q_OS_WIN32) +#include +#endif + +VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ +} + +/* \internal + Generates a project file for the given profile. + Options are either a Visual Studio projectfiles, or + recursive projectfiles.. Maybe we can make .sln files + someday? +*/ +bool VcprojGenerator::writeMakefile(QTextStream &t) +{ + // Check if all requirements are fullfilled + if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { + fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", + var("QMAKE_FAILED_REQUIREMENTS").latin1()); + return TRUE; + } + + // Generate full project file + if(project->first("TEMPLATE") == "vcapp" || + project->first("TEMPLATE") == "vclib") { + debug_msg(1, "Generator: MSVC.NET: Writing project file" ); + t << vcProject; + return TRUE; + } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project + debug_msg(1, "Generator: MSVC.NET: Writing solution file" ); + writeSubDirs(t); + return TRUE; + } + return FALSE; + +} + +struct VcsolutionDepend { + QString vcprojFile, orig_target, target; + QStringList dependencies; +}; + +void VcprojGenerator::writeSubDirs(QTextStream &t) +{ + if(project->first("TEMPLATE") == "subdirs") { + writeHeader(t); + Win32MakefileGenerator::writeSubDirs(t); + return; + } + + QPtrList solution_depends; + solution_depends.setAutoDelete(TRUE); + QStringList subdirs = project->variables()["SUBDIRS"]; + QString oldpwd = QDir::currentDirPath(); + for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { + QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); + if(fi.exists()) { + if(fi.isDir()) { + QString profile = (*it); + if(!profile.endsWith(Option::dir_sep)) + profile += Option::dir_sep; + profile += fi.baseName() + ".pro"; + subdirs.append(profile); + } else { + QMakeProject tmp_proj; + QString dir = fi.dirPath(), fn = fi.fileName(); + if(!dir.isEmpty()) { + if(!QDir::setCurrent(dir)) + fprintf(stderr, "Cannot find directory: %s\n", dir.latin1()); + } + if(tmp_proj.read(fn, oldpwd)) { + if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { + QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); + subdirs += tmp_subdirs; + } else if(tmp_proj.first("TEMPLATE") == "vcapp" || + tmp_proj.first("TEMPLATE") == "vclib") { + QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION"); + if(QFile::exists(vcproj) || 1) { + VcprojGenerator tmp_dsp(&tmp_proj); + tmp_dsp.setNoIO(TRUE); + tmp_dsp.init(); + if(Option::debug_level) { + QMap &vars = tmp_proj.variables(); + for(QMap::Iterator it = vars.begin(); + it != vars.end(); ++it) { + if(it.key().left(1) != "." && !it.data().isEmpty()) + debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(), + it.data().join(" :: ").latin1()); + } + } + VcsolutionDepend *newDep = new VcsolutionDepend; + newDep->vcprojFile = fileFixify(vcproj); + newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); + newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); + if(newDep->target.endsWith(".dll")) + newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; + if(!tmp_proj.isEmpty("FORMS")) + newDep->dependencies << "uic.exe"; + { + QStringList where("QMAKE_LIBS"); + if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) + where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; + for(QStringList::iterator wit = where.begin(); + wit != where.end(); ++wit) { + QStringList &l = tmp_proj.variables()[(*wit)]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + QString opt = (*it); + if(!opt.startsWith("/")) //Not a switch + newDep->dependencies << opt.section(Option::dir_sep, -1); + } + } + } + solution_depends.append(newDep); + } + } + } + QDir::setCurrent(oldpwd); + } + } + } + + VcsolutionDepend *vc; + QMap uuids; + QRegExp libVersion("[0-9]{3,3}\\.lib$"); + for(vc = solution_depends.first(); vc; vc = solution_depends.next()) { + static int uuid = 666; + uuids.insert(vc->target, uuid); + if(libVersion.match(vc->target) != -1) + uuids.insert(vc->target.left(vc->target.length() - libVersion.matchedLength()) + ".lib", + uuid); + t << "\"" << vc->orig_target << "\" \"" << vc->vcprojFile << "\" { " << uuid << " }" << endl; + uuid++; + } + for(vc = solution_depends.first(); vc; vc = solution_depends.next()) { + int uuid = uuids[vc->target], cnt = 0; + for(QStringList::iterator dit = vc->dependencies.begin(); dit != vc->dependencies.end(); ++dit) { + if(uuids.contains((*dit))) + t << uuid << "." << cnt++ << " = " << uuids[(*dit)] << endl; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ + +void VcprojGenerator::init() +{ + if( init_flag ) + return; + if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs + init_flag = TRUE; + return; + } + + debug_msg(1, "Generator: MSVC.NET: Initializing variables" ); + +/* + // Once to be nice and clean code... + // Wouldn't life be great? + + // Are we building Qt? + bool is_qt = + ( project->first("TARGET") == "qt"QTDLL_POSTFIX || + project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); + + // Are we using Qt? + bool isQtActive = project->isActiveConfig("qt"); + + if ( isQtActive ) { + project->variables()["CONFIG"] += "moc"; + project->variables()["CONFIG"] += "windows"; + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + + if( projectTarget == SharedLib ) + project->variables()["DEFINES"] += "QT_DLL"; + + if( project->isActiveConfig("accessibility" ) ) + project->variables()["DEFINES"] += "QT_ACCESSIBILITY_SUPPORT"; + + if ( project->isActiveConfig("plugin")) { + project->variables()["DEFINES"] += "QT_PLUGIN"; + project->variables()["CONFIG"] += "dll"; + } + + if( project->isActiveConfig("thread") ) { + project->variables()["DEFINES"] += "QT_THREAD_SUPPORT"; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + } else { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + } + } + + if ( project->isActiveConfig("opengl") ) { + project->variables()["CONFIG"] += "windows"; // <-- Also in 'qt' above + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + + } +*/ + initOld(); // Currently calling old DSP code to set variables. CLEAN UP! + + // Figure out what we're trying to build + if ( project->first("TEMPLATE") == "vcapp" ) { + projectTarget = Application; + } else if ( project->first("TEMPLATE") == "vclib") { + if ( project->isActiveConfig( "staticlib" ) ) + projectTarget = StaticLib; + else + projectTarget = SharedLib; + } + initProject(); // Fills the whole project with proper data +} + +void VcprojGenerator::initProject() +{ + // Initialize XML sub elements + // - Do this first since project elements may need + // - to know of certain configuration options + initConfiguration(); + initSourceFiles(); + initHeaderFiles(); + initMOCFiles(); + initUICFiles(); + initFormsFiles(); + initTranslationFiles(); + initLexYaccFiles(); + initResourceFiles(); + + // Own elements ----------------------------- + vcProject.Name = project->first("QMAKE_ORIG_TARGET"); + vcProject.Version = "7.00"; + vcProject.PlatformName = ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); + // These are not used by Qt, but may be used by customers + vcProject.SccProjectName = project->first("SCCPROJECTNAME"); + vcProject.SccLocalPath = project->first("SCCLOCALPATH"); +} + +void VcprojGenerator::initConfiguration() +{ + // Initialize XML sub elements + // - Do this first since main configuration elements may need + // - to know of certain compiler/linker options + initCompilerTool(); + if ( projectTarget == StaticLib ) + initLibrarianTool(); + else + initLinkerTool(); + initIDLTool(); + + // Own elements ----------------------------- + QString temp = project->first("BuildBrowserInformation"); + switch ( projectTarget ) { + case SharedLib: + vcProject.Configuration.ConfigurationType = typeDynamicLibrary; + break; + case StaticLib: + vcProject.Configuration.ConfigurationType = typeStaticLibrary; + break; + case Application: + default: + vcProject.Configuration.ConfigurationType = typeApplication; + break; + } + vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" ); + vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); + vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); + vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() ); + temp = project->first("CharacterSet"); + vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() ); + vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); + vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; + vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); +// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR"); + vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp ); + vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput"); + vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization; + temp = project->first("UseOfATL"); + if ( !temp.isEmpty() ) + vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() ); + temp = project->first("UseOfMfc"); + if ( !temp.isEmpty() ) + vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() ); + + // Configuration does not need parameters from + // these sub XML items; + initCustomBuildTool(); + initPreBuildEventTools(); + initPostBuildEventTools(); + initPreLinkEventTools(); +} + +void VcprojGenerator::initCompilerTool() +{ + QString placement = project->first("OBJECTS_DIR"); + if ( placement.isEmpty() ) + placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\"; + + vcProject.Configuration.compiler.AssemblerListingLocation = placement ; + vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; + vcProject.Configuration.compiler.ObjectFile = placement ; + vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch"; + + if ( project->isActiveConfig("debug") ){ + // Debug version + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); + if ( project->isActiveConfig("thread") ) { + if ( (projectTarget == Application) || (projectTarget == StaticLib) ) + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); + else + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); + } else { + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] ); + } + } else { + // Release version + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); + vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + if ( project->isActiveConfig("thread") ) { + if ( (projectTarget == Application) || (projectTarget == StaticLib) ) + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); + else + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); + } else { + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] ); + } + } + + // Common for both release and debug + if ( project->isActiveConfig("warn_off") ) + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); + else + vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); + if ( project->isActiveConfig("windows") ) + vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; + + // Can this be set for ALL configs? + // If so, use qmake.conf! + if ( projectTarget == SharedLib ) + vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS"; + + vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; + vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; + vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); +} + +void VcprojGenerator::initLibrarianTool() +{ + vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" ); + if( vcProject.Configuration.librarian.OutputFile.isEmpty() ) + vcProject.Configuration.librarian.OutputFile = ".\\"; + + if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") ) + vcProject.Configuration.librarian.OutputFile += '\\'; + + vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); +} + +void VcprojGenerator::initLinkerTool() +{ + vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); + vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; + + switch ( projectTarget ) { + case Application: + vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); + break; + case SharedLib: + vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); + vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); + break; + } + + if( vcProject.Configuration.linker.OutputFile.isEmpty() ) + vcProject.Configuration.linker.OutputFile = ".\\"; + + if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") ) + vcProject.Configuration.linker.OutputFile += '\\'; + + vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET"); + vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb"; + + if ( project->isActiveConfig("debug") ){ + vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); + } else { + vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); + } + + if ( project->isActiveConfig("dll") ){ + vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); + } + + if ( project->isActiveConfig("console") ){ + vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); + } else { + vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); + } + +} + +void VcprojGenerator::initIDLTool() +{ +} + +void VcprojGenerator::initCustomBuildTool() +{ +} + +void VcprojGenerator::initPreBuildEventTools() +{ + QString collectionName = project->first("QMAKE_IMAGE_COLLECTION"); + if( !collectionName.isEmpty() ) { + QStringList& list = project->variables()["IMAGES"]; + vcProject.Configuration.preBuild.Description = "Generate imagecollection"; + //vcProject.Configuration.preBuild.AdditionalDependencies += list; + vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName; + //vcProject.Configuration.preBuild.Outputs = collectionName; + + } +} + +void VcprojGenerator::initPostBuildEventTools() +{ + if( project->isActiveConfig( "activeqt" ) ) { + QString name = project->first( "QMAKE_ORIG_TARGET" ); + QString nameext = project->first( "TARGET" ); + QString objdir = project->first( "OBJECTS_DIR" ); + QString idc = project->first( "QMAKE_IDC" ); + + vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; + + if( project->isActiveConfig( "dll" ) ) { // In process + vcProject.Configuration.postBuild.CommandLine = + // call idc to generate .idl file from .dll + idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 && " + + // call midl to create implementations of the .idl file + project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + + "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + + objdir + "dump.midl && " + + // call idc to replace tlb... + idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + + // register server + idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver"; + } else { // out of process + vcProject.Configuration.postBuild.CommandLine = + // call application to dump idl + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 && " + + // call midl to create implementations of the .idl file + project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + + "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + + objdir + "dump.midl && " + + // call idc to replace tlb... + idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + + // call app to register + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; + } + } +} + +void VcprojGenerator::initPreLinkEventTools() +{ +} + +void VcprojGenerator::initSourceFiles() +{ + vcProject.SourceFiles.Name = "Source Files"; + vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"; + vcProject.SourceFiles.Files += project->variables()["SOURCES"]; + vcProject.SourceFiles.Files.sort(); + vcProject.SourceFiles.Project = this; + vcProject.SourceFiles.Config = &(vcProject.Configuration); + vcProject.SourceFiles.CustomBuild = none; +} + +void VcprojGenerator::initHeaderFiles() +{ + vcProject.HeaderFiles.Name = "Header Files"; + vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl"; + vcProject.HeaderFiles.Files += project->variables()["HEADERS"]; + vcProject.HeaderFiles.Files.sort(); + vcProject.HeaderFiles.Project = this; + vcProject.HeaderFiles.Config = &(vcProject.Configuration); + vcProject.HeaderFiles.CustomBuild = moc; +} + +void VcprojGenerator::initMOCFiles() +{ + vcProject.MOCFiles.Name = "Generated MOC Files"; + vcProject.MOCFiles.Filter = "cpp;c;cxx;moc"; + vcProject.MOCFiles.Files += project->variables()["SRCMOC"]; + vcProject.MOCFiles.Files.sort(); + vcProject.MOCFiles.Project = this; + vcProject.MOCFiles.Config = &(vcProject.Configuration); + vcProject.MOCFiles.CustomBuild = moc; +} + +void VcprojGenerator::initUICFiles() +{ + vcProject.UICFiles.Name = "Generated UI Files"; + vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;"; + vcProject.UICFiles.Project = this; + vcProject.UICFiles.Files += project->variables()["UICDECLS"]; + vcProject.UICFiles.Files += project->variables()["UICIMPLS"]; + vcProject.UICFiles.Files.sort(); + vcProject.UICFiles.Config = &(vcProject.Configuration); + vcProject.UICFiles.CustomBuild = none; +} + +void VcprojGenerator::initFormsFiles() +{ + vcProject.FormFiles.Name = "Forms"; + vcProject.FormFiles.ParseFiles = _False; + vcProject.FormFiles.Filter = "ui"; + vcProject.FormFiles.Files += project->variables()["FORMS"]; + vcProject.FormFiles.Files.sort(); + vcProject.FormFiles.Project = this; + vcProject.FormFiles.Config = &(vcProject.Configuration); + vcProject.FormFiles.CustomBuild = uic; +} + +void VcprojGenerator::initTranslationFiles() +{ + vcProject.TranslationFiles.Name = "Translations Files"; + vcProject.TranslationFiles.ParseFiles = _False; + vcProject.TranslationFiles.Filter = "ts"; + vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"]; + vcProject.TranslationFiles.Files.sort(); + vcProject.TranslationFiles.Project = this; + vcProject.TranslationFiles.Config = &(vcProject.Configuration); + vcProject.TranslationFiles.CustomBuild = none; +} + +void VcprojGenerator::initLexYaccFiles() +{ + vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; + vcProject.LexYaccFiles.ParseFiles = _False; + vcProject.LexYaccFiles.Filter = "l;y"; + vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"]; + vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"]; + vcProject.LexYaccFiles.Files.sort(); + vcProject.LexYaccFiles.Project = this; + vcProject.LexYaccFiles.CustomBuild = lexyacc; +} + +void VcprojGenerator::initResourceFiles() +{ + vcProject.ResourceFiles.Name = "Resources"; + vcProject.ResourceFiles.ParseFiles = _False; + vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; + vcProject.ResourceFiles.Files += project->variables()["RC_FILE"]; + vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"]; + vcProject.ResourceFiles.Files += project->variables()["IMAGES"]; + vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"]; + vcProject.ResourceFiles.Files.sort(); + vcProject.ResourceFiles.Project = this; + vcProject.ResourceFiles.CustomBuild = none; +} + +/* +// $$MSVCPROJ_IDLSOURCES --------------------------------------------- +void VcprojGenerator::writeIDLs( QTextStream &t ) +{ + QStringList &l = project->variables()["MSVCPROJ_IDLSOURCES"]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + t << "# Begin Source File" << endl << endl; + t << "SOURCE=" << (*it) << endl; + t << "# PROP Exclude_From_Build 1" << endl; + t << "# End Source File" << endl << endl; + } + debug_msg(3, "Generator: MSVC.NET: Added IDLs" ); +} +*/ + +/* \internal + Sets up all needed variables from the environment and all the different caches and .conf files +*/ + +void VcprojGenerator::initOld() +{ + if( init_flag ) + return; + + init_flag = TRUE; + QStringList::Iterator it; + + // this should probably not be here, but I'm using it to wrap the .t files + if(project->first("TEMPLATE") == "vcapp" ) + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "vclib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + if ( project->variables()["QMAKESPEC"].isEmpty() ) + project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); + + bool is_qt = + ( project->first("TARGET") == "qt"QTDLL_POSTFIX || + project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); + + QStringList &configs = project->variables()["CONFIG"]; + + if ( project->isActiveConfig( "shared" ) ) + project->variables()["DEFINES"].append( "QT_DLL" ); + + if ( project->isActiveConfig( "qt_dll" ) && + configs.findIndex("qt") == -1 ) + configs.append("qt"); + + if ( project->isActiveConfig( "qt" ) ) { + if ( project->isActiveConfig( "plugin" ) ) { + project->variables()["CONFIG"].append( "dll" ); + 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 we are a dll, then we cannot be a staticlib at the same time... + 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 we need 'qt' and/or 'opengl', then we need windows and not console + if ( project->isActiveConfig( "qt" ) || project->isActiveConfig( "opengl" ) ) { + project->variables()["CONFIG"].append( "windows" ); + } + + // Decode version, and add it to $$MSVCPROJ_VERSION -------------- + if ( !project->variables()["VERSION"].isEmpty() ) { + QString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + QString major = version.left( firstDot ); + QString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( QRegExp( "\\." ), "" ); + project->variables()["MSVCPROJ_VERSION"].append( "/VERSION:" + major + "." + minor ); + } + + // QT ------------------------------------------------------------ + 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 ( 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"].append("/BASE:0x39D00000"); + } + } else { + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + 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; + ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + QStringList &libs = project->variables()["QMAKE_LIBS"]; + for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE")); + } + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + + // Set target directories ---------------------------------------- + // if ( !project->first("OBJECTS_DIR").isEmpty() ) + //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->first("OBJECTS_DIR"); + // else + //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->isActiveConfig( "release" )?"Release":"Debug"; + // if ( !project->first("DESTDIR").isEmpty() ) + //project->variables()["MSVCPROJ_TARGETDIR"] = project->first("DESTDIR"); + // else + //project->variables()["MSVCPROJ_TARGETDIR"] = project->isActiveConfig( "release" )?"Release":"Debug"; + + // OPENGL -------------------------------------------------------- + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + + // THREAD -------------------------------------------------------- + if ( project->isActiveConfig("thread") ) { + if(project->isActiveConfig("qt")) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); + if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt + && project->first("TARGET") != "qtmain" ) + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:libc"); + } + + // ACCESSIBILITY ------------------------------------------------- + if(project->isActiveConfig("qt")) { + 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"); + } + + // DLL ----------------------------------------------------------- + if ( project->isActiveConfig("dll") ) { + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + QString ver_xyz(project->first("VERSION")); + ver_xyz.replace(QRegExp("\\."), ""); + project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } + // EXE / LIB ----------------------------------------------------- + else { + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) + project->variables()["TARGET_EXT"].append(".exe"); + else + project->variables()["TARGET_EXT"].append(".lib"); + } + + project->variables()["MSVCPROJ_VER"] = "7.00"; + project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI"; + + // INCREMENTAL:NO ------------------------------------------------ + if(!project->isActiveConfig("incremental")) { + project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); + if ( is_qt ) + project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi"; + } + + // MOC ----------------------------------------------------------- + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + + + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + + // Run through all variables containing filepaths, and ----------- + // slash-slosh them correctly depending on current OS ----------- + project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + QStringList &l = project->variables()["QMAKE_FILETAGS"]; + 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); + } + + // Get filename w/o extention ----------------------------------- + QString msvcproj_project = ""; + QString targetfilename = ""; + if ( project->variables()["TARGET"].count() ) { + msvcproj_project = project->variables()["TARGET"].first(); + targetfilename = msvcproj_project; + } + + // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------ + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + // TARGET (add extention to $$TARGET) ---------------------------- + project->variables()["TARGET"].first() += project->first("TARGET_EXT"); + + // Init base class too ------------------------------------------- + MakefileGenerator::init(); + + + if ( msvcproj_project.isEmpty() ) + msvcproj_project = Option::output.name(); + + msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 ); + msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) ); + msvcproj_project.replace(QRegExp("-"), ""); + + project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project); + QStringList &proj = project->variables()["MSVCPROJ_PROJECT"]; + + for(it = proj.begin(); it != proj.end(); ++it) + (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); + + // SUBSYSTEM ----------------------------------------------------- + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) ); + if ( project->isActiveConfig("console") ) { + project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE"); + project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE"); + project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103"); + project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE"); + } else { + project->variables()["MSVCPROJ_CONSOLE"].clear(); + project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS"); + project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101"); + project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS"); + } + } else { + if ( project->isActiveConfig("dll") ) { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) ); + } else { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) ); + } + } + + // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- + project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"]; + project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:","")); + project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; + // We don't use this... Direct manipulation of compiler object + //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); + //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); + QStringList &incs = project->variables()["INCLUDEPATH"]; + for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + QString inc = (*incit); + inc.replace(QRegExp("\""), ""); + project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc ); + } + project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir()); + + QString dest; + project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET"); + if ( !project->variables()["DESTDIR"].isEmpty() ) { + project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); + Option::fixPathToTargetOS(project->first("TARGET")); + dest = project->first("TARGET"); + if ( project->first("TARGET").startsWith("$(QTDIR)") ) + dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); + project->variables()["MSVCPROJ_TARGET"].append( + QString("/OUT:") + dest ); + if ( project->isActiveConfig("dll") ) { + QString imp = dest; + imp.replace(QRegExp("\\.dll"), ".lib"); + project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp ); + } + } + + // DLL COPY ------------------------------------------------------ + if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { + QStringList dlldirs = project->variables()["DLLDESTDIR"]; + QString copydll = "# Begin Special Build Tool\n" + "TargetPath=" + dest + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" + "PostBuild_Cmds="; + + for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; + } + + copydll += "\n# End Special Build Tool"; + project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll ); + project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll ); + } + + // ACTIVEQT ------------------------------------------------------ + if ( project->isActiveConfig("activeqt") ) { + QString idl = project->variables()["QMAKE_IDL"].first(); + QString idc = project->variables()["QMAKE_IDC"].first(); + QString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); + project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); + project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); + if ( project->isActiveConfig( "dll" ) ) { + QString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveQt server...\n" + "PostBuild_Cmds=" + + idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + + "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" + "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + "\tregsvr32 /s %1\n" + "# End Special Build Tool"; + + QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } else { + QString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveQt server...\n" + "PostBuild_Cmds=" + "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + + "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" + "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + "\t%1 -regserver\n" + "# End Special Build Tool"; + + QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } + + } + + // FORMS --------------------------------------------------------- + QStringList &list = project->variables()["FORMS"]; + for( it = list.begin(); it != list.end(); ++it ) { + if ( QFile::exists( *it + ".h" ) ) + project->variables()["SOURCES"].append( *it + ".h" ); + } + + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS"; + + // Verbose output if "-d -d"... + outputVariables(); +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ + +bool VcprojGenerator::openOutput(QFile &file) const +{ + QString outdir; + if(!file.name().isEmpty()) { + QFileInfo fi(file); + if(fi.isDir()) + outdir = file.name() + QDir::separator(); + } + if(!outdir.isEmpty() || file.name().isEmpty()) { + QString ext = project->first("VCPROJ_EXTENSION"); + if(project->first("TEMPLATE") == "vcsubdirs") + ext = project->first("VCSOLUTION_EXTENSION"); + file.setName(outdir + project->first("TARGET") + ext); + } + if(QDir::isRelativePath(file.name())) { + QString ofile; + ofile = file.name(); + int slashfind = ofile.findRev('\\'); + if (slashfind == -1) { + ofile = ofile.replace("-", "_"); + } else { + int hypenfind = ofile.find('-', slashfind); + while (hypenfind != -1 && slashfind < hypenfind) { + ofile = ofile.replace(hypenfind, 1, "_"); + hypenfind = ofile.find('-', hypenfind + 1); + } + } + file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile)); + } + return Win32MakefileGenerator::openOutput(file); +} + +QString VcprojGenerator::findTemplate(QString file) +{ + QString ret; + if(!QFile::exists((ret = file)) && + !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && + !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) && + !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) + return ""; + debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() ); + return ret; +} + + +void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l) +{ + if(var == "QMAKE_PRL_DEFINES") { + QStringList &out = project->variables()["MSVCPROJ_DEFINES"]; + for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + if(out.findIndex((*it)) == -1) + out.append((" /D " + *it )); + } + } else { + MakefileGenerator::processPrlVariable(var, l); + } +} + +void VcprojGenerator::outputVariables() +{ +#if 0 + debug_msg(3, "Generator: MSVC.NET: List of current variables:" ); + for ( QMap::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) { + debug_msg(3, "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() ); + } +#endif +} diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h new file mode 100644 index 0000000..583b164 --- a/dev/null +++ b/qmake/generators/win32/msvc_vcproj.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** $Id$ +** +** Definition of VcprojGenerator class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __VCPROJMAKE_H__ +#define __VCPROJMAKE_H__ + +#include "winmakefile.h" +#include "msvc_objectmodel.h" + +enum target { + Application, + SharedLib, + StaticLib +}; + +class VcprojGenerator : public Win32MakefileGenerator +{ + bool init_flag; + bool writeVcprojParts(QTextStream &); + + bool writeMakefile(QTextStream &); + virtual void writeSubDirs(QTextStream &t); + QString findTemplate(QString file); + void init(); + +public: + VcprojGenerator(QMakeProject *p); + ~VcprojGenerator(); + + QString defaultMakefile() const; + virtual bool doDepends() const { return FALSE; } //never necesary + +protected: + virtual bool openOutput(QFile &file) const; + virtual void processPrlVariable(const QString &, const QStringList &); + virtual bool findLibraries(); + virtual void outputVariables(); + + void initOld(); + void initProject(); + void initConfiguration(); + void initCompilerTool(); + void initLinkerTool(); + void initLibrarianTool(); + void initIDLTool(); + void initCustomBuildTool(); + void initPreBuildEventTools(); + void initPostBuildEventTools(); + void initPreLinkEventTools(); + void initSourceFiles(); + void initHeaderFiles(); + void initMOCFiles(); + void initUICFiles(); + void initFormsFiles(); + void initTranslationFiles(); + void initLexYaccFiles(); + void initResourceFiles(); + + /* + void writeGuid( QTextStream &t ); + void writeAdditionalOptions( QTextStream &t ); + void writeHeaders( QTextStream &t ); + void writeSources( QTextStream &t ); + void writeMocs( QTextStream &t ); + void writeLexs( QTextStream &t ); + void writeYaccs( QTextStream &t ); + void writePictures( QTextStream &t ); + void writeImages( QTextStream &t ); + void writeIDLs( QTextStream &t ); + + void writeForms( QTextStream &t ); + void writeFormsSourceHeaders( QString &variable, QTextStream &t ); + void writeTranslations( QTextStream &t ); + void writeStrippedTranslations( QTextStream &t ); + */ + + VCProject vcProject; + target projectTarget; + + friend class VCFilter; +}; + +inline VcprojGenerator::~VcprojGenerator() +{ } + +inline QString VcprojGenerator::defaultMakefile() const +{ + return project->first("TARGET") + project->first("VCPROJ_EXTENSION"); +} + +inline bool VcprojGenerator::findLibraries() +{ + return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS"); +} + +#endif /* __VCPROJMAKE_H__ */ diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp new file mode 100644 index 0000000..a07c921 --- a/dev/null +++ b/qmake/generators/win32/winmakefile.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 "winmakefile.h" +#include "option.h" +#include "project.h" +#include +#include +#include +#include +#include +#include + + +Win32MakefileGenerator::Win32MakefileGenerator(QMakeProject *p) : MakefileGenerator(p) +{ + +} + + +struct SubDir +{ + QString directory, profile, target, makefile; +}; + +void +Win32MakefileGenerator::writeSubDirs(QTextStream &t) +{ + QPtrList subdirs; + { + QStringList subdirs_in = project->variables()["SUBDIRS"]; + for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { + QString file = (*it); + file = fileFixify(file); + SubDir *sd = new SubDir; + subdirs.append(sd); + sd->makefile = "$(MAKEFILE)"; + if((*it).right(4) == ".pro") { + int slsh = file.findRev(Option::dir_sep); + if(slsh != -1) { + sd->directory = file.left(slsh+1); + sd->profile = file.mid(slsh+1); + } else { + sd->profile = file; + } + } else { + sd->directory = file; + } + while(sd->directory.right(1) == Option::dir_sep) + sd->directory = sd->directory.left(sd->directory.length() - 1); + if(!sd->profile.isEmpty()) { + QString basename = sd->directory; + int new_slsh = basename.findRev(Option::dir_sep); + if(new_slsh != -1) + basename = basename.mid(new_slsh+1); + if(sd->profile != basename + ".pro") + sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro + } + sd->target = "sub-" + (*it); + sd->target.replace('/', '-'); + sd->target.replace('.', '_'); + } + } + QPtrListIterator it(subdirs); + + if(!project->isEmpty("MAKEFILE")) + t << "MAKEFILE= " << var("MAKEFILE") << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "SUBTARGETS = "; + for( it.toFirst(); it.current(); ++it) + t << " \\\n\t\t" << it.current()->target; + t << endl << endl; + t << "all: qmake_all $(SUBTARGETS)" << endl << endl; + + for( it.toFirst(); it.current(); ++it) { + bool have_dir = !(*it)->directory.isEmpty(); + + //make the makefile + QString mkfile = (*it)->makefile; + if(have_dir) + mkfile.prepend((*it)->directory + Option::dir_sep); + t << mkfile << ":"; + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << " FORCE"; + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); + if((*it)->makefile != "$(MAKEFILE)") + t << " -o " << (*it)->makefile; + if(have_dir) { + int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + t << endl; + + //now actually build + t << (*it)->target << ": " << mkfile; + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << " FORCE"; + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + t << "\n\t" << "$(MAKE)"; + if((*it)->makefile != "$(MAKEFILE)") + t << " -f " << (*it)->makefile; + if(have_dir) { + int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + t << endl << endl; + } + + if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) + project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); + writeMakeQmake(t); + + t << "qmake_all:"; + if ( !subdirs.isEmpty() ) { + for( it.toFirst(); it.current(); ++it) { + QString subdir = (*it)->directory; + int subLevels = subdir.contains(Option::dir_sep) + 1; + t << "\n\t" + << "cd " << subdir << "\n\t"; + int lastSlash = subdir.findRev(Option::dir_sep); + if(lastSlash != -1) + subdir = subdir.mid( lastSlash + 1 ); + t << "$(QMAKE) " << subdir << ".pro" + << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString("")) + << " " << buildArgs() << "\n\t" + << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + } else { + // Borland make does not like empty an empty command section, so insert + // a dummy command. + t << "\n\t" << "@cd ."; + } + t << endl << endl; + + QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null }; + for(int x = 0; targs[x] != QString::null; x++) { + t << targs[x] << ": qmake_all"; + if(targs[x] == "clean") + t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", ""); + if (!subdirs.isEmpty()) { + for( it.toFirst(); it.current(); ++it) { + int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; + bool have_dir = !(*it)->directory.isEmpty(); + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + QString in_file; + if((*it)->makefile != "$(MAKEFILE)") + in_file = " -f " + (*it)->makefile; + t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; + if(have_dir) { + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + } + } else { + // Borland make does not like empty an empty command section, so + // insert a dummy command. + t << "\n\t" << "@cd ."; + } + t << endl << endl; + } + + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << "FORCE:" << endl << endl; +} + + +int +Win32MakefileGenerator::findHighestVersion(const QString &d, const + QString &stem) +{ + if(!QFile::exists(Option::fixPathToLocalOS(d))) + return -1; + if(!project->variables()["QMAKE_" + stem.upper() + + "_VERSION_OVERRIDE"].isEmpty()) + return project->variables()["QMAKE_" + stem.upper() + + "_VERSION_OVERRIDE"].first().toInt(); + QString bd = d; + fixEnvVariables(bd); + QDir dir(bd); + int biggest=-1; + QStringList entries = dir.entryList(); + QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE ); + for(QStringList::Iterator it = entries.begin(); it != entries.end(); + ++it) { + if(regx.exactMatch((*it))) + biggest = QMAX(biggest, (regx.cap(1) == stem || + regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); + } + return biggest; +} + + +bool +Win32MakefileGenerator::findLibraries(const QString &where) +{ + + QStringList &l = project->variables()[where]; + QPtrList dirs; + dirs.setAutoDelete(TRUE); + for(QStringList::Iterator it = l.begin(); it != l.end(); ) { + QString opt = (*it); + bool remove = FALSE; + if(opt.startsWith("-L") || opt.startsWith("/L")) { + QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r); + dirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + remove = TRUE; + } else if(opt.startsWith("-l") || opt.startsWith("/l")) { + QString lib = opt.right(opt.length() - 2), out; + if(!lib.isEmpty()) { + for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { + int ver = findHighestVersion(mdd->local_dir, lib); + if(ver > 0) + lib += QString::number(ver); + lib += ".lib"; + if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) { + out = mdd->real_dir + Option::dir_sep + lib; + break; + } + } + } + if(out.isEmpty()) + remove = TRUE; + else + (*it) = out; + } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { + QString dir, file = opt; + int slsh = file.findRev(Option::dir_sep); + if(slsh != -1) { + dir = file.left(slsh+1); + file = file.right(file.length() - slsh - 1); + } + if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) { + if(file.endsWith(".lib")) { + file = file.left(file.length() - 4); + if(!file.at(file.length()-1).isNumber()) { + int ver = findHighestVersion(dir, file); + if(ver != -1) { + file = QString(dir + file + "%1" + ".lib"); + if(ver) + (*it) = file.arg(ver); + else + (*it) = file.arg(""); + } + } + } + } + } + if(remove) + it = l.remove(it); + else + ++it; + } + return TRUE; +} + +void +Win32MakefileGenerator::processPrlFiles() +{ + QDict processed; + QPtrList libdirs; + libdirs.setAutoDelete(TRUE); + { + QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; + for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { + QString r = (*libpathit), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } + } + for(bool ret = FALSE; TRUE; ret = FALSE) { + //read in any prl files included.. + QStringList l_out; + QString where = "QMAKE_LIBS"; + if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) + where = project->first("QMAKE_INTERNAL_PRL_LIBS"); + QStringList &l = project->variables()[where]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + QString opt = (*it); + if(opt.left(1) == "/") { + if(opt.left(9) == "/LIBPATH:") { + QString r = opt.mid(9), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } + } else { + if(!processed[opt]) { + if(processPrlFile(opt)) { + processed.insert(opt, (void*)1); + ret = TRUE; + } else { + for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { + QString prl = mdd->local_dir + Option::dir_sep + opt; + if(processed[prl]) { + break; + } else if(processPrlFile(prl)) { + processed.insert(prl, (void*)1); + ret = TRUE; + break; + } + } + } + } + } + if(!opt.isEmpty()) + l_out.append(opt); + } + if(ret) + l = l_out; + else + break; + } +} diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h new file mode 100644 index 0000000..75ba0e0 --- a/dev/null +++ b/qmake/generators/win32/winmakefile.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** $Id$ +** +** Definition of ________ class. +** +** Created : 970521 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the network module of the Qt GUI Toolkit. +** +** 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 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 __WINMAKEFILE_H__ +#define __WINMAKEFILE_H__ + +#include "makefile.h" + +// In the Qt evaluation and educational version, we have a postfix in the +// library name (e.g. qtmteval301.dll). QTDLL_POSTFIX is used for this. +// A script modifies these lines when building eval/edu version, so be careful +// when changing them. +#ifndef QTDLL_POSTFIX +#define QTDLL_POSTFIX "" +#endif + +class Win32MakefileGenerator : public MakefileGenerator +{ +protected: + virtual void writeSubDirs(QTextStream &t); + int findHighestVersion(const QString &dir, const QString &stem); + bool findLibraries(const QString &); + virtual bool findLibraries(); + virtual void processPrlFiles(); + +public: + Win32MakefileGenerator(QMakeProject *p); + ~Win32MakefileGenerator(); +}; + +inline Win32MakefileGenerator::~Win32MakefileGenerator() +{ } + +inline bool Win32MakefileGenerator::findLibraries() +{ return findLibraries("QMAKE_LIBS"); } + + + +#endif /* __WINMAKEFILE_H__ */ -- cgit v0.9.0.2