2002-08-31 00:01:48 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2002-08-31 00:01:48 +04:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2002-08-31 00:01:48 +04:00
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef cmLocalUnixMakefileGenerator_h
|
|
|
|
#define cmLocalUnixMakefileGenerator_h
|
|
|
|
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
|
2002-12-10 17:28:05 +03:00
|
|
|
class cmDependInformation;
|
2002-08-31 00:01:48 +04:00
|
|
|
class cmMakeDepend;
|
|
|
|
class cmTarget;
|
|
|
|
class cmSourceFile;
|
|
|
|
|
|
|
|
/** \class cmLocalUnixMakefileGenerator
|
|
|
|
* \brief Write a LocalUnix makefiles.
|
|
|
|
*
|
|
|
|
* cmLocalUnixMakefileGenerator produces a LocalUnix makefile from its
|
|
|
|
* member m_Makefile.
|
|
|
|
*/
|
|
|
|
class cmLocalUnixMakefileGenerator : public cmLocalGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///! Set cache only and recurse to false by default.
|
|
|
|
cmLocalUnixMakefileGenerator();
|
|
|
|
|
|
|
|
virtual ~cmLocalUnixMakefileGenerator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the makefile for this directory. fromTheTop indicates if this
|
|
|
|
* is being invoked as part of a global Generate or specific to this
|
|
|
|
* directory. The difference is that when done from the Top we might skip
|
|
|
|
* some steps to save time, such as dependency generation for the
|
|
|
|
* makefiles. This is done by a direct invocation from make.
|
|
|
|
*/
|
|
|
|
virtual void Generate(bool fromTheTop);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output the depend information for all the classes
|
|
|
|
* in the makefile. These would have been generated
|
|
|
|
* by the class cmMakeDepend.
|
|
|
|
*/
|
|
|
|
virtual bool OutputObjectDepends(std::ostream&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output the check depend information for all the classes
|
|
|
|
* in the makefile. These would have been generated
|
|
|
|
* by the class cmMakeDepend.
|
|
|
|
*/
|
|
|
|
virtual void OutputCheckDepends(std::ostream&);
|
|
|
|
|
2002-11-08 23:46:08 +03:00
|
|
|
/**
|
|
|
|
* Set to true if the shell being used is the windows shell.
|
|
|
|
* This controls if statements in the makefile and the SHELL variable.
|
|
|
|
* The default is false.
|
|
|
|
*/
|
|
|
|
void SetWindowsShell(bool v) {m_WindowsShell = v;}
|
|
|
|
|
|
|
|
///! Set the string used to include one makefile into another default is include.
|
|
|
|
void SetIncludeDirective(const char* s) { m_IncludeDirective = s; }
|
|
|
|
|
|
|
|
///! Set the flag used to keep the make program silent.
|
|
|
|
void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; }
|
|
|
|
|
|
|
|
///! Set max makefile variable size, default is 0 which means unlimited.
|
|
|
|
void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
|
|
|
|
|
2003-08-01 21:13:43 +04:00
|
|
|
///! If ignore lib prefix is true, then do not strip lib from the name of a library.
|
|
|
|
void SetIgnoreLibPrefix(bool s) { m_IgnoreLibPrefix = s; }
|
|
|
|
|
2003-10-28 19:06:06 +03:00
|
|
|
/**
|
|
|
|
* If true, then explicitly pass MAKEFLAGS on the make all target for makes
|
|
|
|
* that do not use environment variables.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SetPassMakeflags(bool s){m_PassMakeflags = s;}
|
2003-08-01 21:13:43 +04:00
|
|
|
|
2002-08-31 00:01:48 +04:00
|
|
|
protected:
|
2004-11-05 23:03:45 +03:00
|
|
|
|
|
|
|
void ConfigureOutputPaths();
|
2002-12-10 17:28:05 +03:00
|
|
|
void AddDependenciesToSourceFile(cmDependInformation const*info,
|
|
|
|
cmSourceFile *i,
|
|
|
|
std::set<cmDependInformation const*> *visited);
|
2002-08-31 00:01:48 +04:00
|
|
|
virtual void ProcessDepends(const cmMakeDepend &md);
|
|
|
|
virtual void OutputMakefile(const char* file, bool withDepends);
|
|
|
|
virtual void OutputTargetRules(std::ostream& fout);
|
2002-11-08 23:46:08 +03:00
|
|
|
void OutputLibraryRule(std::ostream& fout,
|
|
|
|
const char* name,
|
|
|
|
const cmTarget &t,
|
|
|
|
const char* createRule,
|
2002-11-12 02:10:30 +03:00
|
|
|
const char* comment,
|
|
|
|
const char* linkFlags
|
2002-11-08 23:46:08 +03:00
|
|
|
);
|
2004-10-21 22:34:02 +04:00
|
|
|
|
2002-08-31 00:01:48 +04:00
|
|
|
virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
|
|
|
|
const cmTarget &);
|
|
|
|
virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
|
|
|
|
const cmTarget &);
|
|
|
|
virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
|
|
|
|
const cmTarget &);
|
|
|
|
virtual void OutputExecutableRule(std::ostream&, const char* name,
|
|
|
|
const cmTarget &);
|
|
|
|
virtual void OutputUtilityRule(std::ostream&, const char* name,
|
|
|
|
const cmTarget &);
|
|
|
|
|
|
|
|
virtual void OutputTargets(std::ostream&);
|
|
|
|
virtual void OutputSubDirectoryRules(std::ostream&);
|
|
|
|
virtual void OutputDependLibs(std::ostream&);
|
|
|
|
virtual void OutputLibDepend(std::ostream&, const char*);
|
|
|
|
virtual void OutputExeDepend(std::ostream&, const char*);
|
|
|
|
virtual void OutputCustomRules(std::ostream&);
|
|
|
|
virtual void OutputMakeVariables(std::ostream&);
|
|
|
|
virtual void OutputMakeRules(std::ostream&);
|
|
|
|
virtual void OutputSourceObjectBuildRules(std::ostream& fout);
|
|
|
|
virtual void OutputBuildObjectFromSource(std::ostream& fout,
|
|
|
|
const char* shortName,
|
|
|
|
const cmSourceFile& source,
|
|
|
|
const char* extraCompileFlags,
|
|
|
|
bool sharedTarget);
|
|
|
|
|
|
|
|
virtual void BuildInSubDirectory(std::ostream& fout,
|
|
|
|
const char* directory,
|
|
|
|
const char* target1,
|
|
|
|
const char* target2,
|
|
|
|
bool silent = false);
|
|
|
|
|
2002-11-08 23:46:08 +03:00
|
|
|
virtual void BuildInSubDirectoryWindows(std::ostream& fout,
|
|
|
|
const char* directory,
|
|
|
|
const char* target1,
|
|
|
|
const char* target2,
|
|
|
|
bool silent = false);
|
2004-04-23 20:52:48 +04:00
|
|
|
///! order == 0, then all subdirs are output, 1 = post order, 2 = preorder
|
2002-08-31 00:01:48 +04:00
|
|
|
virtual void OutputSubDirectoryVars(std::ostream& fout,
|
|
|
|
const char* var,
|
|
|
|
const char* target,
|
|
|
|
const char* target1,
|
|
|
|
const char* target2,
|
|
|
|
const char* depend,
|
2004-03-10 00:28:44 +03:00
|
|
|
const std::vector<std::pair<cmStdString, bool> >&
|
2002-08-31 00:01:48 +04:00
|
|
|
SubDirectories,
|
2004-04-23 20:52:48 +04:00
|
|
|
bool silent = false, int order = 0);
|
2002-08-31 00:01:48 +04:00
|
|
|
|
2002-11-08 23:46:08 +03:00
|
|
|
virtual void OutputMakeRule(std::ostream&,
|
|
|
|
const char* comment,
|
|
|
|
const char* target,
|
|
|
|
const char* depends,
|
|
|
|
const std::vector<std::string>& commands);
|
2002-12-14 00:16:48 +03:00
|
|
|
|
2003-08-07 19:53:19 +04:00
|
|
|
virtual void OutputMakeRule(std::ostream&,
|
|
|
|
const char* comment,
|
|
|
|
const char* target,
|
|
|
|
const std::vector<std::string>& depends,
|
|
|
|
const char* command);
|
|
|
|
|
2002-12-14 00:16:48 +03:00
|
|
|
virtual void OutputMakeRule(std::ostream&,
|
|
|
|
const char* comment,
|
|
|
|
const char* target,
|
|
|
|
const std::vector<std::string>& depends,
|
|
|
|
const std::vector<std::string>& commands);
|
2002-11-08 23:46:08 +03:00
|
|
|
|
2002-08-31 00:01:48 +04:00
|
|
|
virtual void OutputMakeRule(std::ostream&,
|
|
|
|
const char* comment,
|
|
|
|
const char* target,
|
|
|
|
const char* depends,
|
|
|
|
const char* command,
|
|
|
|
const char* command2 = 0,
|
|
|
|
const char* command3 = 0,
|
|
|
|
const char* command4 = 0);
|
2002-11-14 02:27:29 +03:00
|
|
|
virtual void OutputBuildTargetInDirWindows(std::ostream& fout,
|
|
|
|
const char* path,
|
|
|
|
const char* library,
|
2004-01-22 18:54:15 +03:00
|
|
|
const char* fullpath);
|
2002-08-31 00:01:48 +04:00
|
|
|
virtual void OutputBuildTargetInDir(std::ostream& fout,
|
|
|
|
const char* path,
|
|
|
|
const char* library,
|
2004-01-22 18:54:15 +03:00
|
|
|
const char* fullpath);
|
2004-01-23 17:54:50 +03:00
|
|
|
|
2002-08-31 00:01:48 +04:00
|
|
|
///! return true if the two paths are the same
|
|
|
|
virtual bool SamePath(const char* path1, const char* path2);
|
2003-06-03 18:30:23 +04:00
|
|
|
std::string CreatePreBuildRules(const cmTarget &target,
|
|
|
|
const char* targetName);
|
|
|
|
std::string CreatePreLinkRules(const cmTarget &target,
|
|
|
|
const char* targetName);
|
|
|
|
std::string CreatePostBuildRules(const cmTarget &target,
|
|
|
|
const char* targetName);
|
2002-11-08 23:46:08 +03:00
|
|
|
virtual std::string CreateMakeVariable(const char* s, const char* s2);
|
2002-08-31 00:01:48 +04:00
|
|
|
|
|
|
|
///! if the OS is case insensitive then return a lower case of the path.
|
2002-11-08 23:46:08 +03:00
|
|
|
virtual std::string LowerCasePath(const char* path);
|
|
|
|
|
2004-01-23 17:54:50 +03:00
|
|
|
/** Convert path to a format vaild for the left or right side of a
|
|
|
|
target: dependencies line in a makefile. */
|
|
|
|
virtual std::string ConvertToMakeTarget(const char*);
|
|
|
|
|
2003-11-27 01:38:37 +03:00
|
|
|
/** Get the base name of the target's file, without path or extension. */
|
|
|
|
std::string GetBaseTargetName(const char* n, const cmTarget& t);
|
|
|
|
|
|
|
|
/** Get the names associated with a library target. */
|
|
|
|
void GetLibraryNames(const char* n, const cmTarget& t,
|
|
|
|
std::string& name,
|
|
|
|
std::string& soName,
|
|
|
|
std::string& realName,
|
|
|
|
std::string& baseName);
|
|
|
|
|
2003-08-05 16:49:23 +04:00
|
|
|
/** Output an echo command to the Makefile */
|
|
|
|
void OutputEcho(std::ostream& fout, const char *msg);
|
2004-04-28 18:15:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert source file name to a safe object file name. Safe here means that
|
|
|
|
* it will not clash with compilers or linkers.
|
|
|
|
*/
|
|
|
|
std::string& CreateSafeUniqueObjectFileName(const char* sin);
|
2003-12-22 20:24:26 +03:00
|
|
|
|
2002-08-31 00:01:48 +04:00
|
|
|
protected:
|
2002-11-08 23:46:08 +03:00
|
|
|
int m_MakefileVariableSize;
|
|
|
|
std::map<cmStdString, cmStdString> m_MakeVariableMap;
|
|
|
|
std::map<cmStdString, cmStdString> m_ShortMakeVariableMap;
|
2004-04-28 18:15:40 +04:00
|
|
|
std::map<cmStdString, cmStdString> m_UniqueObjectNamesMap;
|
2002-11-08 23:46:08 +03:00
|
|
|
std::string m_IncludeDirective;
|
|
|
|
std::string m_MakeSilentFlag;
|
2002-08-31 00:01:48 +04:00
|
|
|
std::string m_ExecutableOutputPath;
|
|
|
|
std::string m_LibraryOutputPath;
|
2003-10-28 19:06:06 +03:00
|
|
|
bool m_PassMakeflags;
|
2002-08-31 00:01:48 +04:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|