adjust newlines around rsym command
[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 using std::map;
11 using std::set;
12
13 typedef set<string> set_string;
14
15 map<ModuleType,MingwModuleHandler*>*
16 MingwModuleHandler::handler_map = NULL;
17 set_string
18 MingwModuleHandler::directory_set;
19 int
20 MingwModuleHandler::ref = 0;
21
22 FILE*
23 MingwModuleHandler::fMakefile = NULL;
24
25 string
26 ReplaceExtension ( const string& filename,
27 const string& newExtension )
28 {
29 size_t index = filename.find_last_of ( '/' );
30 if (index == string::npos) index = 0;
31 string tmp = filename.substr( index, filename.size() - index );
32 size_t ext_index = tmp.find_last_of( '.' );
33 if (ext_index != string::npos)
34 return filename.substr ( 0, index + ext_index ) + newExtension;
35 return filename + newExtension;
36 }
37
38
39 MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )
40 {
41 if ( !ref++ )
42 handler_map = new map<ModuleType,MingwModuleHandler*>;
43 (*handler_map)[moduletype] = this;
44 }
45
46 MingwModuleHandler::~MingwModuleHandler()
47 {
48 if ( !--ref )
49 {
50 delete handler_map;
51 handler_map = NULL;
52 }
53 }
54
55 const string &
56 MingwModuleHandler::PassThruCacheDirectory ( const string &file ) const
57 {
58 directory_set.insert ( GetDirectory ( file ) );
59 return file;
60 }
61
62 void
63 MingwModuleHandler::SetMakefile ( FILE* f )
64 {
65 fMakefile = f;
66 }
67
68 MingwModuleHandler*
69 MingwModuleHandler::LookupHandler ( const string& location,
70 ModuleType moduletype )
71 {
72 if ( !handler_map )
73 throw Exception ( "internal tool error: no registered module handlers" );
74 MingwModuleHandler* h = (*handler_map)[moduletype];
75 if ( !h )
76 {
77 throw UnknownModuleTypeException ( location, moduletype );
78 return NULL;
79 }
80 return h;
81 }
82
83 string
84 MingwModuleHandler::GetWorkingDirectory () const
85 {
86 return ".";
87 }
88
89 string
90 MingwModuleHandler::GetBasename ( const string& filename ) const
91 {
92 size_t index = filename.find_last_of ( '.' );
93 if ( index != string::npos )
94 return filename.substr ( 0, index );
95 return "";
96 }
97
98 string
99 MingwModuleHandler::GetActualSourceFilename ( const string& filename ) const
100 {
101 string extension = GetExtension ( filename );
102 if ( extension == ".spec" || extension == "SPEC" )
103 {
104 string basename = GetBasename ( filename );
105 return basename + ".stubs.c";
106 }
107 else
108 return filename;
109 }
110
111 string
112 MingwModuleHandler::GetModuleArchiveFilename ( const Module& module ) const
113 {
114 return ReplaceExtension ( FixupTargetFilename ( module.GetPath () ),
115 ".a" );
116 }
117
118 bool
119 MingwModuleHandler::IsGeneratedFile ( const File& file ) const
120 {
121 string extension = GetExtension ( file.name );
122 if ( extension == ".spec" || extension == "SPEC" )
123 return true;
124 else
125 return false;
126 }
127
128 string
129 MingwModuleHandler::GetImportLibraryDependency ( const Module& importedModule ) const
130 {
131 if ( importedModule.type == ObjectLibrary )
132 return GetObjectsMacro ( importedModule );
133 else
134 return PassThruCacheDirectory ( FixupTargetFilename ( importedModule.GetDependencyPath () ) );
135 }
136
137 string
138 MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
139 {
140 string dependencies ( "" );
141 for ( size_t i = 0; i < module.libraries.size (); i++ )
142 {
143 if ( dependencies.size () > 0 )
144 dependencies += " ";
145 const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );
146 assert ( importedModule != NULL );
147 dependencies += GetImportLibraryDependency ( *importedModule );
148 }
149 return dependencies;
150 }
151
152 string
153 MingwModuleHandler::GetModuleDependencies ( const Module& module ) const
154 {
155 if ( module.dependencies.size () == 0 )
156 return "";
157
158 string dependencies ( "" );
159 for ( size_t i = 0; i < module.dependencies.size (); i++ )
160 {
161 if ( dependencies.size () > 0 )
162 dependencies += " ";
163 const Dependency* dependency = module.dependencies[i];
164 const Module* dependencyModule = dependency->dependencyModule;
165 dependencies += dependencyModule->GetTargets ();
166 }
167 string definitionDependencies = GetDefinitionDependencies ( module );
168 if ( dependencies.length () > 0 && definitionDependencies.length () > 0 )
169 dependencies += " " + definitionDependencies;
170 else if ( definitionDependencies.length () > 0 )
171 dependencies = definitionDependencies;
172 return dependencies;
173 }
174
175 string
176 MingwModuleHandler::GetAllDependencies ( const Module& module ) const
177 {
178 string dependencies = GetImportLibraryDependencies ( module );
179 string s = GetModuleDependencies ( module );
180 if ( s.length () > 0 )
181 {
182 dependencies += " ";
183 dependencies += s;
184 }
185 return dependencies;
186 }
187
188 string
189 MingwModuleHandler::GetSourceFilenames ( const Module& module,
190 bool includeGeneratedFiles ) const
191 {
192 size_t i;
193
194 string sourceFilenames ( "" );
195 for ( i = 0; i < module.files.size (); i++ )
196 {
197 if ( includeGeneratedFiles || !IsGeneratedFile ( *module.files[i] ) )
198 sourceFilenames += " " + GetActualSourceFilename ( module.files[i]->name );
199 }
200 vector<If*> ifs = module.ifs;
201 for ( i = 0; i < ifs.size (); i++ )
202 {
203 size_t j;
204 If& rIf = *ifs[i];
205 for ( j = 0; j < rIf.ifs.size (); j++ )
206 ifs.push_back ( rIf.ifs[j] );
207 for ( j = 0; j < rIf.files.size (); j++ )
208 {
209 if ( includeGeneratedFiles || !IsGeneratedFile ( *rIf.files[j] ) )
210 sourceFilenames += " " + GetActualSourceFilename ( rIf.files[j]->name );
211 }
212 }
213 return sourceFilenames;
214 }
215
216 string
217 MingwModuleHandler::GetSourceFilenames ( const Module& module ) const
218 {
219 return GetSourceFilenames ( module,
220 true );
221 }
222
223 string
224 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const
225 {
226 return GetSourceFilenames ( module,
227 false );
228 }
229
230 string
231 MingwModuleHandler::GetObjectFilename ( const string& sourceFilename )
232 {
233 string newExtension;
234 string extension = GetExtension ( sourceFilename );
235 if ( extension == ".rc" || extension == ".RC" )
236 newExtension = ".coff";
237 else if ( extension == ".spec" || extension == ".SPEC" )
238 newExtension = ".stubs.o";
239 else
240 newExtension = ".o";
241 return FixupTargetFilename ( ReplaceExtension ( sourceFilename, newExtension ) );
242 }
243
244 string
245 MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
246 {
247 if ( module.files.size () == 0 )
248 return "";
249
250 string objectFilenames ( "" );
251 for ( size_t i = 0; i < module.files.size (); i++ )
252 {
253 if ( objectFilenames.size () > 0 )
254 objectFilenames += " ";
255 objectFilenames += PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( module.files[i]->name ) );
256 }
257 return objectFilenames;
258 }
259
260 bool
261 MingwModuleHandler::IncludeDirectoryTarget ( const string& directory ) const
262 {
263 if ( directory == "$(ROS_INTERMEDIATE)." SSEP "tools")
264 return false;
265 else
266 return true;
267 }
268
269 void
270 MingwModuleHandler::GenerateDirectoryTargets () const
271 {
272 if ( directory_set.size () == 0 )
273 return;
274
275 set_string::iterator i;
276 fprintf ( fMakefile, "directories::" );
277
278 for ( i = directory_set.begin ();
279 i != directory_set.end ();
280 i++ )
281 {
282 if ( IncludeDirectoryTarget ( *i ) )
283 {
284 fprintf ( fMakefile,
285 " %s",
286 i->c_str () );
287 }
288 }
289
290 fprintf ( fMakefile, "\n\n" );
291
292 for ( i = directory_set.begin ();
293 i != directory_set.end ();
294 i++ )
295 {
296 if ( IncludeDirectoryTarget ( *i ) )
297 {
298 fprintf ( fMakefile,
299 "%s ",
300 i->c_str () );
301 }
302 }
303
304 fprintf ( fMakefile,
305 "::\n\t${mkdir} $@\n\n" );
306
307 directory_set.clear ();
308 }
309
310 string
311 MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector<Define*>& defines ) const
312 {
313 string parameters;
314 for ( size_t i = 0; i < defines.size (); i++ )
315 {
316 Define& define = *defines[i];
317 if (parameters.length () > 0)
318 parameters += " ";
319 parameters += "-D";
320 parameters += define.name;
321 if (define.value.length () > 0)
322 {
323 parameters += "=";
324 parameters += define.value;
325 }
326 }
327 return parameters;
328 }
329
330 string
331 MingwModuleHandler::GenerateGccDefineParameters ( const Module& module ) const
332 {
333 string parameters = GenerateGccDefineParametersFromVector ( module.project.defines );
334 string s = GenerateGccDefineParametersFromVector ( module.defines );
335 if ( s.length () > 0 )
336 {
337 parameters += " ";
338 parameters += s;
339 }
340 return parameters;
341 }
342
343 string
344 MingwModuleHandler::ConcatenatePaths ( const string& path1,
345 const string& path2 ) const
346 {
347 if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )
348 return path2;
349 if ( path1[path1.length ()] == CSEP )
350 return path1 + path2;
351 else
352 return path1 + CSEP + path2;
353 }
354
355 string
356 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Include*>& includes ) const
357 {
358 string parameters;
359 for ( size_t i = 0; i < includes.size (); i++ )
360 {
361 Include& include = *includes[i];
362 if ( parameters.length () > 0 )
363 parameters += " ";
364 parameters += "-I" + include.directory;
365 }
366 return parameters;
367 }
368
369 string
370 MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
371 {
372 string parameters = GenerateGccIncludeParametersFromVector ( module.includes );
373 string s = GenerateGccIncludeParametersFromVector ( module.project.includes );
374 if ( s.length () > 0 )
375 {
376 parameters += " ";
377 parameters += s;
378 }
379 return parameters;
380 }
381
382
383 string
384 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
385 {
386 string parameters;
387 for ( size_t i = 0; i < compilerFlags.size (); i++ )
388 {
389 CompilerFlag& compilerFlag = *compilerFlags[i];
390 if ( parameters.length () > 0 )
391 parameters += " ";
392 parameters += compilerFlag.flag;
393 }
394 return parameters;
395 }
396
397 string
398 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector<LinkerFlag*>& linkerFlags ) const
399 {
400 string parameters;
401 for ( size_t i = 0; i < linkerFlags.size (); i++ )
402 {
403 LinkerFlag& linkerFlag = *linkerFlags[i];
404 if ( parameters.length () > 0 )
405 parameters += " ";
406 parameters += linkerFlag.flag;
407 }
408 return parameters;
409 }
410
411 string
412 MingwModuleHandler::GenerateLinkerParameters ( const Module& module ) const
413 {
414 return GenerateLinkerParametersFromVector ( module.linkerFlags );
415 }
416
417 void
418 MingwModuleHandler::GenerateMacro ( const char* assignmentOperation,
419 const string& macro,
420 const vector<Include*>& includes,
421 const vector<Define*>& defines,
422 const vector<CompilerFlag*>* compilerFlags ) const
423 {
424 size_t i;
425
426 fprintf (
427 fMakefile,
428 "%s %s",
429 macro.c_str(),
430 assignmentOperation );
431
432 if ( compilerFlags != NULL )
433 {
434 string compilerParameters = GenerateCompilerParametersFromVector ( *compilerFlags );
435 if ( compilerParameters.size () > 0 )
436 {
437 fprintf (
438 fMakefile,
439 " %s",
440 compilerParameters.c_str () );
441 }
442 }
443
444 for ( i = 0; i < includes.size(); i++ )
445 {
446 fprintf (
447 fMakefile,
448 " -I%s",
449 includes[i]->directory.c_str() );
450 }
451 for ( i = 0; i < defines.size(); i++ )
452 {
453 Define& d = *defines[i];
454 fprintf (
455 fMakefile,
456 " -D%s",
457 d.name.c_str() );
458 if ( d.value.size() )
459 fprintf (
460 fMakefile,
461 "=%s",
462 d.value.c_str() );
463 }
464 fprintf ( fMakefile, "\n" );
465 }
466
467 void
468 MingwModuleHandler::GenerateMacros (
469 const char* assignmentOperation,
470 const vector<File*>& files,
471 const vector<Include*>& includes,
472 const vector<Define*>& defines,
473 const vector<CompilerFlag*>* compilerFlags,
474 const vector<LinkerFlag*>* linkerFlags,
475 const vector<If*>& ifs,
476 const string& cflags_macro,
477 const string& nasmflags_macro,
478 const string& windresflags_macro,
479 const string& linkerflags_macro,
480 const string& objs_macro) const
481 {
482 size_t i;
483
484 if ( includes.size () > 0 || defines.size () > 0 )
485 {
486 GenerateMacro ( assignmentOperation,
487 cflags_macro,
488 includes,
489 defines,
490 compilerFlags );
491 GenerateMacro ( assignmentOperation,
492 windresflags_macro,
493 includes,
494 defines,
495 compilerFlags );
496 }
497
498 if ( linkerFlags != NULL )
499 {
500 string linkerParameters = GenerateLinkerParametersFromVector ( *linkerFlags );
501 if ( linkerParameters.size () > 0 )
502 {
503 fprintf (
504 fMakefile,
505 "%s %s %s\n",
506 linkerflags_macro.c_str (),
507 assignmentOperation,
508 linkerParameters.c_str() );
509 }
510 }
511
512 if ( files.size () > 0 )
513 {
514 for ( i = 0; i < files.size (); i++ )
515 {
516 if ( files[i]->first )
517 {
518 fprintf ( fMakefile,
519 "%s := %s $(%s)\n",
520 objs_macro.c_str(),
521 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ).c_str (),
522 objs_macro.c_str() );
523 }
524 }
525 fprintf (
526 fMakefile,
527 "%s %s",
528 objs_macro.c_str (),
529 assignmentOperation );
530 for ( i = 0; i < files.size(); i++ )
531 {
532 if ( !files[i]->first )
533 {
534 fprintf (
535 fMakefile,
536 "%s%s",
537 ( i%10 == 9 ? "\\\n\t" : " " ),
538 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ).c_str () );
539 }
540 }
541 fprintf ( fMakefile, "\n" );
542 }
543
544 for ( i = 0; i < ifs.size(); i++ )
545 {
546 If& rIf = *ifs[i];
547 if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() )
548 {
549 fprintf (
550 fMakefile,
551 "ifeq (\"$(%s)\",\"%s\")\n",
552 rIf.property.c_str(),
553 rIf.value.c_str() );
554 GenerateMacros (
555 "+=",
556 rIf.files,
557 rIf.includes,
558 rIf.defines,
559 NULL,
560 NULL,
561 rIf.ifs,
562 cflags_macro,
563 nasmflags_macro,
564 windresflags_macro,
565 linkerflags_macro,
566 objs_macro );
567 fprintf (
568 fMakefile,
569 "endif\n\n" );
570 }
571 }
572 }
573
574 void
575 MingwModuleHandler::GenerateMacros (
576 const Module& module,
577 const string& cflags_macro,
578 const string& nasmflags_macro,
579 const string& windresflags_macro,
580 const string& linkerflags_macro,
581 const string& objs_macro) const
582 {
583 GenerateMacros (
584 "=",
585 module.files,
586 module.includes,
587 module.defines,
588 &module.compilerFlags,
589 &module.linkerFlags,
590 module.ifs,
591 cflags_macro,
592 nasmflags_macro,
593 windresflags_macro,
594 linkerflags_macro,
595 objs_macro );
596 fprintf ( fMakefile, "\n" );
597
598 fprintf (
599 fMakefile,
600 "%s += $(PROJECT_CFLAGS)\n\n",
601 cflags_macro.c_str () );
602
603 fprintf (
604 fMakefile,
605 "%s += $(PROJECT_RCFLAGS)\n\n",
606 windresflags_macro.c_str () );
607
608 fprintf (
609 fMakefile,
610 "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
611 module.name.c_str () );
612 }
613
614 void
615 MingwModuleHandler::GenerateGccCommand ( const Module& module,
616 const string& sourceFilename,
617 const string& cc,
618 const string& cflagsMacro ) const
619 {
620 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
621 fprintf ( fMakefile,
622 "%s: %s\n",
623 objectFilename.c_str (),
624 sourceFilename.c_str () );
625 fprintf ( fMakefile,
626 "\t%s -c %s -o %s %s\n",
627 cc.c_str (),
628 sourceFilename.c_str (),
629 objectFilename.c_str (),
630 cflagsMacro.c_str () );
631 }
632
633 void
634 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
635 const string& sourceFilename,
636 const string& cc,
637 const string& cflagsMacro ) const
638 {
639 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
640 fprintf ( fMakefile,
641 "%s: %s\n",
642 objectFilename.c_str (),
643 sourceFilename.c_str () );
644 fprintf ( fMakefile,
645 "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
646 cc.c_str (),
647 sourceFilename.c_str (),
648 objectFilename.c_str (),
649 cflagsMacro.c_str () );
650 }
651
652 void
653 MingwModuleHandler::GenerateNasmCommand ( const Module& module,
654 const string& sourceFilename,
655 const string& nasmflagsMacro ) const
656 {
657 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
658 fprintf ( fMakefile,
659 "%s: %s\n",
660 objectFilename.c_str (),
661 sourceFilename.c_str () );
662 fprintf ( fMakefile,
663 "\t%s -f win32 %s -o %s %s\n",
664 "nasm",
665 sourceFilename.c_str (),
666 objectFilename.c_str (),
667 nasmflagsMacro.c_str () );
668 }
669
670 void
671 MingwModuleHandler::GenerateWindresCommand ( const Module& module,
672 const string& sourceFilename,
673 const string& windresflagsMacro ) const
674 {
675 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
676 string rciFilename = ReplaceExtension ( sourceFilename,
677 ".rci" );
678 string resFilename = ReplaceExtension ( sourceFilename,
679 ".res" );
680 fprintf ( fMakefile,
681 "%s: %s\n",
682 objectFilename.c_str (),
683 sourceFilename.c_str () );
684 fprintf ( fMakefile,
685 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
686 windresflagsMacro.c_str (),
687 sourceFilename.c_str (),
688 rciFilename.c_str () );
689 fprintf ( fMakefile,
690 "\t${wrc} ${%s} %s %s\n",
691 windresflagsMacro.c_str (),
692 rciFilename.c_str (),
693 resFilename.c_str () );
694 fprintf ( fMakefile,
695 "\t${rm} %s\n",
696 rciFilename.c_str () );
697 fprintf ( fMakefile,
698 "\t${windres} %s -o %s\n",
699 resFilename.c_str (),
700 objectFilename.c_str () );
701 fprintf ( fMakefile,
702 "\t${rm} %s\n",
703 resFilename.c_str () );
704 }
705
706 void
707 MingwModuleHandler::GenerateWinebuildCommands ( const Module& module,
708 const string& sourceFilename ) const
709 {
710 string basename = GetBasename ( sourceFilename );
711 fprintf ( fMakefile,
712 "%s.spec.def: %s\n",
713 basename.c_str (),
714 sourceFilename.c_str () );
715 fprintf ( fMakefile,
716 "\t%s --def=%s -o %s.spec.def\n",
717 "${winebuild}",
718 sourceFilename.c_str (),
719 basename.c_str () );
720
721 fprintf ( fMakefile,
722 "%s.stubs.c: %s\n",
723 basename.c_str (),
724 sourceFilename.c_str () );
725 fprintf ( fMakefile,
726 "\t%s --pedll=%s -o %s.stubs.c\n",
727 "${winebuild}",
728 sourceFilename.c_str (),
729 basename.c_str () );
730 }
731
732 void
733 MingwModuleHandler::GenerateCommands ( const Module& module,
734 const string& sourceFilename,
735 const string& cc,
736 const string& cppc,
737 const string& cflagsMacro,
738 const string& nasmflagsMacro,
739 const string& windresflagsMacro ) const
740 {
741 string extension = GetExtension ( sourceFilename );
742 if ( extension == ".c" || extension == ".C" )
743 {
744 GenerateGccCommand ( module,
745 sourceFilename,
746 cc,
747 cflagsMacro );
748 return;
749 }
750 else if ( extension == ".cc" || extension == ".CC" ||
751 extension == ".cpp" || extension == ".CPP" ||
752 extension == ".cxx" || extension == ".CXX" )
753 {
754 GenerateGccCommand ( module,
755 sourceFilename,
756 cppc,
757 cflagsMacro );
758 return;
759 }
760 else if ( extension == ".s" || extension == ".S" )
761 {
762 GenerateGccAssemblerCommand ( module,
763 sourceFilename,
764 cc,
765 cflagsMacro );
766 return;
767 }
768 else if ( extension == ".asm" || extension == ".ASM" )
769 {
770 GenerateNasmCommand ( module,
771 sourceFilename,
772 nasmflagsMacro );
773 return;
774 }
775 else if ( extension == ".rc" || extension == ".RC" )
776 {
777 GenerateWindresCommand ( module,
778 sourceFilename,
779 windresflagsMacro );
780 return;
781 }
782 else if ( extension == ".spec" || extension == ".SPEC" )
783 {
784 GenerateWinebuildCommands ( module,
785 sourceFilename );
786 GenerateGccCommand ( module,
787 GetActualSourceFilename ( sourceFilename ),
788 cc,
789 cflagsMacro );
790 return;
791 }
792
793 throw InvalidOperationException ( __FILE__,
794 __LINE__,
795 "Unsupported filename extension '%s' in file '%s'",
796 extension.c_str (),
797 sourceFilename.c_str () );
798 }
799
800 void
801 MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
802 const string& linker,
803 const string& linkerParameters,
804 const string& objectFilenames ) const
805 {
806 string targetName ( module.GetTargetName () );
807 string target ( FixupTargetFilename ( module.GetPath () ) );
808 string importLibraryDependencies = GetImportLibraryDependencies ( module );
809 if ( module.importLibrary != NULL )
810 {
811 static string ros_junk ( "$(ROS_TEMPORARY)" );
812 string base_tmp = ros_junk + module.name + ".base.tmp";
813 string junk_tmp = ros_junk + module.name + ".junk.tmp";
814 string temp_exp = ros_junk + module.name + ".temp.exp";
815
816 fprintf ( fMakefile,
817 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
818 linker.c_str (),
819 linkerParameters.c_str (),
820 base_tmp.c_str (),
821 junk_tmp.c_str (),
822 objectFilenames.c_str (),
823 importLibraryDependencies.c_str (),
824 GetLinkerMacro ( module ).c_str () );
825
826 fprintf ( fMakefile,
827 "\t${rm} %s\n",
828 junk_tmp.c_str () );
829
830 string killAt = module.mangledSymbols ? "" : "--kill-at";
831 fprintf ( fMakefile,
832 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
833 targetName.c_str (),
834 base_tmp.c_str (),
835 ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
836 temp_exp.c_str (),
837 killAt.c_str () );
838
839 fprintf ( fMakefile,
840 "\t${rm} %s\n",
841 base_tmp.c_str () );
842
843 fprintf ( fMakefile,
844 "\t%s %s %s -o %s %s %s %s\n\n",
845 linker.c_str (),
846 linkerParameters.c_str (),
847 temp_exp.c_str (),
848 target.c_str (),
849 objectFilenames.c_str (),
850 importLibraryDependencies.c_str (),
851 GetLinkerMacro ( module ).c_str () );
852
853 fprintf ( fMakefile,
854 "\t${rm} %s\n\n",
855 temp_exp.c_str () );
856 }
857 else
858 {
859 fprintf ( fMakefile,
860 "\t%s %s -o %s %s %s %s\n",
861 linker.c_str (),
862 linkerParameters.c_str (),
863 target.c_str (),
864 objectFilenames.c_str (),
865 importLibraryDependencies.c_str (),
866 GetLinkerMacro ( module ).c_str () );
867 }
868
869 fprintf ( fMakefile,
870 "\t${rsym} %s %s\n\n",
871 target.c_str (),
872 target.c_str () );
873 }
874
875 void
876 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
877 const vector<File*>& files,
878 const vector<If*>& ifs,
879 const string& cc,
880 const string& cppc,
881 const string& cflagsMacro,
882 const string& nasmflagsMacro,
883 const string& windresflagsMacro ) const
884 {
885 size_t i;
886
887 for ( i = 0; i < files.size (); i++ )
888 {
889 string sourceFilename = files[i]->name;
890 GenerateCommands ( module,
891 sourceFilename,
892 cc,
893 cppc,
894 cflagsMacro,
895 nasmflagsMacro,
896 windresflagsMacro );
897 fprintf ( fMakefile,
898 "\n" );
899 }
900
901 for ( i = 0; i < ifs.size(); i++ )
902 {
903 GenerateObjectFileTargets ( module,
904 ifs[i]->files,
905 ifs[i]->ifs,
906 cc,
907 cppc,
908 cflagsMacro,
909 nasmflagsMacro,
910 windresflagsMacro );
911 }
912 }
913
914 void
915 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
916 const string& cc,
917 const string& cppc,
918 const string& cflagsMacro,
919 const string& nasmflagsMacro,
920 const string& windresflagsMacro ) const
921 {
922 GenerateObjectFileTargets ( module,
923 module.files,
924 module.ifs,
925 cc,
926 cppc,
927 cflagsMacro,
928 nasmflagsMacro,
929 windresflagsMacro );
930 fprintf ( fMakefile, "\n" );
931 }
932
933 void
934 MingwModuleHandler::GetCleanTargets ( vector<string>& out,
935 const vector<File*>& files,
936 const vector<If*>& ifs ) const
937 {
938 size_t i;
939
940 for ( i = 0; i < files.size(); i++ )
941 out.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ) );
942
943 for ( i = 0; i < ifs.size(); i++ )
944 GetCleanTargets ( out, ifs[i]->files, ifs[i]->ifs );
945 }
946
947 string
948 MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
949 const string& ar,
950 const string& objs_macro ) const
951 {
952 string archiveFilename = GetModuleArchiveFilename ( module );
953
954 fprintf ( fMakefile,
955 "%s: %s\n",
956 archiveFilename.c_str (),
957 objs_macro.c_str ());
958
959 fprintf ( fMakefile,
960 "\t%s -rc %s %s\n\n",
961 ar.c_str (),
962 archiveFilename.c_str (),
963 objs_macro.c_str ());
964
965 return archiveFilename;
966 }
967
968 string
969 MingwModuleHandler::GetCFlagsMacro ( const Module& module ) const
970 {
971 return ssprintf ( "$(%s_CFLAGS)",
972 module.name.c_str () );
973 }
974
975 string
976 MingwModuleHandler::GetObjectsMacro ( const Module& module ) const
977 {
978 return ssprintf ( "$(%s_OBJS)",
979 module.name.c_str () );
980 }
981
982 string
983 MingwModuleHandler::GetLinkerMacro ( const Module& module ) const
984 {
985 return ssprintf ( "$(%s_LFLAGS)",
986 module.name.c_str () );
987 }
988
989 void
990 MingwModuleHandler::GenerateMacrosAndTargets (
991 const Module& module,
992 const string& cc,
993 const string& cppc,
994 const string& ar,
995 const string* cflags,
996 const string* nasmflags ) const
997 {
998 string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
999 string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
1000 string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
1001 string linkerFlagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
1002 string objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
1003
1004 GenerateMacros ( module,
1005 cflagsMacro,
1006 nasmflagsMacro,
1007 windresflagsMacro,
1008 linkerFlagsMacro,
1009 objectsMacro );
1010
1011 if ( cflags != NULL )
1012 {
1013 fprintf ( fMakefile,
1014 "%s += %s\n\n",
1015 cflagsMacro.c_str (),
1016 cflags->c_str () );
1017 }
1018
1019 if ( nasmflags != NULL )
1020 {
1021 fprintf ( fMakefile,
1022 "%s += %s\n\n",
1023 nasmflagsMacro.c_str (),
1024 nasmflags->c_str () );
1025 }
1026
1027 // generate phony target for module name
1028 fprintf ( fMakefile, ".PHONY: %s\n",
1029 module.name.c_str () );
1030 fprintf ( fMakefile, "%s: %s\n\n",
1031 module.name.c_str (),
1032 FixupTargetFilename ( module.GetPath () ).c_str () );
1033
1034 // future references to the macros will be to get their values
1035 cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());
1036 nasmflagsMacro = ssprintf ("$(%s)", nasmflagsMacro.c_str ());
1037 objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
1038
1039 string ar_target = GenerateArchiveTarget ( module, ar, objectsMacro );
1040 GenerateObjectFileTargets ( module,
1041 cc,
1042 cppc,
1043 cflagsMacro,
1044 nasmflagsMacro,
1045 windresflagsMacro );
1046
1047 vector<string> clean_files;
1048 clean_files.push_back ( FixupTargetFilename(module.GetPath()) );
1049 clean_files.push_back ( ar_target );
1050 GetCleanTargets ( clean_files, module.files, module.ifs );
1051
1052 fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );
1053 fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() );
1054 for ( size_t i = 0; i < clean_files.size(); i++ )
1055 {
1056 if ( 9==(i%10) )
1057 fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );
1058 fprintf ( fMakefile, " %s", clean_files[i].c_str() );
1059 }
1060 fprintf ( fMakefile, " 2>$(NUL)\n" );
1061 fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );
1062 }
1063
1064 void
1065 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
1066 {
1067 GenerateMacrosAndTargets ( module,
1068 "${host_gcc}",
1069 "${host_gpp}",
1070 "${host_ar}",
1071 NULL,
1072 NULL );
1073 }
1074
1075 void
1076 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const
1077 {
1078 GenerateMacrosAndTargetsTarget ( module,
1079 NULL,
1080 NULL );
1081 }
1082
1083 void
1084 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,
1085 const string* cflags,
1086 const string* nasmflags ) const
1087 {
1088 GenerateMacrosAndTargets ( module,
1089 "${gcc}",
1090 "${gpp}",
1091 "${ar}",
1092 cflags,
1093 nasmflags );
1094 }
1095
1096 string
1097 MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const
1098 {
1099 string dependencies;
1100 for ( size_t i = 0; i < module.invocations.size (); i++ )
1101 {
1102 Invoke& invoke = *module.invocations[i];
1103 if (invoke.invokeModule == &module)
1104 /* Protect against circular dependencies */
1105 continue;
1106 if ( dependencies.length () > 0 )
1107 dependencies += " ";
1108 dependencies += invoke.GetTargets ();
1109 }
1110 return dependencies;
1111 }
1112
1113 void
1114 MingwModuleHandler::GenerateInvocations ( const Module& module ) const
1115 {
1116 if ( module.invocations.size () == 0 )
1117 return;
1118
1119 for ( size_t i = 0; i < module.invocations.size (); i++ )
1120 {
1121 const Invoke& invoke = *module.invocations[i];
1122
1123 if ( invoke.invokeModule->type != BuildTool )
1124 {
1125 throw InvalidBuildFileException ( module.node.location,
1126 "Only modules of type buildtool can be invoked." );
1127 }
1128
1129 string invokeTarget = module.GetInvocationTarget ( i );
1130 fprintf ( fMakefile,
1131 ".PHONY: %s\n\n",
1132 invokeTarget.c_str () );
1133 fprintf ( fMakefile,
1134 "%s: %s\n\n",
1135 invokeTarget.c_str (),
1136 invoke.GetTargets ().c_str () );
1137 fprintf ( fMakefile,
1138 "%s: %s\n",
1139 invoke.GetTargets ().c_str (),
1140 FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () );
1141 fprintf ( fMakefile,
1142 "\t%s %s\n\n",
1143 FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),
1144 invoke.GetParameters ().c_str () );
1145 }
1146 }
1147
1148 string
1149 MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const
1150 {
1151 return ssprintf ( "%s_precondition",
1152 module.name.c_str () );
1153 }
1154
1155 string
1156 MingwModuleHandler::GetDefaultDependencies ( const Module& module ) const
1157 {
1158 /* Avoid circular dependency */
1159 if ( module.type == BuildTool || module.name == "zlib" )
1160 return "$(ROS_INTERMEDIATE)." SSEP "tools $(ROS_INTERMEDIATE)." SSEP "lib" SSEP "zlib";
1161 else
1162 return "init";
1163 }
1164
1165 void
1166 MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const
1167 {
1168 string preconditionDependenciesName = GetPreconditionDependenciesName ( module );
1169 string sourceFilenames = GetSourceFilenamesWithoutGeneratedFiles ( module );
1170 string dependencies = GetDefaultDependencies ( module );
1171 string s = GetModuleDependencies ( module );
1172 if ( s.length () > 0 )
1173 {
1174 if ( dependencies.length () > 0 )
1175 dependencies += " ";
1176 dependencies += s;
1177 }
1178
1179 s = GetInvocationDependencies ( module );
1180 if ( s.length () > 0 )
1181 {
1182 if ( dependencies.length () > 0 )
1183 dependencies += " ";
1184 dependencies += s;
1185 }
1186
1187 fprintf ( fMakefile,
1188 ".PHONY: %s\n\n",
1189 preconditionDependenciesName.c_str () );
1190 fprintf ( fMakefile,
1191 "%s: %s\n\n",
1192 preconditionDependenciesName.c_str (),
1193 dependencies.c_str () );
1194 const char* p = sourceFilenames.c_str();
1195 const char* end = p + strlen(p);
1196 while ( p < end )
1197 {
1198 const char* p2 = &p[512];
1199 if ( p2 > end )
1200 p2 = end;
1201 while ( p2 > p && !isspace(*p2) )
1202 --p2;
1203 if ( p == p2 )
1204 {
1205 p2 = strpbrk ( p, " \t" );
1206 if ( !p2 )
1207 p2 = end;
1208 }
1209 fprintf ( fMakefile,
1210 "%.*s: %s\n",
1211 p2-p,
1212 p,
1213 preconditionDependenciesName.c_str ());
1214 p = p2;
1215 p += strspn ( p, " \t" );
1216 }
1217 fprintf ( fMakefile, "\n" );
1218 }
1219
1220 void
1221 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const
1222 {
1223 if ( module.importLibrary != NULL )
1224 {
1225 string definitionDependencies = GetDefinitionDependencies ( module );
1226 fprintf ( fMakefile, "%s: %s\n",
1227 FixupTargetFilename( module.GetDependencyPath () ).c_str (),
1228 definitionDependencies.c_str () );
1229
1230 string killAt = module.mangledSymbols ? "" : "--kill-at";
1231 fprintf ( fMakefile,
1232 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1233 module.GetTargetName ().c_str (),
1234 ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
1235 FixupTargetFilename ( module.GetDependencyPath () ).c_str (),
1236 killAt.c_str () );
1237 }
1238 }
1239
1240 string
1241 MingwModuleHandler::GetSpecObjectDependencies ( const string& filename ) const
1242 {
1243 string basename = GetBasename ( filename );
1244 return basename + ".spec.def" + " " + basename + ".stubs.c";
1245 }
1246
1247 string
1248 MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
1249 {
1250 string dependencies;
1251 string dkNkmLibNoFixup = "dk/nkm/lib";
1252 dependencies += FixupTargetFilename ( dkNkmLibNoFixup );
1253 PassThruCacheDirectory ( dkNkmLibNoFixup + SSEP );
1254 for ( size_t i = 0; i < module.files.size (); i++ )
1255 {
1256 File& file = *module.files[i];
1257 string extension = GetExtension ( file.name );
1258 if ( extension == ".spec" || extension == ".SPEC" )
1259 {
1260 if ( dependencies.length () > 0 )
1261 dependencies += " ";
1262 dependencies += GetSpecObjectDependencies ( file.name );
1263 }
1264 }
1265 return dependencies;
1266 }
1267
1268 string
1269 MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const
1270 {
1271 string dependencies = GetImportLibraryDependencies ( module );
1272 string s = GetDefinitionDependencies ( module );
1273 if ( s.length () > 0 )
1274 {
1275 dependencies += " ";
1276 dependencies += s;
1277 }
1278 return dependencies;
1279 }
1280
1281 bool
1282 MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const
1283 {
1284 if ( module.HasFileWithExtensions ( ".cc", ".CC" ) )
1285 return true;
1286 if ( module.HasFileWithExtensions ( ".cxx", ".CXX" ) )
1287 return true;
1288 if ( module.HasFileWithExtensions ( ".cpp", ".CPP" ) )
1289 return true;
1290 return false;
1291 }
1292
1293
1294 static MingwBuildToolModuleHandler buildtool_handler;
1295
1296 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
1297 : MingwModuleHandler ( BuildTool )
1298 {
1299 }
1300
1301 void
1302 MingwBuildToolModuleHandler::Process ( const Module& module )
1303 {
1304 GeneratePreconditionDependencies ( module );
1305 GenerateBuildToolModuleTarget ( module );
1306 GenerateInvocations ( module );
1307 }
1308
1309 void
1310 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module )
1311 {
1312 string target ( FixupTargetFilename ( module.GetPath () ) );
1313 string objectsMacro = GetObjectsMacro ( module );
1314 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1315
1316 GenerateMacrosAndTargetsHost ( module );
1317
1318 string linker;
1319 if ( IsCPlusPlusModule ( module ) )
1320 linker = "${host_gpp}";
1321 else
1322 linker = "${host_gcc}";
1323
1324 fprintf ( fMakefile, "%s: %s %s\n",
1325 target.c_str (),
1326 objectsMacro.c_str (),
1327 importLibraryDependencies.c_str () );
1328 fprintf ( fMakefile,
1329 "\t%s %s -o %s %s %s\n\n",
1330 linker.c_str (),
1331 GetLinkerMacro ( module ).c_str (),
1332 target.c_str (),
1333 objectsMacro.c_str (),
1334 importLibraryDependencies.c_str () );
1335 }
1336
1337
1338 static MingwKernelModuleHandler kernelmodule_handler;
1339
1340 MingwKernelModuleHandler::MingwKernelModuleHandler ()
1341 : MingwModuleHandler ( Kernel )
1342 {
1343 }
1344
1345 void
1346 MingwKernelModuleHandler::Process ( const Module& module )
1347 {
1348 GeneratePreconditionDependencies ( module );
1349 GenerateKernelModuleTarget ( module );
1350 GenerateInvocations ( module );
1351 }
1352
1353 void
1354 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
1355 {
1356 static string ros_junk ( "$(ROS_TEMPORARY)" );
1357 string targetName ( module.GetTargetName () );
1358 string target ( FixupTargetFilename (module.GetPath ()) );
1359 string workingDirectory = GetWorkingDirectory ();
1360 string objectsMacro = GetObjectsMacro ( module );
1361 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1362 string base_tmp = ros_junk + module.name + ".base.tmp";
1363 string junk_tmp = ros_junk + module.name + ".junk.tmp";
1364 string temp_exp = ros_junk + module.name + ".temp.exp";
1365 string gccOptions = 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",
1366 module.GetBasePath ().c_str (),
1367 module.entrypoint.c_str (),
1368 module.baseaddress.c_str () );
1369
1370 GenerateMacrosAndTargetsTarget ( module );
1371
1372 GenerateImportLibraryTargetIfNeeded ( module );
1373
1374 fprintf ( fMakefile, "%s: %s %s\n",
1375 target.c_str (),
1376 objectsMacro.c_str (),
1377 importLibraryDependencies.c_str () );
1378 fprintf ( fMakefile,
1379 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1380 GetLinkerMacro ( module ).c_str (),
1381 gccOptions.c_str (),
1382 base_tmp.c_str (),
1383 junk_tmp.c_str (),
1384 objectsMacro.c_str (),
1385 importLibraryDependencies.c_str () );
1386 fprintf ( fMakefile,
1387 "\t${rm} %s\n",
1388 junk_tmp.c_str () );
1389 string killAt = module.mangledSymbols ? "" : "--kill-at";
1390 fprintf ( fMakefile,
1391 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1392 targetName.c_str (),
1393 base_tmp.c_str (),
1394 temp_exp.c_str (),
1395 killAt.c_str () );
1396 fprintf ( fMakefile,
1397 "\t${rm} %s\n",
1398 base_tmp.c_str () );
1399 fprintf ( fMakefile,
1400 "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",
1401 GetLinkerMacro ( module ).c_str (),
1402 gccOptions.c_str (),
1403 temp_exp.c_str (),
1404 target.c_str (),
1405 objectsMacro.c_str (),
1406 importLibraryDependencies.c_str () );
1407 fprintf ( fMakefile,
1408 "\t${rm} %s\n",
1409 temp_exp.c_str () );
1410 fprintf ( fMakefile,
1411 "\t${rsym} %s %s\n\n",
1412 target.c_str (),
1413 target.c_str () );
1414 }
1415
1416
1417 static MingwStaticLibraryModuleHandler staticlibrary_handler;
1418
1419 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
1420 : MingwModuleHandler ( StaticLibrary )
1421 {
1422 }
1423
1424 void
1425 MingwStaticLibraryModuleHandler::Process ( const Module& module )
1426 {
1427 GeneratePreconditionDependencies ( module );
1428 GenerateStaticLibraryModuleTarget ( module );
1429 GenerateInvocations ( module );
1430 }
1431
1432 void
1433 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )
1434 {
1435 GenerateMacrosAndTargetsTarget ( module );
1436 }
1437
1438
1439 static MingwObjectLibraryModuleHandler objectlibrary_handler;
1440
1441 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
1442 : MingwModuleHandler ( ObjectLibrary )
1443 {
1444 }
1445
1446 void
1447 MingwObjectLibraryModuleHandler::Process ( const Module& module )
1448 {
1449 GeneratePreconditionDependencies ( module );
1450 GenerateObjectLibraryModuleTarget ( module );
1451 GenerateInvocations ( module );
1452 }
1453
1454 void
1455 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module )
1456 {
1457 GenerateMacrosAndTargetsTarget ( module );
1458 }
1459
1460
1461 static MingwKernelModeDLLModuleHandler kernelmodedll_handler;
1462
1463 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
1464 : MingwModuleHandler ( KernelModeDLL )
1465 {
1466 }
1467
1468 void
1469 MingwKernelModeDLLModuleHandler::Process ( const Module& module )
1470 {
1471 GeneratePreconditionDependencies ( module );
1472 GenerateKernelModeDLLModuleTarget ( module );
1473 GenerateInvocations ( module );
1474 }
1475
1476 void
1477 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module )
1478 {
1479 static string ros_junk ( "$(ROS_TEMPORARY)" );
1480 string target ( FixupTargetFilename ( module.GetPath () ) );
1481 string workingDirectory = GetWorkingDirectory ( );
1482 string objectsMacro = GetObjectsMacro ( module );
1483 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1484
1485 GenerateImportLibraryTargetIfNeeded ( module );
1486
1487 if ( module.files.size () > 0 )
1488 {
1489 GenerateMacrosAndTargetsTarget ( module );
1490
1491 fprintf ( fMakefile, "%s: %s %s\n",
1492 target.c_str (),
1493 objectsMacro.c_str (),
1494 importLibraryDependencies.c_str () );
1495
1496 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1497 module.entrypoint.c_str (),
1498 module.baseaddress.c_str () );
1499 GenerateLinkerCommand ( module,
1500 "${gcc}",
1501 linkerParameters,
1502 objectsMacro );
1503 }
1504 else
1505 {
1506 fprintf ( fMakefile, ".PHONY: %s\n\n",
1507 target.c_str ());
1508 fprintf ( fMakefile, "%s:\n",
1509 target.c_str ());
1510 }
1511 }
1512
1513
1514 static MingwKernelModeDriverModuleHandler kernelmodedriver_handler;
1515
1516 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
1517 : MingwModuleHandler ( KernelModeDriver )
1518 {
1519 }
1520
1521 void
1522 MingwKernelModeDriverModuleHandler::Process ( const Module& module )
1523 {
1524 GeneratePreconditionDependencies ( module );
1525 GenerateKernelModeDriverModuleTarget ( module );
1526 GenerateInvocations ( module );
1527 }
1528
1529
1530 void
1531 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )
1532 {
1533 static string ros_junk ( "$(ROS_TEMPORARY)" );
1534 string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) );
1535 string workingDirectory = GetWorkingDirectory ();
1536 string objectsMacro = GetObjectsMacro ( module );
1537 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1538
1539 GenerateImportLibraryTargetIfNeeded ( module );
1540
1541 if ( module.files.size () > 0 )
1542 {
1543 string* cflags = new string ( "-D__NTDRIVER__" );
1544 GenerateMacrosAndTargetsTarget ( module,
1545 cflags,
1546 NULL );
1547 delete cflags;
1548
1549 fprintf ( fMakefile, "%s: %s %s\n",
1550 target.c_str (),
1551 objectsMacro.c_str (),
1552 importLibraryDependencies.c_str () );
1553
1554 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1555 module.entrypoint.c_str (),
1556 module.baseaddress.c_str () );
1557 GenerateLinkerCommand ( module,
1558 "${gcc}",
1559 linkerParameters,
1560 objectsMacro );
1561 }
1562 else
1563 {
1564 fprintf ( fMakefile, ".PHONY: %s\n\n",
1565 target.c_str ());
1566 fprintf ( fMakefile, "%s:\n",
1567 target.c_str () );
1568 }
1569 }
1570
1571
1572 static MingwNativeDLLModuleHandler nativedll_handler;
1573
1574 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
1575 : MingwModuleHandler ( NativeDLL )
1576 {
1577 }
1578
1579 void
1580 MingwNativeDLLModuleHandler::Process ( const Module& module )
1581 {
1582 GeneratePreconditionDependencies ( module );
1583 GenerateNativeDLLModuleTarget ( module );
1584 GenerateInvocations ( module );
1585 }
1586
1587 void
1588 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module )
1589 {
1590 static string ros_junk ( "$(ROS_TEMPORARY)" );
1591 string target ( FixupTargetFilename ( module.GetPath () ) );
1592 string workingDirectory = GetWorkingDirectory ( );
1593 string objectsMacro = GetObjectsMacro ( module );
1594 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1595
1596 GenerateImportLibraryTargetIfNeeded ( module );
1597
1598 if ( module.files.size () > 0 )
1599 {
1600 GenerateMacrosAndTargetsTarget ( module );
1601
1602 fprintf ( fMakefile, "%s: %s %s\n",
1603 target.c_str (),
1604 objectsMacro.c_str (),
1605 importLibraryDependencies.c_str () );
1606
1607 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
1608 module.entrypoint.c_str (),
1609 module.baseaddress.c_str () );
1610 GenerateLinkerCommand ( module,
1611 "${gcc}",
1612 linkerParameters,
1613 objectsMacro );
1614 }
1615 else
1616 {
1617 fprintf ( fMakefile, ".PHONY: %s\n\n",
1618 target.c_str ());
1619 fprintf ( fMakefile, "%s:\n\n",
1620 target.c_str ());
1621 }
1622 }
1623
1624
1625 static MingwNativeCUIModuleHandler nativecui_handler;
1626
1627 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler ()
1628 : MingwModuleHandler ( NativeCUI )
1629 {
1630 }
1631
1632 void
1633 MingwNativeCUIModuleHandler::Process ( const Module& module )
1634 {
1635 GeneratePreconditionDependencies ( module );
1636 GenerateNativeCUIModuleTarget ( module );
1637 GenerateInvocations ( module );
1638 }
1639
1640 void
1641 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module )
1642 {
1643 static string ros_junk ( "$(ROS_TEMPORARY)" );
1644 string target ( FixupTargetFilename ( module.GetPath () ) );
1645 string workingDirectory = GetWorkingDirectory ( );
1646 string objectsMacro = GetObjectsMacro ( module );
1647 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1648
1649 GenerateImportLibraryTargetIfNeeded ( module );
1650
1651 if ( module.files.size () > 0 )
1652 {
1653 string* cflags = new string ( "-D__NTAPP__" );
1654 GenerateMacrosAndTargetsTarget ( module,
1655 cflags,
1656 NULL );
1657 delete cflags;
1658
1659 fprintf ( fMakefile, "%s: %s %s\n",
1660 target.c_str (),
1661 objectsMacro.c_str (),
1662 importLibraryDependencies.c_str () );
1663
1664 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
1665 module.entrypoint.c_str (),
1666 module.baseaddress.c_str () );
1667 GenerateLinkerCommand ( module,
1668 "${gcc}",
1669 linkerParameters,
1670 objectsMacro );
1671 }
1672 else
1673 {
1674 fprintf ( fMakefile, ".PHONY: %s\n\n",
1675 target.c_str ());
1676 fprintf ( fMakefile, "%s:\n\n",
1677 target.c_str ());
1678 }
1679 }
1680
1681
1682 static MingwWin32DLLModuleHandler win32dll_handler;
1683
1684 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
1685 : MingwModuleHandler ( Win32DLL )
1686 {
1687 }
1688
1689 void
1690 MingwWin32DLLModuleHandler::Process ( const Module& module )
1691 {
1692 GenerateExtractWineDLLResourcesTarget ( module );
1693 GeneratePreconditionDependencies ( module );
1694 GenerateWin32DLLModuleTarget ( module );
1695 GenerateInvocations ( module );
1696 }
1697
1698 void
1699 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module )
1700 {
1701 fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n",
1702 module.name.c_str () );
1703 fprintf ( fMakefile, "%s_extractresources: bin2res\n",
1704 module.name.c_str () );
1705 for ( size_t i = 0; i < module.files.size (); i++ )
1706 {
1707 File& file = *module.files[i];
1708 string extension = GetExtension ( file.name );
1709 if ( extension == ".rc" || extension == ".RC" )
1710 {
1711 string resource = FixupTargetFilename ( file.name );
1712 fprintf ( fMakefile, "\t@echo ${bin2res} -f -x %s\n",
1713 resource.c_str () );
1714 }
1715 }
1716 fprintf ( fMakefile, "\n");
1717 }
1718
1719 void
1720 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module )
1721 {
1722 static string ros_junk ( "$(ROS_TEMPORARY)" );
1723 string target ( FixupTargetFilename ( module.GetPath () ) );
1724 string workingDirectory = GetWorkingDirectory ( );
1725 string objectsMacro = GetObjectsMacro ( module );
1726 string linkingDependencies = GetLinkingDependencies ( module );
1727
1728 GenerateImportLibraryTargetIfNeeded ( module );
1729 if ( module.files.size () > 0 )
1730 {
1731 GenerateMacrosAndTargetsTarget ( module );
1732
1733 fprintf ( fMakefile, "%s: %s %s\n",
1734 target.c_str (),
1735 objectsMacro.c_str (),
1736 linkingDependencies.c_str () );
1737
1738 string linker;
1739 if ( IsCPlusPlusModule ( module ) )
1740 linker = "${gpp}";
1741 else
1742 linker = "${gcc}";
1743
1744 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
1745 module.entrypoint.c_str (),
1746 module.baseaddress.c_str () );
1747 GenerateLinkerCommand ( module,
1748 linker,
1749 linkerParameters,
1750 objectsMacro );
1751 }
1752 else
1753 {
1754 fprintf ( fMakefile, ".PHONY: %s\n\n",
1755 target.c_str () );
1756 fprintf ( fMakefile, "%s:\n\n",
1757 target.c_str () );
1758 }
1759 }
1760
1761
1762 static MingwWin32CUIModuleHandler win32cui_handler;
1763
1764 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler ()
1765 : MingwModuleHandler ( Win32CUI )
1766 {
1767 }
1768
1769 void
1770 MingwWin32CUIModuleHandler::Process ( const Module& module )
1771 {
1772 GeneratePreconditionDependencies ( module );
1773 GenerateWin32CUIModuleTarget ( module );
1774 GenerateInvocations ( module );
1775 }
1776
1777 void
1778 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module )
1779 {
1780 static string ros_junk ( "$(ROS_TEMPORARY)" );
1781 string target ( FixupTargetFilename ( module.GetPath () ) );
1782 string workingDirectory = GetWorkingDirectory ( );
1783 string objectsMacro = GetObjectsMacro ( module );
1784 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1785
1786 GenerateImportLibraryTargetIfNeeded ( module );
1787
1788 if ( module.files.size () > 0 )
1789 {
1790 GenerateMacrosAndTargetsTarget ( module );
1791
1792 fprintf ( fMakefile, "%s: %s %s\n",
1793 target.c_str (),
1794 objectsMacro.c_str (),
1795 importLibraryDependencies.c_str () );
1796
1797 string linker;
1798 if ( IsCPlusPlusModule ( module ) )
1799 linker = "${gpp}";
1800 else
1801 linker = "${gcc}";
1802
1803 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1804 module.entrypoint.c_str (),
1805 module.baseaddress.c_str () );
1806 GenerateLinkerCommand ( module,
1807 linker,
1808 linkerParameters,
1809 objectsMacro );
1810 }
1811 else
1812 {
1813 fprintf ( fMakefile, ".PHONY: %s\n\n",
1814 target.c_str ());
1815 fprintf ( fMakefile, "%s:\n\n",
1816 target.c_str ());
1817 }
1818 }
1819
1820
1821 static MingwWin32GUIModuleHandler win32gui_handler;
1822
1823 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
1824 : MingwModuleHandler ( Win32GUI )
1825 {
1826 }
1827
1828 void
1829 MingwWin32GUIModuleHandler::Process ( const Module& module )
1830 {
1831 GeneratePreconditionDependencies ( module );
1832 GenerateWin32GUIModuleTarget ( module );
1833 GenerateInvocations ( module );
1834 }
1835
1836 void
1837 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module )
1838 {
1839 static string ros_junk ( "$(ROS_TEMPORARY)" );
1840 string target ( FixupTargetFilename ( module.GetPath () ) );
1841 string workingDirectory = GetWorkingDirectory ( );
1842 string objectsMacro = GetObjectsMacro ( module );
1843 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1844
1845 GenerateImportLibraryTargetIfNeeded ( module );
1846
1847 if ( module.files.size () > 0 )
1848 {
1849 GenerateMacrosAndTargetsTarget ( module );
1850
1851 fprintf ( fMakefile, "%s: %s %s\n",
1852 target.c_str (),
1853 objectsMacro.c_str (),
1854 importLibraryDependencies.c_str () );
1855
1856 string linker;
1857 if ( IsCPlusPlusModule ( module ) )
1858 linker = "${gpp}";
1859 else
1860 linker = "${gcc}";
1861
1862 string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1863 module.entrypoint.c_str (),
1864 module.baseaddress.c_str () );
1865 GenerateLinkerCommand ( module,
1866 linker,
1867 linkerParameters,
1868 objectsMacro );
1869 }
1870 else
1871 {
1872 fprintf ( fMakefile, ".PHONY: %s\n\n",
1873 target.c_str ());
1874 fprintf ( fMakefile, "%s:\n\n",
1875 target.c_str ());
1876 }
1877 }
1878
1879
1880 static MingwBootLoaderModuleHandler bootloadermodule_handler;
1881
1882 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
1883 : MingwModuleHandler ( BootLoader )
1884 {
1885 }
1886
1887 void
1888 MingwBootLoaderModuleHandler::Process ( const Module& module )
1889 {
1890 GeneratePreconditionDependencies ( module );
1891 GenerateBootLoaderModuleTarget ( module );
1892 GenerateInvocations ( module );
1893 }
1894
1895 void
1896 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& module )
1897 {
1898 static string ros_junk ( "$(ROS_TEMPORARY)" );
1899 string targetName ( module.GetTargetName () );
1900 string target ( FixupTargetFilename ( module.GetPath () ) );
1901 string workingDirectory = GetWorkingDirectory ();
1902 string junk_tmp = ros_junk + module.name + ".junk.tmp";
1903 string objectsMacro = GetObjectsMacro ( module );
1904 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1905
1906 GenerateMacrosAndTargetsTarget ( module );
1907
1908 fprintf ( fMakefile, "%s: %s %s\n",
1909 target.c_str (),
1910 objectsMacro.c_str (),
1911 importLibraryDependencies.c_str () );
1912
1913 fprintf ( fMakefile,
1914 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
1915 GetLinkerMacro ( module ).c_str (),
1916 junk_tmp.c_str (),
1917 objectsMacro.c_str (),
1918 importLibraryDependencies.c_str () );
1919 fprintf ( fMakefile,
1920 "\t${objcopy} -O binary %s %s\n",
1921 junk_tmp.c_str (),
1922 target.c_str () );
1923 fprintf ( fMakefile,
1924 "\t${rm} %s\n",
1925 junk_tmp.c_str () );
1926 }
1927
1928
1929 static MingwBootSectorModuleHandler bootsectormodule_handler;
1930
1931 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ()
1932 : MingwModuleHandler ( BootSector )
1933 {
1934 }
1935
1936 void
1937 MingwBootSectorModuleHandler::Process ( const Module& module )
1938 {
1939 GeneratePreconditionDependencies ( module );
1940 GenerateBootSectorModuleTarget ( module );
1941 GenerateInvocations ( module );
1942 }
1943
1944 void
1945 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module )
1946 {
1947 string objectsMacro = GetObjectsMacro ( module );
1948
1949 string* nasmflags = new string ( "-f bin" );
1950 GenerateMacrosAndTargetsTarget ( module,
1951 NULL,
1952 nasmflags);
1953
1954 fprintf ( fMakefile, ".PHONY: %s\n\n",
1955 module.name.c_str ());
1956 fprintf ( fMakefile,
1957 "%s: %s\n",
1958 module.name.c_str (),
1959 objectsMacro.c_str () );
1960 }
1961
1962
1963 static MingwIsoModuleHandler isomodule_handler;
1964
1965 MingwIsoModuleHandler::MingwIsoModuleHandler ()
1966 : MingwModuleHandler ( Iso )
1967 {
1968 }
1969
1970 void
1971 MingwIsoModuleHandler::Process ( const Module& module )
1972 {
1973 GeneratePreconditionDependencies ( module );
1974 GenerateIsoModuleTarget ( module );
1975 GenerateInvocations ( module );
1976 }
1977
1978 void
1979 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( const string bootcdDirectory,
1980 const Module& module ) const
1981 {
1982 for ( size_t i = 0; i < module.project.modules.size (); i++ )
1983 {
1984 const Module& m = *module.project.modules[i];
1985 if ( m.bootstrap != NULL )
1986 {
1987 string targetFilenameNoFixup = bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd;
1988 string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) );
1989 fprintf ( fMakefile,
1990 "\t${cp} %s %s\n",
1991 m.GetPath ().c_str (),
1992 targetFilename.c_str () );
1993 }
1994 }
1995 }
1996
1997 void
1998 MingwIsoModuleHandler::OutputCdfileCopyCommands ( const string bootcdDirectory,
1999 const Module& module ) const
2000 {
2001 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2002 {
2003 const CDFile& cdfile = *module.project.cdfiles[i];
2004 string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd;
2005 string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) );
2006 fprintf ( fMakefile,
2007 "\t${cp} %s %s\n",
2008 cdfile.GetPath ().c_str (),
2009 targetFilename.c_str () );
2010 }
2011 }
2012
2013 string
2014 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string bootcdDirectory,
2015 const Module& module ) const
2016 {
2017 string directories;
2018 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2019 {
2020 const Module& m = *module.project.modules[i];
2021 if ( m.bootstrap != NULL )
2022 {
2023 string targetDirecctory = bootcdDirectory + SSEP + m.bootstrap->base;
2024 if ( directories.size () > 0 )
2025 directories += " ";
2026 directories += FixupTargetFilename ( targetDirecctory );
2027 }
2028 }
2029 return directories;
2030 }
2031
2032 string
2033 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string bootcdDirectory,
2034 const Module& module ) const
2035 {
2036 string directories;
2037 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2038 {
2039 const CDFile& cdfile = *module.project.cdfiles[i];
2040 string targetDirecctory = bootcdDirectory + SSEP + cdfile.base;
2041 if ( directories.size () > 0 )
2042 directories += " ";
2043 directories += FixupTargetFilename ( targetDirecctory );
2044 }
2045 return directories;
2046 }
2047
2048 string
2049 MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory,
2050 const Module& module ) const
2051 {
2052 string directories = GetBootstrapCdDirectories ( bootcdDirectory,
2053 module );
2054 directories += " " + GetNonModuleCdDirectories ( bootcdDirectory,
2055 module );
2056 return directories;
2057 }
2058
2059 string
2060 MingwIsoModuleHandler::GetBootstrapCdFiles ( const string bootcdDirectory,
2061 const Module& module ) const
2062 {
2063 string cdfiles;
2064 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2065 {
2066 const Module& m = *module.project.modules[i];
2067 if ( m.bootstrap != NULL )
2068 {
2069 if ( cdfiles.size () > 0 )
2070 cdfiles += " ";
2071 cdfiles += FixupTargetFilename ( m.GetPath () );
2072 }
2073 }
2074 return cdfiles;
2075 }
2076
2077 string
2078 MingwIsoModuleHandler::GetNonModuleCdFiles ( const string bootcdDirectory,
2079 const Module& module ) const
2080 {
2081 string cdfiles;
2082 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2083 {
2084 const CDFile& cdfile = *module.project.cdfiles[i];
2085 if ( cdfiles.size () > 0 )
2086 cdfiles += " ";
2087 cdfiles += NormalizeFilename ( cdfile.GetPath () );
2088 }
2089 return cdfiles;
2090 }
2091
2092 string
2093 MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory,
2094 const Module& module ) const
2095 {
2096 string cdfiles = GetBootstrapCdFiles ( bootcdDirectory,
2097 module );
2098 cdfiles += " " + GetNonModuleCdFiles ( bootcdDirectory,
2099 module );
2100 return cdfiles;
2101 }
2102
2103 void
2104 MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
2105 {
2106 string bootcdDirectory = "cd";
2107 string isoboot = FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" );
2108 string bootcdReactosNoFixup = bootcdDirectory + "/reactos";
2109 string bootcdReactos = FixupTargetFilename ( bootcdReactosNoFixup );
2110 PassThruCacheDirectory ( bootcdReactos + SSEP );
2111 string reactosInf = FixupTargetFilename ( bootcdReactosNoFixup + "/reactos.inf" );
2112 string reactosDff = NormalizeFilename ( "bootdata/packages/reactos.dff" );
2113 string cdDirectories = bootcdReactos + " " + GetCdDirectories ( bootcdDirectory,
2114 module );
2115 string cdFiles = GetCdFiles ( bootcdDirectory,
2116 module );
2117
2118 fprintf ( fMakefile, ".PHONY: %s\n\n",
2119 module.name.c_str ());
2120 fprintf ( fMakefile,
2121 "%s: all %s %s %s\n",
2122 module.name.c_str (),
2123 isoboot.c_str (),
2124 cdDirectories.c_str (),
2125 cdFiles.c_str () );
2126 fprintf ( fMakefile,
2127 "\t${cabman} -C %s -L %s -I\n",
2128 reactosDff.c_str (),
2129 bootcdReactos.c_str () );
2130 fprintf ( fMakefile,
2131 "\t${cabman} -C %s -RC %s -L %s -N\n",
2132 reactosDff.c_str (),
2133 reactosInf.c_str (),
2134 bootcdReactos.c_str () );
2135 fprintf ( fMakefile,
2136 "\t- ${rm} %s\n",
2137 reactosInf.c_str () );
2138 OutputBootstrapfileCopyCommands ( bootcdDirectory,
2139 module );
2140 OutputCdfileCopyCommands ( bootcdDirectory,
2141 module );
2142 fprintf ( fMakefile,
2143 "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n",
2144 isoboot.c_str (),
2145 bootcdDirectory.c_str () );
2146 fprintf ( fMakefile,
2147 "\n" );
2148 }