📄 unixmake2.cpp
字号:
t << "clean:" << clean_targets << "\n\t"; if(!project->isEmpty("OBJECTS")) t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; if(!project->isEmpty("IMAGES")) t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; if(src_incremental) t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") << "-$(DEL_FILE) *~ core *.core" << "\n" << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; t << "####### Sub-libraries" << endl << endl; if ( !project->variables()["SUBLIBS"].isEmpty() ) { QString libdir = "tmp/"; if(!project->isEmpty("SUBLIBS_DIR")) libdir = project->first("SUBLIBS_DIR"); QStringList &l = project->variables()["SUBLIBS"]; for(it = l.begin(); it != l.end(); ++it) t << libdir << "lib" << (*it) << ".a" << ":\n\t" << var(QString("MAKELIB") + (*it)) << endl << endl; } QString destdir = project->first("DESTDIR"); if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) destdir += Option::dir_sep; 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() && !project->isActiveConfig("plugin")) t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " << destdir << "$(TARGET2) $(TARGETA)" << "\n"; t << endl << endl; if ( !project->isEmpty("PRECOMPH") ) { QString outdir = project->first("MOC_DIR"); QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); t << "###### Combined headers" << endl << endl; //XXX t << outdir << "allmoc.cpp: " << qt_dot_h << " " << varList("HEADERS_ORIG") << "\n\t" << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " << outdir << "allmoc.cpp" << "\n\t" << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; } // blasted user defined targets QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; for(it = qut.begin(); it != qut.end(); ++it) { QString targ = var((*it) + ".target"), cmd = var((*it) + ".commands"), deps; if(targ.isEmpty()) targ = (*it); QStringList &deplist = project->variables()[(*it) + ".depends"]; for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { QString dep = var((*dep_it) + ".target"); if(dep.isEmpty()) dep = (*dep_it); deps += " " + dep; } t << targ << ":" << deps << "\n\t" << cmd << endl << endl; } t <<"FORCE:" << endl << endl;}struct SubDir{ QString directory, profile, target, makefile;};voidUnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct){ QPtrList<SubDir> subdirs; { QStringList subdirs_in = project->variables()["SUBDIRS"]; for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { QString file = (*it); fileFixify(file); SubDir *sd = new SubDir; subdirs.append(sd); sd->makefile = "$(MAKEFILE)"; if((*it).right(4) == ".pro") { int slsh = file.findRev(Option::dir_sep); if(slsh != -1) { sd->directory = file.left(slsh+1); sd->profile = file.mid(slsh+1); } else { sd->profile = file; } } else { sd->directory = file; } while(sd->directory.right(1) == Option::dir_sep) sd->directory = sd->directory.left(sd->directory.length() - 1); if(!sd->profile.isEmpty()) { QString basename = sd->directory; int new_slsh = basename.findRev(Option::dir_sep); if(new_slsh != -1) basename = basename.mid(new_slsh+1); if(sd->profile != basename + ".pro") sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro } sd->target = "sub-" + (*it); sd->target.replace('/', '-'); sd->target.replace('.', '_'); } } QPtrListIterator<SubDir> it(subdirs); QString ofile = Option::output.name(); if(ofile.findRev(Option::dir_sep) != -1) ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1); t << "MAKEFILE = " << var("MAKEFILE") << endl; t << "QMAKE = " << var("QMAKE") << endl; t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "SUBTARGETS = "; // subdirectory targets are sub-directory for( it.toFirst(); it.current(); ++it) t << " \\\n\t\t" << it.current()->target; t << endl << endl; t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl; // generate target rules for( it.toFirst(); it.current(); ++it) { bool have_dir = !(*it)->directory.isEmpty(); QString mkfile = (*it)->makefile, out; if(have_dir) mkfile.prepend((*it)->directory + Option::dir_sep); if(direct || (*it)->makefile != "$(MAKEFILE)") out = " -o " + (*it)->makefile; //qmake it t << mkfile << ": " << "\n\t"; if(have_dir) t << "cd " << (*it)->directory << " && "; t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; //actually compile t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; if(have_dir) t << "cd " << (*it)->directory << " && "; t << "$(MAKE) -f " << (*it)->makefile << endl << endl; } if (project->isActiveConfig("ordered")) { // generate dependencies for( it.toFirst(); it.current(); ) { QString tar = it.current()->target; ++it; if (it.current()) t << it.current()->target << ": " << tar << endl; } t << endl; } writeMakeQmake(t); if(project->isEmpty("SUBDIRS")) { t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl; } else { t << "all: $(SUBTARGETS)" << endl; t << "qmake_all:"; for( it.toFirst(); it.current(); ++it) { t << " "; if(!(*it)->directory.isEmpty()) t << (*it)->directory << Option::dir_sep; t << (*it)->makefile; } for( it.toFirst(); it.current(); ++it) { t << "\n\t ( "; if(!(*it)->directory.isEmpty()) t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; t << "grep \"^qmake_all:\" " << (*it)->makefile << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; } t << endl; t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE"; for( it.toFirst(); it.current(); ++it) { t << "\n\t ( "; if(!(*it)->directory.isEmpty()) t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; } t << endl; t << "distclean: qmake_all FORCE"; for( it.toFirst(); it.current(); ++it) { t << "\n\t ( "; if(!(*it)->directory.isEmpty()) t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true"; } t << endl << endl; } t <<"FORCE:" << endl << endl;}void UnixMakefileGenerator::init2(){ //version handling if(project->variables()["VERSION"].isEmpty()) project->variables()["VERSION"].append("1.0." + (project->isEmpty("VER_PAT") ? QString("0") : project->first("VER_PAT")) ); QStringList l = QStringList::split('.', project->first("VERSION")); l << "0" << "0"; //make sure there are three project->variables()["VER_MAJ"].append(l[0]); project->variables()["VER_MIN"].append(l[1]); project->variables()["VER_PAT"].append(l[2]); if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {#if 0 if ( project->isActiveConfig("dll") ) { project->variables()["TARGET"] += project->variables()["TARGET.so"]; if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty()) project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET"); }#endif project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); } else if ( project->isActiveConfig("staticlib") ) { project->variables()["TARGET"].first().prepend("lib"); project->variables()["TARGET"].first() += ".a"; if(project->variables()["QMAKE_AR_CMD"].isEmpty()) project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); } else { project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); else project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); if( project->isActiveConfig("plugin") ) { project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); if(project->isActiveConfig("lib_version_first")) project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("QMAKE_EXTENSION_SHLIB")); else project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ")); project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; if(project->isActiveConfig("qt")) project->variables()["DEFINES"].append("QT_PLUGIN"); } 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->first("TARGET")); else project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ")); project->variables()["TARGET"] = project->variables()["TARGET_x"]; } else if ( !project->isEmpty("QMAKE_AIX_SHLIB") ) { project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a"); if(project->isActiveConfig("lib_version_first")) { project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("QMAKE_EXTENSION_SHLIB")); project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("QMAKE_EXTENSION_SHLIB")); project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT") + "." + project->first("QMAKE_EXTENSION_SHLIB")); } else { project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ")); project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN")); project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT")); } project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; } else { project->variables()["TARGET_"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); if(project->isActiveConfig("lib_version_first")) { project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("QMAKE_EXTENSION_SHLIB")); project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("QMAKE_EXTENSION_SHLIB")); project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT") + "." + project->variables()["QMAKE_EXTENSION_SHLIB"].first()); } else { project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ")); project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN")); project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + project->variables()[ "QMAKE_EXTENSION_SHLIB"].first() + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT")); } project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; } if(project->isEmpty("QMAKE_LN_SHLIB")) project->variables()["QMAKE_LN_SHLIB"].append("ln -s"); project->variables()["DESTDIR_TARGET"].append("$(TARGET)"); if ( !project->variables()["DESTDIR"].isEmpty() ) 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_LINK_SHLIB_CMD"].isEmpty() ) project->variables()["QMAKE_LINK_SHLIB_CMD"].append( "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); } if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; } else if ( project->isActiveConfig("dll") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; if ( project->isActiveConfig("plugin") ) { project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; if( !project->isActiveConfig("plugin_no_soname") ) project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; } else { project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; } QString destdir = project->first("DESTDIR"); if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) { QString rpath_destdir = destdir; if(QDir::isRelativePath(rpath_destdir)) { QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir)); if(fi.convertToAbs()) //strange, shouldn't really happen rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); else rpath_destdir = fi.filePath(); } else { rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); } project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -