summaryrefslogtreecommitdiff
path: root/qmake/generators/unix/unixmake2.cpp
Side-by-side diff
Diffstat (limited to 'qmake/generators/unix/unixmake2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/unix/unixmake2.cpp185
1 files changed, 122 insertions, 63 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 9bb6f6b..7fbb9f4 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -81,5 +81,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
(!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
- !project->isActiveConfig("staticlib"))),
+ !project->isActiveConfig("staticlib"))),
src_incremental=FALSE, moc_incremental=FALSE;
- QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
@@ -110,3 +109,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl;
- t << "INCPATH = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl;
+ t << "INCPATH = " << "-I" << specdir();
+ if(!project->isActiveConfig("no_include_pwd")) {
+ QString pwd = fileFixify(QDir::currentDirPath());
+ if(pwd.isEmpty())
+ pwd = ".";
+ t << " -I" << pwd;
+ }
+ t << varGlue("INCLUDEPATH"," -I", " -I", "") << endl;
@@ -138,3 +144,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "MOVE = " << var("QMAKE_MOVE") << endl;
- t << "PRO = " << fileFixify(project->projectFile() )<< endl;
+ t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
+ t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
t << endl;
@@ -214,4 +221,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
do_incremental = FALSE;
- t << "DIST = " << varList("DISTFILES") << endl;
- t << "PRO = " << fileFixify(project->projectFile()) << endl;
+ t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
@@ -223,7 +229,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "TARGETA = " << var("TARGETA") << endl;
- if (os == "hpux") {
- t << "TARGETD = " << var("TARGET_x") << endl;
- t << "TARGET0 = " << var("TARGET_") << endl;
- }
- else {
+ if (project->isEmpty("QMAKE_HPUX_SHLIB")) {
t << "TARGETD = " << var("TARGET_x.y.z") << endl;
@@ -232,2 +234,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "TARGET2 = " << var("TARGET_x.y") << endl;
+ } else {
+ t << "TARGETD = " << var("TARGET_x") << endl;
+ t << "TARGET0 = " << var("TARGET_") << endl;
}
@@ -263,3 +268,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
odir = project->first("OBJECTS_DIR");
- t << "###### Dependancies" << endl << endl;
+ t << "###### Dependencies" << endl << endl;
t << odir << ".deps/%.d: %.cpp\n\t"
@@ -388,3 +393,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
//real target
- t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t";
+ t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps
+ << " " << var("POST_TARGETDEPS") << "\n\t";
if(!destdir.isEmpty())
@@ -401,3 +407,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
- t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t";
+ t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
+ << var("POST_TARGETDEPS") << "\n\t";
if(!destdir.isEmpty())
@@ -462,4 +469,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
//real target
- t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " <<
- var("TARGETDEPS");
+ t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " "
+ << incr_deps << " $(SUBLIBS) " << var("POST_TARGETDEPS");
} else {
@@ -467,4 +474,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
var("DESTDIR_TARGET") << endl << endl;
- t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " <<
- var("TARGETDEPS");
+ t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS")
+ << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << var("POST_TARGETDEPS");
}
@@ -485,16 +492,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &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 {
+ } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
t << "\n\t"
@@ -515,2 +509,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << endl << endl;
+ } else {
+ 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;
}
@@ -520,6 +527,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "staticlib: $(TARGETA)" << endl << endl;
- t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)";
+ t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC)";
if(do_incremental)
t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
- t << var("TARGETDEPS") << "\n\t"
+ t << var("POST_TARGETDEPS") << "\n\t"
<< "-$(DEL_FILE) $(TARGETA) " << "\n\t"
@@ -533,3 +540,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} else {
- t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
+ t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
<< varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n"
@@ -537,3 +544,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
- t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t";
+ t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
+ << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("POST_TARGETDEPS") << "\n\t";
if(!project->isEmpty("DESTDIR")) {
@@ -548,3 +556,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
- if(!project->isEmpty("DESTDIR"))
+ if(!project->isEmpty("DESTDIR"))
t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n"
@@ -552,3 +560,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} else {
- int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
+ int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"],
@@ -556,6 +564,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
libs.prepend("$(TARGET)");
- for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
+ 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++)
+ for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
build << (*objit);
@@ -563,6 +571,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
if((*libit) == "$(TARGET)") {
- t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) "
- << valList(build) << "\n\t";
+ t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
+ << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
ar = project->variables()["QMAKE_AR_CMD"].first();
- ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
+ ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
build.join(" "));
@@ -582,3 +590,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\t" << "$(RANLIB) " << (*libit) << "\n";
- if(!project->isEmpty("DESTDIR"))
+ if(!project->isEmpty("DESTDIR"))
t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n"
@@ -594,3 +602,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
//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
+ //moc itself shouldn't have this dependency - this is a little kludgy but it is
//better than the alternative for now.
@@ -599,3 +607,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
fixEnvVariables(moc);
- if(target != moc)
+ if(target != moc)
t << "$(MOC): \n\t"
@@ -645,3 +653,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
QString ui_h = fileFixify((*formit) + Option::h_ext.first());
- if(QFile::exists(ui_h) )
+ if(QFile::exists(ui_h) )
ui_headers << ui_h;
@@ -655,3 +663,3 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && "
- << "$(DEL_DIR) " << ddir_c
+ << "$(DEL_FILE) -r " << ddir_c
<< endl << endl;
@@ -679,2 +687,41 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
+ t << "yaccclean:" << "\n";
+ if(!var("YACCSOURCES").isEmpty()) {
+ QStringList clean, &l = project->variables()["YACCSOURCES"];
+ for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ QFileInfo fi((*it));
+ 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;
+ clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
+ clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
+ }
+ if(!clean.isEmpty()) {
+ t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
+ clean_targets += " yaccclean";
+ }
+ }
+
+ t << "lexclean:" << "\n";
+ if(!var("LEXSOURCES").isEmpty()) {
+ QStringList clean, &l = project->variables()["LEXSOURCES"];
+ for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ QFileInfo fi((*it));
+ 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;
+ clean << dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
+ }
+ if(!clean.isEmpty()) {
+ t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
+ clean_targets += " lexclean";
+ }
+ }
+
if(do_incremental) {
@@ -712,4 +759,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
destdir += Option::dir_sep;
- t << "distclean: " << "clean\n\t"
- << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
+ t << "distclean: " << "clean\n";
+ if(project->first("TEMPLATE") == "app" &&
+ project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
+ t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n";
+ else
+ t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
@@ -808,3 +859,3 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
t << "SUBTARGETS = "; // subdirectory targets are sub-directory
- for( it.toFirst(); it.current(); ++it)
+ for( it.toFirst(); it.current(); ++it)
t << " \\\n\t\t" << it.current()->target;
@@ -837,3 +888,3 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
++it;
- if (it.current())
+ if (it.current())
t << it.current()->target << ": " << tar << endl;
@@ -846,3 +897,3 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
if(project->isEmpty("SUBDIRS")) {
- t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl;
+ t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl;
} else {
@@ -860,3 +911,3 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
- t << "grep \"^qmake_all:\" " << (*it)->makefile
+ t << "grep \"^qmake_all:\" " << (*it)->makefile
<< " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
@@ -864,3 +915,3 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
t << endl;
- t << "clean uninstall install uiclean mocclean: qmake_all FORCE";
+ t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE";
for( it.toFirst(); it.current(); ++it) {
@@ -908,2 +959,4 @@ void UnixMakefileGenerator::init2()
project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
+ if ( !project->variables()["QMAKE_CYGWIN_EXE"].isEmpty() )
+ project->variables()["TARGET_EXT"].append(".exe");
} else if ( project->isActiveConfig("staticlib") ) {
@@ -919,3 +972,2 @@ void UnixMakefileGenerator::init2()
project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
- QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
if( project->isActiveConfig("plugin") ) {
@@ -925,3 +977,3 @@ void UnixMakefileGenerator::init2()
project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
- project->first("VER_MAJ") + "." +
+ project->first("VER_MAJ") + "." +
project->first("QMAKE_EXTENSION_SHLIB"));
@@ -935,12 +987,12 @@ void UnixMakefileGenerator::init2()
project->variables()["DEFINES"].append("QT_PLUGIN");
- } else if ( os == "hpux" ) {
+ } else if ( !project->isEmpty("QMAKE_HPUX_SHLIB") ) {
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->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." +
project->first("TARGET"));
else
- project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
+ project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
project->first("VER_MAJ"));
project->variables()["TARGET"] = project->variables()["TARGET_x"];
- } else if ( os == "aix" ) {
+ } else if ( !project->isEmpty("QMAKE_AIX_SHLIB") ) {
project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a");
@@ -1013,4 +1065,11 @@ void UnixMakefileGenerator::init2()
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_LFLAGS_SONAME"].isEmpty()) {
+ if(project->isActiveConfig("plugin")) {
+ if(!project->variables()["TARGET"].isEmpty() )
+ project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
+ } else {
+ if(!project->variables()["TARGET_x"].isEmpty() )
+ project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x");
+ }
+ }
if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )