From a2f148936b335c6ebb31d2fa7bfef521a043330c Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 25 May 2005 15:09:06 -0400 Subject: ENH: added clean target for subdirs --- Source/cmGlobalUnixMakefileGenerator3.cxx | 52 ++++++++++++++++++++++++++++++- Source/cmLocalUnixMakefileGenerator3.cxx | 34 ++++++-------------- 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 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 subdirs = lg->GetChildren(); + + // for each subdir add the directory depend + std::vector::iterator sdi = subdirs.begin(); + for (; sdi != subdirs.end(); ++sdi) + { + cmLocalUnixMakefileGenerator3 * lg2 = + static_cast(*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 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 no_depends; - std::vector 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 depends; std::vector 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); } -- cgit v0.12