2 * Copyright (C) 2005 Casper S. Hornstrup
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.
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.
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.
21 #include "../backend.h"
26 #define NUL "/dev/null"
30 class MingwModuleHandler
;
33 v2s ( const string_list
& v
, int wrap_at
);
36 class MingwBackend
: public Backend
39 MingwBackend ( Project
& project
,
40 Configuration
& configuration
);
42 virtual void Process ();
43 std::string
AddDirectoryTarget ( const std::string
& directory
,
44 Directory
* directoryTree
);
45 const Module
& GetAliasedModuleOrModule ( const Module
& module
) const;
46 std::string compilerPrefix
;
47 std::string compilerCommand
;
48 std::string nasmCommand
;
49 std::string binutilsPrefix
;
50 std::string binutilsCommand
;
51 bool usePipe
, manualBinutilsSetting
;
52 Directory
* intermediateDirectory
;
53 Directory
* outputDirectory
;
54 Directory
* installDirectory
;
56 void CreateMakefile ();
57 void CloseMakefile () const;
58 void GenerateHeader () const;
59 std::string
GenerateIncludesAndDefines ( IfableData
& data
) const;
60 void GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
61 IfableData
& data
) const;
62 void GenerateGlobalCFlagsAndProperties ( const char* op
,
63 IfableData
& data
) const;
64 void GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
65 IfableData
& data
) const;
66 void GenerateProjectGccOptions ( const char* assignmentOperation
,
67 IfableData
& data
) const;
68 std::string
GenerateProjectLFLAGS () const;
69 void GenerateDirectories ();
70 void GenerateGlobalVariables () const;
71 bool IncludeInAllTarget ( const Module
& module
) const;
72 void GenerateAllTarget ( const std::vector
<MingwModuleHandler
*>& handlers
) const;
73 std::string
GetBuildToolDependencies () const;
74 void GenerateInitTarget () const;
75 void GenerateRegTestsRunTarget () const;
76 void GenerateXmlBuildFilesMacro() const;
77 std::string
GetBin2ResExecutable ();
78 void UnpackWineResources ();
79 void GenerateTestSupportCode ();
80 void GenerateCompilationUnitSupportCode ();
81 void GenerateSysSetup ();
82 std::string
GetProxyMakefileTree () const;
83 void GenerateProxyMakefiles ();
84 void CheckAutomaticDependencies ();
85 bool IncludeDirectoryTarget ( const std::string
& directory
) const;
86 bool TryToDetectThisCompiler ( const std::string
& compiler
);
87 void DetectCompiler ();
88 std::string
GetCompilerVersion ( const std::string
& compilerCommand
);
89 bool IsSupportedCompilerVersion ( const std::string
& compilerVersion
);
90 bool TryToDetectThisNetwideAssembler ( const std::string
& assembler
);
91 bool TryToDetectThisBinutils ( const std::string
& binutils
);
92 std::string
GetBinutilsVersion ( const std::string
& binutilsCommand
);
93 std::string
GetBinutilsVersionDate ( const std::string
& binutilsCommand
);
94 bool IsSupportedBinutilsVersion ( const std::string
& binutilsVersion
);
95 std::string
GetVersionString ( const std::string
& versionCommand
);
96 std::string
GetNetwideAssemblerVersion ( const std::string
& nasmCommand
);
97 void DetectBinutils ();
98 void DetectNetwideAssembler ();
99 void DetectPipeSupport ();
100 void DetectPCHSupport ();
101 bool CanEnablePreCompiledHeaderSupportForModule ( const Module
& module
);
102 void ProcessModules ();
103 void CheckAutomaticDependenciesForModuleOnly ();
104 void ProcessNormal ();
105 std::string
GetNonModuleInstallDirectories ( const std::string
& installDirectory
);
106 std::string
GetInstallDirectories ( const std::string
& installDirectory
);
107 void GetNonModuleInstallFiles ( std::vector
<std::string
>& out
) const;
108 void GetInstallFiles ( std::vector
<std::string
>& out
) const;
109 void GetNonModuleInstallTargetFiles ( std::vector
<std::string
>& out
) const;
110 void GetModuleInstallTargetFiles ( std::vector
<std::string
>& out
) const;
111 void GetInstallTargetFiles ( std::vector
<std::string
>& out
) const;
112 void OutputInstallTarget ( const std::string
& sourceFilename
,
113 const std::string
& targetFilename
,
114 const std::string
& targetDirectory
);
115 void OutputNonModuleInstallTargets ();
116 void OutputModuleInstallTargets ();
117 std::string
GetRegistrySourceFiles ();
118 std::string
GetRegistryTargetFiles ();
119 void OutputRegistryInstallTarget ();
120 void GenerateInstallTarget ();
121 void GetModuleTestTargets ( std::vector
<std::string
>& out
) const;
122 void GenerateTestTarget ();
123 void GenerateDirectoryTargets ();
132 ProxyMakefile ( const Project
& project
);
134 void GenerateProxyMakefiles ( bool verbose
,
135 std::string outputTree
);
137 std::string
GeneratePathToParentDirectory ( int numberOfParentDirectories
);
138 std::string
GetPathToTopDirectory ( Module
& module
);
139 bool GenerateProxyMakefile ( Module
& module
);
140 void GenerateProxyMakefileForModule ( Module
& module
,
142 std::string outputTree
);
143 const Project
& project
;