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