Name the proxy makefiles "GNUmakefile" instead of "makefile".
[reactos.git] / reactos / tools / rbuild / backend / mingw / mingw.h
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #ifndef MINGW_H
19 #define MINGW_H
20
21 #include "../backend.h"
22
23 #ifdef WIN32
24 #define NUL "NUL"
25 #else
26 #define NUL "/dev/null"
27 #endif
28
29 class Directory;
30 class MingwModuleHandler;
31
32 extern std::string
33 v2s ( const string_list& v, int wrap_at );
34
35 typedef std::map<std::string,Directory*> directory_map;
36
37
38 class Directory
39 {
40 public:
41 std::string name;
42 directory_map subdirs;
43 Directory ( const std::string& name );
44 void Add ( const char* subdir );
45 void GenerateTree ( const std::string& parent,
46 bool verbose );
47 std::string EscapeSpaces ( std::string path );
48 void CreateRule ( FILE* f,
49 const std::string& parent );
50 private:
51 bool mkdir_p ( const char* path );
52 std::string ReplaceVariable ( std::string name,
53 std::string value,
54 std::string path );
55 std::string GetEnvironmentVariable ( const std::string& name );
56 void ResolveVariablesInPath ( char* buf,
57 std::string path );
58 bool CreateDirectory ( std::string path );
59 };
60
61
62 class MingwBackend : public Backend
63 {
64 public:
65 MingwBackend ( Project& project,
66 Configuration& configuration );
67 ~MingwBackend ();
68 virtual void Process ();
69 std::string AddDirectoryTarget ( const std::string& directory,
70 Directory* directoryTree );
71 const Module& GetAliasedModuleOrModule ( const Module& module ) const;
72 std::string compilerPrefix;
73 std::string compilerCommand;
74 std::string nasmCommand;
75 bool usePipe;
76 Directory* intermediateDirectory;
77 Directory* outputDirectory;
78 Directory* installDirectory;
79 private:
80 void CreateMakefile ();
81 void CloseMakefile () const;
82 void GenerateHeader () const;
83 std::string GenerateIncludesAndDefines ( IfableData& data ) const;
84 void GenerateProjectCFlagsMacro ( const char* assignmentOperation,
85 IfableData& data ) const;
86 void GenerateGlobalCFlagsAndProperties ( const char* op,
87 IfableData& data ) const;
88 void GenerateProjectGccOptionsMacro ( const char* assignmentOperation,
89 IfableData& data ) const;
90 void GenerateProjectGccOptions ( const char* assignmentOperation,
91 IfableData& data ) const;
92 std::string GenerateProjectLFLAGS () const;
93 void GenerateDirectories ();
94 void GenerateGlobalVariables () const;
95 bool IncludeInAllTarget ( const Module& module ) const;
96 void GenerateAllTarget ( const std::vector<MingwModuleHandler*>& handlers ) const;
97 std::string GetBuildToolDependencies () const;
98 void GenerateInitTarget () const;
99 void GenerateRegTestsRunTarget () const;
100 void GenerateXmlBuildFilesMacro() const;
101 std::string GetBin2ResExecutable ();
102 void UnpackWineResources ();
103 void GenerateTestSupportCode ();
104 std::string GetProxyMakefileTree () const;
105 void GenerateProxyMakefiles ();
106 void CheckAutomaticDependencies ();
107 bool IncludeDirectoryTarget ( const std::string& directory ) const;
108 bool TryToDetectThisCompiler ( const std::string& compiler );
109 void DetectCompiler ();
110 bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
111 void DetectNetwideAssembler ();
112 void DetectPipeSupport ();
113 void DetectPCHSupport ();
114 void ProcessModules ();
115 void CheckAutomaticDependenciesForModuleOnly ();
116 void ProcessNormal ();
117 std::string GetNonModuleInstallDirectories ( const std::string& installDirectory );
118 std::string GetInstallDirectories ( const std::string& installDirectory );
119 void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const;
120 void GetInstallFiles ( std::vector<std::string>& out ) const;
121 void GetNonModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
122 void GetModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
123 void GetInstallTargetFiles ( std::vector<std::string>& out ) const;
124 void OutputInstallTarget ( const std::string& sourceFilename,
125 const std::string& targetFilename,
126 const std::string& targetDirectory );
127 void OutputNonModuleInstallTargets ();
128 void OutputModuleInstallTargets ();
129 std::string GetRegistrySourceFiles ();
130 std::string GetRegistryTargetFiles ();
131 void OutputRegistryInstallTarget ();
132 void GenerateInstallTarget ();
133 void GetModuleTestTargets ( std::vector<std::string>& out ) const;
134 void GenerateTestTarget ();
135 void GenerateDirectoryTargets ();
136 FILE* fMakefile;
137 bool use_pch;
138 };
139
140
141 class ProxyMakefile
142 {
143 public:
144 ProxyMakefile ( const Project& project );
145 ~ProxyMakefile ();
146 void GenerateProxyMakefiles ( bool verbose,
147 std::string outputTree );
148 private:
149 std::string GeneratePathToParentDirectory ( int numberOfParentDirectories );
150 std::string GetPathToTopDirectory ( Module& module );
151 bool GenerateProxyMakefile ( Module& module );
152 void GenerateProxyMakefileForModule ( Module& module,
153 bool verbose,
154 std::string outputTree );
155 const Project& project;
156 };
157
158 #endif /* MINGW_H */