cmUnixMakefileGenerator.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2001 Insight Consortium
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright notice,
  14. this list of conditions and the following disclaimer in the documentation
  15. and/or other materials provided with the distribution.
  16. * The name of the Insight Consortium, nor the names of any consortium members,
  17. nor of any contributors, may be used to endorse or promote products derived
  18. from this software without specific prior written permission.
  19. * Modified source versions must be plainly marked as such, and must not be
  20. misrepresented as being the original software.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  25. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. =========================================================================*/
  32. #ifndef cmUnixMakefileGenerator_h
  33. #define cmUnixMakefileGenerator_h
  34. #include "cmMakefile.h"
  35. #include "cmMakefileGenerator.h"
  36. /** \class cmUnixMakefileGenerator
  37. * \brief Write a Unix makefiles.
  38. *
  39. * cmUnixMakefileGenerator produces a Unix makefile from its
  40. * member m_Makefile.
  41. */
  42. class cmUnixMakefileGenerator : public cmMakefileGenerator
  43. {
  44. public:
  45. ///! Set cache only and recurse to false by default.
  46. cmUnixMakefileGenerator();
  47. virtual ~cmUnixMakefileGenerator();
  48. ///! Get the name for the generator.
  49. virtual const char* GetName() {return "Unix Makefiles";}
  50. ///! virtual copy constructor
  51. virtual cmMakefileGenerator* CreateObject()
  52. { return new cmUnixMakefileGenerator;}
  53. //! just sets the Cache Only and Recurse flags
  54. virtual void SetLocal(bool local);
  55. /**
  56. * If cache only is on.
  57. * and only stub makefiles are generated, and no depends, for speed.
  58. * The default is OFF.
  59. **/
  60. void SetCacheOnlyOn() {m_CacheOnly = true;}
  61. void SetCacheOnlyOff() {m_CacheOnly = false;}
  62. /**
  63. * If recurse is on, then all the makefiles below this one are parsed as well.
  64. */
  65. void SetRecurseOn() {m_Recurse = true;}
  66. void SetRecurseOff() {m_Recurse = false;}
  67. /**
  68. * Produce the makefile (in this case a Unix makefile).
  69. */
  70. virtual void GenerateMakefile();
  71. /**
  72. * Output the depend information for all the classes
  73. * in the makefile. These would have been generated
  74. * by the class cmMakeDepend.
  75. */
  76. virtual void OutputObjectDepends(std::ostream&);
  77. /**
  78. * Try to determine system infomation such as shared library
  79. * extension, pthreads, byte order etc.
  80. */
  81. virtual void ComputeSystemInfo();
  82. protected:
  83. virtual void RecursiveGenerateCacheOnly();
  84. virtual void ProcessDepends(const cmMakeDepend &md);
  85. virtual void GenerateCacheOnly();
  86. virtual void OutputMakefile(const char* file);
  87. virtual void OutputTargetRules(std::ostream& fout);
  88. virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
  89. virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
  90. const cmTarget &);
  91. virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
  92. const cmTarget &);
  93. virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
  94. const cmTarget &);
  95. virtual void OutputExecutableRule(std::ostream&, const char* name,
  96. const cmTarget &);
  97. virtual void OutputTargets(std::ostream&);
  98. virtual void OutputSubDirectoryRules(std::ostream&);
  99. virtual void OutputDependLibs(std::ostream&);
  100. virtual void OutputLibDepend(std::ostream&, const char*);
  101. virtual void OutputCustomRules(std::ostream&);
  102. virtual void OutputMakeVariables(std::ostream&);
  103. virtual void OutputMakeRules(std::ostream&);
  104. virtual void OutputInstallRules(std::ostream&);
  105. virtual void OutputSourceObjectBuildRules(std::ostream& fout);
  106. virtual void OutputBuildObjectFromSource(std::ostream& fout,
  107. const char* shortName,
  108. const cmSourceFile& source,
  109. const char* extraCompileFlags,
  110. bool sharedTarget);
  111. virtual void BuildInSubDirectory(std::ostream& fout,
  112. const char* directory,
  113. const char* target1,
  114. const char* target2);
  115. virtual void OutputSubDirectoryVars(std::ostream& fout,
  116. const char* var,
  117. const char* target,
  118. const char* target1,
  119. const char* target2,
  120. const std::vector<std::string>&
  121. SubDirectories);
  122. virtual void OutputMakeRule(std::ostream&,
  123. const char* comment,
  124. const char* target,
  125. const char* depends,
  126. const char* command,
  127. const char* command2 = 0,
  128. const char* command3 = 0,
  129. const char* command4 = 0);
  130. void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;}
  131. void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;}
  132. void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
  133. void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;}
  134. void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;}
  135. protected:
  136. std::string m_ExecutableOutputPath;
  137. std::string m_LibraryOutputPath;
  138. private:
  139. bool m_CacheOnly;
  140. bool m_Recurse;
  141. std::string m_ObjectFileExtension;
  142. std::string m_ExecutableExtension;
  143. std::string m_StaticLibraryExtension;
  144. std::string m_SharedLibraryExtension;
  145. std::string m_LibraryPrefix;
  146. };
  147. #endif