cmGlobalUnixMakefileGenerator3.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator3
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2005 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmGlobalUnixMakefileGenerator3_h
  14. #define cmGlobalUnixMakefileGenerator3_h
  15. #include "cmGlobalGenerator.h"
  16. class cmGeneratedFileStream;
  17. class cmLocalUnixMakefileGenerator3;
  18. /** \class cmGlobalUnixMakefileGenerator3
  19. * \brief Write a Unix makefiles.
  20. *
  21. * cmGlobalUnixMakefileGenerator3 manages UNIX build process for a tree
  22. The basic approach of this generator is to produce Makefiles that will all
  23. be run with the current working directory set to the Home Output
  24. directory. The one exception to this is the subdirectory Makefiles which are
  25. created as a convenience and just cd up to the Home Output directory and
  26. invoke the main Makefiles.
  27. The make process starts with Makefile. Makefile should only contain the
  28. targets the user is likely to invoke directly from a make command line. No
  29. internal targets should be in this file. Makefile2 contains the internal
  30. targets that are required to make the process work.
  31. Makefile2 in turn will recursively make targets in the correct order. Each
  32. target has its own directory <target>.dir and its own makefile build.make in
  33. that directory. Also in that directory is a couple makefiles per source file
  34. used by the target. Typically these are named source.obj.build.make and
  35. source.obj.build.depend.make. The source.obj.build.make contains the rules
  36. for building, cleaning, and computing dependencies for the given source
  37. file. The build.depend.make contains additional dependencies that were
  38. computed during dependency scanning. An additional file called
  39. source.obj.depend is used as a marker to indicate when dependencies must be
  40. rescanned.
  41. Rules for custom commands follow the same model as rules for source files.
  42. */
  43. class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
  44. {
  45. public:
  46. cmGlobalUnixMakefileGenerator3();
  47. static cmGlobalGenerator* New() { return new cmGlobalUnixMakefileGenerator3; }
  48. ///! Get the name for the generator.
  49. virtual const char* GetName() const {
  50. return cmGlobalUnixMakefileGenerator3::GetActualName();}
  51. static const char* GetActualName() {return "Unix Makefiles";}
  52. /** Get the documentation entry for this generator. */
  53. virtual void GetDocumentation(cmDocumentationEntry& entry) const;
  54. ///! Create a local generator appropriate to this Global Generator3
  55. virtual cmLocalGenerator *CreateLocalGenerator();
  56. /**
  57. * Try to determine system infomation such as shared library
  58. * extension, pthreads, byte order etc.
  59. */
  60. virtual void EnableLanguage(std::vector<std::string>const& languages,
  61. cmMakefile *);
  62. /**
  63. * Generate the all required files for building this project/tree. This
  64. * basically creates a series of LocalGenerators for each directory and
  65. * requests that they Generate.
  66. */
  67. virtual void Generate();
  68. void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
  69. std::vector<cmLocalGenerator *> &);
  70. // write out the help rule listing the valid targets
  71. void WriteHelpRule(std::ostream& ruleFileStream,
  72. cmLocalUnixMakefileGenerator3 *);
  73. // write the top lvel target rules
  74. void WriteConvenienceRules(std::ostream& ruleFileStream,
  75. std::set<cmStdString> &emitted);
  76. /** In order to support parallel builds for custom commands with
  77. multiple outputs the outputs are given a serial order, and only
  78. the first output actually has the build rule. Other outputs
  79. just depend on the first one. The check-build-system step must
  80. remove a dependee if the depender is missing to make sure both
  81. are regenerated properly. This method is used by the local
  82. makefile generators to register such pairs. */
  83. void AddMultipleOutputPair(const char* depender, const char* dependee);
  84. /** Support for multiple custom command outputs. Called during
  85. check-build-system step. */
  86. virtual void CheckMultipleOutputs(cmMakefile* mf, bool verbose);
  87. protected:
  88. void WriteMainMakefile2();
  89. void WriteMainCMakefile();
  90. void WriteConvenienceRules2(std::ostream& ruleFileStream,
  91. cmLocalUnixMakefileGenerator3 *,
  92. bool exclude);
  93. void WriteDirectoryRule2(std::ostream& ruleFileStream,
  94. cmLocalUnixMakefileGenerator3* lg,
  95. const char* pass, bool check_all,
  96. bool check_relink);
  97. void WriteDirectoryRules2(std::ostream& ruleFileStream,
  98. cmLocalUnixMakefileGenerator3* lg);
  99. void AppendGlobalTargetDepends(std::vector<std::string>& depends,
  100. cmTarget& target);
  101. void AppendAnyGlobalDepend(std::vector<std::string>& depends,
  102. const char* name,
  103. std::set<cmStdString>& emitted,
  104. cmTarget &target);
  105. // does this generator need a requires step for any of its targets
  106. bool NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg, const char *);
  107. // Setup target names
  108. virtual const char* GetAllTargetName() { return "all"; }
  109. virtual const char* GetInstallTargetName() { return "install"; }
  110. virtual const char* GetPreinstallTargetName() { return "preinstall"; }
  111. virtual const char* GetTestTargetName() { return "test"; }
  112. virtual const char* GetPackageTargetName() { return "package"; }
  113. virtual const char* GetEditCacheTargetName() { return "edit_cache"; }
  114. virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; }
  115. // Some make programs (Borland) do not keep a rule if there are no
  116. // dependencies or commands. This is a problem for creating rules
  117. // that might not do anything but might have other dependencies
  118. // added later. If non-empty this variable holds a fake dependency
  119. // that can be added.
  120. std::string EmptyRuleHackDepends;
  121. typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
  122. MultipleOutputPairsType MultipleOutputPairs;
  123. };
  124. #endif