cmLocalUnixMakefileGenerator.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 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 cmLocalUnixMakefileGenerator_h
  14. #define cmLocalUnixMakefileGenerator_h
  15. #include "cmLocalGenerator.h"
  16. class cmMakeDepend;
  17. class cmTarget;
  18. class cmSourceFile;
  19. /** \class cmLocalUnixMakefileGenerator
  20. * \brief Write a LocalUnix makefiles.
  21. *
  22. * cmLocalUnixMakefileGenerator produces a LocalUnix makefile from its
  23. * member m_Makefile.
  24. */
  25. class cmLocalUnixMakefileGenerator : public cmLocalGenerator
  26. {
  27. public:
  28. ///! Set cache only and recurse to false by default.
  29. cmLocalUnixMakefileGenerator();
  30. virtual ~cmLocalUnixMakefileGenerator();
  31. /**
  32. * Generate the makefile for this directory. fromTheTop indicates if this
  33. * is being invoked as part of a global Generate or specific to this
  34. * directory. The difference is that when done from the Top we might skip
  35. * some steps to save time, such as dependency generation for the
  36. * makefiles. This is done by a direct invocation from make.
  37. */
  38. virtual void Generate(bool fromTheTop);
  39. /**
  40. * Output the depend information for all the classes
  41. * in the makefile. These would have been generated
  42. * by the class cmMakeDepend.
  43. */
  44. virtual bool OutputObjectDepends(std::ostream&);
  45. /**
  46. * Output the check depend information for all the classes
  47. * in the makefile. These would have been generated
  48. * by the class cmMakeDepend.
  49. */
  50. virtual void OutputCheckDepends(std::ostream&);
  51. /**
  52. * Set to true if the shell being used is the windows shell.
  53. * This controls if statements in the makefile and the SHELL variable.
  54. * The default is false.
  55. */
  56. void SetWindowsShell(bool v) {m_WindowsShell = v;}
  57. ///! Set the string used to include one makefile into another default is include.
  58. void SetIncludeDirective(const char* s) { m_IncludeDirective = s; }
  59. ///! Set the flag used to keep the make program silent.
  60. void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; }
  61. ///! Set max makefile variable size, default is 0 which means unlimited.
  62. void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
  63. protected:
  64. virtual const char* GetSafeDefinition(const char*);
  65. virtual void ProcessDepends(const cmMakeDepend &md);
  66. virtual void OutputMakefile(const char* file, bool withDepends);
  67. virtual void OutputTargetRules(std::ostream& fout);
  68. virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
  69. void OutputLibraryRule(std::ostream& fout,
  70. const char* name,
  71. const cmTarget &t,
  72. const char* prefix,
  73. const char* suffix,
  74. const char* createRule,
  75. const char* comment,
  76. const char* linkFlags
  77. );
  78. void ExpandRuleVariables(std::string& string,
  79. const char* objects=0,
  80. const char* target=0,
  81. const char* linkLibs=0,
  82. const char* source=0,
  83. const char* object =0,
  84. const char* flags = 0,
  85. const char* objectsquoted = 0,
  86. const char* targetBase = 0,
  87. const char* linkFlags = 0);
  88. virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
  89. const cmTarget &);
  90. virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
  91. const cmTarget &);
  92. virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
  93. const cmTarget &);
  94. virtual void OutputExecutableRule(std::ostream&, const char* name,
  95. const cmTarget &);
  96. virtual void OutputUtilityRule(std::ostream&, const char* name,
  97. const cmTarget &);
  98. virtual void OutputTargets(std::ostream&);
  99. virtual void OutputSubDirectoryRules(std::ostream&);
  100. virtual void OutputDependLibs(std::ostream&);
  101. virtual void OutputLibDepend(std::ostream&, const char*);
  102. virtual void OutputExeDepend(std::ostream&, const char*);
  103. virtual void OutputCustomRules(std::ostream&);
  104. virtual void OutputMakeVariables(std::ostream&);
  105. virtual void OutputMakeRules(std::ostream&);
  106. virtual void OutputInstallRules(std::ostream&);
  107. virtual void OutputSourceObjectBuildRules(std::ostream& fout);
  108. virtual void OutputBuildObjectFromSource(std::ostream& fout,
  109. const char* shortName,
  110. const cmSourceFile& source,
  111. const char* extraCompileFlags,
  112. bool sharedTarget);
  113. virtual void BuildInSubDirectory(std::ostream& fout,
  114. const char* directory,
  115. const char* target1,
  116. const char* target2,
  117. bool silent = false);
  118. virtual void BuildInSubDirectoryWindows(std::ostream& fout,
  119. const char* directory,
  120. const char* target1,
  121. const char* target2,
  122. bool silent = false);
  123. virtual void OutputSubDirectoryVars(std::ostream& fout,
  124. const char* var,
  125. const char* target,
  126. const char* target1,
  127. const char* target2,
  128. const char* depend,
  129. const std::vector<std::string>&
  130. SubDirectories,
  131. bool silent = false);
  132. virtual void OutputMakeRule(std::ostream&,
  133. const char* comment,
  134. const char* target,
  135. const char* depends,
  136. const std::vector<std::string>& commands);
  137. virtual void OutputMakeRule(std::ostream&,
  138. const char* comment,
  139. const char* target,
  140. const char* depends,
  141. const char* command,
  142. const char* command2 = 0,
  143. const char* command3 = 0,
  144. const char* command4 = 0);
  145. virtual void OutputBuildTargetInDirWindows(std::ostream& fout,
  146. const char* path,
  147. const char* library,
  148. const char* fullpath,
  149. const char* outputPath);
  150. virtual void OutputBuildTargetInDir(std::ostream& fout,
  151. const char* path,
  152. const char* library,
  153. const char* fullpath,
  154. const char* outputPath);
  155. ///! return true if the two paths are the same
  156. virtual bool SamePath(const char* path1, const char* path2);
  157. virtual std::string GetOutputExtension(const char* sourceExtension);
  158. std::string CreateTargetRules(const cmTarget &target,
  159. const char* targetName);
  160. virtual std::string CreateMakeVariable(const char* s, const char* s2);
  161. ///! if the OS is case insensitive then return a lower case of the path.
  162. virtual std::string LowerCasePath(const char* path);
  163. ///! for existing files convert to output path and short path if spaces
  164. std::string ConvertToOutputForExisting(const char*);
  165. protected:
  166. int m_MakefileVariableSize;
  167. std::map<cmStdString, cmStdString> m_MakeVariableMap;
  168. std::map<cmStdString, cmStdString> m_ShortMakeVariableMap;
  169. std::string m_IncludeDirective;
  170. std::string m_MakeSilentFlag;
  171. std::string m_ExecutableOutputPath;
  172. std::string m_LibraryOutputPath;
  173. bool m_WindowsShell;
  174. private:
  175. };
  176. #endif