Ignore:
Timestamp:
Jun 16, 2009, 1:59:37 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: os2/GNUMAKE: Common qmake fixes (proper include directory processing; new QMAKE_CFLAGS_INCDIR, QMAKE_LFLAGS_LIBDIR and QMAKE_LFLAGS_LIB options; replaced .a with .lib in makefile generation).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qmake/generators/os2/gnumake.cpp

    r29 r31  
    8080QString GNUMakefileGenerator::getLibTarget()
    8181{
    82     return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");
     82    return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".lib");
    8383}
    8484
     
    104104            for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
    105105                QString extension;
    106                 int ver = findHighestVersion((*dir_it).local(), steam, "dll.a|a");
     106                int ver = findHighestVersion((*dir_it).local(), steam, "dll.lib|lib");
    107107                if (ver != -1)
    108108                    extension += QString::number(ver);
    109109                extension += suffix;
    110110                if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
    111                     exists((*dir_it).local() + Option::dir_sep + steam + extension + ".a") ||
    112                     exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.a")) {
     111                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".lib") ||
     112                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.lib")) {
    113113                        out = (*it) + extension;
    114114                        break;
     
    162162 }
    163163
    164 /* @todo remove
    165 void createLdObjectScriptFile(const QString &fileName, const QStringList &objList)
    166 {
    167     QString filePath = Option::output_dir + QDir::separator() + fileName;
    168     QFile file(filePath);
    169     if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
    170         QTextStream t(&file);
    171         t << "INPUT(" << endl;
    172         for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
    173             if (QDir::isRelativePath(*it))
    174                 t << "./" << *it << endl;
    175             else
    176                 t << *it << endl;
    177         }
    178         t << ");" << endl;
    179         t.flush();
    180         file.close();
    181     }
    182 }
    183 
    184 void createArObjectScriptFile(const QString &fileName, const QString &target, const QStringList &objList)
    185 {
    186     QString filePath = Option::output_dir + QDir::separator() + fileName;
    187     QFile file(filePath);
    188     if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
    189         QTextStream t(&file);
    190         t << "CREATE " << target << endl;
    191         for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
    192             if (QDir::isRelativePath(*it))
    193                 t << "ADDMOD " << *it << endl;
    194             else
    195                 t << *it << endl;
    196         }
    197         t << "SAVE" << endl;
    198         t.flush();
    199         file.close();
    200     }
    201 }
    202 */
    203 
    204164void GNUMakefileGenerator::writeGNUParts(QTextStream &t)
    205165{
     166    t << "QMAKESPECDIR  = " << quote << specdir() << quote << endl << endl;
     167
    206168    writeStandardParts(t);
    207169
    208170    if (!preCompHeaderOut.isEmpty()) {
    209         QString header = project->first("PRECOMPILED_HEADER");
    210         QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
    211         t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
    212           << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
    213           << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
    214           << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
    215           << endl << endl;
    216         QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
    217         t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
    218           << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
    219           << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
    220           << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
    221           << endl << endl;
     171        QString header = project->first("PRECOMPILED_HEADER");
     172        QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
     173        t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
     174            << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
     175            << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
     176            << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
     177            << endl << endl;
     178        QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
     179        t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
     180            << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
     181            << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
     182            << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
     183            << endl << endl;
    222184    }
    223185}
     
    275237        if(!project->first("DESTDIR").isEmpty())
    276238            destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
    277         project->values("MINGW_IMPORT_LIB").prepend(destDir + "lib" + project->first("TARGET")
    278                                                          + project->first("TARGET_VERSION_EXT") + ".a");
    279         project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB"));
    280239    }
    281240
     
    307266                                                         " $(CXXFLAGS) $(INCPATH) -o $@ $<");
    308267    }
    309 
    310     if(project->isActiveConfig("dll")) {
    311         project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB"));
    312     }
    313268}
    314269
     
    316271{
    317272    if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    318         project->values("TARGET_EXT").append(".a");
     273        project->values("TARGET_EXT").append(".lib");
    319274        project->values("QMAKE_LFLAGS").append("-static");
    320275        project->values("TARGET").first() =  "lib" + project->first("TARGET");
     
    326281void GNUMakefileGenerator::writeIncPart(QTextStream &t)
    327282{
    328     t << "INCPATH       = ";
    329 
     283    t << "INCPATH       =";
     284
     285    QString opt = var("QMAKE_CFLAGS_INCDIR");
    330286    QStringList &incs = project->values("INCLUDEPATH");
     287    QString incsSemicolon;
    331288    for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
    332         QString inc = (*incit);
    333         inc.replace(QRegExp("\\\\$"), "");
    334         inc.replace(QRegExp("\""), "");
    335         t << "-I" << quote << inc << quote << " ";
    336     }
    337     t << "-I" << quote << specdir() << quote
    338       << endl;
     289        QString inc = maybeQuotePath(*incit);
     290        t << " " << opt << inc;
     291        incsSemicolon += inc + Option::dirlist_sep;
     292    }
     293    t << " " << opt << "$(QMAKESPECDIR)" << endl;
     294    incsSemicolon += "$(QMAKESPECDIR)";
     295    t << "INCLUDEPATH   = " << incsSemicolon << endl;
    339296}
    340297
     
    342299{
    343300    if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    344         t << "LIB        =        " << var("QMAKE_LIB") << endl;
     301        t << "LIB           = " << var("QMAKE_LIB") << endl;
    345302    } else {
    346         t << "LINK        =        " << var("QMAKE_LINK") << endl;
    347         t << "LFLAGS        =        " << var("QMAKE_LFLAGS") << endl;
    348         t << "LIBS        =        ";
     303        t << "LINK          = " << var("QMAKE_LINK") << endl;
     304        t << "LFLAGS        = " << var("QMAKE_LFLAGS") << endl;
     305        t << "LIBS          =";
    349306        if(!project->values("QMAKE_LIBDIR").isEmpty())
    350307            writeLibDirPart(t);
    351         t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
     308        QString opt = var("QMAKE_LFLAGS_LIB");
     309        QStringList libs = project->values("QMAKE_LIBS");
     310        for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) {
     311            QString lib = maybeQuotePath(*it);
     312            t << " " << opt << lib;
     313        }
     314        t << endl;
    352315    }
    353316}
     
    355318void GNUMakefileGenerator::writeLibDirPart(QTextStream &t)
    356319{
     320    QString opt = var("QMAKE_LFLAGS_LIBDIR");
    357321    QStringList libDirs = project->values("QMAKE_LIBDIR");
    358     for (int i = 0; i < libDirs.size(); ++i)
    359         libDirs[i].remove("\"");
    360     t << valGlue(libDirs,"-L"+quote,quote+" -L" +quote,quote) << " ";
     322    for(QStringList::Iterator it = libDirs.begin(); it != libDirs.end(); ++it) {
     323        QString libDir = maybeQuotePath(*it);
     324        t << " " << opt << libDir;
     325    }
    361326}
    362327
    363328void GNUMakefileGenerator::writeObjectsPart(QTextStream &t)
    364329{
    365     if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
    366         objectsLinkLine = "$(OBJECTS)";
    367     } else if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    368         QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
    369         if (!var("BUILD_NAME").isEmpty()) {
    370             ar_script_file += "." + var("BUILD_NAME");
    371         }
    372 /* @todo remove
    373         createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
    374 */
    375         objectsLinkLine = "ar -M < " + ar_script_file;
    376     } else {
    377         QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
    378         if (!var("BUILD_NAME").isEmpty()) {
    379             ld_script_file += "." + var("BUILD_NAME");
    380         }
    381 /* @todo remove
    382         createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
    383 */
    384         objectsLinkLine = ld_script_file;
    385     }
     330    /* @todo generate response files for the linker to overcome the 1024 chars
     331     * CMD.EXE limitation */
    386332    Win32MakefileGenerator::writeObjectsPart(t);
    387333}
     
    395341        t << "\n\t" <<var("QMAKE_PRE_LINK");
    396342    if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    397         if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
    398             t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
    399         } else {
    400             t << "\n\t" << objectsLinkLine << " " ;
    401         }
     343        t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) $(OBJECTS)";
    402344    } else {
    403         t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) " << objectsLinkLine << " " << " $(LIBS)";
     345        t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)";
    404346    }
    405347    if(!project->isEmpty("QMAKE_POST_LINK"))
     
    466408}
    467409
     410QString GNUMakefileGenerator::maybeQuotePath(const QString &path)
     411{
     412    QString quoted = path;
     413    quoted.replace(QRegExp("\\\\$"), "");
     414    quoted.replace(QRegExp("\""), "");
     415    if (quoted.contains(QRegExp("[ +&;$%()]")))
     416        quoted = quote + quoted + quote;
     417    return quoted;
     418}
     419
    468420QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.