return archiveFilename;\r
}\r
\r
+string\r
+MingwModuleHandler::GetCFlagsMacro ( const Module& module ) const\r
+{\r
+ return ssprintf ( "$(%s_CFLAGS)",\r
+ module.name.c_str () );\r
+}\r
+\r
string\r
MingwModuleHandler::GetObjectsMacro ( const Module& module ) const\r
{\r
MingwModuleHandler::GenerateMacrosAndTargets (\r
const Module& module,\r
const string& cc,\r
- const string& ar ) const\r
+ const string& ar,\r
+ const string* cflags ) const\r
{\r
string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());\r
string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());\r
linkerFlagsMacro,\r
objectsMacro );\r
\r
+ if ( cflags != NULL )\r
+ {\r
+ fprintf ( fMakefile,\r
+ "%s += %s\n\n",\r
+ cflagsMacro.c_str (),\r
+ cflags->c_str () );\r
+ }\r
+ \r
// generate phony target for module name\r
fprintf ( fMakefile, ".PHONY: %s\n",\r
- module.name.c_str() );\r
+ module.name.c_str () );\r
fprintf ( fMakefile, "%s: %s\n\n",\r
- module.name.c_str(),\r
- module.GetPath().c_str() );\r
+ module.name.c_str (),\r
+ module.GetPath ().c_str () );\r
\r
// future references to the macros will be to get their values\r
cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());\r
void\r
MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const\r
{\r
- GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}" );\r
+ GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}", NULL );\r
}\r
\r
void\r
MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const\r
{\r
- GenerateMacrosAndTargets ( module, "${gcc}", "${ar}" );\r
+ GenerateMacrosAndTargetsTarget ( module,\r
+ NULL );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,\r
+ const string* clags ) const\r
+{\r
+ GenerateMacrosAndTargets ( module, "${gcc}", "${ar}", clags );\r
}\r
\r
string\r
fprintf ( fMakefile, "\n" );\r
}\r
\r
+void\r
+MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const\r
+{\r
+ if ( module.importLibrary != NULL )\r
+ {\r
+ fprintf ( fMakefile, "%s:\n",\r
+ module.GetDependencyPath ().c_str () );\r
+\r
+ fprintf ( fMakefile,\r
+ "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",\r
+ module.GetTargetName ().c_str (),\r
+ FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
+ FixupTargetFilename ( module.GetDependencyPath () ).c_str () );\r
+ }\r
+}\r
+\r
\r
static MingwBuildToolModuleHandler buildtool_handler;\r
\r
\r
GenerateMacrosAndTargetsTarget ( module );\r
\r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
+\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
objectsMacro.c_str (),\r
string archiveFilename = GetModuleArchiveFilename ( module );\r
string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
\r
- if (module.importLibrary != NULL)\r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
+\r
+ if ( module.files.size () > 0 )\r
{\r
- fprintf ( fMakefile, "%s:\n",\r
- module.GetDependencyPath ().c_str () );\r
+ GenerateMacrosAndTargetsTarget ( module );\r
\r
+ fprintf ( fMakefile, "%s: %s %s\n",\r
+ target.c_str (),\r
+ archiveFilename.c_str (),\r
+ importLibraryDependencies.c_str () );\r
+\r
+ string linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll" );\r
+ string linkerCommand = GenerateLinkerCommand ( module,\r
+ "${gcc}",\r
+ linkerParameters,\r
+ archiveFilename );\r
fprintf ( fMakefile,\r
- "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",\r
- module.GetTargetName ().c_str (),\r
- FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
- FixupTargetFilename ( module.GetDependencyPath () ).c_str () );\r
+ "\t%s\n\n",\r
+ linkerCommand.c_str () );\r
}\r
+ else\r
+ {\r
+ fprintf ( fMakefile, "%s:\n",\r
+ target.c_str ());\r
+ fprintf ( fMakefile, ".PHONY: %s\n\n",\r
+ target.c_str ());\r
+ }\r
+}\r
+\r
+\r
+static MingwKernelModeDriverModuleHandler kernelmodedriver_handler;\r
+\r
+MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()\r
+ : MingwModuleHandler ( KernelModeDriver )\r
+{\r
+}\r
+\r
+void\r
+MingwKernelModeDriverModuleHandler::Process ( const Module& module )\r
+{\r
+ GeneratePreconditionDependencies ( module );\r
+ GenerateKernelModeDriverModuleTarget ( module );\r
+ GenerateInvocations ( module );\r
+}\r
+\r
+void\r
+MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )\r
+{\r
+ static string ros_junk ( "$(ROS_TEMPORARY)" );\r
+ string target ( FixupTargetFilename ( module.GetPath () ) );\r
+ string workingDirectory = GetWorkingDirectory ( );\r
+ string archiveFilename = GetModuleArchiveFilename ( module );\r
+ string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
\r
- if (module.files.size () > 0)\r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
+\r
+ if ( module.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module );\r
+ string* cflags = new string ( "-D__NTDRIVER__" );\r
+ GenerateMacrosAndTargetsTarget ( module,\r
+ cflags );\r
+ delete cflags;\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
string workingDirectory = GetWorkingDirectory ( );\r
string archiveFilename = GetModuleArchiveFilename ( module );\r
string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+ \r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
\r
- if (module.importLibrary != NULL)\r
- {\r
- fprintf ( fMakefile, "%s:\n",\r
- module.GetDependencyPath ().c_str () );\r
-\r
- fprintf ( fMakefile,\r
- "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",\r
- module.GetTargetName ().c_str (),\r
- FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
- FixupTargetFilename ( module.GetDependencyPath () ).c_str () );\r
- }\r
-\r
- if (module.files.size () > 0)\r
+ if ( module.files.size () > 0 )\r
{\r
GenerateMacrosAndTargetsTarget ( module );\r
\r
string archiveFilename = GetModuleArchiveFilename ( module );\r
string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
\r
- if (module.importLibrary != NULL)\r
- {\r
- fprintf ( fMakefile, "%s:\n",\r
- module.GetDependencyPath ().c_str () );\r
-\r
- fprintf ( fMakefile,\r
- "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",\r
- module.GetTargetName ().c_str (),\r
- FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
- FixupTargetFilename ( module.GetDependencyPath () ).c_str () );\r
- }\r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
\r
- if (module.files.size () > 0)\r
+ if ( module.files.size () > 0 )\r
{\r
GenerateMacrosAndTargetsTarget ( module );\r
\r
string objectFilenames = GetObjectFilenames ( module );\r
string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
\r
- if (module.files.size () > 0)\r
+ GenerateImportLibraryTargetIfNeeded ( module );\r
+\r
+ if ( module.files.size () > 0 )\r
{\r
GenerateMacrosAndTargetsTarget ( module );\r
\r
std::string GetObjectFilenames ( const Module& module ) const;\r
void GenerateMacrosAndTargetsHost ( const Module& module ) const;\r
void GenerateMacrosAndTargetsTarget ( const Module& module ) const;\r
+ void GenerateMacrosAndTargetsTarget ( const Module& module,\r
+ const std::string* clags ) const;\r
std::string GetInvocationDependencies ( const Module& module ) const;\r
std::string GetInvocationParameters ( const Invoke& invoke ) const;\r
void GenerateInvocations ( const Module& module ) const;\r
void GeneratePreconditionDependencies ( const Module& module ) const;\r
+ std::string GetCFlagsMacro ( const Module& module ) const;\r
std::string GetObjectsMacro ( const Module& module ) const;\r
std::string GetLinkerMacro ( const Module& module ) const;\r
std::string GenerateLinkerCommand ( const Module& module,\r
const std::string& linker,\r
const std::string& linkerParameters,\r
const std::string& objectFilenames ) const;\r
+ void GenerateImportLibraryTargetIfNeeded ( const Module& module ) const;\r
static FILE* fMakefile;\r
private:\r
std::string ConcatenatePaths ( const std::string& path1,\r
const std::string& objs_macro ) const;\r
void GenerateMacrosAndTargets ( const Module& module,\r
const std::string& cc,\r
- const std::string& ar ) const;\r
+ const std::string& ar,\r
+ const std::string* clags ) const;\r
std::string GetPreconditionDependenciesName ( const Module& module ) const;\r
};\r
\r
};\r
\r
\r
+class MingwKernelModeDriverModuleHandler : public MingwModuleHandler\r
+{\r
+public:\r
+ MingwKernelModeDriverModuleHandler ();\r
+ virtual void Process ( const Module& module );\r
+private:\r
+ void GenerateKernelModeDriverModuleTarget ( const Module& module );\r
+};\r
+\r
+\r
class MingwNativeDLLModuleHandler : public MingwModuleHandler\r
{\r
public:\r