summaryrefslogtreecommitdiff
path: root/qmake/generators/makefile.cpp
Side-by-side diff
Diffstat (limited to 'qmake/generators/makefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/makefile.cpp476
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
@@ -6,5 +6,5 @@
** Created : 970521
**
-** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
**
** This file is part of the network module of the Qt GUI Toolkit.
@@ -60,6 +60,20 @@
#endif
+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;
bool ret = TRUE;
@@ -78,6 +92,6 @@ 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)
{
@@ -89,10 +103,10 @@ static char *gimme_buffer(off_t s)
static int big_buffer_size = 0;
if(!big_buffer || big_buffer_size < s)
- big_buffer = (char *)realloc(big_buffer, s);
+ big_buffer = (char *)realloc(big_buffer, s);
return big_buffer;
}
bool
-MakefileGenerator::generateMocList(QString fn_target)
+MakefileGenerator::generateMocList(const QString &fn_target)
{
if(!findMocDestination(fn_target).isEmpty())
@@ -174,5 +188,6 @@ MakefileGenerator::generateMocList(QString fn_target)
if(interesting) {
*(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);
int ext_pos = fn_target.findRev('.');
@@ -186,5 +201,6 @@ 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))))
break;
@@ -192,8 +208,8 @@ MakefileGenerator::generateMocList(QString fn_target)
if(cpp_ext) {
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))) {
mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) +
@@ -226,11 +242,10 @@ 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);
QString fix_env_fn = Option::fixPathToLocalOS(fn);
@@ -289,6 +304,8 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
(*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
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');
x++);
@@ -329,5 +346,5 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
// skip whitespaces
while(x < total_size_read &&
- (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
+ (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
x++;
if(*(big_buffer + x) == '<') {
@@ -343,5 +360,5 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
(*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) {
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)) {
for(x += 8; *(big_buffer + x) != '='; x++);
@@ -370,5 +387,5 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
if(where == "in implementation") {
QString cpp = fn.left(fn.length() - Option::ui_ext.length()) +
- Option::cpp_ext.first();
+ Option::cpp_ext.first();
outdeps = &findDependencies(cpp);
}
@@ -384,4 +401,5 @@ 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(),
line_count, inc.latin1());
@@ -405,4 +423,5 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
!stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) {
fqn = fndir + inc;
+ goto handle_fqn;
} else {
if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
@@ -416,15 +435,15 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
!S_ISDIR(fst.st_mode)) {
fqn = mdd->real_dir + QDir::separator() + inc;
- break;
+ goto handle_fqn;
}
}
}
}
- if(fqn.isEmpty()) {
+ if(fqn.isEmpty() && Option::mkfile::do_dep_heuristics) {
//these are some hacky heuristics it will try to do on an include
//however these can be turned off at runtime, I'm not sure how
//reliable these will be, most likely when problems arise turn it off
//and see if they go away..
- if(Option::mkfile::do_dep_heuristics && depHeuristics.contains(inc)) {
+ if(depHeuristics.contains(inc)) {
fqn = depHeuristics[inc];
} else if(Option::mkfile::do_dep_heuristics) { //some heuristics..
@@ -448,9 +467,32 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
fqn += Option::dir_sep;
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;
+ }
}
}
}
- if(fqn.isEmpty()) { //is it from a .y?
+ { //is it from a .y?
QString rhs = Option::yacc_mod + Option::h_ext.first();
if(inc.endsWith(rhs)) {
@@ -468,5 +510,32 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
if(s == lhs) {
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;
}
}
@@ -475,10 +544,12 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
depHeuristics.insert(inc, fqn);
}
- 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)
outdeps->append(fqn);
@@ -498,5 +569,5 @@ 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;
}
@@ -614,5 +685,9 @@ MakefileGenerator::init()
/* get deps and mocables */
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 ||
Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) {
@@ -629,5 +704,5 @@ MakefileGenerator::init()
l.replace("\"","")));
}
- 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")) {
QFile cachef(cache_file);
@@ -684,5 +759,5 @@ 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());
findDependencies(file) = files;
@@ -744,4 +819,5 @@ MakefileGenerator::init()
if(!(*val_it).isEmpty()) {
QString file = Option::fixPathToLocalOS((*val_it));
+ QStringList file_list(file);
if(!QFile::exists(file)) {
bool found = FALSE;
@@ -770,5 +846,5 @@ MakefileGenerator::init()
if(regex.findRev(Option::dir_sep) != -1) {
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);
regex = regex.right(regex.length() - dir.length());
@@ -783,7 +859,12 @@ MakefileGenerator::init()
continue;
} 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]);
+ }
}
} else {
@@ -796,37 +877,41 @@ 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));
}
}
@@ -854,9 +939,10 @@ MakefileGenerator::init()
QStringList &l = v[moc_sources[x]];
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;
}
}
@@ -947,8 +1033,9 @@ MakefileGenerator::init()
//UI files
{
+ 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"];
QStringList &l = v["FORMS"];
@@ -961,17 +1048,18 @@ MakefileGenerator::init()
if( d == ".")
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 {
if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR"))
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();
if( d == ".")
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);
}
if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR"))
@@ -984,5 +1072,19 @@ 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();
logicWarn(impl, "SOURCES");
@@ -1031,7 +1133,7 @@ MakefileGenerator::init()
v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION"));
}
-
- 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));
//moc files
@@ -1067,5 +1169,5 @@ 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")) {
QString stem = prl_file, dir, extn;
@@ -1105,5 +1207,5 @@ MakefileGenerator::processPrlFile(QString &file)
debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1());
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());
} else {
@@ -1197,4 +1299,6 @@ MakefileGenerator::writePrlFile(QTextStream &t)
if(!project->isEmpty("CONFIG"))
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")) {
QStringList libs;
@@ -1229,6 +1333,5 @@ MakefileGenerator::write()
if(!project->isEmpty("DESTDIR"))
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);
if(ft.open(IO_WriteOnly)) {
@@ -1241,5 +1344,5 @@ 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();
@@ -1303,5 +1406,5 @@ 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);
p.replace(stringSrc, (*sit));
@@ -1321,18 +1424,34 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl;
{
- 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);
}
t << decl << ": " << (*it) << " " << deps << "\n\t"
@@ -1371,5 +1490,5 @@ 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");
p.replace(stringSrc, (*sit));
@@ -1414,7 +1533,11 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
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();
QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
@@ -1424,5 +1547,5 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
mangle = fi.baseName(TRUE);
yaccflags += " -p " + mangle;
- }
+ }
QString out_h = default_out_h, out_c = default_out_c;
if(!mangle.isEmpty()) {
@@ -1453,5 +1576,8 @@ MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src)
for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
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;
@@ -1464,5 +1590,5 @@ MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src)
}
QString out_c = default_out_c;
- if(!stub.isEmpty())
+ if(!stub.isEmpty())
out_c.replace(stringBase, stub);
@@ -1495,5 +1621,5 @@ 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");
p.replace( stringSrc, src);
@@ -1542,74 +1668,103 @@ 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;
for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) {
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++) {
QString file = dir[x];
if(file == "." || file == "..") //blah
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)
target = defaultInstall((*it));
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) + " ";
if(!uninst.isEmpty()) {
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) + " ";
}
@@ -1788,5 +1943,5 @@ MakefileGenerator::writeHeader(QTextStream &t)
t << "#############################################################################" << endl;
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;
t << "# Template: " << var("TEMPLATE") << endl;
@@ -1803,5 +1958,5 @@ 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")) {
QStringList files = fileFixify(Option::mkfile::project_files);
@@ -1847,7 +2002,13 @@ QString
MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) 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;
if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
@@ -1891,4 +2052,10 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
out_dir = out_fi.filePath();
}
+ 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;
}
if(out_dir != in_dir || !QDir::isRelativePath(qfile)) {
@@ -1900,4 +2067,9 @@ 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);
if(file == match_dir) {
@@ -1930,7 +2102,10 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
}
file = Option::fixPathToTargetOS(file, FALSE);
+ if(file.isEmpty())
+ file = ".";
if(!quote.isNull())
file = quote + file + quote;
debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth);
+ ((MakefileGenerator*)this)->fileFixed.insert(key, file);
return file;
}
@@ -2040,6 +2215,7 @@ MakefileGenerator::openOutput(QFile &file) const
//Factory thing
#include "unixmake.h"
-#include "borland_bmake.h"
#include "msvc_nmake.h"
+#include "borland_bmake.h"
+#include "mingw_make.h"
#include "msvc_dsp.h"
#include "msvc_vcproj.h"
@@ -2062,5 +2238,5 @@ MakefileGenerator::create(QMakeProject *proj)
mkfile = new UnixMakefileGenerator(proj);
} else if(gen == "MSVC") {
- // Visual Studio =< v6.0
+ // Visual Studio =< v6.0
if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
mkfile = new DspMakefileGenerator(proj);
@@ -2068,5 +2244,5 @@ MakefileGenerator::create(QMakeProject *proj)
mkfile = new NmakeMakefileGenerator(proj);
} else if(gen == "MSVC.NET") {
- // Visual Studio >= v7.0
+ // Visual Studio >= v7.0
if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
mkfile = new VcprojGenerator(proj);
@@ -2075,4 +2251,6 @@ MakefileGenerator::create(QMakeProject *proj)
} else if(gen == "BMAKE") {
mkfile = new BorlandMakefileGenerator(proj);
+ } else if(gen == "MINGW") {
+ mkfile = new MingwMakefileGenerator(proj);
} else if(gen == "METROWERKS") {
mkfile = new MetrowerksMakefileGenerator(proj);