\r
using std::string;\r
using std::vector;\r
+using std::map;\r
\r
-MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile )\r
- : fMakefile ( fMakefile )\r
+map<ModuleType,MingwModuleHandler*>*\r
+MingwModuleHandler::handler_map = NULL;\r
+int\r
+MingwModuleHandler::ref = 0;\r
+\r
+FILE*\r
+MingwModuleHandler::fMakefile = NULL;\r
+\r
+MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )\r
{\r
+ if ( !ref++ )\r
+ handler_map = new map<ModuleType,MingwModuleHandler*>;\r
+ (*handler_map)[moduletype] = this;\r
+}\r
+\r
+MingwModuleHandler::~MingwModuleHandler()\r
+{\r
+ if ( !--ref )\r
+ {\r
+ delete handler_map;\r
+ handler_map = NULL;\r
+ }\r
+}\r
+\r
+/*static*/ void\r
+MingwModuleHandler::SetMakefile ( FILE* f )\r
+{\r
+ fMakefile = f;\r
+}\r
+\r
+/*static*/ MingwModuleHandler*\r
+MingwModuleHandler::LookupHandler ( const string& location,\r
+ ModuleType moduletype )\r
+{\r
+ if ( !handler_map )\r
+ throw Exception ( "internal tool error: no registered module handlers" );\r
+ MingwModuleHandler* h = (*handler_map)[moduletype];\r
+ if ( !h )\r
+ {\r
+ throw UnknownModuleTypeException ( location, moduletype );\r
+ return NULL;\r
+ }\r
+ return h;\r
}\r
\r
string\r
return ".";\r
}\r
\r
+string\r
+MingwModuleHandler::GetExtension ( const string& filename ) const\r
+{\r
+ size_t index = filename.find_last_of ( '.' );\r
+ if (index != string::npos)\r
+ return filename.substr ( index );\r
+ return "";\r
+}\r
+\r
string\r
MingwModuleHandler::ReplaceExtension ( const string& filename,\r
const string& newExtension ) const\r
string\r
MingwModuleHandler::GetModuleArchiveFilename ( const Module& module ) const\r
{\r
- return ReplaceExtension ( module.GetPath ().c_str (),\r
+ return ReplaceExtension ( FixupTargetFilename ( module.GetPath () ).c_str (),\r
".a" );\r
}\r
\r
{\r
if ( dependencies.size () > 0 )\r
dependencies += " ";\r
- Module* importedModule = module.project->LocateModule ( module.libraries[i]->name );\r
+ const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );\r
assert ( importedModule != NULL );\r
- dependencies += importedModule->GetPath ().c_str ();\r
+ dependencies += FixupTargetFilename ( importedModule->GetDependencyPath () ).c_str ();\r
+ }\r
+ return dependencies;\r
+}\r
+\r
+string\r
+MingwModuleHandler::GetModuleDependencies ( const Module& module ) const\r
+{\r
+ if ( module.dependencies.size () == 0 )\r
+ return "";\r
+ \r
+ string dependencies ( "" );\r
+ for ( size_t i = 0; i < module.dependencies.size (); i++ )\r
+ {\r
+ if ( dependencies.size () > 0 )\r
+ dependencies += " ";\r
+ const Dependency* dependency = module.dependencies[i];\r
+ const Module* dependencyModule = dependency->dependencyModule;\r
+ dependencies += dependencyModule->GetTargets ();\r
+ }\r
+ return dependencies;\r
+}\r
+\r
+string\r
+MingwModuleHandler::GetAllDependencies ( const Module& module ) const\r
+{\r
+ string dependencies = GetImportLibraryDependencies ( module );\r
+ string s = GetModuleDependencies ( module );\r
+ if (s.length () > 0)\r
+ {\r
+ dependencies += " ";\r
+ dependencies += s;\r
}\r
return dependencies;\r
}\r
string\r
MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const\r
{\r
- return ReplaceExtension ( sourceFilename,\r
- ".o" );\r
+ return FixupTargetFilename ( ReplaceExtension ( sourceFilename,\r
+ ".o" ) );\r
}\r
\r
string\r
string\r
MingwModuleHandler::GenerateGccDefineParameters ( const Module& module ) const\r
{\r
- string parameters = GenerateGccDefineParametersFromVector ( module.project->defines );\r
+ string parameters = GenerateGccDefineParametersFromVector ( module.project.defines );\r
string s = GenerateGccDefineParametersFromVector ( module.defines );\r
if (s.length () > 0)\r
{\r
}\r
\r
string\r
-MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const string& basePath,\r
- const vector<Include*>& includes ) const\r
+MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Include*>& includes ) const\r
{\r
string parameters;\r
- for (size_t i = 0; i < includes.size (); i++)\r
+ for ( size_t i = 0; i < includes.size (); i++ )\r
{\r
Include& include = *includes[i];\r
if (parameters.length () > 0)\r
parameters += " ";\r
- parameters += "-I";\r
- parameters += ConcatenatePaths ( basePath,\r
- include.directory );\r
+ parameters += "-I" + include.directory;\r
}\r
return parameters;\r
}\r
\r
+void\r
+MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const\r
+{\r
+ string name ( module.name + "_CFLAGS" );\r
+ fprintf ( fMakefile,\r
+ "%s := %s %s\n",\r
+ name.c_str(),\r
+ GenerateGccDefineParameters(module).c_str(),\r
+ GenerateGccIncludeParameters(module).c_str() );\r
+}\r
+\r
string\r
MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const\r
{\r
- string parameters = GenerateGccIncludeParametersFromVector ( ".",\r
- module.project->includes );\r
- string s = GenerateGccIncludeParametersFromVector ( module.path,\r
- module.includes );\r
- if (s.length () > 0)\r
+ string parameters = GenerateGccIncludeParametersFromVector ( module.includes );\r
+ string s = GenerateGccIncludeParametersFromVector ( module.project.includes );\r
+ if ( s.length () > 0 )\r
{\r
parameters += " ";\r
parameters += s;\r
string\r
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const\r
{\r
- string parameters = GenerateGccDefineParameters ( module );\r
- string s = GenerateGccIncludeParameters ( module );\r
- if (s.length () > 0)\r
- {\r
- parameters += " ";\r
- parameters += s;\r
- }\r
- return parameters;\r
+ return ssprintf(" $(%s_CFLAGS)", module.name.c_str());\r
+}\r
+\r
+string\r
+MingwModuleHandler::GenerateNasmParameters ( const Module& module ) const\r
+{\r
+ return "";\r
+}\r
+\r
+string\r
+MingwModuleHandler::GenerateGccCommand ( const Module& module,\r
+ const string& sourceFilename,\r
+ const string& cc ) const\r
+{\r
+ string objectFilename = GetObjectFilename ( sourceFilename );\r
+ return ssprintf ( "%s -c %s -o %s %s\n",\r
+ cc.c_str (),\r
+ sourceFilename.c_str (),\r
+ objectFilename.c_str (),\r
+ GenerateGccParameters ( module ).c_str () );\r
+}\r
+\r
+string\r
+MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,\r
+ const string& sourceFilename,\r
+ const string& cc ) const\r
+{\r
+ string objectFilename = GetObjectFilename ( sourceFilename );\r
+ return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",\r
+ cc.c_str (),\r
+ sourceFilename.c_str (),\r
+ objectFilename.c_str (),\r
+ GenerateGccParameters ( module ).c_str () );\r
+}\r
+\r
+string\r
+MingwModuleHandler::GenerateNasmCommand ( const Module& module,\r
+ const string& sourceFilename ) const\r
+{\r
+ string objectFilename = GetObjectFilename ( sourceFilename );\r
+ return ssprintf ( "%s -f win32 %s -o %s %s\n",\r
+ "nasm",\r
+ sourceFilename.c_str (),\r
+ objectFilename.c_str (),\r
+ GenerateNasmParameters ( module ).c_str () );\r
+}\r
+\r
+string\r
+MingwModuleHandler::GenerateCommand ( const Module& module,\r
+ const string& sourceFilename,\r
+ const string& cc ) const\r
+{\r
+ string extension = GetExtension ( sourceFilename );\r
+ if ( extension == ".c" || extension == ".C" )\r
+ return GenerateGccCommand ( module,\r
+ sourceFilename,\r
+ cc );\r
+ else if ( extension == ".s" || extension == ".S" )\r
+ return GenerateGccAssemblerCommand ( module,\r
+ sourceFilename,\r
+ cc );\r
+ else if ( extension == ".asm" || extension == ".ASM" )\r
+ return GenerateNasmCommand ( module,\r
+ sourceFilename );\r
+\r
+ throw InvalidOperationException ( __FILE__,\r
+ __LINE__,\r
+ "Unsupported filename extension '%s' in file '%s'",\r
+ extension.c_str (),\r
+ sourceFilename.c_str () );\r
}\r
\r
void\r
-MingwModuleHandler::GenerateObjectFileTargets ( const Module& module ) const\r
+MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,\r
+ const string& cc) const\r
{\r
if ( module.files.size () == 0 )\r
return;\r
\r
+ GenerateGccModuleIncludeVariable ( module );\r
+\r
for ( size_t i = 0; i < module.files.size (); i++ )\r
{\r
string sourceFilename = module.files[i]->name;\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
objectFilename.c_str (),\r
- sourceFilename.c_str() );\r
+ sourceFilename.c_str () );\r
fprintf ( fMakefile,\r
- "\t${gcc} -c %s -o %s %s\n",\r
- sourceFilename.c_str (),\r
- objectFilename.c_str (),\r
- GenerateGccParameters ( module ).c_str () );\r
+ "\t%s\n",\r
+ GenerateCommand ( module,\r
+ sourceFilename,\r
+ cc ).c_str () );\r
}\r
\r
fprintf ( fMakefile, "\n" );\r
}\r
\r
void\r
-MingwModuleHandler::GenerateArchiveTarget ( const Module& module ) const\r
+MingwModuleHandler::GenerateObjectFileTargetsHost ( const Module& module ) const\r
+{\r
+ GenerateObjectFileTargets ( module,\r
+ "${host_gcc}" );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GenerateObjectFileTargetsTarget ( const Module& module ) const\r
+{\r
+ GenerateObjectFileTargets ( module,\r
+ "${gcc}" );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GenerateArchiveTarget ( const Module& module,\r
+ const string& ar ) const\r
{\r
string archiveFilename = GetModuleArchiveFilename ( module );\r
string sourceFilenames = GetSourceFilenames ( module );\r
- string objectFilenames = GetObjectFilenames ( module );\r
+ string objectsMacro = GenerateObjectList ( module );\r
\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
archiveFilename.c_str (),\r
- objectFilenames.c_str ());\r
+ objectsMacro.c_str ());\r
\r
fprintf ( fMakefile,\r
- "\t${ar} -rc %s %s\n\n",\r
- archiveFilename.c_str (),\r
- objectFilenames.c_str ());\r
+ "\t%s -rc %s %s\n\n",\r
+ ar.c_str (),\r
+ archiveFilename.c_str (),\r
+ objectsMacro.c_str ());\r
}\r
\r
+void\r
+MingwModuleHandler::GenerateArchiveTargetHost ( const Module& module ) const\r
+{\r
+ GenerateArchiveTarget ( module,\r
+ "${host_ar}" );\r
+}\r
\r
-MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile )\r
- : MingwModuleHandler ( fMakefile )\r
+void\r
+MingwModuleHandler::GenerateArchiveTargetTarget ( const Module& module ) const\r
{\r
+ GenerateArchiveTarget ( module,\r
+ "${ar}" );\r
}\r
\r
-bool\r
-MingwKernelModuleHandler::CanHandleModule ( const Module& module ) const\r
+string\r
+MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const\r
+{\r
+ string dependencies;\r
+ for ( size_t i = 0; i < module.invocations.size (); i++ )\r
+ {\r
+ Invoke& invoke = *module.invocations[i];\r
+ if (invoke.invokeModule == &module)\r
+ /* Protect against circular dependencies */\r
+ continue;\r
+ if ( dependencies.length () > 0 )\r
+ dependencies += " ";\r
+ dependencies += invoke.GetTargets ();\r
+ }\r
+ return dependencies;\r
+}\r
+\r
+string\r
+MingwModuleHandler::GetInvocationParameters ( const Invoke& invoke ) const\r
+{\r
+ string parameters ( "" );\r
+ size_t i;\r
+ for (i = 0; i < invoke.output.size (); i++)\r
+ {\r
+ if (parameters.length () > 0)\r
+ parameters += " ";\r
+ InvokeFile& invokeFile = *invoke.output[i];\r
+ if (invokeFile.switches.length () > 0)\r
+ {\r
+ parameters += invokeFile.switches;\r
+ parameters += " ";\r
+ }\r
+ parameters += invokeFile.name;\r
+ }\r
+\r
+ for (i = 0; i < invoke.input.size (); i++)\r
+ {\r
+ if (parameters.length () > 0)\r
+ parameters += " ";\r
+ InvokeFile& invokeFile = *invoke.input[i];\r
+ if (invokeFile.switches.length () > 0)\r
+ {\r
+ parameters += invokeFile.switches;\r
+ parameters += " ";\r
+ }\r
+ parameters += invokeFile.name;\r
+ }\r
+\r
+ return parameters;\r
+}\r
+\r
+void\r
+MingwModuleHandler::GenerateInvocations ( const Module& module ) const\r
+{\r
+ if ( module.invocations.size () == 0 )\r
+ return;\r
+ \r
+ for ( size_t i = 0; i < module.invocations.size (); i++ )\r
+ {\r
+ const Invoke& invoke = *module.invocations[i];\r
+\r
+ if ( invoke.invokeModule->type != BuildTool )\r
+ throw InvalidBuildFileException ( module.node.location,\r
+ "Only modules of type buildtool can be invoked." );\r
+\r
+ string invokeTarget = module.GetInvocationTarget ( i );\r
+ fprintf ( fMakefile,\r
+ "%s: %s\n\n",\r
+ invoke.GetTargets ().c_str (),\r
+ invokeTarget.c_str () );\r
+ fprintf ( fMakefile,\r
+ "%s: %s\n",\r
+ invokeTarget.c_str (),\r
+ FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () );\r
+ fprintf ( fMakefile,\r
+ "\t%s %s\n\n",\r
+ FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),\r
+ GetInvocationParameters ( invoke ).c_str () );\r
+ fprintf ( fMakefile,\r
+ ".PNONY: %s\n\n",\r
+ invokeTarget.c_str () );\r
+ }\r
+}\r
+\r
+string\r
+MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const\r
+{\r
+ return ssprintf ( "%s_precondition",\r
+ module.name.c_str () );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const\r
+{\r
+ string preconditionDependenciesName = GetPreconditionDependenciesName ( module );\r
+ string sourceFilenames = GetSourceFilenames ( module );\r
+ string dependencies = GetModuleDependencies ( module );\r
+ string s = GetInvocationDependencies ( module );\r
+ if ( s.length () > 0 )\r
+ {\r
+ if ( dependencies.length () > 0 )\r
+ dependencies += " ";\r
+ dependencies += s;\r
+ }\r
+ \r
+ fprintf ( fMakefile,\r
+ "%s: %s\n\n",\r
+ preconditionDependenciesName.c_str (),\r
+ dependencies.c_str () );\r
+ fprintf ( fMakefile,\r
+ "%s: %s\n\n",\r
+ sourceFilenames.c_str (),\r
+ preconditionDependenciesName.c_str ());\r
+ fprintf ( fMakefile,\r
+ ".PHONY: %s\n\n",\r
+ preconditionDependenciesName.c_str () );\r
+}\r
+\r
+string MingwModuleHandler::GenerateObjectList ( const Module& module ) const\r
+{\r
+ string macro ( ssprintf("%s_OBJS",module.name.c_str()) );\r
+ fprintf (\r
+ fMakefile,\r
+ "%s = %s\n",\r
+ macro.c_str(),\r
+ GetObjectFilenames(module).c_str() );\r
+ return ssprintf("$(%s)",macro.c_str());\r
+}\r
+\r
+\r
+static MingwBuildToolModuleHandler buildtool_handler;\r
+\r
+MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()\r
+ : MingwModuleHandler ( BuildTool )\r
+{\r
+}\r
+\r
+void\r
+MingwBuildToolModuleHandler::Process ( const Module& module )\r
+{\r
+ GeneratePreconditionDependencies ( module );\r
+ GenerateBuildToolModuleTarget ( module );\r
+ GenerateInvocations ( module );\r
+}\r
+\r
+void\r
+MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module )\r
+{\r
+ string target ( FixupTargetFilename ( module.GetPath () ) );\r
+ string archiveFilename = GetModuleArchiveFilename ( module );\r
+ fprintf ( fMakefile, "%s: %s\n",\r
+ target.c_str (),\r
+ archiveFilename.c_str () );\r
+ fprintf ( fMakefile,\r
+ "\t${host_gcc} -o %s %s\n",\r
+ target.c_str (),\r
+ archiveFilename.c_str () );\r
+ GenerateArchiveTargetHost ( module );\r
+ GenerateObjectFileTargetsHost ( module );\r
+}\r
+\r
+static MingwKernelModuleHandler kernelmodule_handler;\r
+\r
+MingwKernelModuleHandler::MingwKernelModuleHandler ()\r
+ : MingwModuleHandler ( Kernel )\r
{\r
- return module.type == KernelModeDLL;\r
}\r
\r
void\r
MingwKernelModuleHandler::Process ( const Module& module )\r
{\r
+ GeneratePreconditionDependencies ( module );\r
GenerateKernelModuleTarget ( module );\r
+ GenerateInvocations ( module );\r
}\r
\r
void\r
MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )\r
{\r
+ static string ros_junk ( "$(ROS_TEMPORARY)" );\r
+ //static string ros_output ( "$(ROS_INTERMEDIATE)" );\r
+ string target ( FixupTargetFilename(module.GetPath()) );\r
string workingDirectory = GetWorkingDirectory ( );\r
string archiveFilename = GetModuleArchiveFilename ( module );\r
string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+ string base_tmp = ros_junk + module.name + ".base.tmp";\r
+ string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
+ string temp_exp = ros_junk + module.name + ".temp.exp";\r
+ string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,_NtProcessStartup -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
+ module.GetBasePath ().c_str () );\r
fprintf ( fMakefile, "%s: %s %s\n",\r
- module.GetPath ().c_str (),\r
+ target.c_str (),\r
archiveFilename.c_str (),\r
importLibraryDependencies.c_str () );\r
fprintf ( fMakefile,\r
- "\t${gcc} -Wl,--base-file,%s" SSEP "base.tmp -o %s" SSEP "junk.tmp %s %s\n",\r
- workingDirectory.c_str (),\r
- workingDirectory.c_str (),\r
+ "\t${gcc} %s -Wl,--base-file,%s -o %s %s %s\n",\r
+ gccOptions.c_str (),\r
+ base_tmp.c_str (),\r
+ junk_tmp.c_str (),\r
archiveFilename.c_str (),\r
importLibraryDependencies.c_str () );\r
fprintf ( fMakefile,\r
- "\t${rm} %s" SSEP "junk.tmp\n",\r
- workingDirectory.c_str () );\r
+ "\t${rm} %s\n",\r
+ junk_tmp.c_str () );\r
fprintf ( fMakefile,\r
- "\t${dlltool} --dllname %s --base-file %s" SSEP "base.tmp --output-exp %s" SSEP "temp.exp --kill-at\n",\r
- module.GetPath ().c_str (),\r
- workingDirectory.c_str (),\r
- workingDirectory.c_str ());\r
+ "\t${dlltool} --dllname %s --base-file %s --output-exp %s --kill-at\n",\r
+ target.c_str (),\r
+ base_tmp.c_str (),\r
+ temp_exp.c_str ());\r
fprintf ( fMakefile,\r
- "\t${rm} %s" SSEP "base.tmp\n",\r
- workingDirectory.c_str () );\r
+ "\t${rm} %s\n",\r
+ base_tmp.c_str () );\r
fprintf ( fMakefile,\r
- "\t${ld} -Wl,%s" SSEP "temp.exp -o %s %s %s\n",\r
- workingDirectory.c_str (),\r
- module.GetPath ().c_str (),\r
+ "\t${gcc} %s -Wl,%s -o %s %s %s\n",\r
+ gccOptions.c_str (),\r
+ temp_exp.c_str (),\r
+ target.c_str (),\r
archiveFilename.c_str (),\r
importLibraryDependencies.c_str () );\r
fprintf ( fMakefile,\r
- "\t${rm} %s" SSEP "temp.exp\n",\r
- workingDirectory.c_str () );\r
+ "\t${rm} %s\n",\r
+ temp_exp.c_str () );\r
\r
- GenerateArchiveTarget ( module );\r
- GenerateObjectFileTargets ( module );\r
+ GenerateArchiveTargetTarget ( module );\r
+ GenerateObjectFileTargetsTarget ( module );\r
}\r
\r
\r
-MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( FILE* fMakefile )\r
- : MingwModuleHandler ( fMakefile )\r
-{\r
-}\r
+static MingwStaticLibraryModuleHandler staticlibrary_handler;\r
\r
-bool\r
-MingwStaticLibraryModuleHandler::CanHandleModule ( const Module& module ) const\r
+MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()\r
+ : MingwModuleHandler ( StaticLibrary )\r
{\r
- return module.type == StaticLibrary;\r
}\r
\r
void\r
MingwStaticLibraryModuleHandler::Process ( const Module& module )\r
{\r
+ GeneratePreconditionDependencies ( module );\r
GenerateStaticLibraryModuleTarget ( module );\r
+ GenerateInvocations ( module );\r
}\r
\r
void\r
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )\r
{\r
- GenerateArchiveTarget ( module );\r
- GenerateObjectFileTargets ( module );\r
+ GenerateArchiveTargetTarget ( module );\r
+ GenerateObjectFileTargetsTarget ( module );\r
+}\r
+\r
+\r
+static MingwKernelModeDLLModuleHandler kernelmodedll_handler;\r
+\r
+MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()\r
+ : MingwModuleHandler ( KernelModeDLL )\r
+{\r
+}\r
+\r
+void\r
+MingwKernelModeDLLModuleHandler::Process ( const Module& module )\r
+{\r
+ GeneratePreconditionDependencies ( module );\r
+ GenerateKernelModeDLLModuleTarget ( module );\r
+ GenerateInvocations ( module );\r
+}\r
+\r
+void\r
+MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( 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.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
+ {\r
+ fprintf ( fMakefile, "%s: %s %s\n",\r
+ target.c_str (),\r
+ archiveFilename.c_str (),\r
+ importLibraryDependencies.c_str () );\r
+ \r
+ fprintf ( fMakefile,\r
+ "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n",\r
+ target.c_str (),\r
+ archiveFilename.c_str (),\r
+ importLibraryDependencies.c_str () );\r
+ \r
+ GenerateArchiveTargetTarget ( module );\r
+ GenerateObjectFileTargetsTarget ( module );\r
+ }\r
+ else\r
+ {\r
+ fprintf ( fMakefile, "%s:\n\n",\r
+ target.c_str ());\r
+ fprintf ( fMakefile, ".PHONY: %s\n\n",\r
+ target.c_str ());\r
+ }\r
}\r