summaryrefslogtreecommitdiffstats
path: root/qmake/generators
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>2011-10-24 13:37:30 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-24 15:39:33 +0200
commit9f14f9239836ec9d7d1f0ba92343e57cd96b1b52 (patch)
tree42e10c9435dc10c82c962b97d0989cf144c03d99 /qmake/generators
parent642fe4040b3b169b9377b6b5bad28a9189aefe2d (diff)
Add CONFIG flag to use the compiler to generate makefile dependencies
Using CONFIG+=GNUmake will enable dependency tracking using included dependency files, but will use an implicit makefile rule to generate each .d file. We now support an additional CONFIG option, gcc_MD_depends, that instead passes the -MD flag to a GCC (compatible) compiler. This will generate a .d file as a side-effect of the normal compile step. Change-Id: Ib6ce1d93e7f07e316a345bf12aa6f2b4e9a6415d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'qmake/generators')
-rw-r--r--qmake/generators/unix/unixmake2.cpp116
1 files changed, 65 insertions, 51 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 2037e3f368..d6bb87e7e1 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -274,61 +274,70 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << (*cit) << Option::obj_ext << ":\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->values("OBJECTS_DIR").isEmpty())
- odir = project->first("OBJECTS_DIR");
-
- QString pwd = escapeFilePath(fileFixify(qmake_getpwd()));
-
- t << "###### Dependencies" << endl << endl;
- t << odir << ".deps/%.d: " << pwd << "/%.cpp\n\t";
- if(project->isActiveConfig("echo_depend_creation"))
- t << "@echo Creating depend for $<" << "\n\t";
- t << mkdir_p_asstring("$(@D)") << "\n\t"
- << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
-
- t << odir << ".deps/%.d: " << pwd << "/%.c\n\t";
- if(project->isActiveConfig("echo_depend_creation"))
- t << "@echo Creating depend for $<" << "\n\t";
- t << mkdir_p_asstring("$(@D)") << "\n\t"
- << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
-
- QString src[] = { "SOURCES", "GENERATED_SOURCES", QString() };
- for(int x = 0; !src[x].isNull(); x++) {
- QStringList &l = project->values(src[x]);
- for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
- if(!(*it).isEmpty()) {
- QString d_file;
- for(QStringList::Iterator cit = Option::c_ext.begin();
- cit != Option::c_ext.end(); ++cit) {
- if((*it).endsWith((*cit))) {
- d_file = (*it).left((*it).length() - (*cit).length());
- break;
- }
- }
- if(d_file.isEmpty()) {
- 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());
+ if (project->isActiveConfig("gcc_MD_depends")) {
+ QStringList objects = project->values("OBJECTS");
+ for(QStringList::Iterator it = objects.begin(); it != objects.end(); ++it) {
+ QString d_file = (*it).replace(QRegExp(Option::obj_ext + "$"), ".d");
+ t << "-include " << d_file << endl;
+ project->values("QMAKE_DISTCLEAN") += d_file;
+ }
+ } else {
+ 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->values("OBJECTS_DIR").isEmpty())
+ odir = project->first("OBJECTS_DIR");
+
+ QString pwd = escapeFilePath(fileFixify(qmake_getpwd()));
+
+ t << "###### Dependencies" << endl << endl;
+ t << odir << ".deps/%.d: " << pwd << "/%.cpp\n\t";
+ if(project->isActiveConfig("echo_depend_creation"))
+ t << "@echo Creating depend for $<" << "\n\t";
+ t << mkdir_p_asstring("$(@D)") << "\n\t"
+ << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
+
+ t << odir << ".deps/%.d: " << pwd << "/%.c\n\t";
+ if(project->isActiveConfig("echo_depend_creation"))
+ t << "@echo Creating depend for $<" << "\n\t";
+ t << mkdir_p_asstring("$(@D)") << "\n\t"
+ << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
+
+ QString src[] = { "SOURCES", "GENERATED_SOURCES", QString() };
+ for(int x = 0; !src[x].isNull(); x++) {
+ QStringList &l = project->values(src[x]);
+ for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ if(!(*it).isEmpty()) {
+ QString d_file;
+ for(QStringList::Iterator cit = Option::c_ext.begin();
+ cit != Option::c_ext.end(); ++cit) {
+ if((*it).endsWith((*cit))) {
+ d_file = (*it).left((*it).length() - (*cit).length());
break;
}
}
- }
+ if(d_file.isEmpty()) {
+ 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/" + fileFixify(d_file, pwd, Option::output_dir) + ".d";
- QStringList deps = findDependencies((*it)).filter(QRegExp(
- "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)"));
- if(!deps.isEmpty())
- t << d_file << ": " << deps.join(" ") << endl;
- t << "-include " << d_file << endl;
- project->values("QMAKE_DISTCLEAN") += d_file;
+ if(!d_file.isEmpty()) {
+ d_file = odir + ".deps/" + fileFixify(d_file, pwd, Option::output_dir) + ".d";
+ QStringList deps = findDependencies((*it)).filter(QRegExp(
+ "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)"));
+ if(!deps.isEmpty())
+ t << d_file << ": " << deps.join(" ") << endl;
+ t << "-include " << d_file << endl;
+ project->values("QMAKE_DISTCLEAN") += d_file;
+ }
}
}
}
@@ -1224,6 +1233,11 @@ void UnixMakefileGenerator::init2()
}
}
+ if (include_deps && project->isActiveConfig("gcc_MD_depends")) {
+ project->values("QMAKE_CFLAGS") += "-MD";
+ project->values("QMAKE_CXXFLAGS") += "-MD";
+ }
+
if(!project->isEmpty("QMAKE_BUNDLE")) {
QString plist = fileFixify(project->first("QMAKE_INFO_PLIST"));
if(plist.isEmpty())