cmUnixMakefileGenerator.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 cmUnixMakefileGenerator_h
  14. #define cmUnixMakefileGenerator_h
  15. #include "cmMakefile.h"
  16. #include "cmMakefileGenerator.h"
  17. /** \class cmUnixMakefileGenerator
  18. * \brief Write a Unix makefiles.
  19. *
  20. * cmUnixMakefileGenerator produces a Unix makefile from its
  21. * member m_Makefile.
  22. */
  23. class cmUnixMakefileGenerator : public cmMakefileGenerator
  24. {
  25. public:
  26. ///! Set cache only and recurse to false by default.
  27. cmUnixMakefileGenerator();
  28. virtual ~cmUnixMakefileGenerator();
  29. ///! Get the name for the generator.
  30. virtual const char* GetName() {return "Unix Makefiles";}
  31. ///! virtual copy constructor
  32. virtual cmMakefileGenerator* CreateObject()
  33. { return new cmUnixMakefileGenerator;}
  34. //! just sets the Cache Only and Recurse flags
  35. virtual void SetLocal(bool local);
  36. /**
  37. * If cache only is on.
  38. * and only stub makefiles are generated, and no depends, for speed.
  39. * The default is OFF.
  40. **/
  41. void SetCacheOnlyOn() {m_CacheOnly = true;}
  42. void SetCacheOnlyOff() {m_CacheOnly = false;}
  43. /**
  44. * If recurse is on, then all the makefiles below this one are parsed as well.
  45. */
  46. void SetRecurseOn() {m_Recurse = true;}
  47. void SetRecurseOff() {m_Recurse = false;}
  48. /**
  49. * Produce the makefile (in this case a Unix makefile).
  50. */
  51. virtual void GenerateMakefile();
  52. /**
  53. * Output the depend information for all the classes
  54. * in the makefile. These would have been generated
  55. * by the class cmMakeDepend.
  56. */
  57. virtual bool OutputObjectDepends(std::ostream&);
  58. /**
  59. * Output the check depend information for all the classes
  60. * in the makefile. These would have been generated
  61. * by the class cmMakeDepend.
  62. */
  63. virtual void OutputCheckDepends(std::ostream&);
  64. /**
  65. * Try to determine system infomation such as shared library
  66. * extension, pthreads, byte order etc.
  67. */
  68. virtual void ComputeSystemInfo();
  69. protected:
  70. virtual void RecursiveGenerateCacheOnly();
  71. virtual void ProcessDepends(const cmMakeDepend &md);
  72. virtual void GenerateCacheOnly();
  73. virtual void OutputMakefile(const char* file);
  74. virtual void OutputTargetRules(std::ostream& fout);
  75. virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
  76. virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
  77. const cmTarget &);
  78. virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
  79. const cmTarget &);
  80. virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
  81. const cmTarget &);
  82. virtual void OutputExecutableRule(std::ostream&, const char* name,
  83. const cmTarget &);
  84. virtual void OutputTargets(std::ostream&);
  85. virtual void OutputSubDirectoryRules(std::ostream&);
  86. virtual void OutputDependLibs(std::ostream&);
  87. virtual void OutputLibDepend(std::ostream&, const char*);
  88. virtual void OutputExeDepend(std::ostream&, const char*);
  89. virtual void OutputCustomRules(std::ostream&);
  90. virtual void OutputMakeVariables(std::ostream&);
  91. virtual void OutputMakeRules(std::ostream&);
  92. virtual void OutputInstallRules(std::ostream&);
  93. virtual void OutputSourceObjectBuildRules(std::ostream& fout);
  94. virtual void OutputBuildObjectFromSource(std::ostream& fout,
  95. const char* shortName,
  96. const cmSourceFile& source,
  97. const char* extraCompileFlags,
  98. bool sharedTarget);
  99. virtual void BuildInSubDirectory(std::ostream& fout,
  100. const char* directory,
  101. const char* target1,
  102. const char* target2);
  103. virtual void OutputSubDirectoryVars(std::ostream& fout,
  104. const char* var,
  105. const char* target,
  106. const char* target1,
  107. const char* target2,
  108. const char* depend,
  109. const std::vector<std::string>&
  110. SubDirectories);
  111. virtual void OutputMakeRule(std::ostream&,
  112. const char* comment,
  113. const char* target,
  114. const char* depends,
  115. const char* command,
  116. const char* command2 = 0,
  117. const char* command3 = 0,
  118. const char* command4 = 0);
  119. virtual void OutputBuildLibraryInDir(std::ostream& fout,
  120. const char* path,
  121. const char* library,
  122. const char* fullpath);
  123. virtual void OutputBuildExecutableInDir(std::ostream& fout,
  124. const char* path,
  125. const char* library,
  126. const char* fullpath);
  127. ///! return true if the two paths are the same
  128. virtual bool SamePath(const char* path1, const char* path2);
  129. virtual std::string GetOutputExtension(const char* sourceExtension);
  130. virtual void OutputIncludeMakefile(std::ostream&, const char* file);
  131. void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;}
  132. void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;}
  133. void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
  134. void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;}
  135. void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;}
  136. // convert a path to an output path for unix this will call
  137. // ConvertToUnixOutputPath
  138. virtual std::string ConvertToOutputPath(const char* s)
  139. { return cmSystemTools::ConvertToOutputPath(s); }
  140. std::string CreateTargetRules(const cmTarget &target,
  141. const char* targetName);
  142. virtual std::string CreateMakeVariable(const char* s, const char* s2)
  143. {
  144. return std::string(s) + std::string(s2);
  145. }
  146. protected:
  147. std::string m_ExecutableOutputPath;
  148. std::string m_LibraryOutputPath;
  149. std::string m_SharedLibraryExtension;
  150. std::string m_ObjectFileExtension;
  151. std::string m_ExecutableExtension;
  152. std::string m_StaticLibraryExtension;
  153. std::string m_LibraryPrefix;
  154. private:
  155. bool m_CacheOnly;
  156. bool m_Recurse;
  157. };
  158. #endif