summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-05-25 19:09:06 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-05-25 19:09:06 (GMT)
commita2f148936b335c6ebb31d2fa7bfef521a043330c (patch)
tree832c9d5cc87dae1136def3176b5b6a4a191ea8f1
parentd7cbf3e1d6c3753b4d05cf43e0d9978ad154f5ff (diff)
downloadCMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.zip
CMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.tar.gz
CMake-a2f148936b335c6ebb31d2fa7bfef521a043330c.tar.bz2
ENH: added clean target for subdirs
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx52
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx34
2 files changed, 60 insertions, 26 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index d0ed30a..e5eb27c 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -477,7 +477,8 @@ cmGlobalUnixMakefileGenerator3
// write the directory rule
commands.clear();
- commands.push_back(lg->GetRecursiveMakeCall("Makefile",makeTargetName.c_str()));
+ commands.push_back
+ (lg->GetRecursiveMakeCall("Makefile",makeTargetName.c_str()));
// Write the rule.
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
@@ -488,7 +489,56 @@ cmGlobalUnixMakefileGenerator3
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
makeTargetName.c_str(), all_tgts, commands);
}
+
+ // now do the clean targets
+ if (lg->GetParent())
+ {
+ std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
+ dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
+ makeTargetName = dir;
+ makeTargetName += "/clean";
+
+ std::vector<std::string> all_tgts;
+
+ // for all of out targets
+ for (cmTargets::const_iterator l = lg->GetMakefile()->GetTargets().begin();
+ l != lg->GetMakefile()->GetTargets().end(); l++)
+ {
+ if((l->second.GetType() == cmTarget::EXECUTABLE) ||
+ (l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
+ (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
+ (l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
+ (l->second.GetType() == cmTarget::UTILITY))
+ {
+ // Add this to the list of depends rules in this directory.
+ std::string tname = lg->GetRelativeTargetDirectory(l->second);
+ tname += "/clean";
+ all_tgts.push_back(tname);
+ }
+ }
+ // write the directory rule add in the subdirs
+ std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
+
+ // for each subdir add the directory depend
+ std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
+ for (; sdi != subdirs.end(); ++sdi)
+ {
+ cmLocalUnixMakefileGenerator3 * lg2 =
+ static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
+ dir = lg2->GetMakefile()->GetStartOutputDirectory();
+ dir += "/clean";
+ dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKEFILE);
+ all_tgts.push_back(dir);
+ }
+
+ // write the directory clean rule
+ commands.clear();
+ lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
+ makeTargetName.c_str(), all_tgts, commands);
+ }
+
// for each target Generate the rule files for each target.
const cmTargets& targets = lg->GetMakefile()->GetTargets();
bool needRequiresStep = this->NeedRequiresStep(lg);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index d507fdc..0ea53bf 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -611,30 +611,6 @@ cmLocalUnixMakefileGenerator3
p_depends.push_back(relativeObj);
this->WriteMakeRule(ruleFileStream, 0,
temp.c_str(), p_depends, no_commands);
-
-#if 0
- if(strcmp(lang, "Fortran") == 0)
- {
- std::string objectProvides = obj;
- objectProvides += ".provides";
- // Add the provides target to build the object file.
- std::vector<std::string> p_depends;
- p_depends.push_back(obj);
- this->WriteMakeRule(ruleFileStream, 0,
- objectProvides.c_str(), p_depends, no_commands);
-
- {
- // Add the requires.build target to recursively build the provides
- // target after needed information is up to date.
- std::vector<std::string> no_depends;
- std::vector<std::string> r_commands;
- r_commands.push_back(this->GetRecursiveMakeCall("Makefile",objectProvides.c_str()));
- objectRequires += ".build";
- this->WriteMakeRule(ruleFileStream, 0,
- objectRequires.c_str(), no_depends, r_commands);
- }
- }
-#endif
}
//----------------------------------------------------------------------------
@@ -2835,13 +2811,21 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
std::vector<std::string> depends;
std::vector<std::string> commands;
- // Write the empty all rule.
+ // Write the all rule.
std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/directorystart";
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
this->CreateJumpCommand(commands,dir);
this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands);
+ // Write the clean rule.
+ dir = m_Makefile->GetStartOutputDirectory();
+ dir += "/clean";
+ dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
+ commands.clear();
+ this->CreateJumpCommand(commands,dir);
+ this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands);
+
// recursively write our targets
this->WriteLocalMakefileTargets(ruleFileStream);
}