Re-insert makefile code for non-DLLs which was removed by accident
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.cpp
1 #include "../../pch.h"
2 #include <assert.h>
3
4 #include "../../rbuild.h"
5 #include "mingw.h"
6 #include "modulehandler.h"
7
8 using std::string;
9 using std::vector;
10
11 #define CLEAN_FILE(f) clean_files.push_back ( f );
12
13 static string ros_temp = "$(TEMPORARY)";
14 MingwBackend*
15 MingwModuleHandler::backend = NULL;
16 FILE*
17 MingwModuleHandler::fMakefile = NULL;
18 bool
19 MingwModuleHandler::use_pch = false;
20
21 string
22 PrefixFilename (
23 const string& filename,
24 const string& prefix )
25 {
26 if ( !prefix.length() )
27 return filename;
28 string out;
29 const char* pfilename = filename.c_str();
30 const char* p1 = strrchr ( pfilename, '/' );
31 const char* p2 = strrchr ( pfilename, '\\' );
32 if ( p1 || p2 )
33 {
34 if ( p2 > p1 )
35 p1 = p2;
36 out += string(pfilename,p1-pfilename) + CSEP;
37 pfilename = p1 + 1;
38 }
39 out += prefix + pfilename;
40 return out;
41 }
42
43 string
44 GetTargetMacro ( const Module& module, bool with_dollar )
45 {
46 string s ( module.name );
47 strupr ( &s[0] );
48 s += "_TARGET";
49 if ( with_dollar )
50 return ssprintf ( "$(%s)", s.c_str() );
51 return s;
52 }
53
54 MingwModuleHandler::MingwModuleHandler (
55 const Module& module_ )
56
57 : module(module_)
58 {
59 }
60
61 MingwModuleHandler::~MingwModuleHandler()
62 {
63 }
64
65 /*static*/ void
66 MingwModuleHandler::SetBackend ( MingwBackend* backend_ )
67 {
68 backend = backend_;
69 }
70
71 /*static*/ void
72 MingwModuleHandler::SetMakefile ( FILE* f )
73 {
74 fMakefile = f;
75 }
76
77 /*static*/ void
78 MingwModuleHandler::SetUsePch ( bool b )
79 {
80 use_pch = b;
81 }
82
83 /* static*/ string
84 MingwModuleHandler::RemoveVariables ( string path)
85 {
86 size_t i = path.find ( '$' );
87 if ( i != string::npos )
88 {
89 size_t j = path.find ( ')', i );
90 if ( j != string::npos )
91 {
92 if ( j + 2 < path.length () && path[j + 1] == CSEP )
93 return path.substr ( j + 2);
94 else
95 return path.substr ( j + 1);
96 }
97 }
98 return path;
99 }
100
101 /*static*/ string
102 MingwModuleHandler::PassThruCacheDirectory (
103 const string &file,
104 Directory* directoryTree )
105 {
106 string directory ( GetDirectory ( RemoveVariables ( file ) ) );
107 string generatedFilesDirectory = backend->AddDirectoryTarget ( directory,
108 directoryTree );
109 if ( directory.find ( generatedFilesDirectory ) != string::npos )
110 /* This path already includes the generated files directory variable */
111 return file;
112 else
113 {
114 if ( file == "" )
115 return generatedFilesDirectory;
116 return generatedFilesDirectory + SSEP + file;
117 }
118 }
119
120 /*static*/ Directory*
121 MingwModuleHandler::GetTargetDirectoryTree (
122 const Module& module )
123 {
124 if ( module.type == StaticLibrary )
125 return backend->intermediateDirectory;
126 return backend->outputDirectory;
127 }
128
129 /*static*/ string
130 MingwModuleHandler::GetTargetFilename (
131 const Module& module,
132 string_list* pclean_files )
133 {
134 string target = PassThruCacheDirectory (
135 NormalizeFilename ( module.GetPath () ),
136 GetTargetDirectoryTree ( module ) );
137 if ( pclean_files )
138 {
139 string_list& clean_files = *pclean_files;
140 CLEAN_FILE ( target );
141 }
142 return target;
143 }
144
145 /*static*/ string
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module& module,
148 string_list* pclean_files )
149 {
150 string target = PassThruCacheDirectory (
151 NormalizeFilename ( module.GetDependencyPath () ),
152 backend->intermediateDirectory );
153 if ( pclean_files )
154 {
155 string_list& clean_files = *pclean_files;
156 CLEAN_FILE ( target );
157 }
158 return target;
159 }
160
161 /*static*/ MingwModuleHandler*
162 MingwModuleHandler::InstanciateHandler (
163 const Module& module,
164 MingwBackend* backend )
165 {
166 MingwModuleHandler* handler;
167 switch ( module.type )
168 {
169 case BuildTool:
170 handler = new MingwBuildToolModuleHandler ( module );
171 break;
172 case StaticLibrary:
173 handler = new MingwStaticLibraryModuleHandler ( module );
174 break;
175 case ObjectLibrary:
176 handler = new MingwObjectLibraryModuleHandler ( module );
177 break;
178 case Kernel:
179 handler = new MingwKernelModuleHandler ( module );
180 break;
181 case NativeCUI:
182 handler = new MingwNativeCUIModuleHandler ( module );
183 break;
184 case Win32CUI:
185 handler = new MingwWin32CUIModuleHandler ( module );
186 break;
187 case Win32GUI:
188 handler = new MingwWin32GUIModuleHandler ( module );
189 break;
190 case KernelModeDLL:
191 handler = new MingwKernelModeDLLModuleHandler ( module );
192 break;
193 case NativeDLL:
194 handler = new MingwNativeDLLModuleHandler ( module );
195 break;
196 case Win32DLL:
197 handler = new MingwWin32DLLModuleHandler ( module );
198 break;
199 case KernelModeDriver:
200 handler = new MingwKernelModeDriverModuleHandler ( module );
201 break;
202 case BootLoader:
203 handler = new MingwBootLoaderModuleHandler ( module );
204 break;
205 case BootSector:
206 handler = new MingwBootSectorModuleHandler ( module );
207 break;
208 case Iso:
209 handler = new MingwIsoModuleHandler ( module );
210 break;
211 case LiveIso:
212 handler = new MingwLiveIsoModuleHandler ( module );
213 break;
214 case Test:
215 handler = new MingwTestModuleHandler ( module );
216 break;
217 case RpcServer:
218 handler = new MingwRpcServerModuleHandler ( module );
219 break;
220 case RpcClient:
221 handler = new MingwRpcClientModuleHandler ( module );
222 break;
223 default:
224 throw UnknownModuleTypeException (
225 module.node.location,
226 module.type );
227 break;
228 }
229 return handler;
230 }
231
232 string
233 MingwModuleHandler::GetWorkingDirectory () const
234 {
235 return ".";
236 }
237
238 string
239 MingwModuleHandler::GetBasename ( const string& filename ) const
240 {
241 size_t index = filename.find_last_of ( '.' );
242 if ( index != string::npos )
243 return filename.substr ( 0, index );
244 return "";
245 }
246
247 string
248 MingwModuleHandler::GetActualSourceFilename (
249 const string& filename ) const
250 {
251 string extension = GetExtension ( filename );
252 if ( extension == ".spec" || extension == ".SPEC" )
253 {
254 string basename = GetBasename ( filename );
255 return PassThruCacheDirectory ( NormalizeFilename ( basename + ".stubs.c" ),
256 backend->intermediateDirectory );
257 }
258 else if ( extension == ".idl" || extension == ".IDL" )
259 {
260 string basename = GetBasename ( filename );
261 string newname;
262 if ( module.type == RpcServer )
263 newname = basename + "_s.c";
264 else
265 newname = basename + "_c.c";
266 return PassThruCacheDirectory ( NormalizeFilename ( newname ),
267 backend->intermediateDirectory );
268 }
269 else
270 return filename;
271 }
272
273 string
274 MingwModuleHandler::GetModuleArchiveFilename () const
275 {
276 if ( module.type == StaticLibrary )
277 return GetTargetFilename ( module, NULL );
278 return PassThruCacheDirectory ( ReplaceExtension (
279 NormalizeFilename ( module.GetPath () ),
280 ".temp.a" ),
281 backend->intermediateDirectory );
282 }
283
284 bool
285 MingwModuleHandler::IsGeneratedFile ( const File& file ) const
286 {
287 string extension = GetExtension ( file.name );
288 return ( extension == ".spec" || extension == ".SPEC" );
289 }
290
291 /*static*/ bool
292 MingwModuleHandler::ReferenceObjects (
293 const Module& module )
294 {
295 if ( module.type == ObjectLibrary )
296 return true;
297 if ( module.type == RpcServer )
298 return true;
299 if ( module.type == RpcClient )
300 return true;
301 return false;
302 }
303
304 string
305 MingwModuleHandler::GetImportLibraryDependency (
306 const Module& importedModule )
307 {
308 string dep;
309 if ( ReferenceObjects ( importedModule ) )
310 dep = GetTargetMacro ( importedModule );
311 else
312 dep = GetImportLibraryFilename ( importedModule, NULL );
313 return dep;
314 }
315
316 void
317 MingwModuleHandler::GetTargets ( const Module& dependencyModule,
318 string_list& targets )
319 {
320 if ( dependencyModule.invocations.size () > 0 )
321 {
322 for ( size_t i = 0; i < dependencyModule.invocations.size (); i++ )
323 {
324 Invoke& invoke = *dependencyModule.invocations[i];
325 invoke.GetTargets ( targets );
326 }
327 }
328 else
329 targets.push_back ( GetImportLibraryDependency ( dependencyModule ) );
330 }
331
332 void
333 MingwModuleHandler::GetModuleDependencies (
334 string_list& dependencies )
335 {
336 size_t iend = module.dependencies.size ();
337
338 if ( iend == 0 )
339 return;
340
341 for ( size_t i = 0; i < iend; i++ )
342 {
343 const Dependency& dependency = *module.dependencies[i];
344 const Module& dependencyModule = *dependency.dependencyModule;
345 GetTargets ( dependencyModule,
346 dependencies );
347 }
348 GetDefinitionDependencies ( dependencies );
349 }
350
351 void
352 MingwModuleHandler::GetSourceFilenames (
353 string_list& list,
354 bool includeGeneratedFiles ) const
355 {
356 size_t i;
357
358 const vector<File*>& files = module.non_if_data.files;
359 for ( i = 0; i < files.size (); i++ )
360 {
361 if ( includeGeneratedFiles || !IsGeneratedFile ( *files[i] ) )
362 {
363 list.push_back (
364 GetActualSourceFilename ( files[i]->name ) );
365 }
366 }
367 // intentionally make a copy so that we can append more work in
368 // the middle of processing without having to go recursive
369 vector<If*> v = module.non_if_data.ifs;
370 for ( i = 0; i < v.size (); i++ )
371 {
372 size_t j;
373 If& rIf = *v[i];
374 // check for sub-ifs to add to list
375 const vector<If*>& ifs = rIf.data.ifs;
376 for ( j = 0; j < ifs.size (); j++ )
377 v.push_back ( ifs[j] );
378 const vector<File*>& files = rIf.data.files;
379 for ( j = 0; j < files.size (); j++ )
380 {
381 File& file = *files[j];
382 if ( includeGeneratedFiles || !IsGeneratedFile ( file ) )
383 {
384 list.push_back (
385 GetActualSourceFilename ( file.name ) );
386 }
387 }
388 }
389 }
390
391 void
392 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
393 string_list& list ) const
394 {
395 GetSourceFilenames ( list, false );
396 }
397
398 string
399 MingwModuleHandler::GetObjectFilename (
400 const string& sourceFilename,
401 string_list* pclean_files ) const
402 {
403 Directory* directoryTree;
404
405 string newExtension;
406 string extension = GetExtension ( sourceFilename );
407 if ( extension == ".rc" || extension == ".RC" )
408 newExtension = ".coff";
409 else if ( extension == ".spec" || extension == ".SPEC" )
410 newExtension = ".stubs.o";
411 else if ( extension == ".idl" || extension == ".IDL" )
412 {
413 if ( module.type == RpcServer )
414 newExtension = "_s.o";
415 else
416 newExtension = "_c.o";
417 }
418 else
419 newExtension = ".o";
420
421 if ( module.type == BootSector )
422 directoryTree = backend->outputDirectory;
423 else
424 directoryTree = backend->intermediateDirectory;
425
426 string obj_file = PassThruCacheDirectory (
427 NormalizeFilename ( ReplaceExtension (
428 RemoveVariables ( sourceFilename ),
429 newExtension ) ),
430 directoryTree );
431 if ( pclean_files )
432 {
433 string_list& clean_files = *pclean_files;
434 CLEAN_FILE ( obj_file );
435 }
436 return obj_file;
437 }
438
439 void
440 MingwModuleHandler::GenerateCleanTarget () const
441 {
442 if ( 0 == clean_files.size() )
443 return;
444 fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );
445 fprintf ( fMakefile, "%s_clean:\n\t-@${rm}", module.name.c_str() );
446 for ( size_t i = 0; i < clean_files.size(); i++ )
447 {
448 if ( 9==((i+1)%10) )
449 fprintf ( fMakefile, " 2>$(NUL)\n\t-@${rm}" );
450 fprintf ( fMakefile, " %s", clean_files[i].c_str() );
451 }
452 fprintf ( fMakefile, " 2>$(NUL)\n" );
453 fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );
454 }
455
456 void
457 MingwModuleHandler::GenerateInstallTarget () const
458 {
459 if ( module.installName.length () == 0 )
460 return;
461 fprintf ( fMakefile, ".PHONY: %s_install\n", module.name.c_str() );
462 fprintf ( fMakefile, "%s_install:\n", module.name.c_str() );
463 string sourceFilename = MingwModuleHandler::PassThruCacheDirectory (
464 NormalizeFilename ( module.GetPath () ),
465 backend->outputDirectory );
466 string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory (
467 NormalizeFilename ( module.installBase + SSEP + module.installName ),
468 backend->installDirectory );
469 fprintf ( fMakefile,
470 "\t$(ECHO_CP)\n" );
471 fprintf ( fMakefile,
472 "\t${cp} %s %s 1>$(NUL)\n",
473 sourceFilename.c_str (),
474 normalizedTargetFilename.c_str () );
475 }
476
477 string
478 MingwModuleHandler::GetObjectFilenames ()
479 {
480 const vector<File*>& files = module.non_if_data.files;
481 if ( files.size () == 0 )
482 return "";
483
484 string objectFilenames ( "" );
485 for ( size_t i = 0; i < files.size (); i++ )
486 {
487 if ( objectFilenames.size () > 0 )
488 objectFilenames += " ";
489 objectFilenames +=
490 GetObjectFilename ( files[i]->name, NULL );
491 }
492 return objectFilenames;
493 }
494
495 /* static */ string
496 MingwModuleHandler::GenerateGccDefineParametersFromVector (
497 const vector<Define*>& defines )
498 {
499 string parameters;
500 for ( size_t i = 0; i < defines.size (); i++ )
501 {
502 Define& define = *defines[i];
503 if (parameters.length () > 0)
504 parameters += " ";
505 parameters += "-D";
506 parameters += define.name;
507 if (define.value.length () > 0)
508 {
509 parameters += "=";
510 parameters += define.value;
511 }
512 }
513 return parameters;
514 }
515
516 string
517 MingwModuleHandler::GenerateGccDefineParameters () const
518 {
519 string parameters = GenerateGccDefineParametersFromVector ( module.project.non_if_data.defines );
520 string s = GenerateGccDefineParametersFromVector ( module.non_if_data.defines );
521 if ( s.length () > 0 )
522 {
523 parameters += " ";
524 parameters += s;
525 }
526 return parameters;
527 }
528
529 string
530 MingwModuleHandler::ConcatenatePaths (
531 const string& path1,
532 const string& path2 ) const
533 {
534 if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )
535 return path2;
536 if ( path1[path1.length ()] == CSEP )
537 return path1 + path2;
538 else
539 return path1 + CSEP + path2;
540 }
541
542 /* static */ string
543 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Include*>& includes )
544 {
545 string parameters;
546 for ( size_t i = 0; i < includes.size (); i++ )
547 {
548 Include& include = *includes[i];
549 if ( parameters.length () > 0 )
550 parameters += " ";
551 parameters += "-I" + include.directory;
552 }
553 return parameters;
554 }
555
556 string
557 MingwModuleHandler::GenerateGccIncludeParameters () const
558 {
559 string parameters = GenerateGccIncludeParametersFromVector ( module.non_if_data.includes );
560 string s = GenerateGccIncludeParametersFromVector ( module.project.non_if_data.includes );
561 if ( s.length () > 0 )
562 {
563 parameters += " ";
564 parameters += s;
565 }
566 return parameters;
567 }
568
569 string
570 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
571 {
572 string parameters;
573 for ( size_t i = 0; i < compilerFlags.size (); i++ )
574 {
575 CompilerFlag& compilerFlag = *compilerFlags[i];
576 if ( parameters.length () > 0 )
577 parameters += " ";
578 parameters += compilerFlag.flag;
579 }
580 return parameters;
581 }
582
583 string
584 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector<LinkerFlag*>& linkerFlags ) const
585 {
586 string parameters;
587 for ( size_t i = 0; i < linkerFlags.size (); i++ )
588 {
589 LinkerFlag& linkerFlag = *linkerFlags[i];
590 if ( parameters.length () > 0 )
591 parameters += " ";
592 parameters += linkerFlag.flag;
593 }
594 return parameters;
595 }
596
597 string
598 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
599 const vector<Library*>& libraries )
600 {
601 string dependencies ( "" );
602 int wrap_count = 0;
603 for ( size_t i = 0; i < libraries.size (); i++ )
604 {
605 if ( wrap_count++ == 5 )
606 dependencies += " \\\n\t\t", wrap_count = 0;
607 else if ( dependencies.size () > 0 )
608 dependencies += " ";
609 dependencies += GetImportLibraryDependency ( *libraries[i]->imported_module );
610 }
611 return dependencies;
612 }
613
614 string
615 MingwModuleHandler::GenerateLinkerParameters () const
616 {
617 return GenerateLinkerParametersFromVector ( module.linkerFlags );
618 }
619
620 void
621 MingwModuleHandler::GenerateMacro (
622 const char* assignmentOperation,
623 const string& macro,
624 const IfableData& data )
625 {
626 size_t i;
627
628 fprintf (
629 fMakefile,
630 "%s %s",
631 macro.c_str(),
632 assignmentOperation );
633
634 string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags );
635 if ( compilerParameters.size () > 0 )
636 {
637 fprintf (
638 fMakefile,
639 " %s",
640 compilerParameters.c_str () );
641 }
642
643 for ( i = 0; i < data.includes.size(); i++ )
644 {
645 fprintf (
646 fMakefile,
647 " -I%s",
648 data.includes[i]->directory.c_str() );
649 }
650 for ( i = 0; i < data.defines.size(); i++ )
651 {
652 Define& d = *data.defines[i];
653 fprintf (
654 fMakefile,
655 " -D%s",
656 d.name.c_str() );
657 if ( d.value.size() )
658 fprintf (
659 fMakefile,
660 "=%s",
661 d.value.c_str() );
662 }
663 fprintf ( fMakefile, "\n" );
664 }
665
666 void
667 MingwModuleHandler::GenerateMacros (
668 const char* assignmentOperation,
669 const IfableData& data,
670 const vector<LinkerFlag*>* linkerFlags )
671 {
672 size_t i;
673
674 if ( data.includes.size () > 0 || data.defines.size () > 0 || data.compilerFlags.size () > 0 )
675 {
676 GenerateMacro ( assignmentOperation,
677 cflagsMacro,
678 data );
679 GenerateMacro ( assignmentOperation,
680 windresflagsMacro,
681 data );
682 }
683
684 if ( linkerFlags != NULL )
685 {
686 string linkerParameters = GenerateLinkerParametersFromVector ( *linkerFlags );
687 if ( linkerParameters.size () > 0 )
688 {
689 fprintf (
690 fMakefile,
691 "%s %s %s\n",
692 linkerflagsMacro.c_str (),
693 assignmentOperation,
694 linkerParameters.c_str() );
695 }
696 }
697
698 if ( data.libraries.size () > 0 )
699 {
700 string deps = GenerateImportLibraryDependenciesFromVector ( data.libraries );
701 if ( deps.size () > 0 )
702 {
703 fprintf (
704 fMakefile,
705 "%s %s %s\n",
706 libsMacro.c_str(),
707 assignmentOperation,
708 deps.c_str() );
709 }
710 }
711
712 const vector<If*>& ifs = data.ifs;
713 for ( i = 0; i < ifs.size(); i++ )
714 {
715 If& rIf = *ifs[i];
716 if ( rIf.data.defines.size()
717 || rIf.data.includes.size()
718 || rIf.data.libraries.size()
719 || rIf.data.files.size()
720 || rIf.data.compilerFlags.size()
721 || rIf.data.ifs.size() )
722 {
723 fprintf (
724 fMakefile,
725 "ifeq (\"$(%s)\",\"%s\")\n",
726 rIf.property.c_str(),
727 rIf.value.c_str() );
728 GenerateMacros (
729 "+=",
730 rIf.data,
731 NULL );
732 fprintf (
733 fMakefile,
734 "endif\n\n" );
735 }
736 }
737 }
738
739 void
740 MingwModuleHandler::GenerateObjectMacros (
741 const char* assignmentOperation,
742 const IfableData& data,
743 const vector<LinkerFlag*>* linkerFlags )
744 {
745 size_t i;
746
747 const vector<File*>& files = data.files;
748 if ( files.size () > 0 )
749 {
750 for ( i = 0; i < files.size (); i++ )
751 {
752 File& file = *files[i];
753 if ( file.first )
754 {
755 fprintf ( fMakefile,
756 "%s := %s $(%s)\n",
757 objectsMacro.c_str(),
758 GetObjectFilename (
759 file.name, NULL ).c_str (),
760 objectsMacro.c_str() );
761 }
762 }
763 fprintf (
764 fMakefile,
765 "%s %s",
766 objectsMacro.c_str (),
767 assignmentOperation );
768 for ( i = 0; i < files.size(); i++ )
769 {
770 File& file = *files[i];
771 if ( !file.first )
772 {
773 fprintf (
774 fMakefile,
775 "%s%s",
776 ( i%10 == 9 ? " \\\n\t" : " " ),
777 GetObjectFilename (
778 file.name, NULL ).c_str () );
779 }
780 }
781 fprintf ( fMakefile, "\n" );
782 }
783
784 const vector<If*>& ifs = data.ifs;
785 for ( i = 0; i < ifs.size(); i++ )
786 {
787 If& rIf = *ifs[i];
788 if ( rIf.data.defines.size()
789 || rIf.data.includes.size()
790 || rIf.data.libraries.size()
791 || rIf.data.files.size()
792 || rIf.data.compilerFlags.size()
793 || rIf.data.ifs.size() )
794 {
795 fprintf (
796 fMakefile,
797 "ifeq (\"$(%s)\",\"%s\")\n",
798 rIf.property.c_str(),
799 rIf.value.c_str() );
800 GenerateObjectMacros (
801 "+=",
802 rIf.data,
803 NULL );
804 fprintf (
805 fMakefile,
806 "endif\n\n" );
807 }
808 }
809 }
810
811 void
812 MingwModuleHandler::GenerateGccCommand (
813 const string& sourceFilename,
814 const string& cc,
815 const string& cflagsMacro )
816 {
817 string dependencies = sourceFilename;
818 if ( module.pch && use_pch )
819 dependencies += " " + module.pch->header + ".gch";
820
821 /* WIDL generated headers may be used */
822 dependencies += " " + GetLinkingDependenciesMacro ();
823 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
824
825 string objectFilename = GetObjectFilename (
826 sourceFilename, &clean_files );
827 fprintf ( fMakefile,
828 "%s: %s | %s\n",
829 objectFilename.c_str (),
830 dependencies.c_str (),
831 GetDirectory ( objectFilename ).c_str () );
832 fprintf ( fMakefile, "\t$(ECHO_CC)\n" );
833 fprintf ( fMakefile,
834 "\t%s -c $< -o $@ %s\n",
835 cc.c_str (),
836 cflagsMacro.c_str () );
837 }
838
839 void
840 MingwModuleHandler::GenerateGccAssemblerCommand (
841 const string& sourceFilename,
842 const string& cc,
843 const string& cflagsMacro )
844 {
845 string dependencies = sourceFilename;
846 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
847 string objectFilename = GetObjectFilename (
848 sourceFilename, &clean_files );
849 fprintf ( fMakefile,
850 "%s: %s | %s\n",
851 objectFilename.c_str (),
852 dependencies.c_str (),
853 GetDirectory ( objectFilename ).c_str () );
854 fprintf ( fMakefile, "\t$(ECHO_GAS)\n" );
855 fprintf ( fMakefile,
856 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
857 cc.c_str (),
858 cflagsMacro.c_str () );
859 }
860
861 void
862 MingwModuleHandler::GenerateNasmCommand (
863 const string& sourceFilename,
864 const string& nasmflagsMacro )
865 {
866 string dependencies = sourceFilename;
867 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
868 string objectFilename = GetObjectFilename (
869 sourceFilename, &clean_files );
870 fprintf ( fMakefile,
871 "%s: %s | %s\n",
872 objectFilename.c_str (),
873 dependencies.c_str (),
874 GetDirectory ( objectFilename ).c_str () );
875 fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );
876 fprintf ( fMakefile,
877 "\t%s -f win32 $< -o $@ %s\n",
878 "$(Q)nasm",
879 nasmflagsMacro.c_str () );
880 }
881
882 void
883 MingwModuleHandler::GenerateWindresCommand (
884 const string& sourceFilename,
885 const string& windresflagsMacro )
886 {
887 string dependencies = sourceFilename;
888 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
889 string objectFilename =
890 GetObjectFilename ( sourceFilename, &clean_files );
891 string rciFilename = ros_temp + module.name + ".rci.tmp";
892 string resFilename = ros_temp + module.name + ".res.tmp";
893 if ( module.useWRC )
894 {
895 fprintf ( fMakefile,
896 "%s: %s $(WRC_TARGET) | %s\n",
897 objectFilename.c_str (),
898 dependencies.c_str (),
899 GetDirectory ( objectFilename ).c_str () );
900 fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );
901 fprintf ( fMakefile,
902 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
903 windresflagsMacro.c_str (),
904 sourceFilename.c_str (),
905 rciFilename.c_str () );
906 fprintf ( fMakefile,
907 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
908 windresflagsMacro.c_str (),
909 rciFilename.c_str (),
910 resFilename.c_str () );
911 fprintf ( fMakefile,
912 "\t-@${rm} %s 2>$(NUL)\n",
913 rciFilename.c_str () );
914 fprintf ( fMakefile,
915 "\t${windres} %s -o $@\n",
916 resFilename.c_str () );
917 fprintf ( fMakefile,
918 "\t-@${rm} %s 2>$(NUL)\n",
919 resFilename.c_str () );
920 }
921 else
922 {
923 fprintf ( fMakefile,
924 "%s: %s $(WRC_TARGET) | %s\n",
925 objectFilename.c_str (),
926 dependencies.c_str (),
927 GetDirectory ( objectFilename ).c_str () );
928 fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );
929 fprintf ( fMakefile,
930 "\t${windres} $(%s) %s -o $@\n",
931 windresflagsMacro.c_str (),
932 sourceFilename.c_str () );
933 }
934 }
935
936 void
937 MingwModuleHandler::GenerateWinebuildCommands (
938 const string& sourceFilename )
939 {
940 string dependencies = sourceFilename;
941 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
942
943 string basename = GetBasename ( sourceFilename );
944 string def_file = PassThruCacheDirectory (
945 basename + ".spec.def",
946 backend->intermediateDirectory );
947 CLEAN_FILE(def_file);
948
949 string stub_file = PassThruCacheDirectory (
950 basename + ".stubs.c",
951 backend->intermediateDirectory );
952 CLEAN_FILE(stub_file)
953
954 fprintf ( fMakefile,
955 "%s: %s $(WINEBUILD_TARGET)\n",
956 def_file.c_str (),
957 dependencies.c_str () );
958 fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
959 fprintf ( fMakefile,
960 "\t%s --def=%s -o %s\n",
961 "$(Q)$(WINEBUILD_TARGET)",
962 sourceFilename.c_str (),
963 def_file.c_str () );
964
965 fprintf ( fMakefile,
966 "%s: %s $(WINEBUILD_TARGET)\n",
967 stub_file.c_str (),
968 sourceFilename.c_str () );
969 fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
970 fprintf ( fMakefile,
971 "\t%s --pedll=%s -o %s\n",
972 "$(Q)$(WINEBUILD_TARGET)",
973 sourceFilename.c_str (),
974 stub_file.c_str () );
975 }
976
977 string
978 MingwModuleHandler::GetWidlFlags ( const File& file )
979 {
980 return file.switches;
981 }
982
983 void
984 MingwModuleHandler::GenerateWidlCommandsServer (
985 const File& file,
986 const string& widlflagsMacro )
987 {
988 string dependencies = file.name;
989 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
990
991 string basename = GetBasename ( file.name );
992
993 /*string generatedHeaderFilename = PassThruCacheDirectory (
994 basename + ".h",
995 backend->intermediateDirectory );
996 CLEAN_FILE(generatedHeaderFilename);
997 */
998 string generatedHeaderFilename = basename + "_s.h";
999 CLEAN_FILE(generatedHeaderFilename);
1000
1001 string generatedServerFilename = PassThruCacheDirectory (
1002 basename + "_s.c",
1003 backend->intermediateDirectory );
1004 CLEAN_FILE(generatedServerFilename);
1005
1006 fprintf ( fMakefile,
1007 "%s %s: %s $(WIDL_TARGET) | %s\n",
1008 generatedServerFilename.c_str (),
1009 generatedHeaderFilename.c_str (),
1010 dependencies.c_str (),
1011 GetDirectory ( generatedServerFilename ).c_str () );
1012 fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
1013 fprintf ( fMakefile,
1014 "\t%s %s %s -h -H %s -s -S %s %s\n",
1015 "$(Q)$(WIDL_TARGET)",
1016 GetWidlFlags ( file ).c_str (),
1017 widlflagsMacro.c_str (),
1018 generatedHeaderFilename.c_str (),
1019 generatedServerFilename.c_str (),
1020 file.name.c_str () );
1021 }
1022
1023 void
1024 MingwModuleHandler::GenerateWidlCommandsClient (
1025 const File& file,
1026 const string& widlflagsMacro )
1027 {
1028 string dependencies = file.name;
1029 dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
1030
1031 string basename = GetBasename ( file.name );
1032
1033 /*string generatedHeaderFilename = PassThruCacheDirectory (
1034 basename + ".h",
1035 backend->intermediateDirectory );
1036 CLEAN_FILE(generatedHeaderFilename);
1037 */
1038 string generatedHeaderFilename = basename + "_c.h";
1039 CLEAN_FILE(generatedHeaderFilename);
1040
1041 string generatedClientFilename = PassThruCacheDirectory (
1042 basename + "_c.c",
1043 backend->intermediateDirectory );
1044 CLEAN_FILE(generatedClientFilename);
1045
1046 fprintf ( fMakefile,
1047 "%s %s: %s $(WIDL_TARGET) | %s\n",
1048 generatedClientFilename.c_str (),
1049 generatedHeaderFilename.c_str (),
1050 dependencies.c_str (),
1051 GetDirectory ( generatedClientFilename ).c_str () );
1052 fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
1053 fprintf ( fMakefile,
1054 "\t%s %s %s -h -H %s -c -C %s %s\n",
1055 "$(Q)$(WIDL_TARGET)",
1056 GetWidlFlags ( file ).c_str (),
1057 widlflagsMacro.c_str (),
1058 generatedHeaderFilename.c_str (),
1059 generatedClientFilename.c_str (),
1060 file.name.c_str () );
1061 }
1062
1063 void
1064 MingwModuleHandler::GenerateWidlCommands (
1065 const File& file,
1066 const string& widlflagsMacro )
1067 {
1068 if ( module.type == RpcServer )
1069 GenerateWidlCommandsServer ( file,
1070 widlflagsMacro );
1071 else
1072 GenerateWidlCommandsClient ( file,
1073 widlflagsMacro );
1074 }
1075
1076 void
1077 MingwModuleHandler::GenerateCommands (
1078 const File& file,
1079 const string& cc,
1080 const string& cppc,
1081 const string& cflagsMacro,
1082 const string& nasmflagsMacro,
1083 const string& windresflagsMacro,
1084 const string& widlflagsMacro )
1085 {
1086 string extension = GetExtension ( file.name );
1087 if ( extension == ".c" || extension == ".C" )
1088 {
1089 GenerateGccCommand ( file.name,
1090 cc,
1091 cflagsMacro );
1092 return;
1093 }
1094 else if ( extension == ".cc" || extension == ".CC" ||
1095 extension == ".cpp" || extension == ".CPP" ||
1096 extension == ".cxx" || extension == ".CXX" )
1097 {
1098 GenerateGccCommand ( file.name,
1099 cppc,
1100 cflagsMacro );
1101 return;
1102 }
1103 else if ( extension == ".s" || extension == ".S" )
1104 {
1105 GenerateGccAssemblerCommand ( file.name,
1106 cc,
1107 cflagsMacro );
1108 return;
1109 }
1110 else if ( extension == ".asm" || extension == ".ASM" )
1111 {
1112 GenerateNasmCommand ( file.name,
1113 nasmflagsMacro );
1114 return;
1115 }
1116 else if ( extension == ".rc" || extension == ".RC" )
1117 {
1118 GenerateWindresCommand ( file.name,
1119 windresflagsMacro );
1120 return;
1121 }
1122 else if ( extension == ".spec" || extension == ".SPEC" )
1123 {
1124 GenerateWinebuildCommands ( file.name );
1125 GenerateGccCommand ( GetActualSourceFilename ( file.name ),
1126 cc,
1127 cflagsMacro );
1128 return;
1129 }
1130 else if ( extension == ".idl" || extension == ".IDL" )
1131 {
1132 GenerateWidlCommands ( file,
1133 widlflagsMacro );
1134 GenerateGccCommand ( GetActualSourceFilename ( file.name ),
1135 cc,
1136 cflagsMacro );
1137 return;
1138 }
1139
1140 throw InvalidOperationException ( __FILE__,
1141 __LINE__,
1142 "Unsupported filename extension '%s' in file '%s'",
1143 extension.c_str (),
1144 file.name.c_str () );
1145 }
1146
1147 void
1148 MingwModuleHandler::GenerateBuildMapCode ()
1149 {
1150 fprintf ( fMakefile,
1151 "ifeq ($(ROS_BUILDMAP),full)\n" );
1152
1153 string mapFilename = PassThruCacheDirectory (
1154 GetBasename ( module.GetPath () ) + ".map",
1155 backend->outputDirectory );
1156 CLEAN_FILE ( mapFilename );
1157
1158 fprintf ( fMakefile,
1159 "\t$(ECHO_OBJDUMP)\n" );
1160 fprintf ( fMakefile,
1161 "\t$(Q)${objdump} -d -S $@ > %s\n",
1162 mapFilename.c_str () );
1163
1164 fprintf ( fMakefile,
1165 "else\n" );
1166 fprintf ( fMakefile,
1167 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1168
1169 fprintf ( fMakefile,
1170 "\t$(ECHO_NM)\n" );
1171 fprintf ( fMakefile,
1172 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1173 mapFilename.c_str () );
1174
1175 fprintf ( fMakefile,
1176 "endif\n" );
1177
1178 fprintf ( fMakefile,
1179 "endif\n" );
1180 }
1181
1182 void
1183 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1184 {
1185 fprintf ( fMakefile,
1186 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1187
1188 string filename = module.GetPath ();
1189 string outputFilename = PassThruCacheDirectory (
1190 filename,
1191 backend->outputDirectory );
1192 string nostripFilename = PassThruCacheDirectory (
1193 GetBasename ( filename ) + ".nostrip" + GetExtension ( filename ),
1194 backend->outputDirectory );
1195 CLEAN_FILE ( nostripFilename );
1196
1197 fprintf ( fMakefile,
1198 "\t$(ECHO_CP)\n" );
1199 fprintf ( fMakefile,
1200 "\t${cp} %s %s 1>$(NUL)\n",
1201 outputFilename.c_str (),
1202 nostripFilename.c_str () );
1203
1204 fprintf ( fMakefile,
1205 "endif\n" );
1206 }
1207
1208 void
1209 MergeStringVector ( const vector<string>& input,
1210 vector<string>& output )
1211 {
1212 int wrap_at = 25;
1213 string s;
1214 int wrap_count = -1;
1215 for ( size_t i = 0; i < input.size (); i++ )
1216 {
1217 if ( input[i].size () == 0 )
1218 continue;
1219 if ( wrap_count++ == wrap_at )
1220 {
1221 output.push_back ( s );
1222 s = "";
1223 wrap_count = 0;
1224 }
1225 else if ( s.size () > 0)
1226 s += " ";
1227 s += input[i];
1228 }
1229 if ( s.length () > 0 )
1230 output.push_back ( s );
1231 }
1232
1233 void
1234 MingwModuleHandler::GetObjectsVector ( const IfableData& data,
1235 vector<string>& objectFiles ) const
1236 {
1237 for ( size_t i = 0; i < data.files.size (); i++ )
1238 {
1239 File& file = *data.files[i];
1240 objectFiles.push_back ( GetObjectFilename ( file.name, NULL ) );
1241 }
1242 }
1243
1244 void
1245 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1246 {
1247 if ( backend->cleanAsYouGo )
1248 {
1249 vector<string> objectFiles;
1250 GetObjectsVector ( module.non_if_data,
1251 objectFiles );
1252 vector<string> lines;
1253 MergeStringVector ( objectFiles,
1254 lines );
1255 for ( size_t i = 0; i < lines.size (); i++ )
1256 {
1257 fprintf ( fMakefile,
1258 "\t-@${rm} %s 2>$(NUL)\n",
1259 lines[i].c_str () );
1260 }
1261 }
1262 }
1263
1264 void
1265 MingwModuleHandler::GenerateRunRsymCode () const
1266 {
1267 fprintf ( fMakefile,
1268 "\t$(ECHO_RSYM)\n" );
1269 fprintf ( fMakefile,
1270 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1271 }
1272
1273 void
1274 MingwModuleHandler::GenerateLinkerCommand (
1275 const string& dependencies,
1276 const string& linker,
1277 const string& linkerParameters,
1278 const string& objectsMacro,
1279 const string& libsMacro )
1280 {
1281 string target ( GetTargetMacro ( module ) );
1282 string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );
1283 string def_file = GetDefinitionFilename ();
1284
1285 fprintf ( fMakefile,
1286 "%s: %s %s $(RSYM_TARGET) | %s\n",
1287 target.c_str (),
1288 def_file.c_str (),
1289 dependencies.c_str (),
1290 target_folder.c_str () );
1291 fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
1292 string targetName ( module.GetTargetName () );
1293
1294 if ( module.IsDLL () )
1295 {
1296 string base_tmp = ros_temp + module.name + ".base.tmp";
1297 CLEAN_FILE ( base_tmp );
1298 string junk_tmp = ros_temp + module.name + ".junk.tmp";
1299 CLEAN_FILE ( junk_tmp );
1300 string temp_exp = ros_temp + module.name + ".temp.exp";
1301 CLEAN_FILE ( temp_exp );
1302
1303 fprintf ( fMakefile,
1304 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1305 linker.c_str (),
1306 linkerParameters.c_str (),
1307 base_tmp.c_str (),
1308 junk_tmp.c_str (),
1309 objectsMacro.c_str (),
1310 libsMacro.c_str (),
1311 GetLinkerMacro ().c_str () );
1312
1313 fprintf ( fMakefile,
1314 "\t-@${rm} %s 2>$(NUL)\n",
1315 junk_tmp.c_str () );
1316
1317 string killAt = module.mangledSymbols ? "" : "--kill-at";
1318 fprintf ( fMakefile,
1319 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1320 targetName.c_str (),
1321 base_tmp.c_str (),
1322 def_file.c_str (),
1323 temp_exp.c_str (),
1324 killAt.c_str () );
1325
1326 fprintf ( fMakefile,
1327 "\t-@${rm} %s 2>$(NUL)\n",
1328 base_tmp.c_str () );
1329
1330 fprintf ( fMakefile,
1331 "\t%s %s %s -o %s %s %s %s\n",
1332 linker.c_str (),
1333 linkerParameters.c_str (),
1334 temp_exp.c_str (),
1335 target.c_str (),
1336 objectsMacro.c_str (),
1337 libsMacro.c_str (),
1338 GetLinkerMacro ().c_str () );
1339
1340 fprintf ( fMakefile,
1341 "\t-@${rm} %s 2>$(NUL)\n",
1342 temp_exp.c_str () );
1343 }
1344 else
1345 {
1346 fprintf ( fMakefile,
1347 "\t%s %s -o %s %s %s %s\n",
1348 linker.c_str (),
1349 linkerParameters.c_str (),
1350 target.c_str (),
1351 objectsMacro.c_str (),
1352 libsMacro.c_str (),
1353 GetLinkerMacro ().c_str () );
1354 }
1355
1356 GenerateBuildMapCode ();
1357 GenerateBuildNonSymbolStrippedCode ();
1358 GenerateRunRsymCode ();
1359 GenerateCleanObjectsAsYouGoCode ();
1360 }
1361
1362 void
1363 MingwModuleHandler::GeneratePhonyTarget() const
1364 {
1365 string targetMacro ( GetTargetMacro(module) );
1366 fprintf ( fMakefile, ".PHONY: %s\n\n",
1367 targetMacro.c_str ());
1368 fprintf ( fMakefile, "%s: | %s\n",
1369 targetMacro.c_str (),
1370 GetDirectory(GetTargetFilename(module,NULL)).c_str () );
1371 }
1372
1373 void
1374 MingwModuleHandler::GenerateObjectFileTargets (
1375 const IfableData& data,
1376 const string& cc,
1377 const string& cppc,
1378 const string& cflagsMacro,
1379 const string& nasmflagsMacro,
1380 const string& windresflagsMacro,
1381 const string& widlflagsMacro )
1382 {
1383 size_t i;
1384
1385 const vector<File*>& files = data.files;
1386 for ( i = 0; i < files.size (); i++ )
1387 {
1388 GenerateCommands ( *files[i],
1389 cc,
1390 cppc,
1391 cflagsMacro,
1392 nasmflagsMacro,
1393 windresflagsMacro,
1394 widlflagsMacro );
1395 fprintf ( fMakefile,
1396 "\n" );
1397 }
1398
1399 const vector<If*>& ifs = data.ifs;
1400 for ( i = 0; i < ifs.size(); i++ )
1401 {
1402 GenerateObjectFileTargets ( ifs[i]->data,
1403 cc,
1404 cppc,
1405 cflagsMacro,
1406 nasmflagsMacro,
1407 windresflagsMacro,
1408 widlflagsMacro );
1409 }
1410 }
1411
1412 void
1413 MingwModuleHandler::GenerateObjectFileTargets (
1414 const string& cc,
1415 const string& cppc,
1416 const string& cflagsMacro,
1417 const string& nasmflagsMacro,
1418 const string& windresflagsMacro,
1419 const string& widlflagsMacro )
1420 {
1421 if ( module.pch )
1422 {
1423 const string& pch_file = module.pch->header;
1424 string gch_file = pch_file + ".gch";
1425 CLEAN_FILE(gch_file);
1426 if ( use_pch )
1427 {
1428 fprintf (
1429 fMakefile,
1430 "%s: %s\n",
1431 gch_file.c_str(),
1432 pch_file.c_str() );
1433 fprintf ( fMakefile, "\t$(ECHO_PCH)\n" );
1434 fprintf (
1435 fMakefile,
1436 "\t%s -o %s %s -g %s\n\n",
1437 ( module.cplusplus ? cppc.c_str() : cc.c_str() ),
1438 gch_file.c_str(),
1439 cflagsMacro.c_str(),
1440 pch_file.c_str() );
1441 }
1442 }
1443
1444 GenerateObjectFileTargets ( module.non_if_data,
1445 cc,
1446 cppc,
1447 cflagsMacro,
1448 nasmflagsMacro,
1449 windresflagsMacro,
1450 widlflagsMacro );
1451 fprintf ( fMakefile, "\n" );
1452 }
1453
1454 string
1455 MingwModuleHandler::GenerateArchiveTarget ( const string& ar,
1456 const string& objs_macro ) const
1457 {
1458 string archiveFilename ( GetModuleArchiveFilename () );
1459
1460 fprintf ( fMakefile,
1461 "%s: %s | %s\n",
1462 archiveFilename.c_str (),
1463 objs_macro.c_str (),
1464 GetDirectory(archiveFilename).c_str() );
1465
1466 fprintf ( fMakefile, "\t$(ECHO_AR)\n" );
1467
1468 fprintf ( fMakefile,
1469 "\t%s -rc $@ %s\n",
1470 ar.c_str (),
1471 objs_macro.c_str ());
1472
1473 GenerateCleanObjectsAsYouGoCode ();
1474
1475 fprintf ( fMakefile, "\n" );
1476
1477 return archiveFilename;
1478 }
1479
1480 string
1481 MingwModuleHandler::GetCFlagsMacro () const
1482 {
1483 return ssprintf ( "$(%s_CFLAGS)",
1484 module.name.c_str () );
1485 }
1486
1487 /*static*/ string
1488 MingwModuleHandler::GetObjectsMacro ( const Module& module )
1489 {
1490 return ssprintf ( "$(%s_OBJS)",
1491 module.name.c_str () );
1492 }
1493
1494 string
1495 MingwModuleHandler::GetLinkingDependenciesMacro () const
1496 {
1497 return ssprintf ( "$(%s_LINKDEPS)", module.name.c_str () );
1498 }
1499
1500 string
1501 MingwModuleHandler::GetLibsMacro () const
1502 {
1503 return ssprintf ( "$(%s_LIBS)", module.name.c_str () );
1504 }
1505
1506 string
1507 MingwModuleHandler::GetLinkerMacro () const
1508 {
1509 return ssprintf ( "$(%s_LFLAGS)",
1510 module.name.c_str () );
1511 }
1512
1513 string
1514 MingwModuleHandler::GetModuleTargets ( const Module& module )
1515 {
1516 if ( ReferenceObjects ( module ) )
1517 return GetObjectsMacro ( module );
1518 else
1519 return GetTargetFilename ( module, NULL );
1520 }
1521
1522 void
1523 MingwModuleHandler::GenerateObjectMacro ()
1524 {
1525 objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
1526
1527 GenerateObjectMacros (
1528 "=",
1529 module.non_if_data,
1530 &module.linkerFlags );
1531
1532 // future references to the macro will be to get its values
1533 objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
1534 }
1535
1536 void
1537 MingwModuleHandler::GenerateTargetMacro ()
1538 {
1539 fprintf ( fMakefile,
1540 "%s := %s\n",
1541 GetTargetMacro ( module, false ).c_str (),
1542 GetModuleTargets ( module ).c_str () );
1543 }
1544
1545 void
1546 MingwModuleHandler::GenerateOtherMacros ()
1547 {
1548 cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
1549 nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
1550 windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
1551 widlflagsMacro = ssprintf ("%s_WIDLFLAGS", module.name.c_str ());
1552 linkerflagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
1553 libsMacro = ssprintf("%s_LIBS", module.name.c_str ());
1554 linkDepsMacro = ssprintf ("%s_LINKDEPS", module.name.c_str ());
1555
1556 GenerateMacros (
1557 "=",
1558 module.non_if_data,
1559 &module.linkerFlags );
1560
1561 if ( module.importLibrary )
1562 {
1563 string_list s;
1564 const vector<File*>& files = module.non_if_data.files;
1565 for ( size_t i = 0; i < files.size (); i++ )
1566 {
1567 File& file = *files[i];
1568 string extension = GetExtension ( file.name );
1569 if ( extension == ".spec" || extension == ".SPEC" )
1570 GetSpecObjectDependencies ( s, file.name );
1571 }
1572 if ( s.size () > 0 )
1573 {
1574 fprintf (
1575 fMakefile,
1576 "%s +=",
1577 linkDepsMacro.c_str() );
1578 for ( size_t i = 0; i < s.size(); i++ )
1579 fprintf ( fMakefile,
1580 " %s",
1581 s[i].c_str () );
1582 fprintf ( fMakefile, "\n" );
1583 }
1584 }
1585
1586 string globalCflags = "-g";
1587 if ( backend->usePipe )
1588 globalCflags += " -pipe";
1589 if ( !module.enableWarnings )
1590 globalCflags += " -Werror";
1591
1592 fprintf (
1593 fMakefile,
1594 "%s += $(PROJECT_CFLAGS) %s\n",
1595 cflagsMacro.c_str (),
1596 globalCflags.c_str () );
1597
1598 fprintf (
1599 fMakefile,
1600 "%s += $(PROJECT_RCFLAGS)\n",
1601 windresflagsMacro.c_str () );
1602
1603 fprintf (
1604 fMakefile,
1605 "%s += $(PROJECT_WIDLFLAGS)\n",
1606 widlflagsMacro.c_str () );
1607
1608 fprintf (
1609 fMakefile,
1610 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1611 module.name.c_str () );
1612
1613 fprintf (
1614 fMakefile,
1615 "%s += $(%s)\n",
1616 linkDepsMacro.c_str (),
1617 libsMacro.c_str () );
1618
1619 string cflags = TypeSpecificCFlags();
1620 if ( cflags.size() > 0 )
1621 {
1622 fprintf ( fMakefile,
1623 "%s += %s\n\n",
1624 cflagsMacro.c_str (),
1625 cflags.c_str () );
1626 }
1627
1628 string nasmflags = TypeSpecificNasmFlags();
1629 if ( nasmflags.size () > 0 )
1630 {
1631 fprintf ( fMakefile,
1632 "%s += %s\n\n",
1633 nasmflagsMacro.c_str (),
1634 nasmflags.c_str () );
1635 }
1636
1637 string linkerflags = TypeSpecificLinkerFlags();
1638 if ( linkerflags.size() > 0 )
1639 {
1640 fprintf ( fMakefile,
1641 "%s += %s\n\n",
1642 linkerflagsMacro.c_str (),
1643 linkerflags.c_str () );
1644 }
1645
1646 fprintf ( fMakefile, "\n\n" );
1647
1648 // future references to the macros will be to get their values
1649 cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());
1650 nasmflagsMacro = ssprintf ("$(%s)", nasmflagsMacro.c_str ());
1651 widlflagsMacro = ssprintf ("$(%s)", widlflagsMacro.c_str ());
1652 }
1653
1654 void
1655 MingwModuleHandler::GenerateRules ()
1656 {
1657 string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" );
1658 string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" );
1659 string ar = ( module.host == HostTrue ? "${host_ar}" : "${ar}" );
1660
1661 string targetMacro = GetTargetMacro ( module );
1662
1663 CLEAN_FILE ( targetMacro );
1664
1665 // generate phony target for module name
1666 fprintf ( fMakefile, ".PHONY: %s\n",
1667 module.name.c_str () );
1668 fprintf ( fMakefile, "%s: %s\n\n",
1669 module.name.c_str (),
1670 GetTargetMacro ( module ).c_str () );
1671
1672 if ( !ReferenceObjects ( module ) )
1673 {
1674 string ar_target ( GenerateArchiveTarget ( ar, objectsMacro ) );
1675 if ( targetMacro != ar_target )
1676 {
1677 CLEAN_FILE ( ar_target );
1678 }
1679 }
1680
1681 GenerateObjectFileTargets ( cc,
1682 cppc,
1683 cflagsMacro,
1684 nasmflagsMacro,
1685 windresflagsMacro,
1686 widlflagsMacro );
1687 }
1688
1689 void
1690 MingwModuleHandler::GetInvocationDependencies (
1691 const Module& module,
1692 string_list& dependencies )
1693 {
1694 for ( size_t i = 0; i < module.invocations.size (); i++ )
1695 {
1696 Invoke& invoke = *module.invocations[i];
1697 if ( invoke.invokeModule == &module )
1698 /* Protect against circular dependencies */
1699 continue;
1700 invoke.GetTargets ( dependencies );
1701 }
1702 }
1703
1704 void
1705 MingwModuleHandler::GenerateInvocations () const
1706 {
1707 if ( module.invocations.size () == 0 )
1708 return;
1709
1710 size_t iend = module.invocations.size ();
1711 for ( size_t i = 0; i < iend; i++ )
1712 {
1713 const Invoke& invoke = *module.invocations[i];
1714
1715 if ( invoke.invokeModule->type != BuildTool )
1716 {
1717 throw InvalidBuildFileException ( module.node.location,
1718 "Only modules of type buildtool can be invoked." );
1719 }
1720
1721 string invokeTarget = module.GetInvocationTarget ( i );
1722 string_list invoke_targets;
1723 assert ( invoke_targets.size() );
1724 invoke.GetTargets ( invoke_targets );
1725 fprintf ( fMakefile,
1726 ".PHONY: %s\n\n",
1727 invokeTarget.c_str () );
1728 fprintf ( fMakefile,
1729 "%s:",
1730 invokeTarget.c_str () );
1731 size_t j, jend = invoke_targets.size();
1732 for ( j = 0; j < jend; j++ )
1733 {
1734 fprintf ( fMakefile,
1735 " %s",
1736 invoke_targets[i].c_str () );
1737 }
1738 fprintf ( fMakefile, "\n\n%s", invoke_targets[0].c_str () );
1739 for ( j = 1; j < jend; j++ )
1740 fprintf ( fMakefile,
1741 " %s",
1742 invoke_targets[i].c_str () );
1743 fprintf ( fMakefile,
1744 ": %s\n",
1745 NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str () );
1746 fprintf ( fMakefile, "\t$(ECHO_INVOKE)\n" );
1747 fprintf ( fMakefile,
1748 "\t%s %s\n\n",
1749 NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str (),
1750 invoke.GetParameters ().c_str () );
1751 }
1752 }
1753
1754 string
1755 MingwModuleHandler::GetPreconditionDependenciesName () const
1756 {
1757 return module.name + "_precondition";
1758 }
1759
1760 void
1761 MingwModuleHandler::GetDefaultDependencies (
1762 string_list& dependencies ) const
1763 {
1764 /* Avoid circular dependency */
1765 if ( module.type != BuildTool
1766 && module.name != "zlib"
1767 && module.name != "hostzlib" )
1768
1769 dependencies.push_back ( "$(INIT)" );
1770 }
1771
1772 void
1773 MingwModuleHandler::GeneratePreconditionDependencies ()
1774 {
1775 string preconditionDependenciesName = GetPreconditionDependenciesName ();
1776 string_list sourceFilenames;
1777 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames );
1778 string_list dependencies;
1779 GetDefaultDependencies ( dependencies );
1780 GetModuleDependencies ( dependencies );
1781
1782 GetInvocationDependencies ( module, dependencies );
1783
1784 if ( dependencies.size() )
1785 {
1786 fprintf ( fMakefile,
1787 "%s =",
1788 preconditionDependenciesName.c_str () );
1789 for ( size_t i = 0; i < dependencies.size(); i++ )
1790 fprintf ( fMakefile,
1791 " %s",
1792 dependencies[i].c_str () );
1793 fprintf ( fMakefile, "\n\n" );
1794 }
1795
1796 for ( size_t i = 0; i < sourceFilenames.size(); i++ )
1797 {
1798 fprintf ( fMakefile,
1799 "%s: ${%s}\n",
1800 sourceFilenames[i].c_str(),
1801 preconditionDependenciesName.c_str ());
1802 }
1803 fprintf ( fMakefile, "\n" );
1804 }
1805
1806 bool
1807 MingwModuleHandler::IsWineModule () const
1808 {
1809 if ( module.importLibrary == NULL)
1810 return false;
1811
1812 size_t index = module.importLibrary->definition.rfind ( ".spec.def" );
1813 return ( index != string::npos );
1814 }
1815
1816 string
1817 MingwModuleHandler::GetDefinitionFilename () const
1818 {
1819 if ( module.importLibrary != NULL )
1820 {
1821 string defFilename = module.GetBasePath () + SSEP + module.importLibrary->definition;
1822 if ( IsWineModule () )
1823 return PassThruCacheDirectory ( NormalizeFilename ( defFilename ),
1824 backend->intermediateDirectory );
1825 else
1826 return defFilename;
1827 }
1828 else
1829 return "tools" SSEP "rbuild" SSEP "empty.def";
1830 }
1831
1832 void
1833 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1834 {
1835 if ( module.importLibrary != NULL )
1836 {
1837 string library_target (
1838 GetImportLibraryFilename ( module, &clean_files ) );
1839 string defFilename = GetDefinitionFilename ();
1840
1841 string_list deps;
1842 GetDefinitionDependencies ( deps );
1843
1844 fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" );
1845
1846 fprintf ( fMakefile, "%s: %s",
1847 library_target.c_str (),
1848 defFilename.c_str () );
1849
1850 size_t i, iend = deps.size();
1851 for ( i = 0; i < iend; i++ )
1852 fprintf ( fMakefile, " %s",
1853 deps[i].c_str () );
1854
1855 fprintf ( fMakefile, " | %s\n",
1856 GetDirectory ( GetImportLibraryFilename ( module, NULL ) ).c_str () );
1857
1858 fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
1859
1860 string killAt = module.mangledSymbols ? "" : "--kill-at";
1861 fprintf ( fMakefile,
1862 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1863 module.GetTargetName ().c_str (),
1864 defFilename.c_str (),
1865 library_target.c_str (),
1866 killAt.c_str () );
1867 }
1868 }
1869
1870 void
1871 MingwModuleHandler::GetSpecObjectDependencies (
1872 string_list& dependencies,
1873 const string& filename ) const
1874 {
1875 string basename = GetBasename ( filename );
1876 string defDependency = PassThruCacheDirectory (
1877 NormalizeFilename ( basename + ".spec.def" ),
1878 backend->intermediateDirectory );
1879 dependencies.push_back ( defDependency );
1880 string stubsDependency = PassThruCacheDirectory (
1881 NormalizeFilename ( basename + ".stubs.c" ),
1882 backend->intermediateDirectory );
1883 dependencies.push_back ( stubsDependency );
1884 }
1885
1886 void
1887 MingwModuleHandler::GetWidlObjectDependencies (
1888 string_list& dependencies,
1889 const string& filename ) const
1890 {
1891 string basename = GetBasename ( filename );
1892 string serverDependency = PassThruCacheDirectory (
1893 NormalizeFilename ( basename + "_s.c" ),
1894 backend->intermediateDirectory );
1895 dependencies.push_back ( serverDependency );
1896 }
1897
1898 void
1899 MingwModuleHandler::GetDefinitionDependencies (
1900 string_list& dependencies ) const
1901 {
1902 string dkNkmLibNoFixup = "dk/nkm/lib";
1903 const vector<File*>& files = module.non_if_data.files;
1904 for ( size_t i = 0; i < files.size (); i++ )
1905 {
1906 File& file = *files[i];
1907 string extension = GetExtension ( file.name );
1908 if ( extension == ".spec" || extension == ".SPEC" )
1909 {
1910 GetSpecObjectDependencies ( dependencies, file.name );
1911 }
1912 if ( extension == ".idl" || extension == ".IDL" )
1913 {
1914 GetWidlObjectDependencies ( dependencies, file.name );
1915 }
1916 }
1917 }
1918
1919
1920 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module& module_ )
1921 : MingwModuleHandler ( module_ )
1922 {
1923 }
1924
1925 void
1926 MingwBuildToolModuleHandler::Process ()
1927 {
1928 GenerateBuildToolModuleTarget ();
1929 }
1930
1931 void
1932 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1933 {
1934 string targetMacro ( GetTargetMacro (module) );
1935 string objectsMacro = GetObjectsMacro ( module );
1936 string linkDepsMacro = GetLinkingDependenciesMacro ();
1937 string libsMacro = GetLibsMacro ();
1938
1939 GenerateRules ();
1940
1941 string linker;
1942 if ( module.cplusplus )
1943 linker = "${host_gpp}";
1944 else
1945 linker = "${host_gcc}";
1946
1947 fprintf ( fMakefile, "%s: %s %s | %s\n",
1948 targetMacro.c_str (),
1949 objectsMacro.c_str (),
1950 linkDepsMacro.c_str (),
1951 GetDirectory(GetTargetFilename(module,NULL)).c_str () );
1952 fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
1953 fprintf ( fMakefile,
1954 "\t%s %s -o $@ %s %s\n\n",
1955 linker.c_str (),
1956 GetLinkerMacro ().c_str (),
1957 objectsMacro.c_str (),
1958 libsMacro.c_str () );
1959 }
1960
1961
1962 MingwKernelModuleHandler::MingwKernelModuleHandler (
1963 const Module& module_ )
1964
1965 : MingwModuleHandler ( module_ )
1966 {
1967 }
1968
1969 void
1970 MingwKernelModuleHandler::Process ()
1971 {
1972 GenerateKernelModuleTarget ();
1973 }
1974
1975 void
1976 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1977 {
1978 string targetMacro ( GetTargetMacro ( module ) );
1979 string workingDirectory = GetWorkingDirectory ( );
1980 string objectsMacro = GetObjectsMacro ( module );
1981 string linkDepsMacro = GetLinkingDependenciesMacro ();
1982 string libsMacro = GetLibsMacro ();
1983
1984 GenerateImportLibraryTargetIfNeeded ();
1985
1986 if ( module.non_if_data.files.size () > 0 )
1987 {
1988 GenerateRules ();
1989
1990 string dependencies = linkDepsMacro + " " + objectsMacro;
1991
1992 string linkerParameters = ssprintf ( "-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
1993 module.GetBasePath ().c_str (),
1994 module.entrypoint.c_str (),
1995 module.baseaddress.c_str () );
1996 GenerateLinkerCommand ( dependencies,
1997 "${gcc}",
1998 linkerParameters,
1999 objectsMacro,
2000 libsMacro );
2001 }
2002 else
2003 {
2004 GeneratePhonyTarget();
2005 }
2006 }
2007
2008
2009 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2010 const Module& module_ )
2011
2012 : MingwModuleHandler ( module_ )
2013 {
2014 }
2015
2016 void
2017 MingwStaticLibraryModuleHandler::Process ()
2018 {
2019 GenerateStaticLibraryModuleTarget ();
2020 }
2021
2022 void
2023 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2024 {
2025 GenerateRules ();
2026 }
2027
2028
2029 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2030 const Module& module_ )
2031
2032 : MingwModuleHandler ( module_ )
2033 {
2034 }
2035
2036 void
2037 MingwObjectLibraryModuleHandler::Process ()
2038 {
2039 GenerateObjectLibraryModuleTarget ();
2040 }
2041
2042 void
2043 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2044 {
2045 GenerateRules ();
2046 }
2047
2048
2049 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2050 const Module& module_ )
2051
2052 : MingwModuleHandler ( module_ )
2053 {
2054 }
2055
2056 void
2057 MingwKernelModeDLLModuleHandler::Process ()
2058 {
2059 GenerateKernelModeDLLModuleTarget ();
2060 }
2061
2062 void
2063 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2064 {
2065 string targetMacro ( GetTargetMacro ( module ) );
2066 string workingDirectory = GetWorkingDirectory ( );
2067 string objectsMacro = GetObjectsMacro ( module );
2068 string linkDepsMacro = GetLinkingDependenciesMacro ();
2069 string libsMacro = GetLibsMacro ();
2070
2071 GenerateImportLibraryTargetIfNeeded ();
2072
2073 if ( module.non_if_data.files.size () > 0 )
2074 {
2075 GenerateRules ();
2076
2077 string dependencies = linkDepsMacro + " " + objectsMacro;
2078
2079 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2080 module.entrypoint.c_str (),
2081 module.baseaddress.c_str () );
2082 GenerateLinkerCommand ( dependencies,
2083 "${gcc}",
2084 linkerParameters,
2085 objectsMacro,
2086 libsMacro );
2087 }
2088 else
2089 {
2090 GeneratePhonyTarget();
2091 }
2092 }
2093
2094
2095 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2096 const Module& module_ )
2097
2098 : MingwModuleHandler ( module_ )
2099 {
2100 }
2101
2102 void
2103 MingwKernelModeDriverModuleHandler::Process ()
2104 {
2105 GenerateKernelModeDriverModuleTarget ();
2106 }
2107
2108
2109 void
2110 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2111 {
2112 string targetMacro ( GetTargetMacro (module) );
2113 string workingDirectory = GetWorkingDirectory ();
2114 string objectsMacro = GetObjectsMacro ( module );
2115 string linkDepsMacro = GetLinkingDependenciesMacro ();
2116 string libsMacro = GetLibsMacro ();
2117
2118 GenerateImportLibraryTargetIfNeeded ();
2119
2120 if ( module.non_if_data.files.size () > 0 )
2121 {
2122 GenerateRules ();
2123
2124 string dependencies = linkDepsMacro + " " + objectsMacro;
2125
2126 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2127 module.entrypoint.c_str (),
2128 module.baseaddress.c_str () );
2129 GenerateLinkerCommand ( dependencies,
2130 "${gcc}",
2131 linkerParameters,
2132 objectsMacro,
2133 libsMacro );
2134 }
2135 else
2136 {
2137 GeneratePhonyTarget();
2138 }
2139 }
2140
2141
2142 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2143 const Module& module_ )
2144
2145 : MingwModuleHandler ( module_ )
2146 {
2147 }
2148
2149 void
2150 MingwNativeDLLModuleHandler::Process ()
2151 {
2152 GenerateNativeDLLModuleTarget ();
2153 }
2154
2155 void
2156 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2157 {
2158 string targetMacro ( GetTargetMacro (module) );
2159 string workingDirectory = GetWorkingDirectory ( );
2160 string objectsMacro = GetObjectsMacro ( module );
2161 string linkDepsMacro = GetLinkingDependenciesMacro ();
2162 string libsMacro = GetLibsMacro ();
2163
2164 GenerateImportLibraryTargetIfNeeded ();
2165
2166 if ( module.non_if_data.files.size () > 0 )
2167 {
2168 GenerateRules ();
2169
2170 string dependencies = linkDepsMacro + " " + objectsMacro;
2171
2172 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll --dll",
2173 module.entrypoint.c_str (),
2174 module.baseaddress.c_str () );
2175 GenerateLinkerCommand ( dependencies,
2176 "${gcc}",
2177 linkerParameters,
2178 objectsMacro,
2179 libsMacro );
2180 }
2181 else
2182 {
2183 GeneratePhonyTarget();
2184 }
2185 }
2186
2187
2188 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2189 const Module& module_ )
2190
2191 : MingwModuleHandler ( module_ )
2192 {
2193 }
2194
2195 void
2196 MingwNativeCUIModuleHandler::Process ()
2197 {
2198 GenerateNativeCUIModuleTarget ();
2199 }
2200
2201 void
2202 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2203 {
2204 string targetMacro ( GetTargetMacro (module) );
2205 string workingDirectory = GetWorkingDirectory ( );
2206 string objectsMacro = GetObjectsMacro ( module );
2207 string linkDepsMacro = GetLinkingDependenciesMacro ();
2208 string libsMacro = GetLibsMacro ();
2209
2210 GenerateImportLibraryTargetIfNeeded ();
2211
2212 if ( module.non_if_data.files.size () > 0 )
2213 {
2214 GenerateRules ();
2215
2216 string dependencies = linkDepsMacro + " " + objectsMacro;
2217
2218 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2219 module.entrypoint.c_str (),
2220 module.baseaddress.c_str () );
2221 GenerateLinkerCommand ( dependencies,
2222 "${gcc}",
2223 linkerParameters,
2224 objectsMacro,
2225 libsMacro );
2226 }
2227 else
2228 {
2229 GeneratePhonyTarget();
2230 }
2231 }
2232
2233
2234 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2235 const Module& module_ )
2236
2237 : MingwModuleHandler ( module_ )
2238 {
2239 }
2240
2241 void
2242 MingwWin32DLLModuleHandler::Process ()
2243 {
2244 GenerateWin32DLLModuleTarget ();
2245 }
2246
2247 void
2248 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2249 {
2250 string targetMacro ( GetTargetMacro (module) );
2251 string workingDirectory = GetWorkingDirectory ( );
2252 string objectsMacro = GetObjectsMacro ( module );
2253 string linkDepsMacro = GetLinkingDependenciesMacro ();
2254 string libsMacro = GetLibsMacro ();
2255
2256 GenerateImportLibraryTargetIfNeeded ();
2257
2258 if ( module.non_if_data.files.size () > 0 )
2259 {
2260 GenerateRules ();
2261
2262 string dependencies = linkDepsMacro + " " + objectsMacro;
2263
2264 string linker;
2265 if ( module.cplusplus )
2266 linker = "${gpp}";
2267 else
2268 linker = "${gcc}";
2269
2270 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2271 module.entrypoint.c_str (),
2272 module.baseaddress.c_str () );
2273 GenerateLinkerCommand ( dependencies,
2274 linker,
2275 linkerParameters,
2276 objectsMacro,
2277 libsMacro );
2278 }
2279 else
2280 {
2281 GeneratePhonyTarget();
2282 }
2283 }
2284
2285
2286 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2287 const Module& module_ )
2288
2289 : MingwModuleHandler ( module_ )
2290 {
2291 }
2292
2293 void
2294 MingwWin32CUIModuleHandler::Process ()
2295 {
2296 GenerateWin32CUIModuleTarget ();
2297 }
2298
2299 void
2300 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2301 {
2302 string targetMacro ( GetTargetMacro (module) );
2303 string workingDirectory = GetWorkingDirectory ( );
2304 string objectsMacro = GetObjectsMacro ( module );
2305 string linkDepsMacro = GetLinkingDependenciesMacro ();
2306 string libsMacro = GetLibsMacro ();
2307
2308 GenerateImportLibraryTargetIfNeeded ();
2309
2310 if ( module.non_if_data.files.size () > 0 )
2311 {
2312 GenerateRules ();
2313
2314 string dependencies = linkDepsMacro + " " + objectsMacro;
2315
2316 string linker;
2317 if ( module.cplusplus )
2318 linker = "${gpp}";
2319 else
2320 linker = "${gcc}";
2321
2322 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2323 module.entrypoint.c_str (),
2324 module.baseaddress.c_str () );
2325 GenerateLinkerCommand ( dependencies,
2326 linker,
2327 linkerParameters,
2328 objectsMacro,
2329 libsMacro );
2330 }
2331 else
2332 {
2333 GeneratePhonyTarget();
2334 }
2335 }
2336
2337
2338 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2339 const Module& module_ )
2340
2341 : MingwModuleHandler ( module_ )
2342 {
2343 }
2344
2345 void
2346 MingwWin32GUIModuleHandler::Process ()
2347 {
2348 GenerateWin32GUIModuleTarget ();
2349 }
2350
2351 void
2352 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2353 {
2354 string targetMacro ( GetTargetMacro (module) );
2355 string workingDirectory = GetWorkingDirectory ( );
2356 string objectsMacro = GetObjectsMacro ( module );
2357 string linkDepsMacro = GetLinkingDependenciesMacro ();
2358 string libsMacro = GetLibsMacro ();
2359
2360 GenerateImportLibraryTargetIfNeeded ();
2361
2362 if ( module.non_if_data.files.size () > 0 )
2363 {
2364 GenerateRules ();
2365
2366 string dependencies = linkDepsMacro + " " + objectsMacro;
2367
2368 string linker;
2369 if ( module.cplusplus )
2370 linker = "${gpp}";
2371 else
2372 linker = "${gcc}";
2373
2374 string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2375 module.entrypoint.c_str (),
2376 module.baseaddress.c_str () );
2377 GenerateLinkerCommand ( dependencies,
2378 linker,
2379 linkerParameters,
2380 objectsMacro,
2381 libsMacro );
2382 }
2383 else
2384 {
2385 GeneratePhonyTarget();
2386 }
2387 }
2388
2389
2390 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2391 const Module& module_ )
2392
2393 : MingwModuleHandler ( module_ )
2394 {
2395 }
2396
2397 void
2398 MingwBootLoaderModuleHandler::Process ()
2399 {
2400 GenerateBootLoaderModuleTarget ();
2401 }
2402
2403 void
2404 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2405 {
2406 string targetName ( module.GetTargetName () );
2407 string targetMacro ( GetTargetMacro (module) );
2408 string workingDirectory = GetWorkingDirectory ();
2409 string junk_tmp = ros_temp + module.name + ".junk.tmp";
2410 CLEAN_FILE ( junk_tmp );
2411 string objectsMacro = GetObjectsMacro ( module );
2412 string linkDepsMacro = GetLinkingDependenciesMacro ();
2413 string libsMacro = GetLibsMacro ();
2414
2415 GenerateRules ();
2416
2417 fprintf ( fMakefile, "%s: %s %s | %s\n",
2418 targetMacro.c_str (),
2419 objectsMacro.c_str (),
2420 linkDepsMacro.c_str (),
2421 GetDirectory(GetTargetFilename(module,NULL)).c_str () );
2422
2423 fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
2424
2425 fprintf ( fMakefile,
2426 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2427 GetLinkerMacro ().c_str (),
2428 junk_tmp.c_str (),
2429 objectsMacro.c_str (),
2430 linkDepsMacro.c_str () );
2431 fprintf ( fMakefile,
2432 "\t${objcopy} -O binary %s $@\n",
2433 junk_tmp.c_str () );
2434 fprintf ( fMakefile,
2435 "\t-@${rm} %s 2>$(NUL)\n",
2436 junk_tmp.c_str () );
2437 }
2438
2439
2440 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2441 const Module& module_ )
2442
2443 : MingwModuleHandler ( module_ )
2444 {
2445 }
2446
2447 void
2448 MingwBootSectorModuleHandler::Process ()
2449 {
2450 GenerateBootSectorModuleTarget ();
2451 }
2452
2453 void
2454 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2455 {
2456 string objectsMacro = GetObjectsMacro ( module );
2457
2458 GenerateRules ();
2459
2460 fprintf ( fMakefile, ".PHONY: %s\n\n",
2461 module.name.c_str ());
2462 fprintf ( fMakefile,
2463 "%s: %s\n",
2464 module.name.c_str (),
2465 objectsMacro.c_str () );
2466 }
2467
2468
2469 MingwIsoModuleHandler::MingwIsoModuleHandler (
2470 const Module& module_ )
2471
2472 : MingwModuleHandler ( module_ )
2473 {
2474 }
2475
2476 void
2477 MingwIsoModuleHandler::Process ()
2478 {
2479 GenerateIsoModuleTarget ();
2480 }
2481
2482 void
2483 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2484 const string& bootcdDirectory )
2485 {
2486 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2487 {
2488 const Module& m = *module.project.modules[i];
2489 if ( m.bootstrap != NULL )
2490 {
2491 string sourceFilename = PassThruCacheDirectory (
2492 NormalizeFilename ( m.GetPath () ),
2493 backend->outputDirectory );
2494 string targetFilenameNoFixup ( bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd );
2495 string targetFilename = MingwModuleHandler::PassThruCacheDirectory (
2496 NormalizeFilename ( targetFilenameNoFixup ),
2497 backend->outputDirectory );
2498 fprintf ( fMakefile,
2499 "\t$(ECHO_CP)\n" );
2500 fprintf ( fMakefile,
2501 "\t${cp} %s %s 1>$(NUL)\n",
2502 sourceFilename.c_str (),
2503 targetFilename.c_str () );
2504 }
2505 }
2506 }
2507
2508 void
2509 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2510 const string& bootcdDirectory )
2511 {
2512 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2513 {
2514 const CDFile& cdfile = *module.project.cdfiles[i];
2515 string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd;
2516 string targetFilename = MingwModuleHandler::PassThruCacheDirectory (
2517 NormalizeFilename ( targetFilenameNoFixup ),
2518 backend->outputDirectory );
2519 fprintf ( fMakefile,
2520 "\t$(ECHO_CP)\n" );
2521 fprintf ( fMakefile,
2522 "\t${cp} %s %s 1>$(NUL)\n",
2523 cdfile.GetPath ().c_str (),
2524 targetFilename.c_str () );
2525 }
2526 }
2527
2528 string
2529 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string& bootcdDirectory )
2530 {
2531 string directories;
2532 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2533 {
2534 const Module& m = *module.project.modules[i];
2535 if ( m.bootstrap != NULL )
2536 {
2537 string targetDirectory ( bootcdDirectory + SSEP + m.bootstrap->base );
2538 if ( directories.size () > 0 )
2539 directories += " ";
2540 directories += PassThruCacheDirectory (
2541 NormalizeFilename ( targetDirectory ),
2542 backend->outputDirectory );
2543 }
2544 }
2545 return directories;
2546 }
2547
2548 string
2549 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string& bootcdDirectory )
2550 {
2551 string directories;
2552 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2553 {
2554 const CDFile& cdfile = *module.project.cdfiles[i];
2555 string targetDirectory ( bootcdDirectory + SSEP + cdfile.base );
2556 if ( directories.size () > 0 )
2557 directories += " ";
2558 directories += PassThruCacheDirectory (
2559 NormalizeFilename ( targetDirectory ),
2560 backend->outputDirectory );
2561 }
2562 return directories;
2563 }
2564
2565 string
2566 MingwIsoModuleHandler::GetCdDirectories ( const string& bootcdDirectory )
2567 {
2568 string directories = GetBootstrapCdDirectories ( bootcdDirectory );
2569 directories += " " + GetNonModuleCdDirectories ( bootcdDirectory );
2570 return directories;
2571 }
2572
2573 void
2574 MingwIsoModuleHandler::GetBootstrapCdFiles (
2575 vector<string>& out ) const
2576 {
2577 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2578 {
2579 const Module& m = *module.project.modules[i];
2580 if ( m.bootstrap != NULL )
2581 {
2582 string filename = PassThruCacheDirectory (
2583 NormalizeFilename ( m.GetPath () ),
2584 backend->outputDirectory );
2585 out.push_back ( filename );
2586 }
2587 }
2588 }
2589
2590 void
2591 MingwIsoModuleHandler::GetNonModuleCdFiles (
2592 vector<string>& out ) const
2593 {
2594 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2595 {
2596 const CDFile& cdfile = *module.project.cdfiles[i];
2597 out.push_back ( cdfile.GetPath () );
2598 }
2599 }
2600
2601 void
2602 MingwIsoModuleHandler::GetCdFiles (
2603 vector<string>& out ) const
2604 {
2605 GetBootstrapCdFiles ( out );
2606 GetNonModuleCdFiles ( out );
2607 }
2608
2609 void
2610 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2611 {
2612 string bootcdDirectory = "cd";
2613 string bootcd = PassThruCacheDirectory (
2614 NormalizeFilename ( bootcdDirectory + SSEP ),
2615 backend->outputDirectory );
2616 string isoboot = PassThruCacheDirectory (
2617 NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ),
2618 backend->outputDirectory );
2619 string bootcdReactosNoFixup = bootcdDirectory + SSEP "reactos";
2620 string bootcdReactos = PassThruCacheDirectory (
2621 NormalizeFilename ( bootcdReactosNoFixup + SSEP ),
2622 backend->outputDirectory );
2623 CLEAN_FILE ( bootcdReactos );
2624 string reactosInf = PassThruCacheDirectory (
2625 NormalizeFilename ( bootcdReactosNoFixup + SSEP "reactos.inf" ),
2626 backend->outputDirectory );
2627 string reactosDff = NormalizeFilename ( "bootdata" SSEP "packages" SSEP "reactos.dff" );
2628 string cdDirectories = GetCdDirectories ( bootcdDirectory );
2629 vector<string> vCdFiles;
2630 GetCdFiles ( vCdFiles );
2631 string cdFiles = v2s ( vCdFiles, 5 );
2632
2633 fprintf ( fMakefile, ".PHONY: %s\n\n",
2634 module.name.c_str ());
2635 fprintf ( fMakefile,
2636 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2637 module.name.c_str (),
2638 isoboot.c_str (),
2639 bootcdReactos.c_str (),
2640 cdDirectories.c_str (),
2641 cdFiles.c_str () );
2642 fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" );
2643 fprintf ( fMakefile,
2644 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2645 reactosDff.c_str (),
2646 bootcdReactos.c_str () );
2647 fprintf ( fMakefile,
2648 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2649 reactosDff.c_str (),
2650 reactosInf.c_str (),
2651 bootcdReactos.c_str ());
2652 fprintf ( fMakefile,
2653 "\t-@${rm} %s 2>$(NUL)\n",
2654 reactosInf.c_str () );
2655 OutputBootstrapfileCopyCommands ( bootcdDirectory );
2656 OutputCdfileCopyCommands ( bootcdDirectory );
2657 fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" );
2658 fprintf ( fMakefile,
2659 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2660 isoboot.c_str (),
2661 bootcd.c_str () );
2662 fprintf ( fMakefile,
2663 "\n" );
2664 }
2665
2666
2667 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2668 const Module& module_ )
2669
2670 : MingwModuleHandler ( module_ )
2671 {
2672 }
2673
2674 void
2675 MingwLiveIsoModuleHandler::Process ()
2676 {
2677 GenerateLiveIsoModuleTarget ();
2678 }
2679
2680 void
2681 MingwLiveIsoModuleHandler::CreateDirectory ( const string& directory )
2682 {
2683 string normalizedDirectory = MingwModuleHandler::PassThruCacheDirectory (
2684 NormalizeFilename ( directory ) + SSEP,
2685 backend->outputDirectory );
2686 }
2687
2688 void
2689 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string& sourceFilename,
2690 const string& targetFilename,
2691 const string& targetDirectory )
2692 {
2693 string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory (
2694 NormalizeFilename ( targetDirectory + SSEP + targetFilename ),
2695 backend->outputDirectory );
2696 fprintf ( fMakefile,
2697 "\t$(ECHO_CP)\n" );
2698 fprintf ( fMakefile,
2699 "\t${cp} %s %s 1>$(NUL)\n",
2700 sourceFilename.c_str (),
2701 normalizedTargetFilename.c_str () );
2702 }
2703
2704 void
2705 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string& livecdDirectory,
2706 string& reactosDirectory )
2707 {
2708 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2709 {
2710 const Module& m = *module.project.modules[i];
2711 if ( m.installName.length () > 0 )
2712 {
2713 string sourceFilename = MingwModuleHandler::PassThruCacheDirectory (
2714 NormalizeFilename ( m.GetPath () ),
2715 backend->outputDirectory );
2716 OutputCopyCommand ( sourceFilename,
2717 m.installName,
2718 livecdDirectory + SSEP + reactosDirectory + SSEP + m.installBase );
2719 }
2720 }
2721 }
2722
2723 void
2724 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string& livecdDirectory,
2725 string& reactosDirectory )
2726 {
2727 for ( size_t i = 0; i < module.project.installfiles.size (); i++ )
2728 {
2729 const InstallFile& installfile = *module.project.installfiles[i];
2730 OutputCopyCommand ( installfile.GetPath (),
2731 installfile.newname,
2732 livecdDirectory + SSEP + reactosDirectory + SSEP + installfile.base );
2733 }
2734 }
2735
2736 void
2737 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string& livecdDirectory )
2738 {
2739 CreateDirectory ( livecdDirectory + SSEP "Profiles" );
2740 CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users") ;
2741 CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users" SSEP "Desktop" );
2742 CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" );
2743 CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "Desktop" );
2744 CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "My Documents" );
2745
2746 string livecdIni = "bootdata" SSEP "livecd.ini";
2747 OutputCopyCommand ( livecdIni,
2748 "freeldr.ini",
2749 livecdDirectory );
2750 }
2751
2752 void
2753 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string& livecdDirectory )
2754 {
2755 string freeldr = PassThruCacheDirectory (
2756 NormalizeFilename ( "boot" SSEP "freeldr" SSEP "freeldr" SSEP "freeldr.sys" ),
2757 backend->outputDirectory );
2758 CreateDirectory ( livecdDirectory + SSEP "loader" );
2759 OutputCopyCommand ( freeldr,
2760 "setupldr.sys",
2761 livecdDirectory + SSEP + "loader" );
2762 }
2763
2764 void
2765 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory )
2766 {
2767 string reactosSystem32ConfigDirectory = NormalizeFilename (
2768 MingwModuleHandler::PassThruCacheDirectory (
2769 livecdDirectory + SSEP "reactos" SSEP "system32" SSEP "config" SSEP,
2770 backend->outputDirectory ) );
2771 fprintf ( fMakefile,
2772 "\t$(ECHO_MKHIVE)\n" );
2773 fprintf ( fMakefile,
2774 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP "livecd.inf bootdata" SSEP "hiveinst.inf\n",
2775 reactosSystem32ConfigDirectory.c_str () );
2776 }
2777
2778 void
2779 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2780 {
2781 string livecdDirectory = "livecd";
2782 string livecd = PassThruCacheDirectory (
2783 NormalizeFilename ( livecdDirectory + SSEP ),
2784 backend->outputDirectory );
2785 string isoboot = PassThruCacheDirectory (
2786 NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ),
2787 backend->outputDirectory );
2788 string reactosDirectory = "reactos";
2789 string livecdReactosNoFixup = livecdDirectory + SSEP + reactosDirectory;
2790 string livecdReactos = NormalizeFilename ( PassThruCacheDirectory (
2791 NormalizeFilename ( livecdReactosNoFixup + SSEP ),
2792 backend->outputDirectory ) );
2793 CLEAN_FILE ( livecdReactos );
2794
2795 fprintf ( fMakefile, ".PHONY: %s\n\n",
2796 module.name.c_str ());
2797 fprintf ( fMakefile,
2798 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2799 module.name.c_str (),
2800 isoboot.c_str (),
2801 livecdReactos.c_str () );
2802 OutputModuleCopyCommands ( livecdDirectory,
2803 reactosDirectory );
2804 OutputNonModuleCopyCommands ( livecdDirectory,
2805 reactosDirectory );
2806 OutputProfilesDirectoryCommands ( livecdDirectory );
2807 OutputLoaderCommands ( livecdDirectory );
2808 OutputRegistryCommands ( livecdDirectory );
2809 fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" );
2810 fprintf ( fMakefile,
2811 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2812 isoboot.c_str (),
2813 livecd.c_str () );
2814 fprintf ( fMakefile,
2815 "\n" );
2816 }
2817
2818
2819 MingwTestModuleHandler::MingwTestModuleHandler (
2820 const Module& module_ )
2821
2822 : MingwModuleHandler ( module_ )
2823 {
2824 }
2825
2826 void
2827 MingwTestModuleHandler::Process ()
2828 {
2829 GenerateTestModuleTarget ();
2830 }
2831
2832 void
2833 MingwTestModuleHandler::GenerateTestModuleTarget ()
2834 {
2835 string targetMacro ( GetTargetMacro ( module ) );
2836 string workingDirectory = GetWorkingDirectory ( );
2837 string objectsMacro = GetObjectsMacro ( module );
2838 string linkDepsMacro = GetLinkingDependenciesMacro ();
2839 string libsMacro = GetLibsMacro ();
2840
2841 GenerateImportLibraryTargetIfNeeded ();
2842
2843 if ( module.non_if_data.files.size () > 0 )
2844 {
2845 GenerateRules ();
2846
2847 string dependencies = linkDepsMacro + " " + objectsMacro;
2848
2849 string linker;
2850 if ( module.cplusplus )
2851 linker = "${gpp}";
2852 else
2853 linker = "${gcc}";
2854
2855 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2856 module.entrypoint.c_str (),
2857 module.baseaddress.c_str () );
2858 GenerateLinkerCommand ( dependencies,
2859 linker,
2860 linkerParameters,
2861 objectsMacro,
2862 libsMacro );
2863 }
2864 else
2865 {
2866 GeneratePhonyTarget();
2867 }
2868 }
2869
2870
2871 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2872 const Module& module_ )
2873
2874 : MingwModuleHandler ( module_ )
2875 {
2876 }
2877
2878 void
2879 MingwRpcServerModuleHandler::Process ()
2880 {
2881 GenerateRules ();
2882 }
2883
2884 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2885 const Module& module_ )
2886
2887 : MingwModuleHandler ( module_ )
2888 {
2889 }
2890
2891 void
2892 MingwRpcClientModuleHandler::Process ()
2893 {
2894 GenerateRules ();
2895 }