Diffstat (limited to 'qmake/generators/makefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/makefile.cpp | 476 |
1 files changed, 327 insertions, 149 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index f490313..c12375d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -7,3 +7,3 @@ ** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. ** @@ -61,4 +61,18 @@ +static QString mkdir_p_asstring(const QString &dir) +{ + QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; + if(Option::target_mode == Option::TARG_WIN_MODE) + ret += "$(MKDIR)"; + else + ret += "|| $(MKDIR)"; + ret += " \"" + dir + "\""; + return ret; +} + static bool createDir(const QString& fullPath) { + if(QFile::exists(fullPath)) + return FALSE; + QDir dirTmp; @@ -79,4 +93,4 @@ static bool createDir(const QString& fullPath) -MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), - init_already(FALSE), moc_aware(FALSE), +MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), + init_already(FALSE), moc_aware(FALSE), no_io(FALSE), project(p) @@ -90,3 +104,3 @@ static char *gimme_buffer(off_t s) if(!big_buffer || big_buffer_size < s) - big_buffer = (char *)realloc(big_buffer, s); + big_buffer = (char *)realloc(big_buffer, s); return big_buffer; @@ -95,3 +109,3 @@ static char *gimme_buffer(off_t s) bool -MakefileGenerator::generateMocList(QString fn_target) +MakefileGenerator::generateMocList(const QString &fn_target) { @@ -175,3 +189,4 @@ MakefileGenerator::generateMocList(QString fn_target) *(big_buffer+x+len) = '\0'; - debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), line_count, big_buffer+x); + debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), + line_count, big_buffer+x); @@ -187,3 +202,4 @@ MakefileGenerator::generateMocList(QString fn_target) bool cpp_ext = FALSE; - for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { + for(QStringList::Iterator cppit = Option::cpp_ext.begin(); + cppit != Option::cpp_ext.end(); ++cppit) { if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) @@ -193,6 +209,6 @@ MakefileGenerator::generateMocList(QString fn_target) mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; - findDependencies(fn_target).append(mocFile); project->variables()["_SRCMOC"].append(mocFile); } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { - for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { + for(QStringList::Iterator hit = Option::h_ext.begin(); + hit != Option::h_ext.end(); ++hit) { if((fn_target.right(ext_len) == (*hit))) { @@ -227,9 +243,8 @@ MakefileGenerator::generateMocList(QString fn_target) bool -MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QString fn, bool recurse) +MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) { - fn = fileFixify(fn); - QStringList &fndeps = findDependencies(fn); + QStringList &fndeps = findDependencies(f); if(!fndeps.isEmpty()) return TRUE; - + QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); fn = Option::fixPathToLocalOS(fn, FALSE); @@ -290,4 +305,6 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri x++; - if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include ", 8)) { - for(x+=8; //skip spaces after keyword + if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && + (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '\t' || + *(big_buffer + x + 7) == '<' || *(big_buffer + x + 7) == '"')) { + for(x+=7; //skip spaces after keyword x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); @@ -330,3 +347,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri while(x < total_size_read && - (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) + (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) x++; @@ -344,3 +361,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri for(x += 8; *(big_buffer + x) != '>'; x++) { - if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && + if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && !strncmp(big_buffer + x, "impldecl", 8)) { @@ -371,3 +388,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri QString cpp = fn.left(fn.length() - Option::ui_ext.length()) + - Option::cpp_ext.first(); + Option::cpp_ext.first(); outdeps = &findDependencies(cpp); @@ -385,2 +402,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri if(!inc.isEmpty()) { + bool from_source_dir = TRUE; debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(), @@ -406,2 +424,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri fqn = fndir + inc; + goto handle_fqn; } else { @@ -417,3 +436,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri fqn = mdd->real_dir + QDir::separator() + inc; - break; + goto handle_fqn; } @@ -422,3 +441,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri } - if(fqn.isEmpty()) { + if(fqn.isEmpty() && Option::mkfile::do_dep_heuristics) { //these are some hacky heuristics it will try to do on an include @@ -427,3 +446,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri //and see if they go away.. - if(Option::mkfile::do_dep_heuristics && depHeuristics.contains(inc)) { + if(depHeuristics.contains(inc)) { fqn = depHeuristics[inc]; @@ -449,3 +468,26 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri fqn += inc_file; - break; + from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) + fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); + goto handle_fqn; + } + } + } + if(project->isActiveConfig("lex_included")) { //is this the lex file? + QString rhs = Option::lex_mod + Option::cpp_ext.first(); + if(inc.endsWith(rhs)) { + QString lhs = inc.left(inc.length() - rhs.length()) + Option::lex_ext; + QStringList ll = project->variables()["LEXSOURCES"]; + for(QStringList::Iterator it = ll.begin(); it != ll.end(); ++it) { + QString s = (*it), d; + int slsh = s.findRev(Option::dir_sep); + if(slsh != -1) { + d = s.left(slsh + 1); + s = s.right(s.length() - slsh - 1); + } + if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) + d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); + if(s == lhs) { + fqn = d + inc; + goto handle_fqn; + } } @@ -453,3 +495,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri } - if(fqn.isEmpty()) { //is it from a .y? + { //is it from a .y? QString rhs = Option::yacc_mod + Option::h_ext.first(); @@ -469,3 +511,30 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri fqn = d + inc; - break; + goto handle_fqn; + } + } + } + } + if(mocAware() && //is it a moc file? + (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) { + QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; + for(int moc = 0; !mocs[moc].isNull(); moc++) { + QStringList &l = project->variables()[mocs[moc]]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + QString file = Option::fixPathToTargetOS((*it)); + if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) { + fqn = (*it); + if(mocs[moc] == "_HDRMOC") { + //Since it is include, no need to link it in as well + project->variables()["_SRCMOC"].append((*it)); + l.remove(it); + } else if(!findMocSource(fqn).endsWith(fn)) { + /* Not really a very good test, but this will at least avoid + confusion if it really does happen (since tmake/qmake + previously didn't even allow this the test is mostly accurate) */ + warn_msg(WarnLogic, + "Found potential multiple MOC include %s (%s) in '%s'", + inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); + } + from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) + goto handle_fqn; } @@ -476,8 +545,10 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri } - if(!Option::mkfile::do_dep_heuristics || fqn.isEmpty()) //I give up - continue; } - - fqn = fileFixify(Option::fixPathToTargetOS(fqn, FALSE)); - debug_msg(4, "Resolved dependancy of %s to %s", inc.latin1(), fqn.latin1()); + handle_fqn: + if(fqn.isEmpty()) //I give up + continue; + fqn = Option::fixPathToTargetOS(fqn, FALSE); + if(from_source_dir) + fqn = fileFixify(fqn); + debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1()); if(outdeps && outdeps->findIndex(fqn) == -1) @@ -499,3 +570,3 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri } - debug_msg(2, "Dependancies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); + debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); return TRUE; @@ -615,3 +686,7 @@ MakefileGenerator::init() QDict<void> cache_found_files; - QString cache_file(Option::output_dir + QDir::separator() + ".qmake.internal.cache"); + QString cache_file(".qmake.internal.cache"); + if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE")) + cache_file = Option::fixPathToLocalOS(project->first("QMAKE_INTERNAL_CACHE_FILE")); + if(cache_file.find(QDir::separator()) == -1) //guess they know what they are doing.. + cache_file.prepend(Option::output_dir + QDir::separator()); if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || @@ -630,3 +705,3 @@ MakefileGenerator::init() } - debug_msg(1, "Dependancy Directories: %s", incDirs.join(" :: ").latin1()); + debug_msg(1, "Dependency Directories: %s", incDirs.join(" :: ").latin1()); if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) { @@ -685,3 +760,3 @@ MakefileGenerator::init() if(found) { - debug_msg(2, "Dependancies (cached): %s -> %s", file.latin1(), + debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), files.join(" :: ").latin1()); @@ -745,2 +820,3 @@ MakefileGenerator::init() QString file = Option::fixPathToLocalOS((*val_it)); + QStringList file_list(file); if(!QFile::exists(file)) { @@ -771,3 +847,3 @@ MakefileGenerator::init() dir = regex.left(regex.findRev(Option::dir_sep) + 1); - real_dir = fileFixify(Option::fixPathToLocalOS(dir), + real_dir = fileFixify(Option::fixPathToLocalOS(dir), QDir::currentDirPath(), Option::output_dir); @@ -784,5 +860,10 @@ MakefileGenerator::init() } else { - (*val_it) = dir + d[0]; - for(int i = 1; i < (int)d.count(); i++) - l.insert(val_it, dir + d[i]); + file_list.clear(); + for(int i = 0; i < (int)d.count(); i++) { + file_list.append(dir + d[i]); + if(i == (int)d.count() - 1) + (*val_it) = dir + d[i]; + else + l.insert(val_it, dir + d[i]); + } } @@ -797,35 +878,39 @@ MakefileGenerator::init() } - - QString val_file = fileFixify((*val_it)); - bool found_cache_moc = FALSE, found_cache_dep = FALSE; - if(read_cache && Option::output.name() != "-" && - project->isActiveConfig("qmake_cache")) { - if(!findDependencies(val_file).isEmpty()) - found_cache_dep = TRUE; - if(cache_found_files[(*val_it)] == (void *)2) - found_cache_moc = TRUE; - if(!found_cache_moc || !found_cache_dep) - write_cache = TRUE; - } - if(!found_cache_dep && sources[x] != "OBJECTS") { - debug_msg(5, "Looking for dependancies for %s", (*val_it).latin1()); - generateDependencies(deplist, (*val_it), doDepends()); - } - if(found_cache_moc) { - QString moc = findMocDestination(val_file); - if(!moc.isEmpty()) { - for(QStringList::Iterator cppit = Option::cpp_ext.begin(); - cppit != Option::cpp_ext.end(); ++cppit) { - if(val_file.endsWith((*cppit))) { - QStringList &deps = findDependencies(val_file); - if(!deps.contains(moc)) - deps.append(moc); - break; + for(QStringList::Iterator file_it = file_list.begin(); + file_it != file_list.end(); ++file_it) { + QString file_list_file = fileFixify((*file_it)); + bool found_cache_moc = FALSE, found_cache_dep = FALSE; + if(read_cache && Option::output.name() != "-" && + project->isActiveConfig("qmake_cache")) { + if(!findDependencies(file_list_file).isEmpty()) + found_cache_dep = TRUE; + if(cache_found_files[(*file_it)] == (void *)2) + found_cache_moc = TRUE; + if(!found_cache_moc || !found_cache_dep) + write_cache = TRUE; + } + /* Do moc before dependency checking since some includes can come from + moc_*.cpp files */ + if(found_cache_moc) { + QString moc = findMocDestination(file_list_file); + if(!moc.isEmpty()) { + for(QStringList::Iterator cppit = Option::cpp_ext.begin(); + cppit != Option::cpp_ext.end(); ++cppit) { + if(file_list_file.endsWith((*cppit))) { + QStringList &deps = findDependencies(file_list_file); + if(!deps.contains(moc)) + deps.append(moc); + break; + } } } + } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && + (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || + Option::mkfile::do_mocs)) { + generateMocList((*file_it)); + } + if(!found_cache_dep && sources[x] != "OBJECTS") { + debug_msg(5, "Looking for dependencies for %s", (*file_it).latin1()); + generateDependencies(deplist, (*file_it), doDepends()); } - } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && - (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || - Option::mkfile::do_mocs)) { - generateMocList((*val_it)); } @@ -855,7 +940,8 @@ MakefileGenerator::init() for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { - if(!(*val_it).isEmpty()) { - mc = mocablesToMOC[(*val_it)]; + QString f = fileFixify((*val_it)); + if(!f.isEmpty()) { + mc = mocablesToMOC[f]; if(mc.isEmpty()) mc = "*qmake_ignore*"; - cachet << (*val_it) << " = " << mc << endl; + cachet << f << " = " << mc << endl; } @@ -948,6 +1034,7 @@ MakefileGenerator::init() { + QStringList &includepath = project->variables()["INCLUDEPATH"]; if(!project->isEmpty("UI_DIR")) - project->variables()["INCLUDEPATH"].append(project->first("UI_DIR")); + includepath.append(project->first("UI_DIR")); else if(!project->isEmpty("UI_HEADERS_DIR")) - project->variables()["INCLUDEPATH"].append(project->first("UI_HEADERS_DIR")); + includepath.append(project->first("UI_HEADERS_DIR")); QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"]; @@ -962,5 +1049,5 @@ MakefileGenerator::init() d = QDir::currentDirPath(); - d = fileFixify(d); - if( !project->variables()["INCLUDEPATH"].contains(d)) - project->variables()["INCLUDEPATH"].append(d); + d = fileFixify(d, QDir::currentDirPath(), Option::output_dir); + if(!includepath.contains(d)) + includepath.append(d); } else { @@ -968,3 +1055,4 @@ MakefileGenerator::init() decl = project->first("UI_HEADERS_DIR"); - if ( !decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && !project->isEmpty("UI_SOURCES_DIR")) ) { + if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && + !project->isEmpty("UI_SOURCES_DIR")) ) { QString d = fi.dirPath(); @@ -972,5 +1060,5 @@ MakefileGenerator::init() d = QDir::currentDirPath(); - d = fileFixify(d); - if( !project->variables()["INCLUDEPATH"].contains(d)) - project->variables()["INCLUDEPATH"].append(d); + d = fileFixify(d, QDir::currentDirPath(), Option::output_dir); + if(includepath.contains(d)) + includepath.append(d); } @@ -985,3 +1073,17 @@ MakefileGenerator::init() } - impl += fi.baseName(TRUE) + Option::cpp_ext.first(), + impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); + if(!impl.isEmpty()) + impl += Option::dir_sep; + impl += fi.baseName(TRUE) + Option::cpp_ext.first(); + if(Option::output_dir != QDir::currentDirPath() && + project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) { + QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); + if(!includepath.contains(decl_fixed)) + includepath.append(decl_fixed); + if(!includepath.contains(decl)) + project->variables()["INCLUDEPATH"].append(decl); + } + decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); + if(!decl.isEmpty()) + decl += Option::dir_sep; decl += fi.baseName(TRUE) + Option::h_ext.first(); @@ -1032,5 +1134,5 @@ MakefileGenerator::init() } - - if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) - project->variables()["INCLUDEPATH"].append(Option::output_dir); + if(Option::output_dir != QDir::currentDirPath()) + project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir, + Option::output_dir)); @@ -1068,3 +1170,3 @@ MakefileGenerator::processPrlFile(QString &file) prl_file = fileFixify(prl_file); - if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && + if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && project->isActiveConfig("qt")) { @@ -1106,3 +1208,3 @@ MakefileGenerator::processPrlFile(QString &file) if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), - QDir::currentDirPath())) { + QDir::currentDirPath(), TRUE)) { fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); @@ -1198,2 +1300,4 @@ MakefileGenerator::writePrlFile(QTextStream &t) t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; + if(!project->isEmpty("VERSION")) + t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl; if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { @@ -1230,4 +1334,3 @@ MakefileGenerator::write() prl.prepend(var("DESTDIR")); - QString local_prl = fileFixify(prl, QDir::currentDirPath(), Option::output_dir); - fixEnvVariables(local_prl); + QString local_prl = Option::fixPathToLocalOS(fileFixify(prl, QDir::currentDirPath(), Option::output_dir)); QFile ft(local_prl); @@ -1242,3 +1345,3 @@ MakefileGenerator::write() if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && - project->isActiveConfig("link_prl")) //load up prl's + project->isActiveConfig("link_prl")) //load up prl's' processPrlFiles(); @@ -1304,3 +1407,3 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s } - if (!use_implicit_rule) { + if (!use_implicit_rule && !project->isEmpty(comp)) { QString p = var(comp); @@ -1322,16 +1425,32 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) { - QString tmp = (*it); + QString tmp = (*it), impl_dir, decl_dir; decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); + decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); + int dlen = decl.findRev(Option::dir_sep) + 1; tmp = (*it); impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); - int dlen = (*it).findRev(Option::dir_sep) + 1; + impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); + int ilen = decl.findRev(Option::dir_sep) + 1; if(!project->isEmpty("UI_DIR")) { + impl_dir = project->first("UI_DIR"); decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); - impl = project->first("UI_DIR") + impl.right(impl.length() - dlen); + impl = project->first("UI_DIR") + impl.right(impl.length() - ilen); } else { - if(!project->isEmpty("UI_HEADERS_DIR")) + if(!project->isEmpty("UI_HEADERS_DIR")) { + decl_dir = project->first("UI_HEADERS_DIR"); decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen); - if(!project->isEmpty("UI_SOURCES_DIR")) - impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - dlen); - } + } + if(!project->isEmpty("UI_SOURCES_DIR")) { + impl_dir = project->first("UI_SOURCES_DIR"); + impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); + } + } + if(decl_dir.isEmpty()) + decl_dir = decl.left(dlen); + if(impl_dir.isEmpty()) + impl_dir = impl.left(ilen); + if(!impl_dir.isEmpty()) + createDir(Option::output_dir + Option::dir_sep + impl_dir); + if(!decl_dir.isEmpty() && decl_dir != impl_dir) + createDir(Option::output_dir + Option::dir_sep + decl_dir); } @@ -1372,3 +1491,3 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString } - if (!use_implicit_rule) { + if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { QString p = var("QMAKE_RUN_CXX"); @@ -1415,5 +1534,9 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) QFileInfo fi((*it)); - QString dir = fileFixify(Option::output_dir); + QString dir; + if(fi.dirPath() != ".") + dir = fi.dirPath() + Option::dir_sep; + dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) dir += Option::dir_sep; + QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); @@ -1425,3 +1548,3 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) yaccflags += " -p " + mangle; - } + } QString out_h = default_out_h, out_c = default_out_c; @@ -1454,3 +1577,6 @@ MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src) QFileInfo fi((*it)); - QString dir = fileFixify(Option::output_dir); + QString dir; + if(fi.dirPath() != ".") + dir = fi.dirPath() + Option::dir_sep; + dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) @@ -1465,3 +1591,3 @@ MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src) QString out_c = default_out_c; - if(!stub.isEmpty()) + if(!stub.isEmpty()) out_c.replace(stringBase, stub); @@ -1496,3 +1622,3 @@ MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj) } - if(!use_implicit_rule) { + if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { QString p = var("QMAKE_RUN_CXX"); @@ -1543,19 +1669,22 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) bool do_default = TRUE; - QString target, dst="$(INSTALL_ROOT)" + Option::fixPathToTargetOS(project->variables()[pvar].first(), FALSE); + const QString root = "$(INSTALL_ROOT)"; + QString target, dst= fileFixify(project->variables()[pvar].first()); +#ifndef Q_WS_WIN if(dst.right(1) != Option::dir_sep) dst += Option::dir_sep; - QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; - //other - tmp = project->variables()[(*it) + ".extra"]; - if(!tmp.isEmpty()) { +#endif + QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; + //other + tmp = project->variables()[(*it) + ".extra"]; + if(!tmp.isEmpty()) { do_default = FALSE; if(!target.isEmpty()) - target += "\n\t"; - target += tmp.join(" "); - } - //masks - tmp = project->variables()[(*it) + ".files"]; - if(!tmp.isEmpty()) { + target += "\n\t"; + target += tmp.join(" "); + } + //masks + tmp = project->variables()[(*it) + ".files"]; + if(!tmp.isEmpty()) { if(!target.isEmpty()) - target += "\n"; + target += "\n"; do_default = FALSE; @@ -1563,25 +1692,32 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild); + QString dirstr = QDir::currentDirPath(), filestr = wild; + int slsh = filestr.findRev(Option::dir_sep); + if(slsh != -1) { + dirstr = filestr.left(slsh+1); + filestr = filestr.right(filestr.length() - slsh - 1); + } + if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep) + dirstr += Option::dir_sep; if(QFile::exists(wild)) { //real file + QString file = wild; QFileInfo fi(wild); - target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + - " \"" + Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + fileFixify(dst) + "\"\n"; + if(!target.isEmpty()) + target += "\t"; + target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + + Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n"; if(!project->isActiveConfig("debug") && !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) - target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + wild) + "\"\n"; - uninst.append(QString("-$(DEL_FILE) -r") + " \"" + fileFixify(dst + wild) + "\""); + target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n"; + if(!uninst.isEmpty()) + uninst.append("\n\t"); + uninst.append( +#ifdef Q_WS_WIN + QString("-$(DEL_FILE)") +#else + QString("-$(DEL_FILE) -r") +#endif + + " \"" + root + fileFixify(dst + filestr) + "\""); continue; } - QString dirstr = QDir::currentDirPath(), f = wild; //wild - int slsh = f.findRev(Option::dir_sep); - if(slsh != -1) { - dirstr = f.left(slsh+1); - f = f.right(f.length() - slsh - 1); - } - if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep) - dirstr += Option::dir_sep; - if(!uninst.isEmpty()) - uninst.append("\n\t"); - uninst.append(QString("-$(DEL_FILE) -r") + " " + fileFixify(dst + f) + ""); - - QDir dir(dirstr, f); + QDir dir(dirstr, filestr); //wild for(uint x = 0; x < dir.count(); x++) { @@ -1590,13 +1726,24 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) continue; + if(!uninst.isEmpty()) + uninst.append("\n\t"); + uninst.append( +#ifdef Q_WS_WIN + QString("-$(DEL_FILE)") +#else + QString("-$(DEL_FILE) -r") +#endif + + " \"" + root + fileFixify(dst + file) + "\""); QFileInfo fi(file); - target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + - " \"" + Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + - "\" \"" + fileFixify(dst) + "\"\n"; + if(!target.isEmpty()) + target += "\t"; + target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + + Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + + "\" \"" + root + fileFixify(dst) + "\"\n"; if(!project->isActiveConfig("debug") && !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) - target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + file) + "\"\n"; + target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n"; } } - } - //default? + } + //default? if(do_default) @@ -1605,5 +1752,13 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) if(!target.isEmpty()) { - t << "install_" << (*it) << ": " << "\n\t" - << "@test -d " << dst << " || mkdir -p " << dst << "\n\t" - << target << endl << endl; + t << "install_" << (*it) << ": " << "\n\t"; + const QStringList &dirs = project->variables()[pvar]; + for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { + QString tmp_dst = fileFixify((*pit)); +#ifndef Q_WS_WIN + if(tmp_dst.right(1) != Option::dir_sep) + tmp_dst += Option::dir_sep; +#endif + t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; + } + t << target << endl << endl; all_installs += QString("install_") + (*it) + " "; @@ -1611,4 +1766,4 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) t << "uninstall_" << (*it) << ": " << "\n\t" - << uninst.join(" ") << "\n\t" - << "-$(DEL_DIR) \"" << dst << "\"" << endl << endl; + << uninst.join("") << "\n\t" + << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; all_uninstalls += "uninstall_" + (*it) + " "; @@ -1789,3 +1944,3 @@ MakefileGenerator::writeHeader(QTextStream &t) t << "# Makefile for building: " << var("TARGET") << endl; - t << "# Generated by qmake (" << qmake_version() << ") on: " << ctime(&foo); + t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: " << ctime(&foo); t << "# Project: " << fileFixify(project->projectFile()) << endl; @@ -1804,3 +1959,3 @@ MakefileGenerator::writeMakeQmake(QTextStream &t) QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); - if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && + if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { @@ -1848,5 +2003,11 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const { + if(file0.isEmpty()) + return file0; + QString key = file0; + if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix) + key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-"); + if(fileFixed.contains(key)) + return fileFixed[key]; + QString file = file0; - if(file.isEmpty()) - return file; int depth = 4; @@ -1892,2 +2053,8 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const } + QString in_canonical_dir = QDir(in_dir).canonicalPath(), + out_canonical_dir = QDir(out_dir).canonicalPath(); + if(!in_canonical_dir.isEmpty()) + in_dir = in_canonical_dir; + if(!out_canonical_dir.isEmpty()) + out_dir = out_canonical_dir; } @@ -1901,2 +2068,7 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const file = Option::fixPathToTargetOS(file, FALSE); + if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) { + QString real_file = QDir(file).canonicalPath(); + if(!real_file.isEmpty()) + file = real_file; + } QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); @@ -1931,2 +2103,4 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const file = Option::fixPathToTargetOS(file, FALSE); + if(file.isEmpty()) + file = "."; if(!quote.isNull()) @@ -1934,2 +2108,3 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); + ((MakefileGenerator*)this)->fileFixed.insert(key, file); return file; @@ -2041,4 +2216,5 @@ MakefileGenerator::openOutput(QFile &file) const #include "unixmake.h" -#include "borland_bmake.h" #include "msvc_nmake.h" +#include "borland_bmake.h" +#include "mingw_make.h" #include "msvc_dsp.h" @@ -2063,3 +2239,3 @@ MakefileGenerator::create(QMakeProject *proj) } else if(gen == "MSVC") { - // Visual Studio =< v6.0 + // Visual Studio =< v6.0 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) @@ -2069,3 +2245,3 @@ MakefileGenerator::create(QMakeProject *proj) } else if(gen == "MSVC.NET") { - // Visual Studio >= v7.0 + // Visual Studio >= v7.0 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) @@ -2076,2 +2252,4 @@ MakefileGenerator::create(QMakeProject *proj) mkfile = new BorlandMakefileGenerator(proj); + } else if(gen == "MINGW") { + mkfile = new MingwMakefileGenerator(proj); } else if(gen == "METROWERKS") { |