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 Backend
* backend
, const std::vector
<FileLocation
>& files
, int wrap_at
);
35 v2s ( const string_list
& v
, int wrap_at
);
38 class MingwBackend
: public Backend
41 MingwBackend ( Project
& project
,
42 Configuration
& configuration
);
44 virtual void Process ();
45 std::string
AddDirectoryTarget ( const std::string
& directory
,
46 Directory
* directoryTree
);
47 const Module
& GetAliasedModuleOrModule ( const Module
& module
) const;
48 std::string compilerPrefix
;
49 std::string compilerCommand
;
50 std::string nasmCommand
;
51 std::string binutilsPrefix
;
52 std::string binutilsCommand
;
53 bool usePipe
, manualBinutilsSetting
;
54 Directory
* intermediateDirectory
;
55 Directory
* outputDirectory
;
56 Directory
* installDirectory
;
58 std::string
GetFullName ( const FileLocation
& file
) const;
59 std::string
GetFullPath ( const FileLocation
& file
) const;
62 void CreateMakefile ();
63 void CloseMakefile () const;
64 void GenerateHeader () const;
65 void GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
66 const IfableData
& data
) const;
67 void GenerateGlobalCFlagsAndProperties ( const char* op
,
68 const IfableData
& data
) const;
69 void GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
70 IfableData
& data
) const;
71 void GenerateProjectGccOptions ( const char* assignmentOperation
,
72 IfableData
& data
) const;
73 std::string
GenerateProjectLFLAGS () const;
74 void GenerateDirectories ();
75 void GenerateGlobalVariables () const;
76 bool IncludeInAllTarget ( const Module
& module
) const;
77 void GenerateAllTarget ( const std::vector
<MingwModuleHandler
*>& handlers
) const;
78 void GenerateRegTestsRunTarget () const;
79 void GenerateXmlBuildFilesMacro() const;
80 void GenerateTestSupportCode ();
81 void GenerateCompilationUnitSupportCode ();
82 void GenerateSysSetup ();
83 std::string
GetProxyMakefileTree () const;
84 void GenerateProxyMakefiles ();
85 void CheckAutomaticDependencies ();
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
<FileLocation
>& out
) const;
110 void GetModuleInstallTargetFiles ( std::vector
<FileLocation
>& out
) const;
111 void GetInstallTargetFiles ( std::vector
<FileLocation
>& out
) const;
112 void OutputInstallTarget ( const FileLocation
& source
, const FileLocation
& target
);
113 void OutputNonModuleInstallTargets ();
114 void OutputModuleInstallTargets ();
115 std::string
GetRegistrySourceFiles ();
116 std::string
GetRegistryTargetFiles ();
117 void OutputRegistryInstallTarget ();
118 void GenerateInstallTarget ();
119 void GetModuleTestTargets ( std::vector
<std::string
>& out
) const;
120 void GenerateTestTarget ();
121 void GenerateDirectoryTargets ();
130 ProxyMakefile ( const Project
& project
);
132 void GenerateProxyMakefiles ( bool verbose
,
133 std::string outputTree
);
134 static bool GenerateProxyMakefile ( const Module
& module
);
137 std::string
GeneratePathToParentDirectory ( int numberOfParentDirectories
);
138 std::string
GetPathToTopDirectory ( Module
& module
);
139 void GenerateProxyMakefileForModule ( Module
& module
,
141 std::string outputTree
);
142 const Project
& project
;
145 typedef struct ModuleHandlerInformations
147 HostType DefaultHost
;
149 const char* nasmflags
;
150 const char* linkerflags
;
153 extern const struct ModuleHandlerInformations ModuleHandlerInformations
[];