1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmUnixMakefileGenerator.h,v $
6 Date: $Date: 2002-07-31 17:45:07 $
7 Version: $Revision: 1.48 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmUnixMakefileGenerator_h
18 #define cmUnixMakefileGenerator_h
20 #include "cmMakefile.h"
21 #include "cmMakefileGenerator.h"
23 /** \class cmUnixMakefileGenerator
24 * \brief Write a Unix makefiles.
26 * cmUnixMakefileGenerator produces a Unix makefile from its
29 class cmUnixMakefileGenerator
: public cmMakefileGenerator
32 ///! Set cache only and recurse to false by default.
33 cmUnixMakefileGenerator();
35 virtual ~cmUnixMakefileGenerator();
37 ///! Get the name for the generator.
38 virtual const char* GetName() {return "Unix Makefiles";}
40 ///! virtual copy constructor
41 virtual cmMakefileGenerator
* CreateObject()
42 { return new cmUnixMakefileGenerator
;}
44 //! just sets the Cache Only and Recurse flags
45 virtual void SetLocal(bool local
);
48 * If cache only is on.
49 * and only stub makefiles are generated, and no depends, for speed.
52 void SetCacheOnlyOn() {m_CacheOnly
= true;}
53 void SetCacheOnlyOff() {m_CacheOnly
= false;}
55 * If recurse is on, then all the makefiles below this one are parsed as well.
57 void SetRecurseOn() {m_Recurse
= true;}
58 void SetRecurseOff() {m_Recurse
= false;}
61 * Produce the makefile (in this case a Unix makefile).
63 virtual void GenerateMakefile();
66 * Output the depend information for all the classes
67 * in the makefile. These would have been generated
68 * by the class cmMakeDepend.
70 virtual bool OutputObjectDepends(std::ostream
&);
73 * Output the check depend information for all the classes
74 * in the makefile. These would have been generated
75 * by the class cmMakeDepend.
77 virtual void OutputCheckDepends(std::ostream
&);
80 * Try to determine system infomation such as shared library
81 * extension, pthreads, byte order etc.
83 virtual void EnableLanguage(const char*);
86 virtual void RecursiveGenerateCacheOnly();
87 virtual void ProcessDepends(const cmMakeDepend
&md
);
88 virtual void GenerateCacheOnly();
89 virtual void OutputMakefile(const char* file
);
90 virtual void OutputTargetRules(std::ostream
& fout
);
91 virtual void OutputLinkLibraries(std::ostream
&, const char* name
, const cmTarget
&);
93 virtual void OutputSharedLibraryRule(std::ostream
&, const char* name
,
95 virtual void OutputModuleLibraryRule(std::ostream
&, const char* name
,
97 virtual void OutputStaticLibraryRule(std::ostream
&, const char* name
,
99 virtual void OutputExecutableRule(std::ostream
&, const char* name
,
101 virtual void OutputUtilityRule(std::ostream
&, const char* name
,
104 virtual void OutputTargets(std::ostream
&);
105 virtual void OutputSubDirectoryRules(std::ostream
&);
106 virtual void OutputDependLibs(std::ostream
&);
107 virtual void OutputLibDepend(std::ostream
&, const char*);
108 virtual void OutputExeDepend(std::ostream
&, const char*);
109 virtual void OutputCustomRules(std::ostream
&);
110 virtual void OutputMakeVariables(std::ostream
&);
111 virtual void OutputMakeRules(std::ostream
&);
112 virtual void OutputInstallRules(std::ostream
&);
113 virtual void OutputSourceObjectBuildRules(std::ostream
& fout
);
114 virtual void OutputBuildObjectFromSource(std::ostream
& fout
,
115 const char* shortName
,
116 const cmSourceFile
& source
,
117 const char* extraCompileFlags
,
120 virtual void BuildInSubDirectory(std::ostream
& fout
,
121 const char* directory
,
124 bool silent
= false);
126 virtual void OutputSubDirectoryVars(std::ostream
& fout
,
132 const std::vector
<std::string
>&
134 bool silent
= false);
136 virtual void OutputMakeRule(std::ostream
&,
141 const char* command2
= 0,
142 const char* command3
= 0,
143 const char* command4
= 0);
144 virtual void OutputBuildTargetInDir(std::ostream
& fout
,
147 const char* fullpath
,
148 const char* outputPath
);
149 ///! return true if the two paths are the same
150 virtual bool SamePath(const char* path1
, const char* path2
);
151 virtual std::string
GetOutputExtension(const char* sourceExtension
);
152 virtual void OutputIncludeMakefile(std::ostream
&, const char* file
);
153 void SetObjectFileExtension(const char* e
) { m_ObjectFileExtension
= e
;}
154 void SetExecutableExtension(const char* e
) { m_ExecutableExtension
= e
;}
155 void SetStaticLibraryExtension(const char* e
) {m_StaticLibraryExtension
= e
;}
156 void SetSharedLibraryExtension(const char* e
) {m_SharedLibraryExtension
= e
;}
157 void SetLibraryPrefix(const char* e
) { m_LibraryPrefix
= e
;}
158 // convert a path to an output path for unix this will call
159 // ConvertToUnixOutputPath
160 virtual std::string
ConvertToOutputPath(const char* s
)
161 { return cmSystemTools::ConvertToOutputPath(s
); }
162 std::string
CreateTargetRules(const cmTarget
&target
,
163 const char* targetName
);
164 virtual std::string
CreateMakeVariable(const char* s
, const char* s2
)
166 return std::string(s
) + std::string(s2
);
169 ///! if the OS is case insensitive then return a lower case of the path.
170 virtual std::string
LowerCasePath(const char* path
)
172 return std::string(path
);
177 std::string m_ExecutableOutputPath
;
178 std::string m_LibraryOutputPath
;
179 std::string m_SharedLibraryExtension
;
180 std::string m_ObjectFileExtension
;
181 std::string m_ExecutableExtension
;
182 std::string m_StaticLibraryExtension
;
183 std::string m_LibraryPrefix
;