cmLocalUnixMakefileGenerator.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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 cmDependInformation;
  17. class cmMakeDepend;
  18. class cmTarget;
  19. class cmSourceFile;
  20. /** \class cmLocalUnixMakefileGenerator
  21. * \brief Write a LocalUnix makefiles.
  22. *
  23. * cmLocalUnixMakefileGenerator produces a LocalUnix makefile from its
  24. * member m_Makefile.
  25. */
  26. class cmLocalUnixMakefileGenerator : public cmLocalGenerator
  27. {
  28. public:
  29. ///! Set cache only and recurse to false by default.
  30. cmLocalUnixMakefileGenerator();
  31. virtual ~cmLocalUnixMakefileGenerator();
  32. /**
  33. * Generate the makefile for this directory. fromTheTop indicates if this
  34. * is being invoked as part of a global Generate or specific to this
  35. * directory. The difference is that when done from the Top we might skip
  36. * some steps to save time, such as dependency generation for the
  37. * makefiles. This is done by a direct invocation from make.
  38. */
  39. virtual void Generate(bool fromTheTop);
  40. /**
  41. * Output the depend information for all the classes
  42. * in the makefile. These would have been generated
  43. * by the class cmMakeDepend.
  44. */
  45. virtual bool OutputObjectDepends(std::ostream&);
  46. /**
  47. * Output the check depend information for all the classes
  48. * in the makefile. These would have been generated
  49. * by the class cmMakeDepend.
  50. */
  51. virtual void OutputCheckDepends(std::ostream&);
  52. /**
  53. * Set to true if the shell being used is the windows shell.
  54. * This controls if statements in the makefile and the SHELL variable.
  55. * The default is false.
  56. */
  57. void SetWindowsShell(bool v) {m_WindowsShell = v;}
  58. ///! Set the string used to include one makefile into another default is include.
  59. void SetIncludeDirective(const char* s) { m_IncludeDirective = s; }
  60. ///! Set the flag used to keep the make program silent.
  61. void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; }
  62. ///! Set max makefile variable size, default is 0 which means unlimited.
  63. void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
  64. ///! If ignore lib prefix is true, then do not strip lib from the name of a library.
  65. void SetIgnoreLibPrefix(bool s) { m_IgnoreLibPrefix = s; }
  66. /**
  67. * If true, then explicitly pass MAKEFLAGS on the make all target for makes
  68. * that do not use environment variables.
  69. *
  70. */
  71. void SetPassMakeflags(bool s){m_PassMakeflags = s;}
  72. protected:
  73. void AddDependenciesToSourceFile(cmDependInformation const*info,
  74. cmSourceFile *i,
  75. std::set<cmDependInformation const*> *visited);
  76. virtual const char* GetSafeDefinition(const char*);
  77. virtual void ProcessDepends(const cmMakeDepend &md);
  78. virtual void OutputMakefile(const char* file, bool withDepends);
  79. virtual void OutputTargetRules(std::ostream& fout);
  80. virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
  81. void OutputLibraryRule(std::ostream& fout,
  82. const char* name,
  83. const cmTarget &t,
  84. const char* createRule,
  85. const char* comment,
  86. const char* linkFlags
  87. );
  88. void ExpandRuleVariables(std::string& string,
  89. const char* objects=0,
  90. const char* target=0,
  91. const char* linkLibs=0,
  92. const char* source=0,
  93. const char* object =0,
  94. const char* flags = 0,
  95. const char* objectsquoted = 0,
  96. const char* targetBase = 0,
  97. const char* targetSOName = 0,
  98. const char* linkFlags = 0);
  99. virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
  100. const cmTarget &);
  101. virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
  102. const cmTarget &);
  103. virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
  104. const cmTarget &);
  105. virtual void OutputExecutableRule(std::ostream&, const char* name,
  106. const cmTarget &);
  107. virtual void OutputUtilityRule(std::ostream&, const char* name,
  108. const cmTarget &);
  109. virtual void OutputTargets(std::ostream&);
  110. virtual void OutputSubDirectoryRules(std::ostream&);
  111. virtual void OutputDependLibs(std::ostream&);
  112. virtual void OutputLibDepend(std::ostream&, const char*);
  113. virtual void OutputExeDepend(std::ostream&, const char*);
  114. virtual void OutputCustomRules(std::ostream&);
  115. virtual void OutputMakeVariables(std::ostream&);
  116. virtual void OutputMakeRules(std::ostream&);
  117. virtual void OutputInstallRules(std::ostream&);
  118. virtual void OutputSourceObjectBuildRules(std::ostream& fout);
  119. virtual void OutputBuildObjectFromSource(std::ostream& fout,
  120. const char* shortName,
  121. const cmSourceFile& source,
  122. const char* extraCompileFlags,
  123. bool sharedTarget);
  124. virtual void BuildInSubDirectory(std::ostream& fout,
  125. const char* directory,
  126. const char* target1,
  127. const char* target2,
  128. bool silent = false);
  129. virtual void BuildInSubDirectoryWindows(std::ostream& fout,
  130. const char* directory,
  131. const char* target1,
  132. const char* target2,
  133. bool silent = false);
  134. virtual void OutputSubDirectoryVars(std::ostream& fout,
  135. const char* var,
  136. const char* target,
  137. const char* target1,
  138. const char* target2,
  139. const char* depend,
  140. const std::vector<std::string>&
  141. SubDirectories,
  142. bool silent = false);
  143. virtual void OutputMakeRule(std::ostream&,
  144. const char* comment,
  145. const char* target,
  146. const char* depends,
  147. const std::vector<std::string>& commands);
  148. virtual void OutputMakeRule(std::ostream&,
  149. const char* comment,
  150. const char* target,
  151. const std::vector<std::string>& depends,
  152. const char* command);
  153. virtual void OutputMakeRule(std::ostream&,
  154. const char* comment,
  155. const char* target,
  156. const std::vector<std::string>& depends,
  157. const std::vector<std::string>& commands);
  158. virtual void OutputMakeRule(std::ostream&,
  159. const char* comment,
  160. const char* target,
  161. const char* depends,
  162. const char* command,
  163. const char* command2 = 0,
  164. const char* command3 = 0,
  165. const char* command4 = 0);
  166. virtual void OutputBuildTargetInDirWindows(std::ostream& fout,
  167. const char* path,
  168. const char* library,
  169. const char* fullpath,
  170. const char* outputPath);
  171. virtual void OutputBuildTargetInDir(std::ostream& fout,
  172. const char* path,
  173. const char* library,
  174. const char* fullpath,
  175. const char* outputPath);
  176. ///! return true if the two paths are the same
  177. virtual bool SamePath(const char* path1, const char* path2);
  178. virtual std::string GetOutputExtension(const char* sourceExtension);
  179. std::string CreatePreBuildRules(const cmTarget &target,
  180. const char* targetName);
  181. std::string CreatePreLinkRules(const cmTarget &target,
  182. const char* targetName);
  183. std::string CreatePostBuildRules(const cmTarget &target,
  184. const char* targetName);
  185. virtual std::string CreateMakeVariable(const char* s, const char* s2);
  186. ///! if the OS is case insensitive then return a lower case of the path.
  187. virtual std::string LowerCasePath(const char* path);
  188. ///! for existing files convert to output path and short path if spaces
  189. std::string ConvertToOutputForExisting(const char*);
  190. /** Get the full name of the target's file, without path. */
  191. std::string GetFullTargetName(const char* n, const cmTarget& t);
  192. /** Get the base name of the target's file, without path or extension. */
  193. std::string GetBaseTargetName(const char* n, const cmTarget& t);
  194. /** Get the names associated with a library target. */
  195. void GetLibraryNames(const char* n, const cmTarget& t,
  196. std::string& name,
  197. std::string& soName,
  198. std::string& realName,
  199. std::string& baseName);
  200. /** Output an echo command to the Makefile */
  201. void OutputEcho(std::ostream& fout, const char *msg);
  202. ///! final processing for a path to be put in a makefile
  203. std::string ConvertToMakefilePath(const char* p);
  204. protected:
  205. int m_MakefileVariableSize;
  206. std::map<cmStdString, cmStdString> m_MakeVariableMap;
  207. std::map<cmStdString, cmStdString> m_ShortMakeVariableMap;
  208. bool m_IgnoreLibPrefix;
  209. std::string m_IncludeDirective;
  210. std::string m_MakeSilentFlag;
  211. std::string m_ExecutableOutputPath;
  212. std::string m_LibraryOutputPath;
  213. std::string m_RelativePathToSourceDir;
  214. std::string m_RelativePathToBinaryDir;
  215. std::string m_CurrentOutputDirectory;
  216. std::string m_HomeOutputDirectory;
  217. std::string m_HomeDirectory;
  218. std::string m_HomeOutputDirectoryNoSlash;
  219. bool m_WindowsShell;
  220. bool m_PassMakeflags;
  221. private:
  222. };
  223. #endif