1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmLocalUnixMakefileGenerator.h,v $
6
Date: $Date: 2004/04/28 14:15:40 $
7
Version: $Revision: 1.26 $
9
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 cmLocalUnixMakefileGenerator_h
18
#define cmLocalUnixMakefileGenerator_h
20
#include "cmLocalGenerator.h"
22
class cmDependInformation;
27
/** \class cmLocalUnixMakefileGenerator
28
* \brief Write a LocalUnix makefiles.
30
* cmLocalUnixMakefileGenerator produces a LocalUnix makefile from its
33
class cmLocalUnixMakefileGenerator : public cmLocalGenerator
36
///! Set cache only and recurse to false by default.
37
cmLocalUnixMakefileGenerator();
39
virtual ~cmLocalUnixMakefileGenerator();
42
* Generate the makefile for this directory. fromTheTop indicates if this
43
* is being invoked as part of a global Generate or specific to this
44
* directory. The difference is that when done from the Top we might skip
45
* some steps to save time, such as dependency generation for the
46
* makefiles. This is done by a direct invocation from make.
48
virtual void Generate(bool fromTheTop);
51
* Output the depend information for all the classes
52
* in the makefile. These would have been generated
53
* by the class cmMakeDepend.
55
virtual bool OutputObjectDepends(std::ostream&);
58
* Output the check depend information for all the classes
59
* in the makefile. These would have been generated
60
* by the class cmMakeDepend.
62
virtual void OutputCheckDepends(std::ostream&);
65
* Set to true if the shell being used is the windows shell.
66
* This controls if statements in the makefile and the SHELL variable.
67
* The default is false.
69
void SetWindowsShell(bool v) {m_WindowsShell = v;}
71
///! Set the string used to include one makefile into another default is include.
72
void SetIncludeDirective(const char* s) { m_IncludeDirective = s; }
74
///! Set the flag used to keep the make program silent.
75
void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; }
77
///! Set max makefile variable size, default is 0 which means unlimited.
78
void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
80
///! If ignore lib prefix is true, then do not strip lib from the name of a library.
81
void SetIgnoreLibPrefix(bool s) { m_IgnoreLibPrefix = s; }
84
* If true, then explicitly pass MAKEFLAGS on the make all target for makes
85
* that do not use environment variables.
88
void SetPassMakeflags(bool s){m_PassMakeflags = s;}
91
void AddDependenciesToSourceFile(cmDependInformation const*info,
93
std::set<cmDependInformation const*> *visited);
94
virtual void ProcessDepends(const cmMakeDepend &md);
95
virtual void OutputMakefile(const char* file, bool withDepends);
96
virtual void OutputTargetRules(std::ostream& fout);
97
virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
98
void OutputLibraryRule(std::ostream& fout,
101
const char* createRule,
103
const char* linkFlags
105
void ExpandRuleVariables(std::string& string,
106
const char* objects=0,
107
const char* target=0,
108
const char* linkLibs=0,
109
const char* source=0,
110
const char* object =0,
111
const char* flags = 0,
112
const char* objectsquoted = 0,
113
const char* targetBase = 0,
114
const char* targetSOName = 0,
115
const char* linkFlags = 0);
116
virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
118
virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
120
virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
122
virtual void OutputExecutableRule(std::ostream&, const char* name,
124
virtual void OutputUtilityRule(std::ostream&, const char* name,
127
virtual void OutputTargets(std::ostream&);
128
virtual void OutputSubDirectoryRules(std::ostream&);
129
virtual void OutputDependLibs(std::ostream&);
130
virtual void OutputLibDepend(std::ostream&, const char*);
131
virtual void OutputExeDepend(std::ostream&, const char*);
132
virtual void OutputCustomRules(std::ostream&);
133
virtual void OutputMakeVariables(std::ostream&);
134
virtual void OutputMakeRules(std::ostream&);
135
virtual void OutputSourceObjectBuildRules(std::ostream& fout);
136
virtual void OutputBuildObjectFromSource(std::ostream& fout,
137
const char* shortName,
138
const cmSourceFile& source,
139
const char* extraCompileFlags,
142
virtual void BuildInSubDirectory(std::ostream& fout,
143
const char* directory,
146
bool silent = false);
148
virtual void BuildInSubDirectoryWindows(std::ostream& fout,
149
const char* directory,
152
bool silent = false);
153
///! order == 0, then all subdirs are output, 1 = post order, 2 = preorder
154
virtual void OutputSubDirectoryVars(std::ostream& fout,
160
const std::vector<std::pair<cmStdString, bool> >&
162
bool silent = false, int order = 0);
164
virtual void OutputMakeRule(std::ostream&,
168
const std::vector<std::string>& commands);
170
virtual void OutputMakeRule(std::ostream&,
173
const std::vector<std::string>& depends,
174
const char* command);
176
virtual void OutputMakeRule(std::ostream&,
179
const std::vector<std::string>& depends,
180
const std::vector<std::string>& commands);
182
virtual void OutputMakeRule(std::ostream&,
187
const char* command2 = 0,
188
const char* command3 = 0,
189
const char* command4 = 0);
190
virtual void OutputBuildTargetInDirWindows(std::ostream& fout,
193
const char* fullpath);
194
virtual void OutputBuildTargetInDir(std::ostream& fout,
197
const char* fullpath);
199
///! return true if the two paths are the same
200
virtual bool SamePath(const char* path1, const char* path2);
201
virtual std::string GetOutputExtension(const char* sourceExtension);
202
std::string CreatePreBuildRules(const cmTarget &target,
203
const char* targetName);
204
std::string CreatePreLinkRules(const cmTarget &target,
205
const char* targetName);
206
std::string CreatePostBuildRules(const cmTarget &target,
207
const char* targetName);
208
virtual std::string CreateMakeVariable(const char* s, const char* s2);
210
///! if the OS is case insensitive then return a lower case of the path.
211
virtual std::string LowerCasePath(const char* path);
213
///! for existing files convert to output path and short path if spaces
214
std::string ConvertToOutputForExisting(const char*);
216
/** Convert path to a format vaild for the left or right side of a
217
target: dependencies line in a makefile. */
218
virtual std::string ConvertToMakeTarget(const char*);
220
/** Get the full name of the target's file, without path. */
221
std::string GetFullTargetName(const char* n, const cmTarget& t);
223
/** Get the base name of the target's file, without path or extension. */
224
std::string GetBaseTargetName(const char* n, const cmTarget& t);
226
/** Get the names associated with a library target. */
227
void GetLibraryNames(const char* n, const cmTarget& t,
230
std::string& realName,
231
std::string& baseName);
233
/** Output an echo command to the Makefile */
234
void OutputEcho(std::ostream& fout, const char *msg);
237
* Convert source file name to a safe object file name. Safe here means that
238
* it will not clash with compilers or linkers.
240
std::string& CreateSafeUniqueObjectFileName(const char* sin);
242
///! final processing for a path to be put in a makefile
244
int m_MakefileVariableSize;
245
std::map<cmStdString, cmStdString> m_MakeVariableMap;
246
std::map<cmStdString, cmStdString> m_ShortMakeVariableMap;
247
std::map<cmStdString, cmStdString> m_UniqueObjectNamesMap;
248
bool m_IgnoreLibPrefix;
249
std::string m_IncludeDirective;
250
std::string m_MakeSilentFlag;
251
std::string m_ExecutableOutputPath;
252
std::string m_LibraryOutputPath;
254
bool m_UseRelativePaths;
255
bool m_PassMakeflags;