2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2005-05-05 16:45:53 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-05-05 16:45:53 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2005-05-05 16:45:53 +00:00
|
|
|
#ifndef cmGlobalUnixMakefileGenerator3_h
|
|
|
|
#define cmGlobalUnixMakefileGenerator3_h
|
|
|
|
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
|
2005-05-06 18:49:38 +00:00
|
|
|
class cmGeneratedFileStream;
|
2009-06-25 13:58:51 +00:00
|
|
|
class cmMakefileTargetGenerator;
|
2005-05-06 18:49:38 +00:00
|
|
|
class cmLocalUnixMakefileGenerator3;
|
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
/** \class cmGlobalUnixMakefileGenerator3
|
|
|
|
* \brief Write a Unix makefiles.
|
|
|
|
*
|
|
|
|
* cmGlobalUnixMakefileGenerator3 manages UNIX build process for a tree
|
2010-11-11 21:02:07 +00:00
|
|
|
|
|
|
|
|
2005-05-31 15:46:49 +00:00
|
|
|
The basic approach of this generator is to produce Makefiles that will all
|
|
|
|
be run with the current working directory set to the Home Output
|
|
|
|
directory. The one exception to this is the subdirectory Makefiles which are
|
|
|
|
created as a convenience and just cd up to the Home Output directory and
|
2010-11-11 21:02:07 +00:00
|
|
|
invoke the main Makefiles.
|
|
|
|
|
2005-05-31 15:46:49 +00:00
|
|
|
The make process starts with Makefile. Makefile should only contain the
|
|
|
|
targets the user is likely to invoke directly from a make command line. No
|
|
|
|
internal targets should be in this file. Makefile2 contains the internal
|
|
|
|
targets that are required to make the process work.
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2005-05-31 15:46:49 +00:00
|
|
|
Makefile2 in turn will recursively make targets in the correct order. Each
|
|
|
|
target has its own directory <target>.dir and its own makefile build.make in
|
|
|
|
that directory. Also in that directory is a couple makefiles per source file
|
|
|
|
used by the target. Typically these are named source.obj.build.make and
|
|
|
|
source.obj.build.depend.make. The source.obj.build.make contains the rules
|
|
|
|
for building, cleaning, and computing dependencies for the given source
|
|
|
|
file. The build.depend.make contains additional dependencies that were
|
|
|
|
computed during dependency scanning. An additional file called
|
|
|
|
source.obj.depend is used as a marker to indicate when dependencies must be
|
|
|
|
rescanned.
|
|
|
|
|
|
|
|
Rules for custom commands follow the same model as rules for source files.
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
*/
|
2005-05-31 15:46:49 +00:00
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmGlobalUnixMakefileGenerator3();
|
2006-05-11 14:40:28 +00:00
|
|
|
static cmGlobalGenerator* New() {
|
|
|
|
return new cmGlobalUnixMakefileGenerator3; }
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
///! Get the name for the generator.
|
|
|
|
virtual const char* GetName() const {
|
|
|
|
return cmGlobalUnixMakefileGenerator3::GetActualName();}
|
2005-05-25 15:18:41 +00:00
|
|
|
static const char* GetActualName() {return "Unix Makefiles";}
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
/** Get the documentation entry for this generator. */
|
|
|
|
virtual void GetDocumentation(cmDocumentationEntry& entry) const;
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
///! Create a local generator appropriate to this Global Generator3
|
|
|
|
virtual cmLocalGenerator *CreateLocalGenerator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to determine system infomation such as shared library
|
2010-11-11 21:02:07 +00:00
|
|
|
* extension, pthreads, byte order etc.
|
2005-05-05 16:45:53 +00:00
|
|
|
*/
|
2006-03-10 18:54:57 +00:00
|
|
|
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
2007-06-28 13:09:26 +00:00
|
|
|
cmMakefile *, bool optional);
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the all required files for building this project/tree. This
|
|
|
|
* basically creates a series of LocalGenerators for each directory and
|
2010-11-11 21:02:07 +00:00
|
|
|
* requests that they Generate.
|
2005-05-05 16:45:53 +00:00
|
|
|
*/
|
|
|
|
virtual void Generate();
|
2010-11-11 21:02:07 +00:00
|
|
|
|
|
|
|
|
2005-07-27 13:49:37 +00:00
|
|
|
void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
|
|
|
|
std::vector<cmLocalGenerator *> &);
|
2005-05-05 16:45:53 +00:00
|
|
|
|
2005-10-20 17:40:28 +00:00
|
|
|
// write out the help rule listing the valid targets
|
|
|
|
void WriteHelpRule(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3 *);
|
|
|
|
|
|
|
|
// write the top lvel target rules
|
2010-11-11 21:02:07 +00:00
|
|
|
void WriteConvenienceRules(std::ostream& ruleFileStream,
|
2005-10-20 17:40:28 +00:00
|
|
|
std::set<cmStdString> &emitted);
|
|
|
|
|
2007-05-16 17:24:17 +00:00
|
|
|
/** Get the command to use for a target that has no rule. This is
|
|
|
|
used for multiple output dependencies and for cmake_force. */
|
|
|
|
std::string GetEmptyRuleHackCommand() { return this->EmptyRuleHackCommand; }
|
2006-05-02 13:56:42 +00:00
|
|
|
|
2006-12-14 19:30:41 +00:00
|
|
|
/** Get the fake dependency to use when a rule has no real commands
|
|
|
|
or dependencies. */
|
|
|
|
std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
|
2006-05-02 13:56:42 +00:00
|
|
|
|
|
|
|
// change the build command for speed
|
|
|
|
virtual std::string GenerateBuildCommand
|
|
|
|
(const char* makeProgram,
|
2010-11-11 21:02:07 +00:00
|
|
|
const char *projectName, const char* additionalOptions,
|
2006-05-02 13:56:42 +00:00
|
|
|
const char *targetName,
|
2006-06-01 19:51:24 +00:00
|
|
|
const char* config, bool ignoreErrors, bool fast);
|
2006-05-02 13:56:42 +00:00
|
|
|
|
2009-06-25 13:58:51 +00:00
|
|
|
/** Record per-target progress information. */
|
|
|
|
void RecordTargetProgress(cmMakefileTargetGenerator* tg);
|
2006-05-25 14:55:24 +00:00
|
|
|
|
2011-01-13 04:39:13 +00:00
|
|
|
void AddCXXCompileCommand(const std::string &sourceFile,
|
|
|
|
const std::string &workingDirectory,
|
|
|
|
const std::string &compileCommand);
|
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
protected:
|
2005-05-31 15:46:49 +00:00
|
|
|
void WriteMainMakefile2();
|
2005-05-05 16:45:53 +00:00
|
|
|
void WriteMainCMakefile();
|
2007-08-03 19:44:25 +00:00
|
|
|
|
|
|
|
void WriteConvenienceRules2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3*);
|
2005-05-31 15:46:49 +00:00
|
|
|
|
2006-03-01 23:54:17 +00:00
|
|
|
void WriteDirectoryRule2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3* lg,
|
|
|
|
const char* pass, bool check_all,
|
|
|
|
bool check_relink);
|
|
|
|
void WriteDirectoryRules2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3* lg);
|
2005-05-18 17:46:00 +00:00
|
|
|
|
|
|
|
void AppendGlobalTargetDepends(std::vector<std::string>& depends,
|
2005-06-22 13:06:46 +00:00
|
|
|
cmTarget& target);
|
2005-05-18 17:46:00 +00:00
|
|
|
|
2005-05-24 15:17:30 +00:00
|
|
|
// does this generator need a requires step for any of its targets
|
2007-08-03 13:39:32 +00:00
|
|
|
bool NeedRequiresStep(cmTarget const&);
|
2005-05-06 18:49:38 +00:00
|
|
|
|
2006-02-23 18:37:35 +00:00
|
|
|
// Setup target names
|
2006-03-01 13:28:39 +00:00
|
|
|
virtual const char* GetAllTargetName() { return "all"; }
|
2006-02-23 18:37:35 +00:00
|
|
|
virtual const char* GetInstallTargetName() { return "install"; }
|
2006-08-29 14:03:47 +00:00
|
|
|
virtual const char* GetInstallLocalTargetName() { return "install/local"; }
|
2007-05-18 17:43:39 +00:00
|
|
|
virtual const char* GetInstallStripTargetName() { return "install/strip"; }
|
2006-02-23 18:37:35 +00:00
|
|
|
virtual const char* GetPreinstallTargetName() { return "preinstall"; }
|
|
|
|
virtual const char* GetTestTargetName() { return "test"; }
|
|
|
|
virtual const char* GetPackageTargetName() { return "package"; }
|
2006-04-17 19:26:54 +00:00
|
|
|
virtual const char* GetPackageSourceTargetName(){ return "package_source"; }
|
2006-02-23 18:37:35 +00:00
|
|
|
virtual const char* GetEditCacheTargetName() { return "edit_cache"; }
|
|
|
|
virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; }
|
2007-11-25 12:34:53 +00:00
|
|
|
virtual const char* GetCleanTargetName() { return "clean"; }
|
2006-02-23 18:37:35 +00:00
|
|
|
|
2008-02-14 21:42:29 +00:00
|
|
|
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; }
|
|
|
|
|
2006-02-16 23:50:16 +00:00
|
|
|
// Some make programs (Borland) do not keep a rule if there are no
|
|
|
|
// dependencies or commands. This is a problem for creating rules
|
|
|
|
// that might not do anything but might have other dependencies
|
|
|
|
// added later. If non-empty this variable holds a fake dependency
|
|
|
|
// that can be added.
|
2006-03-15 16:02:08 +00:00
|
|
|
std::string EmptyRuleHackDepends;
|
2006-04-11 15:06:19 +00:00
|
|
|
|
2007-05-16 17:24:17 +00:00
|
|
|
// Some make programs (Watcom) do not like rules with no commands.
|
|
|
|
// If non-empty this variable holds a bogus command that may be put
|
|
|
|
// in the rule to satisfy the make program.
|
|
|
|
std::string EmptyRuleHackCommand;
|
2006-04-13 14:15:48 +00:00
|
|
|
|
2009-06-25 13:58:51 +00:00
|
|
|
// Store per-target progress counters.
|
|
|
|
struct TargetProgress
|
|
|
|
{
|
|
|
|
TargetProgress(): NumberOfActions(0) {}
|
|
|
|
unsigned long NumberOfActions;
|
|
|
|
std::string VariableFile;
|
2010-06-25 12:48:59 +00:00
|
|
|
std::vector<unsigned long> Marks;
|
2009-06-25 13:58:51 +00:00
|
|
|
void WriteProgressVariables(unsigned long total, unsigned long& current);
|
|
|
|
};
|
2009-09-29 12:34:39 +00:00
|
|
|
struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; };
|
2009-09-28 21:34:23 +00:00
|
|
|
typedef std::map<cmTarget*, TargetProgress,
|
|
|
|
ProgressMapCompare> ProgressMapType;
|
2009-06-25 13:58:51 +00:00
|
|
|
ProgressMapType ProgressMap;
|
|
|
|
|
|
|
|
size_t CountProgressMarksInTarget(cmTarget* target,
|
|
|
|
std::set<cmTarget*>& emitted);
|
|
|
|
size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);
|
2011-01-13 04:39:13 +00:00
|
|
|
|
|
|
|
cmGeneratedFileStream *CommandDatabase;
|
2005-05-05 16:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|