50986984839e7193679c041d31820de99e92e47e
[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() || defines.size() )
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() )
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 string extension = GetExtension ( files[i]->name );
533 if ( extension != ".spec"
534 && extension != ".SPEC"
535 && !files[i]->first )
536 {
537 fprintf (
538 fMakefile,
539 "%s%s",
540 ( i%10 == 9 ? "\\\n\t" : " " ),
541 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ).c_str () );
542 }
543 }
544 fprintf ( fMakefile, "\n" );
545 }
546
547 for ( i = 0; i < ifs.size(); i++ )
548 {
549 If& rIf = *ifs[i];
550 if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() )
551 {
552 fprintf (
553 fMakefile,
554 "ifeq (\"$(%s)\",\"%s\")\n",
555 rIf.property.c_str(),
556 rIf.value.c_str() );
557 GenerateMacros (
558 "+=",
559 rIf.files,
560 rIf.includes,
561 rIf.defines,
562 NULL,
563 NULL,
564 rIf.ifs,
565 cflags_macro,
566 nasmflags_macro,
567 windresflags_macro,
568 linkerflags_macro,
569 objs_macro );
570 fprintf (
571 fMakefile,
572 "endif\n\n" );
573 }
574 }
575 }
576
577 void
578 MingwModuleHandler::GenerateMacros (
579 const Module& module,
580 const string& cflags_macro,
581 const string& nasmflags_macro,
582 const string& windresflags_macro,
583 const string& linkerflags_macro,
584 const string& objs_macro) const
585 {
586 GenerateMacros (
587 "=",
588 module.files,
589 module.includes,
590 module.defines,
591 &module.compilerFlags,
592 &module.linkerFlags,
593 module.ifs,
594 cflags_macro,
595 nasmflags_macro,
596 windresflags_macro,
597 linkerflags_macro,
598 objs_macro );
599 fprintf ( fMakefile, "\n" );
600
601 fprintf (
602 fMakefile,
603 "%s += $(PROJECT_CFLAGS)\n\n",
604 cflags_macro.c_str () );
605
606 fprintf (
607 fMakefile,
608 "%s += $(PROJECT_RCFLAGS)\n\n",
609 windresflags_macro.c_str () );
610
611 fprintf (
612 fMakefile,
613 "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
614 module.name.c_str () );
615 }
616
617 void
618 MingwModuleHandler::GenerateGccCommand ( const Module& module,
619 const string& sourceFilename,
620 const string& cc,
621 const string& cflagsMacro ) const
622 {
623 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
624 fprintf ( fMakefile,
625 "%s: %s\n",
626 objectFilename.c_str (),
627 sourceFilename.c_str () );
628 fprintf ( fMakefile,
629 "\t%s -c %s -o %s %s\n",
630 cc.c_str (),
631 sourceFilename.c_str (),
632 objectFilename.c_str (),
633 cflagsMacro.c_str () );
634 }
635
636 void
637 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
638 const string& sourceFilename,
639 const string& cc,
640 const string& cflagsMacro ) const
641 {
642 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
643 fprintf ( fMakefile,
644 "%s: %s\n",
645 objectFilename.c_str (),
646 sourceFilename.c_str () );
647 fprintf ( fMakefile,
648 "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
649 cc.c_str (),
650 sourceFilename.c_str (),
651 objectFilename.c_str (),
652 cflagsMacro.c_str () );
653 }
654
655 void
656 MingwModuleHandler::GenerateNasmCommand ( const Module& module,
657 const string& sourceFilename,
658 const string& nasmflagsMacro ) const
659 {
660 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
661 fprintf ( fMakefile,
662 "%s: %s\n",
663 objectFilename.c_str (),
664 sourceFilename.c_str () );
665 fprintf ( fMakefile,
666 "\t%s -f win32 %s -o %s %s\n",
667 "nasm",
668 sourceFilename.c_str (),
669 objectFilename.c_str (),
670 nasmflagsMacro.c_str () );
671 }
672
673 void
674 MingwModuleHandler::GenerateWindresCommand ( const Module& module,
675 const string& sourceFilename,
676 const string& windresflagsMacro ) const
677 {
678 string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
679 string rciFilename = ReplaceExtension ( sourceFilename,
680 ".rci" );
681 string resFilename = ReplaceExtension ( sourceFilename,
682 ".res" );
683 fprintf ( fMakefile,
684 "%s: %s\n",
685 objectFilename.c_str (),
686 sourceFilename.c_str () );
687 fprintf ( fMakefile,
688 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
689 windresflagsMacro.c_str (),
690 sourceFilename.c_str (),
691 rciFilename.c_str () );
692 fprintf ( fMakefile,
693 "\t${wrc} ${%s} %s %s\n",
694 windresflagsMacro.c_str (),
695 rciFilename.c_str (),
696 resFilename.c_str () );
697 fprintf ( fMakefile,
698 "\t${rm} %s\n",
699 rciFilename.c_str () );
700 fprintf ( fMakefile,
701 "\t${windres} %s -o %s\n",
702 resFilename.c_str (),
703 objectFilename.c_str () );
704 fprintf ( fMakefile,
705 "\t${rm} %s\n",
706 resFilename.c_str () );
707 }
708
709 void
710 MingwModuleHandler::GenerateWinebuildCommands ( const Module& module,
711 const string& sourceFilename ) const
712 {
713 string basename = GetBasename ( sourceFilename );
714 fprintf ( fMakefile,
715 "%s.spec.def: %s\n",
716 basename.c_str (),
717 sourceFilename.c_str () );
718 fprintf ( fMakefile,
719 "\t%s --def=%s -o %s.spec.def\n",
720 "${winebuild}",
721 sourceFilename.c_str (),
722 basename.c_str () );
723
724 fprintf ( fMakefile,
725 "%s.stubs.c: %s\n",
726 basename.c_str (),
727 sourceFilename.c_str () );
728 fprintf ( fMakefile,
729 "\t%s --pedll=%s -o %s.stubs.c\n",
730 "${winebuild}",
731 sourceFilename.c_str (),
732 basename.c_str () );
733 }
734
735 void
736 MingwModuleHandler::GenerateCommands ( const Module& module,
737 const string& sourceFilename,
738 const string& cc,
739 const string& cppc,
740 const string& cflagsMacro,
741 const string& nasmflagsMacro,
742 const string& windresflagsMacro ) const
743 {
744 string extension = GetExtension ( sourceFilename );
745 if ( extension == ".c" || extension == ".C" )
746 {
747 GenerateGccCommand ( module,
748 sourceFilename,
749 cc,
750 cflagsMacro );
751 return;
752 }
753 else if ( extension == ".cc" || extension == ".CC" ||
754 extension == ".cpp" || extension == ".CPP" ||
755 extension == ".cxx" || extension == ".CXX" )
756 {
757 GenerateGccCommand ( module,
758 sourceFilename,
759 cppc,
760 cflagsMacro );
761 return;
762 }
763 else if ( extension == ".s" || extension == ".S" )
764 {
765 GenerateGccAssemblerCommand ( module,
766 sourceFilename,
767 cc,
768 cflagsMacro );
769 return;
770 }
771 else if ( extension == ".asm" || extension == ".ASM" )
772 {
773 GenerateNasmCommand ( module,
774 sourceFilename,
775 nasmflagsMacro );
776 return;
777 }
778 else if ( extension == ".rc" || extension == ".RC" )
779 {
780 GenerateWindresCommand ( module,
781 sourceFilename,
782 windresflagsMacro );
783 return;
784 }
785 else if ( extension == ".spec" || extension == ".SPEC" )
786 {
787 GenerateWinebuildCommands ( module,
788 sourceFilename );
789 GenerateGccCommand ( module,
790 GetActualSourceFilename ( sourceFilename ),
791 cc,
792 cflagsMacro );
793 return;
794 }
795
796 throw InvalidOperationException ( __FILE__,
797 __LINE__,
798 "Unsupported filename extension '%s' in file '%s'",
799 extension.c_str (),
800 sourceFilename.c_str () );
801 }
802
803 void
804 MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
805 const string& linker,
806 const string& linkerParameters,
807 const string& objectFilenames ) const
808 {
809 string targetName ( module.GetTargetName () );
810 string target ( FixupTargetFilename ( module.GetPath () ) );
811 string importLibraryDependencies = GetImportLibraryDependencies ( module );
812 if ( module.importLibrary != NULL )
813 {
814 static string ros_junk ( "$(ROS_TEMPORARY)" );
815 string base_tmp = ros_junk + module.name + ".base.tmp";
816 string junk_tmp = ros_junk + module.name + ".junk.tmp";
817 string temp_exp = ros_junk + module.name + ".temp.exp";
818
819 fprintf ( fMakefile,
820 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
821 linker.c_str (),
822 linkerParameters.c_str (),
823 base_tmp.c_str (),
824 junk_tmp.c_str (),
825 objectFilenames.c_str (),
826 importLibraryDependencies.c_str (),
827 GetLinkerMacro ( module ).c_str () );
828
829 fprintf ( fMakefile,
830 "\t${rm} %s\n",
831 junk_tmp.c_str () );
832
833 string killAt = module.mangledSymbols ? "" : "--kill-at";
834 fprintf ( fMakefile,
835 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
836 targetName.c_str (),
837 base_tmp.c_str (),
838 ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
839 temp_exp.c_str (),
840 killAt.c_str () );
841
842 fprintf ( fMakefile,
843 "\t${rm} %s\n",
844 base_tmp.c_str () );
845
846 fprintf ( fMakefile,
847 "\t%s %s %s -o %s %s %s %s\n\n",
848 linker.c_str (),
849 linkerParameters.c_str (),
850 temp_exp.c_str (),
851 target.c_str (),
852 objectFilenames.c_str (),
853 importLibraryDependencies.c_str (),
854 GetLinkerMacro ( module ).c_str () );
855
856 fprintf ( fMakefile,
857 "\t${rm} %s\n\n",
858 temp_exp.c_str () );
859 }
860 else
861 {
862 fprintf ( fMakefile,
863 "\t%s %s -o %s %s %s %s\n\n",
864 linker.c_str (),
865 linkerParameters.c_str (),
866 target.c_str (),
867 objectFilenames.c_str (),
868 importLibraryDependencies.c_str (),
869 GetLinkerMacro ( module ).c_str () );
870 }
871 }
872
873 void
874 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
875 const vector<File*>& files,
876 const vector<If*>& ifs,
877 const string& cc,
878 const string& cppc,
879 const string& cflagsMacro,
880 const string& nasmflagsMacro,
881 const string& windresflagsMacro ) const
882 {
883 size_t i;
884
885 for ( i = 0; i < files.size (); i++ )
886 {
887 string sourceFilename = files[i]->name;
888 GenerateCommands ( module,
889 sourceFilename,
890 cc,
891 cppc,
892 cflagsMacro,
893 nasmflagsMacro,
894 windresflagsMacro );
895 fprintf ( fMakefile,
896 "\n" );
897 }
898
899 for ( i = 0; i < ifs.size(); i++ )
900 {
901 GenerateObjectFileTargets ( module,
902 ifs[i]->files,
903 ifs[i]->ifs,
904 cc,
905 cppc,
906 cflagsMacro,
907 nasmflagsMacro,
908 windresflagsMacro );
909 }
910 }
911
912 void
913 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
914 const string& cc,
915 const string& cppc,
916 const string& cflagsMacro,
917 const string& nasmflagsMacro,
918 const string& windresflagsMacro ) const
919 {
920 GenerateObjectFileTargets ( module,
921 module.files,
922 module.ifs,
923 cc,
924 cppc,
925 cflagsMacro,
926 nasmflagsMacro,
927 windresflagsMacro );
928 fprintf ( fMakefile, "\n" );
929 }
930
931 void
932 MingwModuleHandler::GetCleanTargets ( vector<string>& out,
933 const vector<File*>& files,
934 const vector<If*>& ifs ) const
935 {
936 size_t i;
937
938 for ( i = 0; i < files.size(); i++ )
939 out.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ) );
940
941 for ( i = 0; i < ifs.size(); i++ )
942 GetCleanTargets ( out, ifs[i]->files, ifs[i]->ifs );
943 }
944
945 string
946 MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
947 const string& ar,
948 const string& objs_macro ) const
949 {
950 string archiveFilename = GetModuleArchiveFilename ( module );
951
952 fprintf ( fMakefile,
953 "%s: %s\n",
954 archiveFilename.c_str (),
955 objs_macro.c_str ());
956
957 fprintf ( fMakefile,
958 "\t%s -rc %s %s\n\n",
959 ar.c_str (),
960 archiveFilename.c_str (),
961 objs_macro.c_str ());
962
963 return archiveFilename;
964 }
965
966 string
967 MingwModuleHandler::GetCFlagsMacro ( const Module& module ) const
968 {
969 return ssprintf ( "$(%s_CFLAGS)",
970 module.name.c_str () );
971 }
972
973 string
974 MingwModuleHandler::GetObjectsMacro ( const Module& module ) const
975 {
976 return ssprintf ( "$(%s_OBJS)",
977 module.name.c_str () );
978 }
979
980 string
981 MingwModuleHandler::GetLinkerMacro ( const Module& module ) const
982 {
983 return ssprintf ( "$(%s_LFLAGS)",
984 module.name.c_str () );
985 }
986
987 void
988 MingwModuleHandler::GenerateMacrosAndTargets (
989 const Module& module,
990 const string& cc,
991 const string& cppc,
992 const string& ar,
993 const string* cflags,
994 const string* nasmflags ) const
995 {
996 string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
997 string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
998 string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
999 string linkerFlagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
1000 string objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
1001
1002 GenerateMacros ( module,
1003 cflagsMacro,
1004 nasmflagsMacro,
1005 windresflagsMacro,
1006 linkerFlagsMacro,
1007 objectsMacro );
1008
1009 if ( cflags != NULL )
1010 {
1011 fprintf ( fMakefile,
1012 "%s += %s\n\n",
1013 cflagsMacro.c_str (),
1014 cflags->c_str () );
1015 }
1016
1017 if ( nasmflags != NULL )
1018 {
1019 fprintf ( fMakefile,
1020 "%s += %s\n\n",
1021 nasmflagsMacro.c_str (),
1022 nasmflags->c_str () );
1023 }
1024
1025 // generate phony target for module name
1026 fprintf ( fMakefile, ".PHONY: %s\n",
1027 module.name.c_str () );
1028 fprintf ( fMakefile, "%s: %s\n\n",
1029 module.name.c_str (),
1030 FixupTargetFilename ( module.GetPath () ).c_str () );
1031
1032 // future references to the macros will be to get their values
1033 cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());
1034 nasmflagsMacro = ssprintf ("$(%s)", nasmflagsMacro.c_str ());
1035 objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
1036
1037 string ar_target = GenerateArchiveTarget ( module, ar, objectsMacro );
1038 GenerateObjectFileTargets ( module,
1039 cc,
1040 cppc,
1041 cflagsMacro,
1042 nasmflagsMacro,
1043 windresflagsMacro );
1044
1045 vector<string> clean_files;
1046 clean_files.push_back ( FixupTargetFilename(module.GetPath()) );
1047 clean_files.push_back ( ar_target );
1048 GetCleanTargets ( clean_files, module.files, module.ifs );
1049
1050 fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );
1051 fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() );
1052 for ( size_t i = 0; i < clean_files.size(); i++ )
1053 {
1054 if ( 9==(i%10) )
1055 fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );
1056 fprintf ( fMakefile, " %s", clean_files[i].c_str() );
1057 }
1058 fprintf ( fMakefile, " 2>$(NUL)\n" );
1059 fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );
1060 }
1061
1062 void
1063 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
1064 {
1065 GenerateMacrosAndTargets ( module,
1066 "${host_gcc}",
1067 "${host_gpp}",
1068 "${host_ar}",
1069 NULL,
1070 NULL );
1071 }
1072
1073 void
1074 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const
1075 {
1076 GenerateMacrosAndTargetsTarget ( module,
1077 NULL,
1078 NULL );
1079 }
1080
1081 void
1082 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,
1083 const string* cflags,
1084 const string* nasmflags ) const
1085 {
1086 GenerateMacrosAndTargets ( module,
1087 "${gcc}",
1088 "${gpp}",
1089 "${ar}",
1090 cflags,
1091 nasmflags );
1092 }
1093
1094 string
1095 MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const
1096 {
1097 string dependencies;
1098 for ( size_t i = 0; i < module.invocations.size (); i++ )
1099 {
1100 Invoke& invoke = *module.invocations[i];
1101 if (invoke.invokeModule == &module)
1102 /* Protect against circular dependencies */
1103 continue;
1104 if ( dependencies.length () > 0 )
1105 dependencies += " ";
1106 dependencies += invoke.GetTargets ();
1107 }
1108 return dependencies;
1109 }
1110
1111 void
1112 MingwModuleHandler::GenerateInvocations ( const Module& module ) const
1113 {
1114 if ( module.invocations.size () == 0 )
1115 return;
1116
1117 for ( size_t i = 0; i < module.invocations.size (); i++ )
1118 {
1119 const Invoke& invoke = *module.invocations[i];
1120
1121 if ( invoke.invokeModule->type != BuildTool )
1122 {
1123 throw InvalidBuildFileException ( module.node.location,
1124 "Only modules of type buildtool can be invoked." );
1125 }
1126
1127 string invokeTarget = module.GetInvocationTarget ( i );
1128 fprintf ( fMakefile,
1129 ".PHONY: %s\n\n",
1130 invokeTarget.c_str () );
1131 fprintf ( fMakefile,
1132 "%s: %s\n\n",
1133 invokeTarget.c_str (),
1134 invoke.GetTargets ().c_str () );
1135 fprintf ( fMakefile,
1136 "%s: %s\n",
1137 invoke.GetTargets ().c_str (),
1138 FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () );
1139 fprintf ( fMakefile,
1140 "\t%s %s\n\n",
1141 FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),
1142 invoke.GetParameters ().c_str () );
1143 }
1144 }
1145
1146 string
1147 MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const
1148 {
1149 return ssprintf ( "%s_precondition",
1150 module.name.c_str () );
1151 }
1152
1153 string
1154 MingwModuleHandler::GetDefaultDependencies ( const Module& module ) const
1155 {
1156 /* Avoid circular dependency */
1157 if ( module.type == BuildTool || module.name == "zlib" )
1158 return "$(ROS_INTERMEDIATE)." SSEP "tools $(ROS_INTERMEDIATE)." SSEP "lib" SSEP "zlib";
1159 else
1160 return "init";
1161 }
1162
1163 void
1164 MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const
1165 {
1166 string preconditionDependenciesName = GetPreconditionDependenciesName ( module );
1167 string sourceFilenames = GetSourceFilenamesWithoutGeneratedFiles ( module );
1168 string dependencies = GetDefaultDependencies ( module );
1169 string s = GetModuleDependencies ( module );
1170 if ( s.length () > 0 )
1171 {
1172 if ( dependencies.length () > 0 )
1173 dependencies += " ";
1174 dependencies += s;
1175 }
1176
1177 s = GetInvocationDependencies ( module );
1178 if ( s.length () > 0 )
1179 {
1180 if ( dependencies.length () > 0 )
1181 dependencies += " ";
1182 dependencies += s;
1183 }
1184
1185 fprintf ( fMakefile,
1186 ".PHONY: %s\n\n",
1187 preconditionDependenciesName.c_str () );
1188 fprintf ( fMakefile,
1189 "%s: %s\n\n",
1190 preconditionDependenciesName.c_str (),
1191 dependencies.c_str () );
1192 const char* p = sourceFilenames.c_str();
1193 const char* end = p + strlen(p);
1194 while ( p < end )
1195 {
1196 const char* p2 = &p[512];
1197 if ( p2 > end )
1198 p2 = end;
1199 while ( p2 > p && !isspace(*p2) )
1200 --p2;
1201 if ( p == p2 )
1202 {
1203 p2 = strpbrk ( p, " \t" );
1204 if ( !p2 )
1205 p2 = end;
1206 }
1207 fprintf ( fMakefile,
1208 "%.*s: %s\n",
1209 p2-p,
1210 p,
1211 preconditionDependenciesName.c_str ());
1212 p = p2;
1213 p += strspn ( p, " \t" );
1214 }
1215 fprintf ( fMakefile, "\n" );
1216 }
1217
1218 void
1219 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const
1220 {
1221 if ( module.importLibrary != NULL )
1222 {
1223 string definitionDependencies = GetDefinitionDependencies ( module );
1224 fprintf ( fMakefile, "%s: %s\n",
1225 FixupTargetFilename( module.GetDependencyPath () ).c_str (),
1226 definitionDependencies.c_str () );
1227
1228 string killAt = module.mangledSymbols ? "" : "--kill-at";
1229 fprintf ( fMakefile,
1230 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1231 module.GetTargetName ().c_str (),
1232 ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
1233 FixupTargetFilename ( module.GetDependencyPath () ).c_str (),
1234 killAt.c_str () );
1235 }
1236 }
1237
1238 string
1239 MingwModuleHandler::GetSpecObjectDependencies ( const string& filename ) const
1240 {
1241 string basename = GetBasename ( filename );
1242 return basename + ".spec.def" + " " + basename + ".stubs.c";
1243 }
1244
1245 string
1246 MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
1247 {
1248 string dependencies;
1249 string dkNkmLibNoFixup = "dk/nkm/lib";
1250 dependencies += FixupTargetFilename ( dkNkmLibNoFixup );
1251 PassThruCacheDirectory ( dkNkmLibNoFixup + SSEP );
1252 for ( size_t i = 0; i < module.files.size (); i++ )
1253 {
1254 File& file = *module.files[i];
1255 string extension = GetExtension ( file.name );
1256 if ( extension == ".spec" || extension == ".SPEC" )
1257 {
1258 if ( dependencies.length () > 0 )
1259 dependencies += " ";
1260 dependencies += GetSpecObjectDependencies ( file.name );
1261 }
1262 }
1263 return dependencies;
1264 }
1265
1266 string
1267 MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const
1268 {
1269 string dependencies = GetImportLibraryDependencies ( module );
1270 string s = GetDefinitionDependencies ( module );
1271 if ( s.length () > 0 )
1272 {
1273 dependencies += " ";
1274 dependencies += s;
1275 }
1276 return dependencies;
1277 }
1278
1279 bool
1280 MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const
1281 {
1282 if ( module.HasFileWithExtensions ( ".cc", ".CC" ) )
1283 return true;
1284 if ( module.HasFileWithExtensions ( ".cxx", ".CXX" ) )
1285 return true;
1286 if ( module.HasFileWithExtensions ( ".cpp", ".CPP" ) )
1287 return true;
1288 return false;
1289 }
1290
1291
1292 static MingwBuildToolModuleHandler buildtool_handler;
1293
1294 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
1295 : MingwModuleHandler ( BuildTool )
1296 {
1297 }
1298
1299 void
1300 MingwBuildToolModuleHandler::Process ( const Module& module )
1301 {
1302 GeneratePreconditionDependencies ( module );
1303 GenerateBuildToolModuleTarget ( module );
1304 GenerateInvocations ( module );
1305 }
1306
1307 void
1308 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module )
1309 {
1310 string target ( FixupTargetFilename ( module.GetPath () ) );
1311 string archiveFilename = GetModuleArchiveFilename ( module );
1312 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1313
1314 GenerateMacrosAndTargetsHost ( module );
1315
1316 string linker;
1317 if ( IsCPlusPlusModule ( module ) )
1318 linker = "${host_gpp}";
1319 else
1320 linker = "${host_gcc}";
1321
1322 fprintf ( fMakefile, "%s: %s %s\n",
1323 target.c_str (),
1324 archiveFilename.c_str (),
1325 importLibraryDependencies.c_str () );
1326 fprintf ( fMakefile,
1327 "\t%s %s -o %s %s %s\n\n",
1328 linker.c_str (),
1329 GetLinkerMacro ( module ).c_str (),
1330 target.c_str (),
1331 archiveFilename.c_str (),
1332 importLibraryDependencies.c_str () );
1333 }
1334
1335
1336 static MingwKernelModuleHandler kernelmodule_handler;
1337
1338 MingwKernelModuleHandler::MingwKernelModuleHandler ()
1339 : MingwModuleHandler ( Kernel )
1340 {
1341 }
1342
1343 void
1344 MingwKernelModuleHandler::Process ( const Module& module )
1345 {
1346 GeneratePreconditionDependencies ( module );
1347 GenerateKernelModuleTarget ( module );
1348 GenerateInvocations ( module );
1349 }
1350
1351 void
1352 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
1353 {
1354 static string ros_junk ( "$(ROS_TEMPORARY)" );
1355 string targetName ( module.GetTargetName () );
1356 string target ( FixupTargetFilename (module.GetPath ()) );
1357 string workingDirectory = GetWorkingDirectory ();
1358 string objectsMacro = GetObjectsMacro ( module );
1359 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1360 string base_tmp = ros_junk + module.name + ".base.tmp";
1361 string junk_tmp = ros_junk + module.name + ".junk.tmp";
1362 string temp_exp = ros_junk + module.name + ".temp.exp";
1363 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",
1364 module.GetBasePath ().c_str (),
1365 module.entrypoint.c_str (),
1366 module.baseaddress.c_str () );
1367
1368 GenerateMacrosAndTargetsTarget ( module );
1369
1370 GenerateImportLibraryTargetIfNeeded ( module );
1371
1372 fprintf ( fMakefile, "%s: %s %s\n",
1373 target.c_str (),
1374 objectsMacro.c_str (),
1375 importLibraryDependencies.c_str () );
1376 fprintf ( fMakefile,
1377 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1378 GetLinkerMacro ( module ).c_str (),
1379 gccOptions.c_str (),
1380 base_tmp.c_str (),
1381 junk_tmp.c_str (),
1382 objectsMacro.c_str (),
1383 importLibraryDependencies.c_str () );
1384 fprintf ( fMakefile,
1385 "\t${rm} %s\n",
1386 junk_tmp.c_str () );
1387 string killAt = module.mangledSymbols ? "" : "--kill-at";
1388 fprintf ( fMakefile,
1389 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1390 targetName.c_str (),
1391 base_tmp.c_str (),
1392 temp_exp.c_str (),
1393 killAt.c_str () );
1394 fprintf ( fMakefile,
1395 "\t${rm} %s\n",
1396 base_tmp.c_str () );
1397 fprintf ( fMakefile,
1398 "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",
1399 GetLinkerMacro ( module ).c_str (),
1400 gccOptions.c_str (),
1401 temp_exp.c_str (),
1402 target.c_str (),
1403 objectsMacro.c_str (),
1404 importLibraryDependencies.c_str () );
1405 fprintf ( fMakefile,
1406 "\t${rm} %s\n\n",
1407 temp_exp.c_str () );
1408 }
1409
1410
1411 static MingwStaticLibraryModuleHandler staticlibrary_handler;
1412
1413 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
1414 : MingwModuleHandler ( StaticLibrary )
1415 {
1416 }
1417
1418 void
1419 MingwStaticLibraryModuleHandler::Process ( const Module& module )
1420 {
1421 GeneratePreconditionDependencies ( module );
1422 GenerateStaticLibraryModuleTarget ( module );
1423 GenerateInvocations ( module );
1424 }
1425
1426 void
1427 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )
1428 {
1429 GenerateMacrosAndTargetsTarget ( module );
1430 }
1431
1432
1433 static MingwObjectLibraryModuleHandler objectlibrary_handler;
1434
1435 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
1436 : MingwModuleHandler ( ObjectLibrary )
1437 {
1438 }
1439
1440 void
1441 MingwObjectLibraryModuleHandler::Process ( const Module& module )
1442 {
1443 GeneratePreconditionDependencies ( module );
1444 GenerateObjectLibraryModuleTarget ( module );
1445 GenerateInvocations ( module );
1446 }
1447
1448 void
1449 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module )
1450 {
1451 GenerateMacrosAndTargetsTarget ( module );
1452 }
1453
1454
1455 static MingwKernelModeDLLModuleHandler kernelmodedll_handler;
1456
1457 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
1458 : MingwModuleHandler ( KernelModeDLL )
1459 {
1460 }
1461
1462 void
1463 MingwKernelModeDLLModuleHandler::Process ( const Module& module )
1464 {
1465 GeneratePreconditionDependencies ( module );
1466 GenerateKernelModeDLLModuleTarget ( module );
1467 GenerateInvocations ( module );
1468 }
1469
1470 void
1471 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module )
1472 {
1473 static string ros_junk ( "$(ROS_TEMPORARY)" );
1474 string target ( FixupTargetFilename ( module.GetPath () ) );
1475 string workingDirectory = GetWorkingDirectory ( );
1476 string archiveFilename = GetModuleArchiveFilename ( module );
1477 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1478
1479 GenerateImportLibraryTargetIfNeeded ( module );
1480
1481 if ( module.files.size () > 0 )
1482 {
1483 GenerateMacrosAndTargetsTarget ( module );
1484
1485 fprintf ( fMakefile, "%s: %s %s\n",
1486 target.c_str (),
1487 archiveFilename.c_str (),
1488 importLibraryDependencies.c_str () );
1489
1490 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1491 module.entrypoint.c_str (),
1492 module.baseaddress.c_str () );
1493 GenerateLinkerCommand ( module,
1494 "${gcc}",
1495 linkerParameters,
1496 archiveFilename );
1497 }
1498 else
1499 {
1500 fprintf ( fMakefile, ".PHONY: %s\n\n",
1501 target.c_str ());
1502 fprintf ( fMakefile, "%s:\n",
1503 target.c_str ());
1504 }
1505 }
1506
1507
1508 static MingwKernelModeDriverModuleHandler kernelmodedriver_handler;
1509
1510 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
1511 : MingwModuleHandler ( KernelModeDriver )
1512 {
1513 }
1514
1515 void
1516 MingwKernelModeDriverModuleHandler::Process ( const Module& module )
1517 {
1518 GeneratePreconditionDependencies ( module );
1519 GenerateKernelModeDriverModuleTarget ( module );
1520 GenerateInvocations ( module );
1521 }
1522
1523
1524 void
1525 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )
1526 {
1527 static string ros_junk ( "$(ROS_TEMPORARY)" );
1528 string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) );
1529 string workingDirectory = GetWorkingDirectory ( );
1530 string archiveFilename = GetModuleArchiveFilename ( module );
1531 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1532
1533 GenerateImportLibraryTargetIfNeeded ( module );
1534
1535 if ( module.files.size () > 0 )
1536 {
1537 string* cflags = new string ( "-D__NTDRIVER__" );
1538 GenerateMacrosAndTargetsTarget ( module,
1539 cflags,
1540 NULL );
1541 delete cflags;
1542
1543 fprintf ( fMakefile, "%s: %s %s\n",
1544 target.c_str (),
1545 archiveFilename.c_str (),
1546 importLibraryDependencies.c_str () );
1547
1548 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1549 module.entrypoint.c_str (),
1550 module.baseaddress.c_str () );
1551 GenerateLinkerCommand ( module,
1552 "${gcc}",
1553 linkerParameters,
1554 archiveFilename );
1555 }
1556 else
1557 {
1558 fprintf ( fMakefile, ".PHONY: %s\n\n",
1559 target.c_str ());
1560 fprintf ( fMakefile, "%s:\n",
1561 target.c_str () );
1562 }
1563 }
1564
1565
1566 static MingwNativeDLLModuleHandler nativedll_handler;
1567
1568 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
1569 : MingwModuleHandler ( NativeDLL )
1570 {
1571 }
1572
1573 void
1574 MingwNativeDLLModuleHandler::Process ( const Module& module )
1575 {
1576 GeneratePreconditionDependencies ( module );
1577 GenerateNativeDLLModuleTarget ( module );
1578 GenerateInvocations ( module );
1579 }
1580
1581 void
1582 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module )
1583 {
1584 static string ros_junk ( "$(ROS_TEMPORARY)" );
1585 string target ( FixupTargetFilename ( module.GetPath () ) );
1586 string workingDirectory = GetWorkingDirectory ( );
1587 string objectFilenames = GetObjectFilenames ( module );
1588 string archiveFilename = GetModuleArchiveFilename ( module );
1589 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1590
1591 GenerateImportLibraryTargetIfNeeded ( module );
1592
1593 if ( module.files.size () > 0 )
1594 {
1595 GenerateMacrosAndTargetsTarget ( module );
1596
1597 fprintf ( fMakefile, "%s: %s %s\n",
1598 target.c_str (),
1599 archiveFilename.c_str (),
1600 importLibraryDependencies.c_str () );
1601
1602 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
1603 module.entrypoint.c_str (),
1604 module.baseaddress.c_str () );
1605 GenerateLinkerCommand ( module,
1606 "${gcc}",
1607 linkerParameters,
1608 objectFilenames );
1609 }
1610 else
1611 {
1612 fprintf ( fMakefile, ".PHONY: %s\n\n",
1613 target.c_str ());
1614 fprintf ( fMakefile, "%s:\n\n",
1615 target.c_str ());
1616 }
1617 }
1618
1619
1620 static MingwNativeCUIModuleHandler nativecui_handler;
1621
1622 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler ()
1623 : MingwModuleHandler ( NativeCUI )
1624 {
1625 }
1626
1627 void
1628 MingwNativeCUIModuleHandler::Process ( const Module& module )
1629 {
1630 GeneratePreconditionDependencies ( module );
1631 GenerateNativeCUIModuleTarget ( module );
1632 GenerateInvocations ( module );
1633 }
1634
1635 void
1636 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module )
1637 {
1638 static string ros_junk ( "$(ROS_TEMPORARY)" );
1639 string target ( FixupTargetFilename ( module.GetPath () ) );
1640 string workingDirectory = GetWorkingDirectory ( );
1641 string objectFilenames = GetObjectFilenames ( module );
1642 string archiveFilename = GetModuleArchiveFilename ( module );
1643 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1644
1645 GenerateImportLibraryTargetIfNeeded ( module );
1646
1647 if ( module.files.size () > 0 )
1648 {
1649 string* cflags = new string ( "-D__NTAPP__" );
1650 GenerateMacrosAndTargetsTarget ( module,
1651 cflags,
1652 NULL );
1653 delete cflags;
1654
1655 fprintf ( fMakefile, "%s: %s %s\n",
1656 target.c_str (),
1657 archiveFilename.c_str (),
1658 importLibraryDependencies.c_str () );
1659
1660 string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
1661 module.entrypoint.c_str (),
1662 module.baseaddress.c_str () );
1663 GenerateLinkerCommand ( module,
1664 "${gcc}",
1665 linkerParameters,
1666 objectFilenames );
1667 }
1668 else
1669 {
1670 fprintf ( fMakefile, ".PHONY: %s\n\n",
1671 target.c_str ());
1672 fprintf ( fMakefile, "%s:\n\n",
1673 target.c_str ());
1674 }
1675 }
1676
1677
1678 static MingwWin32DLLModuleHandler win32dll_handler;
1679
1680 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
1681 : MingwModuleHandler ( Win32DLL )
1682 {
1683 }
1684
1685 void
1686 MingwWin32DLLModuleHandler::Process ( const Module& module )
1687 {
1688 GenerateExtractWineDLLResourcesTarget ( module );
1689 GeneratePreconditionDependencies ( module );
1690 GenerateWin32DLLModuleTarget ( module );
1691 GenerateInvocations ( module );
1692 }
1693
1694 void
1695 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module )
1696 {
1697 fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n",
1698 module.name.c_str () );
1699 fprintf ( fMakefile, "%s_extractresources: bin2res\n",
1700 module.name.c_str () );
1701 for ( size_t i = 0; i < module.files.size (); i++ )
1702 {
1703 File& file = *module.files[i];
1704 string extension = GetExtension ( file.name );
1705 if ( extension == ".rc" || extension == ".RC" )
1706 {
1707 string resource = FixupTargetFilename ( file.name );
1708 fprintf ( fMakefile, "\t@echo ${bin2res} -f -x %s\n",
1709 resource.c_str () );
1710 }
1711 }
1712 fprintf ( fMakefile, "\n");
1713 }
1714
1715 void
1716 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module )
1717 {
1718 static string ros_junk ( "$(ROS_TEMPORARY)" );
1719 string target ( FixupTargetFilename ( module.GetPath () ) );
1720 string workingDirectory = GetWorkingDirectory ( );
1721 string objectFilenames = GetObjectFilenames ( module );
1722 string linkingDependencies = GetLinkingDependencies ( module );
1723
1724 GenerateImportLibraryTargetIfNeeded ( module );
1725 if ( module.files.size () > 0 )
1726 {
1727 GenerateMacrosAndTargetsTarget ( module );
1728
1729 fprintf ( fMakefile, "%s: %s %s\n",
1730 target.c_str (),
1731 objectFilenames.c_str (),
1732 linkingDependencies.c_str () );
1733
1734 string linker;
1735 if ( IsCPlusPlusModule ( module ) )
1736 linker = "${gpp}";
1737 else
1738 linker = "${gcc}";
1739
1740 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
1741 module.entrypoint.c_str (),
1742 module.baseaddress.c_str () );
1743 GenerateLinkerCommand ( module,
1744 linker,
1745 linkerParameters,
1746 objectFilenames );
1747 }
1748 else
1749 {
1750 fprintf ( fMakefile, ".PHONY: %s\n\n",
1751 target.c_str () );
1752 fprintf ( fMakefile, "%s:\n\n",
1753 target.c_str () );
1754 }
1755 }
1756
1757
1758 static MingwWin32CUIModuleHandler win32cui_handler;
1759
1760 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler ()
1761 : MingwModuleHandler ( Win32CUI )
1762 {
1763 }
1764
1765 void
1766 MingwWin32CUIModuleHandler::Process ( const Module& module )
1767 {
1768 GeneratePreconditionDependencies ( module );
1769 GenerateWin32CUIModuleTarget ( module );
1770 GenerateInvocations ( module );
1771 }
1772
1773 void
1774 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module )
1775 {
1776 static string ros_junk ( "$(ROS_TEMPORARY)" );
1777 string target ( FixupTargetFilename ( module.GetPath () ) );
1778 string workingDirectory = GetWorkingDirectory ( );
1779 string objectFilenames = GetObjectFilenames ( module );
1780 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1781
1782 GenerateImportLibraryTargetIfNeeded ( module );
1783
1784 if ( module.files.size () > 0 )
1785 {
1786 GenerateMacrosAndTargetsTarget ( module );
1787
1788 fprintf ( fMakefile, "%s: %s %s\n",
1789 target.c_str (),
1790 objectFilenames.c_str (),
1791 importLibraryDependencies.c_str () );
1792
1793 string linker;
1794 if ( IsCPlusPlusModule ( module ) )
1795 linker = "${gpp}";
1796 else
1797 linker = "${gcc}";
1798
1799 string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1800 module.entrypoint.c_str (),
1801 module.baseaddress.c_str () );
1802 GenerateLinkerCommand ( module,
1803 linker,
1804 linkerParameters,
1805 objectFilenames );
1806 }
1807 else
1808 {
1809 fprintf ( fMakefile, ".PHONY: %s\n\n",
1810 target.c_str ());
1811 fprintf ( fMakefile, "%s:\n\n",
1812 target.c_str ());
1813 }
1814 }
1815
1816
1817 static MingwWin32GUIModuleHandler win32gui_handler;
1818
1819 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
1820 : MingwModuleHandler ( Win32GUI )
1821 {
1822 }
1823
1824 void
1825 MingwWin32GUIModuleHandler::Process ( const Module& module )
1826 {
1827 GeneratePreconditionDependencies ( module );
1828 GenerateWin32GUIModuleTarget ( module );
1829 GenerateInvocations ( module );
1830 }
1831
1832 void
1833 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module )
1834 {
1835 static string ros_junk ( "$(ROS_TEMPORARY)" );
1836 string target ( FixupTargetFilename ( module.GetPath () ) );
1837 string workingDirectory = GetWorkingDirectory ( );
1838 string objectFilenames = GetObjectFilenames ( module );
1839 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1840
1841 GenerateImportLibraryTargetIfNeeded ( module );
1842
1843 if ( module.files.size () > 0 )
1844 {
1845 GenerateMacrosAndTargetsTarget ( module );
1846
1847 fprintf ( fMakefile, "%s: %s %s\n",
1848 target.c_str (),
1849 objectFilenames.c_str (),
1850 importLibraryDependencies.c_str () );
1851
1852 string linker;
1853 if ( IsCPlusPlusModule ( module ) )
1854 linker = "${gpp}";
1855 else
1856 linker = "${gcc}";
1857
1858 string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1859 module.entrypoint.c_str (),
1860 module.baseaddress.c_str () );
1861 GenerateLinkerCommand ( module,
1862 linker,
1863 linkerParameters,
1864 objectFilenames );
1865 }
1866 else
1867 {
1868 fprintf ( fMakefile, ".PHONY: %s\n\n",
1869 target.c_str ());
1870 fprintf ( fMakefile, "%s:\n\n",
1871 target.c_str ());
1872 }
1873 }
1874
1875
1876 static MingwBootLoaderModuleHandler bootloadermodule_handler;
1877
1878 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
1879 : MingwModuleHandler ( BootLoader )
1880 {
1881 }
1882
1883 void
1884 MingwBootLoaderModuleHandler::Process ( const Module& module )
1885 {
1886 GeneratePreconditionDependencies ( module );
1887 GenerateBootLoaderModuleTarget ( module );
1888 GenerateInvocations ( module );
1889 }
1890
1891 void
1892 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& module )
1893 {
1894 static string ros_junk ( "$(ROS_TEMPORARY)" );
1895 string targetName ( module.GetTargetName () );
1896 string target ( FixupTargetFilename ( module.GetPath () ) );
1897 string workingDirectory = GetWorkingDirectory ();
1898 string junk_tmp = ros_junk + module.name + ".junk.tmp";
1899 string objectsMacro = GetObjectsMacro ( module );
1900 string importLibraryDependencies = GetImportLibraryDependencies ( module );
1901
1902 GenerateMacrosAndTargetsTarget ( module );
1903
1904 fprintf ( fMakefile, "%s: %s %s\n",
1905 target.c_str (),
1906 objectsMacro.c_str (),
1907 importLibraryDependencies.c_str () );
1908
1909 fprintf ( fMakefile,
1910 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
1911 GetLinkerMacro ( module ).c_str (),
1912 junk_tmp.c_str (),
1913 objectsMacro.c_str (),
1914 importLibraryDependencies.c_str () );
1915 fprintf ( fMakefile,
1916 "\t${objcopy} -O binary %s %s\n",
1917 junk_tmp.c_str (),
1918 target.c_str () );
1919 fprintf ( fMakefile,
1920 "\t${rm} %s\n",
1921 junk_tmp.c_str () );
1922 }
1923
1924
1925 static MingwBootSectorModuleHandler bootsectormodule_handler;
1926
1927 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ()
1928 : MingwModuleHandler ( BootSector )
1929 {
1930 }
1931
1932 void
1933 MingwBootSectorModuleHandler::Process ( const Module& module )
1934 {
1935 GeneratePreconditionDependencies ( module );
1936 GenerateBootSectorModuleTarget ( module );
1937 GenerateInvocations ( module );
1938 }
1939
1940 void
1941 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module )
1942 {
1943 string objectsMacro = GetObjectsMacro ( module );
1944
1945 string* nasmflags = new string ( "-f bin" );
1946 GenerateMacrosAndTargetsTarget ( module,
1947 NULL,
1948 nasmflags);
1949
1950 fprintf ( fMakefile, ".PHONY: %s\n\n",
1951 module.name.c_str ());
1952 fprintf ( fMakefile,
1953 "%s: %s\n",
1954 module.name.c_str (),
1955 objectsMacro.c_str () );
1956 }
1957
1958
1959 static MingwIsoModuleHandler isomodule_handler;
1960
1961 MingwIsoModuleHandler::MingwIsoModuleHandler ()
1962 : MingwModuleHandler ( Iso )
1963 {
1964 }
1965
1966 void
1967 MingwIsoModuleHandler::Process ( const Module& module )
1968 {
1969 GeneratePreconditionDependencies ( module );
1970 GenerateIsoModuleTarget ( module );
1971 GenerateInvocations ( module );
1972 }
1973
1974 void
1975 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( const string bootcdDirectory,
1976 const Module& module ) const
1977 {
1978 for ( size_t i = 0; i < module.project.modules.size (); i++ )
1979 {
1980 const Module& m = *module.project.modules[i];
1981 if ( m.bootstrap != NULL )
1982 {
1983 string targetFilenameNoFixup = bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd;
1984 string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) );
1985 fprintf ( fMakefile,
1986 "\t${cp} %s %s\n",
1987 m.GetPath ().c_str (),
1988 targetFilename.c_str () );
1989 }
1990 }
1991 }
1992
1993 void
1994 MingwIsoModuleHandler::OutputCdfileCopyCommands ( const string bootcdDirectory,
1995 const Module& module ) const
1996 {
1997 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
1998 {
1999 const CDFile& cdfile = *module.project.cdfiles[i];
2000 string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd;
2001 string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) );
2002 fprintf ( fMakefile,
2003 "\t${cp} %s %s\n",
2004 cdfile.GetPath ().c_str (),
2005 targetFilename.c_str () );
2006 }
2007 }
2008
2009 string
2010 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string bootcdDirectory,
2011 const Module& module ) const
2012 {
2013 string directories;
2014 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2015 {
2016 const Module& m = *module.project.modules[i];
2017 if ( m.bootstrap != NULL )
2018 {
2019 string targetDirecctory = bootcdDirectory + SSEP + m.bootstrap->base;
2020 if ( directories.size () > 0 )
2021 directories += " ";
2022 directories += FixupTargetFilename ( targetDirecctory );
2023 }
2024 }
2025 return directories;
2026 }
2027
2028 string
2029 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string bootcdDirectory,
2030 const Module& module ) const
2031 {
2032 string directories;
2033 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2034 {
2035 const CDFile& cdfile = *module.project.cdfiles[i];
2036 string targetDirecctory = bootcdDirectory + SSEP + cdfile.base;
2037 if ( directories.size () > 0 )
2038 directories += " ";
2039 directories += FixupTargetFilename ( targetDirecctory );
2040 }
2041 return directories;
2042 }
2043
2044 string
2045 MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory,
2046 const Module& module ) const
2047 {
2048 string directories = GetBootstrapCdDirectories ( bootcdDirectory,
2049 module );
2050 directories += " " + GetNonModuleCdDirectories ( bootcdDirectory,
2051 module );
2052 return directories;
2053 }
2054
2055 string
2056 MingwIsoModuleHandler::GetBootstrapCdFiles ( const string bootcdDirectory,
2057 const Module& module ) const
2058 {
2059 string cdfiles;
2060 for ( size_t i = 0; i < module.project.modules.size (); i++ )
2061 {
2062 const Module& m = *module.project.modules[i];
2063 if ( m.bootstrap != NULL )
2064 {
2065 if ( cdfiles.size () > 0 )
2066 cdfiles += " ";
2067 cdfiles += FixupTargetFilename ( m.GetPath () );
2068 }
2069 }
2070 return cdfiles;
2071 }
2072
2073 string
2074 MingwIsoModuleHandler::GetNonModuleCdFiles ( const string bootcdDirectory,
2075 const Module& module ) const
2076 {
2077 string cdfiles;
2078 for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )
2079 {
2080 const CDFile& cdfile = *module.project.cdfiles[i];
2081 if ( cdfiles.size () > 0 )
2082 cdfiles += " ";
2083 cdfiles += NormalizeFilename ( cdfile.GetPath () );
2084 }
2085 return cdfiles;
2086 }
2087
2088 string
2089 MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory,
2090 const Module& module ) const
2091 {
2092 string cdfiles = GetBootstrapCdFiles ( bootcdDirectory,
2093 module );
2094 cdfiles += " " + GetNonModuleCdFiles ( bootcdDirectory,
2095 module );
2096 return cdfiles;
2097 }
2098
2099 void
2100 MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
2101 {
2102 string bootcdDirectory = "cd";
2103 string isoboot = FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" );
2104 string bootcdReactosNoFixup = bootcdDirectory + "/reactos";
2105 string bootcdReactos = FixupTargetFilename ( bootcdReactosNoFixup );
2106 PassThruCacheDirectory ( bootcdReactos + SSEP );
2107 string reactosInf = FixupTargetFilename ( bootcdReactosNoFixup + "/reactos.inf" );
2108 string reactosDff = NormalizeFilename ( "bootdata/packages/reactos.dff" );
2109 string cdDirectories = bootcdReactos + " " + GetCdDirectories ( bootcdDirectory,
2110 module );
2111 string cdFiles = GetCdFiles ( bootcdDirectory,
2112 module );
2113
2114 fprintf ( fMakefile, ".PHONY: %s\n\n",
2115 module.name.c_str ());
2116 fprintf ( fMakefile,
2117 "%s: all %s %s %s\n",
2118 module.name.c_str (),
2119 isoboot.c_str (),
2120 cdDirectories.c_str (),
2121 cdFiles.c_str () );
2122 fprintf ( fMakefile,
2123 "\t${cabman} -C %s -L %s -I\n",
2124 reactosDff.c_str (),
2125 bootcdReactos.c_str () );
2126 fprintf ( fMakefile,
2127 "\t${cabman} -C %s -RC %s -L %s -N\n",
2128 reactosDff.c_str (),
2129 reactosInf.c_str (),
2130 bootcdReactos.c_str () );
2131 fprintf ( fMakefile,
2132 "\t- ${rm} %s\n",
2133 reactosInf.c_str () );
2134 OutputBootstrapfileCopyCommands ( bootcdDirectory,
2135 module );
2136 OutputCdfileCopyCommands ( bootcdDirectory,
2137 module );
2138 fprintf ( fMakefile,
2139 "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n",
2140 isoboot.c_str (),
2141 bootcdDirectory.c_str () );
2142 fprintf ( fMakefile,
2143 "\n" );
2144 }