|
1 # Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 |
|
17 package Cl_codewarrior; |
|
18 |
|
19 # declare variables global for module |
|
20 my @Win32LibList=(); |
|
21 my $Win32StdHeaders; |
|
22 my $BaseAddressFlag; |
|
23 my $Win32Resrc; |
|
24 |
|
25 my $MWCC; |
|
26 my $MWLD; |
|
27 my $MWIncludePath; |
|
28 my $MWIncludeVar; |
|
29 my $CWVersion; |
|
30 my $CWVersionReadable; |
|
31 my $CWBuildNum; |
|
32 my $CWRuntimeLibs=""; |
|
33 |
|
34 require Exporter; |
|
35 @ISA=qw(Exporter); |
|
36 @EXPORT=qw( |
|
37 PMHelp_Mmp |
|
38 |
|
39 PMCheckPlatformL |
|
40 |
|
41 PMPlatProcessMmp |
|
42 |
|
43 PMPlatCheckSource |
|
44 |
|
45 PMStartBldList |
|
46 PMBld |
|
47 PMStartSrcList |
|
48 PMBitMapBld |
|
49 PMResrcBld |
|
50 PMAifBld |
|
51 PMStartSrc |
|
52 PMSrcDepend |
|
53 PMSrcBldDepend |
|
54 PMEndSrcBld |
|
55 PMEndSrc |
|
56 PMEndSrcList |
|
57 ); |
|
58 |
|
59 use strict; |
|
60 use Winutl; |
|
61 use cl_generic; |
|
62 use E32Variant; |
|
63 |
|
64 my $NamedSymLkup = 0; |
|
65 |
|
66 my $stdcpp_tag_file = 'tag_coff'; |
|
67 my $stdcpp_tag_path = '$(EPOCROOT)epoc32\tools\tag'; |
|
68 |
|
69 sub RoundUp1k($) { |
|
70 # Accept C hexadecimal number (0xNNN). Convert argument to Kb |
|
71 # rounded up to the next 1kb boundary. |
|
72 use integer; |
|
73 return (hex($_[0]) + 1023) / 1024; |
|
74 } |
|
75 |
|
76 |
|
77 sub PMHelp_Mmp { |
|
78 &Winutl_Help_Mmp; |
|
79 } |
|
80 |
|
81 sub SysTrg () { |
|
82 return 1 if &main::SystemTrg; |
|
83 my $ExportLibrary=&main::ExportLibrary; |
|
84 return 1 if ($ExportLibrary =~ /EKERN/i); |
|
85 my $Trg=&main::Trg; |
|
86 return 1 if ($Trg =~ /KSRT/i); |
|
87 return 0; |
|
88 } |
|
89 |
|
90 sub PMCheckPlatformL { |
|
91 |
|
92 my $IsProxyWrapperOption=&main::ProxyWrapperOption(); |
|
93 |
|
94 # check version of CodeWarrior for Symbian OS |
|
95 |
|
96 if (defined($ENV{MWCSym2Includes})) { |
|
97 $MWCC = "mwccsym2.exe"; |
|
98 $MWLD = "mwldsym2.exe"; |
|
99 } |
|
100 if (!defined($MWCC) && defined($ENV{MWSym2Libraries})) { |
|
101 $MWCC = "mwccsym2.exe"; |
|
102 $MWLD = "mwldsym2.exe"; |
|
103 } |
|
104 if (!defined($MWCC) && defined($ENV{CWFolder})) { |
|
105 $MWCC = "mwcc.exe"; |
|
106 $MWLD = "mwld.exe"; |
|
107 } |
|
108 if (!defined($MWCC)) { |
|
109 die "ERROR: Unable to identify a valid CodeWarrior for Symbian OS installation\n"; |
|
110 } |
|
111 |
|
112 # determine default include path |
|
113 |
|
114 $MWIncludeVar = 'MWCIncludes'; # default, even if it doesn't exist |
|
115 $MWIncludePath = ''; # default is empty |
|
116 |
|
117 foreach my $var ('MWCSym2Includes','MWCWinx86Includes','MWCIncludes') { |
|
118 if (defined($ENV{$var})) { |
|
119 $MWIncludePath = $ENV{$var}; |
|
120 $MWIncludeVar = $var; |
|
121 last; |
|
122 } |
|
123 } |
|
124 |
|
125 open PIPE, "$MWCC |", or &main::FatalError( "Failed to find version information for $MWCC \n"); |
|
126 while (<PIPE>) { |
|
127 if($_ =~ /Version\s+(\d+)\.(\d+)\.(\d+)\s+build\s+(\d+)/) { |
|
128 my $MajorVer = $1; |
|
129 my $MinorVer = $2; |
|
130 my $PatchNum = $3; |
|
131 |
|
132 $CWBuildNum = $4; |
|
133 |
|
134 $CWVersionReadable = "$1.$2.$3 build $4"; |
|
135 |
|
136 # The CW compiler documentation says that the compiler version is a 2-byte value as |
|
137 # 0xMnpp (the corresponding CW's pre-defined macro is __MWERKS__), where, |
|
138 # M is the major version number (which means it is accomodated in the first 4 bits, |
|
139 # n is the minor version number (which means it is accomodated in the next 4 bits, |
|
140 # pp is the patch number (which means it is accomodated in the next 8 bits. |
|
141 # Here, an integer is formed from these 3 values to uniquely identify the compiler version. |
|
142 $CWVersion = ($MajorVer << 12) + ($MinorVer << 8) + $PatchNum; |
|
143 last; |
|
144 } |
|
145 } |
|
146 close PIPE; |
|
147 |
|
148 if ($IsProxyWrapperOption){ |
|
149 $MWCC = "$ENV{ABLD_COMPWRAP} " . $MWCC; |
|
150 $MWLD = "$ENV{ABLD_COMPWRAP} " . $MWLD; |
|
151 } |
|
152 } |
|
153 |
|
154 sub PMPlatProcessMmp (@) { |
|
155 &Winutl_DoMmp(\@_, $MWIncludePath); |
|
156 $BaseAddressFlag=&Winutl_BaseAddress; |
|
157 if ($BaseAddressFlag ne "") { |
|
158 $BaseAddressFlag=" -imagebase \"$BaseAddressFlag\""; |
|
159 } |
|
160 @Win32LibList=&Winutl_Win32LibList; |
|
161 $Win32Resrc=&Winutl_Win32Resrc; |
|
162 $Win32StdHeaders=&Winutl_Win32StdHeaders; |
|
163 } |
|
164 |
|
165 sub PMPlatCheckSource () { |
|
166 &Winutl_CheckSourceMMPMetaData (); |
|
167 } |
|
168 |
|
169 sub PMStartBldList($) { |
|
170 my ($makecmd) = @_; |
|
171 my $AifStructRef=&main::AifStructRef; |
|
172 my $BaseTrg=&main::BaseTrg; |
|
173 my $BitMapStructRef=&main::BitMapStructRef; |
|
174 my @BldList=&main::BldList; |
|
175 my @ChopSysIncPaths=&main::Path_Chop(&main::SysIncPaths); |
|
176 my @ChopUserIncPaths=&main::Path_Chop(&main::UserIncPaths); |
|
177 my $ExportLibrary=&main::ExportLibrary; |
|
178 my $NoExportLibrary=&main::NoExportLibrary; |
|
179 my $DefFile=&main::DefFile; |
|
180 my $BasicTrgType=&main::BasicTrgType; |
|
181 my $LibPath=&main::LibPath; |
|
182 my @MacroList=&main::MacroList(); |
|
183 push @MacroList, "__SUPPORT_CPP_EXCEPTIONS__"; |
|
184 |
|
185 push @MacroList, "__SYMBIAN_STDCPP_SUPPORT__" if StdCppTarget(); |
|
186 |
|
187 my $VariantFile=&main::VariantFile(); |
|
188 my $ResourceStructRef=&main::ResourceStructRef; |
|
189 my $Plat=&main::Plat; |
|
190 my $Trg=&main::Trg; |
|
191 my $TrgType=&main::TrgType; |
|
192 my $WarningLevel=&main::CompilerOption("CW"); |
|
193 my $LinkAs=&main::LinkAs; |
|
194 |
|
195 Generic_Header(0,$makecmd); # define standard things using absolute paths |
|
196 |
|
197 my $TrgDir=""; |
|
198 my $AifTrgDir=""; |
|
199 if (&Generic_Definition("TRGDIR") ne "") { |
|
200 $TrgDir="\$(TRGDIR)\\"; |
|
201 $AifTrgDir=$TrgDir; |
|
202 } |
|
203 |
|
204 # Handle migration of binaries to secure location |
|
205 |
|
206 &Winutl_AdjustTargetPath(\$TrgDir); |
|
207 |
|
208 # Change - mwwinrc.exe uses MWWinx86Includes or MWCIncludes, but some installations |
|
209 # fail to install either. Set MWCIncludes from the chosen variable as part |
|
210 # of the Makefile. |
|
211 if (!defined($ENV{MWCIncludes}) && $MWIncludeVar ne 'MWCIncludes') { |
|
212 &main::Output( |
|
213 "\n", |
|
214 "MWCIncludes:=\$($MWIncludeVar)\n", |
|
215 "export MWCIncludes\n", |
|
216 "\n" |
|
217 ); |
|
218 } |
|
219 if( ($CWVersion == 0x3205 && $CWBuildNum == 465)){ |
|
220 if($TrgType =~ /^(STDDLL|STDEXE|STDLIB)$/o) { |
|
221 &main::Output( |
|
222 "\n", |
|
223 "MWSym2LibraryFiles:=msl_all_mse_symbian_d.lib;gdi32.lib;user32.lib;kernel32.lib;\n", |
|
224 "export MWSym2LibraryFiles\n", |
|
225 "\n" |
|
226 ); |
|
227 } |
|
228 else { |
|
229 &main::Output( |
|
230 "\n", |
|
231 "MWSym2LibraryFiles:=msl_all_static_mse_symbian_d.lib;gdi32.lib;user32.lib;kernel32.lib;\n", |
|
232 "export MWSym2LibraryFiles\n", |
|
233 "\n" |
|
234 ); |
|
235 } |
|
236 } |
|
237 |
|
238 if($WarningLevel =~ /\-cwd\s\s*include/){ |
|
239 &main::Output( |
|
240 "# EPOC DEFINITIONS\n", |
|
241 "\n", |
|
242 "INCDIR = -cwd include -i-" |
|
243 ); |
|
244 } |
|
245 else { |
|
246 &main::Output( |
|
247 "# EPOC DEFINITIONS\n", |
|
248 "\n", |
|
249 "INCDIR = -cwd source -i-" |
|
250 ); |
|
251 } |
|
252 foreach (@ChopUserIncPaths,@ChopSysIncPaths) { |
|
253 &main::Output( |
|
254 " \\\n -i \"$_\"" |
|
255 ); |
|
256 } |
|
257 use Pathutl; |
|
258 if($VariantFile){ |
|
259 my $variantFilePath = Path_Split('Path',$VariantFile); |
|
260 $VariantFile = Path_Split('FILE',$VariantFile); |
|
261 # workaround for codewarrior defect: |
|
262 # codewarrior at the moment doesn't accept an absolute path with the |
|
263 # the -include option unless it contains a drive letter, this is solved |
|
264 # by including the directory and the file separately |
|
265 &main::Output("\\\n -i \"$variantFilePath \" -include \"$VariantFile\""); |
|
266 } |
|
267 &main::Output( |
|
268 "\n", |
|
269 "\n" |
|
270 ); |
|
271 |
|
272 &main::Output( |
|
273 "CWFLAGS =" |
|
274 ); |
|
275 |
|
276 # 'wchar_t' should be treated as default datatype for OE targets because when wchar_t option is turned off, |
|
277 # using 'wchar_t' defaults to the unsigned short int and wrong functionality. |
|
278 if ( $TrgType =~ /^(STDEXE|STDDLL|STDLIB)$/io || StdCppTarget() ) |
|
279 { |
|
280 &main::Output( |
|
281 " -wchar_t on" |
|
282 ); |
|
283 } |
|
284 else |
|
285 { |
|
286 &main::Output( |
|
287 " -wchar_t off" |
|
288 ); |
|
289 } |
|
290 |
|
291 &main::Output( |
|
292 " -align 4", # long alignment |
|
293 " -warnings on", # selection of warnings |
|
294 " -w nohidevirtual", # turn off "hides inherited virtual function" warning |
|
295 ",nounusedexpr", # turn off "expression has no side effect" warning |
|
296 " -msgstyle gcc", # use GCC-style message format |
|
297 # " -strict on", # strict ANSI/ISO C++ checking |
|
298 " -enum int", # use int for enumeration types |
|
299 " -str pool", # pool strings into a single data object |
|
300 " -exc ms", # SEH C++ exception implementation |
|
301 " -trigraphs on", # Enable recognition of C-style trigraphs, e.g. '??/' -> '\' |
|
302 " $WarningLevel" |
|
303 |
|
304 ); |
|
305 |
|
306 if ($Win32StdHeaders or &main::Plat eq 'TOOLS') { |
|
307 &main::Output( |
|
308 " -stdinc" # insist because mwccsym2 has -nostdinc as the default(?) |
|
309 ); |
|
310 } |
|
311 else { |
|
312 &main::Output( |
|
313 " -nostdinc" # insist because mwcc has -stdinc as the default. |
|
314 ); |
|
315 } |
|
316 &main::Output( |
|
317 "\n", |
|
318 "\n" |
|
319 ); |
|
320 |
|
321 &main::Output( |
|
322 "CWDEFS = " |
|
323 ); |
|
324 foreach(@MacroList) { |
|
325 &main::Output( |
|
326 " -d \"$_\"" |
|
327 ); |
|
328 } |
|
329 &main::Output( |
|
330 " \$(USERDEFS)\n", |
|
331 "\n" |
|
332 ); |
|
333 |
|
334 foreach (@BldList) { |
|
335 &main::Output( |
|
336 "CW$_ = $MWCC" |
|
337 ); |
|
338 if (/DEB$/o) { |
|
339 &main::Output( |
|
340 ' -g -O0' # debug information, no optimisation |
|
341 ); |
|
342 # euser change to apply inlining on the _NAKED functions |
|
343 |
|
344 # stdexe/stddll change so that the inline functions dont |
|
345 # get exported (in debug build) causing a different export list for debug and release builds |
|
346 if ($BaseTrg!~/^EUSER$/oi && $TrgType !~ /^(STDEXE|STDDLL)$/io) { |
|
347 &main::Output( |
|
348 ' -inline off' |
|
349 ); |
|
350 } |
|
351 } |
|
352 elsif (/REL$/o) { |
|
353 &main::Output( |
|
354 ' -O4,s' # highest level of optimisation, optimise for space |
|
355 ); |
|
356 } |
|
357 |
|
358 if( ($CWVersion == 0x3205 && $CWBuildNum >= 465) || $CWVersion > 0x3205){ |
|
359 if ($TrgType =~ /^(STDEXE|STDDLL|STDLIB)$/io) { |
|
360 &main::Output( |
|
361 ' -runtime dllmulti' |
|
362 ); |
|
363 } |
|
364 else { |
|
365 &main::Output( |
|
366 ' -runtime staticmulti' |
|
367 ); |
|
368 } |
|
369 } |
|
370 |
|
371 &main::Output( |
|
372 ' $(CWFLAGS)' |
|
373 ); |
|
374 foreach (&main::MacroList($_)) { |
|
375 &main::Output( |
|
376 " -d $_" |
|
377 ); |
|
378 } |
|
379 &main::Output( |
|
380 " \$(CWDEFS) \$(INCDIR)\n" |
|
381 ); |
|
382 } |
|
383 &main::Output( |
|
384 "\n", |
|
385 "\n" |
|
386 ); |
|
387 |
|
388 foreach (@BldList) { |
|
389 &main::Output( |
|
390 "$_ :" |
|
391 ); |
|
392 |
|
393 if ($BasicTrgType !~ /IMPLIB/io) { |
|
394 &main::Output ( |
|
395 " \\\n", |
|
396 "\t", &Generic_Quote("\$(EPOCTRG$_)\\$TrgDir$Trg") |
|
397 ); |
|
398 if (&Winutl_CopyForStaticLinkage) { |
|
399 &main::Output( |
|
400 " \\\n", |
|
401 "\t", &Generic_Quote("\$(EPOCTRG$_)\\$Trg") |
|
402 ); |
|
403 } |
|
404 } |
|
405 |
|
406 # lib has to come after the main target so that a .DEF file will be generated if the project is not frozen |
|
407 if ($DefFile and not &main::ExportUnfrozen) { |
|
408 &main::Output( |
|
409 " \\\n", |
|
410 "\tLIBRARY\n" |
|
411 ); |
|
412 } |
|
413 &main::Output( |
|
414 "\n", |
|
415 "\n" |
|
416 ); |
|
417 } |
|
418 |
|
419 foreach (@BldList) { |
|
420 my $makework="MAKEWORK$_"; |
|
421 &main::Output( |
|
422 "\n", |
|
423 "RESOURCE$_ : $makework" |
|
424 ); |
|
425 |
|
426 my $BitMapRef; |
|
427 foreach $BitMapRef (@$BitMapStructRef) { |
|
428 my $file="\$(EPOCTRG$_)\\$$BitMapRef{TrgPath}$$BitMapRef{Trg}"; |
|
429 &Generic_MakeWorkFile($makework,$file); |
|
430 &main::Output( |
|
431 " \\\n", |
|
432 "\t", &Generic_Quote($file) |
|
433 ); |
|
434 } |
|
435 undef $BitMapRef; |
|
436 |
|
437 my $ResourceRef; |
|
438 foreach $ResourceRef (@$ResourceStructRef) { |
|
439 if(! defined $$ResourceRef{Hdronly}) { |
|
440 my $file="\$(EPOCTRG$_)\\$$ResourceRef{Trg}"; |
|
441 &Generic_MakeWorkFile($makework,$file); |
|
442 &main::Output( # must come before main target because source for target will depend on the |
|
443 " \\\n", # *.rsg file in $EPOCIncPath |
|
444 "\t", &Generic_Quote("$file") |
|
445 ); |
|
446 } |
|
447 } |
|
448 undef $ResourceRef; |
|
449 |
|
450 my $AifRef; |
|
451 foreach $AifRef (@$AifStructRef) { |
|
452 my $file="\$(EPOCTRG$_)\\$AifTrgDir$$AifRef{Trg}"; |
|
453 &Generic_MakeWorkFile($makework,$file); |
|
454 &main::Output( |
|
455 " \\\n", |
|
456 "\t", &Generic_Quote($file) |
|
457 ); |
|
458 } |
|
459 undef $AifRef; |
|
460 |
|
461 &main::Output( |
|
462 "\n" |
|
463 ); |
|
464 } |
|
465 &main::Output( |
|
466 "\n", |
|
467 "\n", |
|
468 ); |
|
469 |
|
470 &main::Output( |
|
471 "\n", |
|
472 "# REAL TARGET - LIBRARY\n", |
|
473 "\n", |
|
474 "LIBRARY : MAKEWORKLIBRARY" |
|
475 ); |
|
476 if ($BasicTrgType=~/^LIB$/o) { |
|
477 # code to ensure that the static libraries for all builds are built at the library stage |
|
478 foreach (@BldList) { |
|
479 &main::Output( |
|
480 " $_" |
|
481 ); |
|
482 } |
|
483 } |
|
484 elsif ($DefFile and !$NoExportLibrary) { |
|
485 unless (&main::ExportUnfrozen) { |
|
486 if (-e $DefFile) { # effectively "if project frozen ..." |
|
487 my $LibLinkAs = ($BasicTrgType=~/^IMPLIB$/io) ? $LinkAs : $Trg; |
|
488 &main::Output( |
|
489 " ", &Generic_Quote("\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib"), "\n", |
|
490 "\n", |
|
491 &Generic_Quote("\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib"), " : ", |
|
492 &Generic_Quote($DefFile), "\n", |
|
493 "\tperl -S prepdef.pl ",&Generic_Quote($DefFile)," \"\$(EPOCBLD)\\$ExportLibrary.prep.def\"\n", |
|
494 "\t$MWLD \"\$(EPOCBLD)\\$ExportLibrary.prep.def\" -importlib -o \$\@", |
|
495 " -addcommand \"out:$LibLinkAs\" -warnings off", |
|
496 "\n" |
|
497 ); |
|
498 } else { |
|
499 &main::Output( |
|
500 "\n", |
|
501 "\t\@echo WARNING: Not attempting to create \"\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib\".\n", |
|
502 "\t\@echo When exports are frozen in \"$DefFile\", regenerate Makefile.\n" |
|
503 ); |
|
504 } |
|
505 } else { |
|
506 &main::Output( |
|
507 "\n", |
|
508 "\t\@echo Not attempting to create \"\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib\"\n", |
|
509 "\t\@echo from frozen .DEF file, since EXPORTUNFROZEN specified.\n" |
|
510 ); |
|
511 } |
|
512 } |
|
513 &main::Output( |
|
514 "\n", |
|
515 "\n", |
|
516 "FREEZE :\n" |
|
517 ); |
|
518 if ($DefFile and $BasicTrgType!~/^IMPLIB$/io) { |
|
519 &main::Output( |
|
520 # call perl on the script here so nmake will die if there are errors - this doesn't happen if calling perl in a batch file |
|
521 "\tperl -w -S efreeze.pl \$(EFREEZE_ALLOW_REMOVE) \"$DefFile\" \"\$(EPOCBLD)\\$ExportLibrary.def\" \n" |
|
522 ); |
|
523 } |
|
524 else { |
|
525 &main::Output( "\tperl -e \"print \\\"warning: freeze could not be supported or \\ |
|
526 you need to declare an explicitly specified def file using the keyword \\ |
|
527 DEFFILE in the MMP file!\\n\\\"\""); |
|
528 } |
|
529 &main::Output( |
|
530 "\n", |
|
531 "CLEANLIBRARY :\n" |
|
532 ); |
|
533 if ($DefFile and !$NoExportLibrary) { |
|
534 &main::Output( |
|
535 "\t-\$(ERASE) \"\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib\"\n" |
|
536 ); |
|
537 } |
|
538 &main::Output( |
|
539 "\n" |
|
540 ); |
|
541 &Generic_MakeWorkDir('MAKEWORKLIBRARY',"${LibPath}UDEB"); |
|
542 |
|
543 &Generic_Releaseables; |
|
544 } |
|
545 |
|
546 my $uidfile; |
|
547 sub PMBld { |
|
548 |
|
549 my $AifStructRef=&main::AifStructRef; |
|
550 my @SrcList=&main::SrcList; |
|
551 my $BaseTrg=&main::BaseTrg; |
|
552 my $BitMapStructRef=&main::BitMapStructRef; |
|
553 my $Bld=&main::Bld; |
|
554 my $ChopBldPath=&main::Path_Chop(&main::BldPath); |
|
555 my $ExportLibrary=&main::ExportLibrary; |
|
556 my $NoExportLibrary=&main::NoExportLibrary; |
|
557 my $DefFile=&main::DefFile; |
|
558 my $EPOCIncPath=&main::EPOCIncPath; |
|
559 my $BasicTrgType=&main::BasicTrgType; |
|
560 my @LibList; |
|
561 my $RelPath=&main::RelPath; |
|
562 my $ResourceStructRef=&main::ResourceStructRef; |
|
563 my @StatLibList=&main::StatLibList; |
|
564 my $Trg=&main::Trg; |
|
565 my $TrgPath=&main::TrgPath; |
|
566 my $TrgType=&main::TrgType; |
|
567 # Get the information regarding supporting Compiler Wrapper Option |
|
568 my $IsCompilerWrapperOption=&main::CompilerWrapperOption(); |
|
569 |
|
570 $NamedSymLkup = 1 if($TrgType =~ /^(STDDLL|STDEXE)$/o); |
|
571 |
|
572 $uidfile = "$BaseTrg.UID"; |
|
573 |
|
574 if ($Bld =~ /DEB/) { |
|
575 @LibList=&main::DebugLibList; |
|
576 } else { |
|
577 @LibList=&main::LibList; |
|
578 } |
|
579 |
|
580 # OE Glue Code |
|
581 my @oe_exe_libs=("libcrt0.lib"); |
|
582 my @oe_exe_libs_wchar=("libwcrt0.lib"); |
|
583 |
|
584 # OE Import Libraries |
|
585 my @oe_import_libs=("euser.lib"); |
|
586 if(not (grep /^libc.lib$/i, @LibList)){ |
|
587 push @oe_import_libs, "libc.lib"; |
|
588 } |
|
589 |
|
590 # Handle migration of binaries to secure location |
|
591 |
|
592 my $BLDTRGPATH = ""; |
|
593 my $AIFBLDTRGPATH = ""; |
|
594 if ($TrgPath) { |
|
595 $BLDTRGPATH = "\$(TRGDIR)\\"; # handles TARGETPATH |
|
596 $AIFBLDTRGPATH = $BLDTRGPATH; |
|
597 &Winutl_AdjustTargetPath(\$BLDTRGPATH); |
|
598 } |
|
599 $BLDTRGPATH = "\$(EPOCTRG$Bld)\\".$BLDTRGPATH; |
|
600 $AIFBLDTRGPATH = "\$(EPOCTRG$Bld)\\".$AIFBLDTRGPATH; |
|
601 |
|
602 # REAL TARGETS |
|
603 #------------- |
|
604 &main::Output( |
|
605 "# REAL TARGET - BUILD VARIANT $Bld\n", |
|
606 "\n" |
|
607 ); |
|
608 |
|
609 # releasables |
|
610 my @releaseables; |
|
611 |
|
612 unless (&main::Plat() eq 'TOOLS') { |
|
613 if ($TrgType !~ /^IMPLIB$/io) { |
|
614 if ($TrgType !~ /^NONE/io) { |
|
615 push @releaseables, "$BLDTRGPATH$Trg"; |
|
616 if ($Bld=~/REL$/o && $BasicTrgType!~/^LIB$/o) { |
|
617 push @releaseables,"$BLDTRGPATH$Trg.map"; |
|
618 } |
|
619 if (&Winutl_CopyForStaticLinkage) { |
|
620 push @releaseables, "\$(EPOCTRG$Bld)\\$Trg"; |
|
621 } |
|
622 } |
|
623 my $BitMapRef; |
|
624 foreach $BitMapRef (@$BitMapStructRef) { |
|
625 push @releaseables, "\$(EPOCTRG$Bld)\\$$BitMapRef{TrgPath}$$BitMapRef{Trg}"; |
|
626 } |
|
627 my $ResourceRef; |
|
628 foreach $ResourceRef (@$ResourceStructRef) { |
|
629 if(! defined $$ResourceRef{Hdronly}) { |
|
630 push @releaseables,"\$(EPOCTRG$Bld)\\$$ResourceRef{Trg}"; |
|
631 } |
|
632 } |
|
633 my $AifRef; |
|
634 foreach $AifRef (@$AifStructRef) { |
|
635 push @releaseables, "$AIFBLDTRGPATH$$AifRef{Trg}"; |
|
636 } |
|
637 } |
|
638 if (-e $DefFile and !$NoExportLibrary) { # effectively "if project frozen ..." |
|
639 push @releaseables, "\$(EPOCLIB$Bld)\\$ExportLibrary.lib"; |
|
640 } |
|
641 if ($Bld=~/DEB$/o) { |
|
642 # debugging support files? |
|
643 } |
|
644 } |
|
645 else { |
|
646 if ($BasicTrgType !~ /^IMPLIB$/io) { |
|
647 my $toolspath=&main::EPOCToolsPath(); |
|
648 push @releaseables, "$toolspath$Trg"; |
|
649 } |
|
650 } |
|
651 |
|
652 |
|
653 my $firstlib = ""; |
|
654 my $newlib = ""; |
|
655 |
|
656 if ( $BasicTrgType =~ /^(EXE|DLL)$/o && main::Plat() ne 'TOOLS' ) { |
|
657 |
|
658 $firstlib = main::FirstLib(); |
|
659 |
|
660 unless ( StdCppTarget() || ! main::StdCppSupport()) { |
|
661 |
|
662 $newlib = main::NewLib(); # Check if has been set in the MMP file. |
|
663 |
|
664 unless ($newlib) { |
|
665 if ( main::SystemTrg() ) { |
|
666 |
|
667 $newlib = 'scppnwdl_kern.lib'; |
|
668 } |
|
669 else { |
|
670 $newlib = 'scppnwdl.lib'; |
|
671 } |
|
672 } |
|
673 } |
|
674 } |
|
675 |
|
676 |
|
677 &main::Output( |
|
678 "WHAT$Bld : WHATGENERIC\n", |
|
679 "\n", |
|
680 "CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld\n", |
|
681 "\n", |
|
682 "CLEANBUILD$Bld : \n", |
|
683 "\t\@perl -w -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n", |
|
684 "\n", |
|
685 "CLEANRELEASE$Bld : CLEANGENERIC\n", |
|
686 "\n" |
|
687 ); |
|
688 &Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releaseables); |
|
689 |
|
690 my $adjustedTargetPath=$TrgPath; |
|
691 &Winutl_AdjustTargetPath(\$adjustedTargetPath); |
|
692 &Generic_MakeWorkDir("MAKEWORK$Bld", &main::BldPath); |
|
693 &Generic_MakeWorkDir("MAKEWORK$Bld", "$RelPath$adjustedTargetPath"); |
|
694 |
|
695 &main::Output( |
|
696 "\n", |
|
697 "\n" |
|
698 ); |
|
699 |
|
700 return if ($BasicTrgType=~/^IMPLIB$/io); |
|
701 |
|
702 &main::Output( |
|
703 "LISTING$Bld : MAKEWORK$Bld" |
|
704 ); |
|
705 foreach (@SrcList) { |
|
706 my $BaseSrc = &main::Path_Split('Base', $_); |
|
707 my $Ext = &main::Path_Split('Ext', $_); |
|
708 $BaseSrc.='_' if (lc($Ext) eq '.cia'); |
|
709 $BaseSrc =~ s/\.UID/_UID_/i if ($BaseSrc eq $uidfile); |
|
710 |
|
711 &main::Output( |
|
712 " \\\n\tLISTING$Bld$BaseSrc" |
|
713 ); |
|
714 } |
|
715 &main::Output( |
|
716 "\n", |
|
717 "\n" |
|
718 ); |
|
719 #Compiler wrapper support starts |
|
720 if($IsCompilerWrapperOption) |
|
721 { |
|
722 my $Platcmpwrap=&main::Plat; |
|
723 |
|
724 &main::Output( |
|
725 "COMPWRAP$Bld : OUTPUT_NAME = ", |
|
726 "$Platcmpwrap\_$Bld", |
|
727 "\n" |
|
728 ); |
|
729 |
|
730 &main::Output( |
|
731 "COMPWRAP$Bld : MAKEWORK$Bld" |
|
732 ); |
|
733 |
|
734 foreach (@SrcList) { |
|
735 my $BaseSrc = &main::Path_Split('Base', $_); |
|
736 my $Ext = &main::Path_Split('Ext', $_); |
|
737 $BaseSrc.='_' if (lc($Ext) eq '.cia'); |
|
738 $BaseSrc =~ s/\.UID/_UID_/i if ($BaseSrc eq $uidfile); |
|
739 |
|
740 &main::Output( |
|
741 " \\\n\tCOMPWRAP$Bld$BaseSrc" |
|
742 ); |
|
743 } |
|
744 |
|
745 &main::Output( |
|
746 "\n", |
|
747 "\n" |
|
748 ); |
|
749 } |
|
750 #--Compiler wrapper support ends |
|
751 |
|
752 # Flag that tells whether to run checklib.exe on static libraries. |
|
753 my $run_checklib = 0; |
|
754 |
|
755 if (@StatLibList && $BasicTrgType =~ /^(EXE|DLL)$/o && !main::SystemTrg() && main::StdCppSupport()) { |
|
756 # There are user-added static libraries. They should be checked for |
|
757 # consistent use of operator new. |
|
758 $run_checklib = 1; |
|
759 |
|
760 #Create a make variable for the libraries. |
|
761 main::Output("\nUSER_ADDED_ARCHIVES_$Bld="); |
|
762 for (@StatLibList) { |
|
763 &main::Output( |
|
764 " \\\n\t", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_") |
|
765 ); |
|
766 } |
|
767 |
|
768 main::Output("\n\n"); |
|
769 } |
|
770 |
|
771 &main::Output( |
|
772 "LIBS$Bld=" |
|
773 ); |
|
774 foreach (@StatLibList) { |
|
775 &main::Output( |
|
776 " \\\n\t", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_") |
|
777 ); |
|
778 } |
|
779 |
|
780 #OE Glue Code |
|
781 if ($TrgType=~/^STDEXE$/o) { |
|
782 if (&main::IsWideCharMain()) { |
|
783 foreach (@oe_exe_libs_wchar) { |
|
784 &main::Output( |
|
785 " \\\n\t", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_") |
|
786 ); |
|
787 } |
|
788 } |
|
789 else { |
|
790 foreach (@oe_exe_libs) { |
|
791 &main::Output( |
|
792 " \\\n\t", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_") |
|
793 ); |
|
794 } |
|
795 } |
|
796 } |
|
797 |
|
798 foreach (@LibList) { |
|
799 &main::Output( |
|
800 " \\\n\t", &Generic_Quote("\$(EPOCLINK$Bld)\\$_") |
|
801 ); |
|
802 } |
|
803 |
|
804 #OE Import Libraries |
|
805 if ($TrgType =~ /^STDEXE$/o || $TrgType =~ /^STDDLL$/o) { |
|
806 foreach (@oe_import_libs) { |
|
807 &main::Output( |
|
808 " \\\n\t", &Generic_Quote("\$(EPOCLINK$Bld)\\$_") |
|
809 ); |
|
810 } |
|
811 } |
|
812 |
|
813 &main::Output( |
|
814 "\n", |
|
815 "\n" |
|
816 ); |
|
817 |
|
818 &main::Output( |
|
819 "LINK_OBJS$Bld=" |
|
820 ); |
|
821 my $have_uidfile = 0; |
|
822 foreach (@SrcList) { |
|
823 my $BaseSrc = &main::Path_Split('Base', $_); |
|
824 my $Ext = &main::Path_Split('Ext', $_); |
|
825 if ($BaseSrc eq $uidfile) { |
|
826 $have_uidfile = 1; |
|
827 next; |
|
828 } |
|
829 $BaseSrc.='_' if (lc($Ext) eq '.cia'); |
|
830 &main::Output( |
|
831 " \\\n", |
|
832 "\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o") |
|
833 ); |
|
834 } |
|
835 |
|
836 my $add_stdcpp_tag = 0; |
|
837 |
|
838 if ($BasicTrgType=~/^LIB$/o && StdCppTarget() ) { |
|
839 $add_stdcpp_tag = 1; |
|
840 } |
|
841 |
|
842 if ($add_stdcpp_tag) { |
|
843 &main::Output( |
|
844 " \\\n", |
|
845 "\t", &Generic_Quote("$stdcpp_tag_path\\$stdcpp_tag_file") |
|
846 ); |
|
847 } |
|
848 if ($Win32Resrc) { |
|
849 my $resbase=&main::Path_Split('Base',$Win32Resrc); |
|
850 &main::Output( |
|
851 " \\\n", |
|
852 "\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$resbase.res") |
|
853 ); |
|
854 } |
|
855 if ($have_uidfile) { |
|
856 # ensure that the uid file is at the end of the list, as it's implicit in |
|
857 # CodeWarrior IDE projects. |
|
858 &main::Output( |
|
859 " \\\n", |
|
860 "\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg"."_UID_.o") |
|
861 ); |
|
862 } |
|
863 &main::Output( |
|
864 "\n", |
|
865 "\n" |
|
866 ); |
|
867 |
|
868 &main::OutFormat( |
|
869 "COMMON_LINK_FLAGS$Bld=", |
|
870 ' -msgstyle gcc', |
|
871 ' -stdlib' # use default runtime library for compiler help functions |
|
872 ); |
|
873 if ($MWLD =~ /mwcc.exe/) { |
|
874 &main::OutFormat( |
|
875 ' -warnings on' # on by default in mwccsym2.exe |
|
876 ); |
|
877 } |
|
878 |
|
879 main::OutFormat(" \"\$(EPOCSTATLINK$Bld)\\$firstlib\" ") if $firstlib; |
|
880 main::OutFormat(" \"\$(EPOCSTATLINK$Bld)\\$newlib\" ") if $newlib; |
|
881 |
|
882 foreach my $lib (@Win32LibList) { |
|
883 my $win32lib = $lib; # take a copy, to avoid updating contents of Win32LibList! |
|
884 $win32lib = "-l$win32lib" unless ($win32lib =~ /\\/); |
|
885 &main::OutFormat( |
|
886 " ",lc $win32lib |
|
887 ); |
|
888 } |
|
889 if ($BasicTrgType=~/^DLL$/o) { |
|
890 &main::OutFormat( |
|
891 "$BaseAddressFlag", |
|
892 ' -main __Win32DllMain@12', |
|
893 ' -shared' |
|
894 ); |
|
895 } |
|
896 elsif ($TrgType=~/^EXEXP$/o) { |
|
897 &main::OutFormat( |
|
898 "$BaseAddressFlag", |
|
899 ' -noentry', |
|
900 ' -shared' |
|
901 ); |
|
902 } |
|
903 elsif ($BasicTrgType=~/^EXE$/o) { |
|
904 unless (&main::Plat eq 'TOOLS') { |
|
905 &main::OutFormat( |
|
906 ' -m "?_E32Bootstrap@@YGXXZ"' |
|
907 ); |
|
908 } |
|
909 } |
|
910 if (&main::Plat=~/^(WINC|TOOLS)$/o && $BasicTrgType=~/^EXE$/o) { |
|
911 &main::OutFormat( |
|
912 ' -subsystem console' |
|
913 ); |
|
914 } |
|
915 else { |
|
916 &main::OutFormat( |
|
917 ' -subsystem windows' |
|
918 ); |
|
919 } |
|
920 if (&main::HeapSize) { |
|
921 my %HeapSize=&main::HeapSize; |
|
922 &main::OutFormat( |
|
923 ' -heapreserve=',RoundUp1k($HeapSize{Max}),' -heapcommit=',RoundUp1k($HeapSize{Min}) |
|
924 ); |
|
925 } |
|
926 if ($BasicTrgType=~/^(DLL|EXE)$/o) { |
|
927 if ($Bld=~/DEB$/o) { |
|
928 &main::OutFormat( |
|
929 ' -g' |
|
930 ); |
|
931 } |
|
932 } |
|
933 &main::Output( |
|
934 "\n", |
|
935 "\n" |
|
936 ); |
|
937 |
|
938 if($TrgType =~/^(STDEXE|STDDLL|STDLIB)$/o) { |
|
939 if(! (( $CWVersion == 0x3205 && $CWBuildNum >= 465 ) || $CWVersion > 0x3205 ) ) { |
|
940 &main::FatalError("TargetType $TrgType requires CodeWarrior version `3.2.5 build 465' or later but you have $CWVersionReadable."); |
|
941 } |
|
942 } |
|
943 |
|
944 my $EntrySymbol=''; |
|
945 if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o || $NamedSymLkup) { |
|
946 my $Include=""; |
|
947 if ($BasicTrgType=~/^DLL$/o) { |
|
948 $Include="-m __E32Dll"; |
|
949 $EntrySymbol='__E32Dll'; |
|
950 } |
|
951 else { |
|
952 $Include="-m __E32Startup"; |
|
953 $EntrySymbol='__E32Startup'; |
|
954 } |
|
955 &main::Output( |
|
956 "STAGE1_LINK_FLAGS$Bld= \$(COMMON_LINK_FLAGS$Bld) \$(LIBS$Bld) \\\n\t", |
|
957 " -o \"\$(EPOCBLD$Bld)\\$Trg\""); |
|
958 |
|
959 if ($NamedSymLkup) { |
|
960 &main::Output( |
|
961 " -export all", |
|
962 " -map \"\$(EPOCBLD$Bld)\\$Trg.map\"" |
|
963 ); |
|
964 } |
|
965 else { |
|
966 &main::Output(' -export dllexport'); |
|
967 } |
|
968 |
|
969 if($CWRuntimeLibs ne "") { |
|
970 &main::Output( |
|
971 " -l$CWRuntimeLibs " |
|
972 ); |
|
973 } |
|
974 if($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o) { |
|
975 &main::Output( |
|
976 " $Include", |
|
977 ' -nocompactimportlib', |
|
978 " -implib \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"", |
|
979 " -addcommand \"out:$Trg\" -warnings off", |
|
980 "\n", |
|
981 ); |
|
982 } |
|
983 else{ |
|
984 # Dont generate import libs for an Exe |
|
985 &main::Output( |
|
986 " $Include", |
|
987 " -addcommand \"out:$Trg\" -warnings off", |
|
988 "\n", |
|
989 ); |
|
990 } |
|
991 } |
|
992 my $AbsentSubst = ''; |
|
993 if ($EntrySymbol) { |
|
994 $AbsentSubst = " -absent $EntrySymbol"; |
|
995 } |
|
996 |
|
997 &main::Output( |
|
998 "LINK_FLAGS$Bld= \$(COMMON_LINK_FLAGS$Bld) \$(LIBS$Bld) \\\n\t", |
|
999 " -o \"$BLDTRGPATH$Trg\" ", &main::LinkerOption("CW") |
|
1000 ); |
|
1001 if($CWRuntimeLibs ne "") { |
|
1002 &main::Output( |
|
1003 " -l$CWRuntimeLibs " |
|
1004 ); |
|
1005 } |
|
1006 if ($Bld=~/REL$/o && $BasicTrgType!~/^LIB$/o) { |
|
1007 # Generate map file for release build executables |
|
1008 &main::Output( |
|
1009 " -map \"$BLDTRGPATH$Trg.map\"", |
|
1010 ); |
|
1011 } |
|
1012 if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o) { |
|
1013 &main::Output( |
|
1014 " -f \"\$(EPOCBLD)\\$ExportLibrary.def\"", # use generated .DEF file |
|
1015 ); |
|
1016 if (&main::ExportUnfrozen) { |
|
1017 &main::Output( |
|
1018 " -implib \"\$(EPOCLIB)\\UDEB\\$ExportLibrary.lib\"", |
|
1019 " -addcommand \"out:$Trg\" -warnings off" |
|
1020 ); |
|
1021 } |
|
1022 else { |
|
1023 &main::Output( |
|
1024 ' -noimplib' |
|
1025 ); |
|
1026 } |
|
1027 } |
|
1028 else { |
|
1029 &main::Output( |
|
1030 ' -noimplib' |
|
1031 ); |
|
1032 } |
|
1033 &main::Output( |
|
1034 "\n", |
|
1035 "\n" |
|
1036 ); |
|
1037 |
|
1038 &main::Output( |
|
1039 &Generic_Quote("$BLDTRGPATH$Trg"), " : \$(LINK_OBJS$Bld) " |
|
1040 ); |
|
1041 if (-e $DefFile) { # effectively "if project frozen ..." |
|
1042 &main::Output( |
|
1043 &Generic_Quote($DefFile) |
|
1044 ); |
|
1045 } |
|
1046 |
|
1047 main::Output(" ", Generic_Quote("\$(EPOCSTATLINK$Bld)\\$firstlib") ) if $firstlib; |
|
1048 main::Output(" ", Generic_Quote("\$(EPOCSTATLINK$Bld)\\$newlib") ) if $newlib; |
|
1049 |
|
1050 &main::Output( |
|
1051 " \$(LIBS$Bld)\n" |
|
1052 ); |
|
1053 |
|
1054 my $checklib = "checklib"; |
|
1055 |
|
1056 if ( StdCppTarget() ) { |
|
1057 $checklib .= " stdc++ --coff"; |
|
1058 } |
|
1059 else { |
|
1060 $checklib .= " symc++ --coff"; |
|
1061 } |
|
1062 |
|
1063 &main::Output( "\t$checklib ","\$(USER_ADDED_ARCHIVES_$Bld)\n" ) if ($run_checklib); |
|
1064 # Link by name first time round for dlls |
|
1065 if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o) { |
|
1066 &main::Output( |
|
1067 "\t$MWLD \$(STAGE1_LINK_FLAGS$Bld) -l \$(EPOCBLD$Bld) -search \$(notdir \$(LINK_OBJS$Bld))\n", |
|
1068 ); |
|
1069 if(!$NamedSymLkup){ |
|
1070 # Dont delete the binary as we need to extract symbol/dependency info |
|
1071 &main::Output( |
|
1072 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$Trg\"\n", |
|
1073 ); |
|
1074 } |
|
1075 |
|
1076 # Generate an export info file |
|
1077 my $show_options = "names,verbose"; |
|
1078 $show_options = "names,unmangled,verbose" if ($MWLD =~ /mwldsym2.exe/); |
|
1079 &main::Output( |
|
1080 "\t$MWLD -S -show only,$show_options -o \"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\" \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n" |
|
1081 ); |
|
1082 |
|
1083 # call makedef to reorder the export information |
|
1084 &main::Output( |
|
1085 # call perl on the script here so nmake will die if there are errors - this doesn't happen if calling perl in a batch file |
|
1086 "\tperl -w -S makedef.pl $AbsentSubst -Inffile \"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\"" |
|
1087 ); |
|
1088 if (SysTrg()) { |
|
1089 &main::Output( "\t\t-SystemTargetType \\\n" ); |
|
1090 } |
|
1091 if (-e $DefFile) { # effectively "if project frozen ..." |
|
1092 &main::Output( |
|
1093 " -Frzfile \"$DefFile\"" |
|
1094 ); |
|
1095 } |
|
1096 my $Export; |
|
1097 my $Ordinal=1; |
|
1098 foreach $Export (&main::Exports) { |
|
1099 # replace "$" with "$$" so that NMAKE doesn't think there's a macro in the function name |
|
1100 $Export=~s-\$-\$\$-go; |
|
1101 &main::Output( |
|
1102 " -$Ordinal $Export" |
|
1103 ); |
|
1104 $Ordinal++; |
|
1105 } |
|
1106 &main::Output(" -sym_name_lkup") if($NamedSymLkup); |
|
1107 |
|
1108 &main::Output(" -export_entrypoint_E32Dll") if ($TrgType =~ /^STDDLL$/i); # Workaround: To export entry point _E32DLL for target type STDDLL |
|
1109 |
|
1110 &main::Output( |
|
1111 " \"\$(EPOCBLD)\\$ExportLibrary.def\" \n", |
|
1112 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\"\n", |
|
1113 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n" |
|
1114 ); |
|
1115 } |
|
1116 elsif($NamedSymLkup) { |
|
1117 # 2-stage linking required for all those targets that enable symbol lookup |
|
1118 &main::Output( "\t$checklib ","\$(USER_ADDED_ARCHIVES_$Bld)\n" ) if ($run_checklib); |
|
1119 &main::Output( |
|
1120 "\t$MWLD \$(STAGE1_LINK_FLAGS$Bld) -l \$(EPOCBLD$Bld) -search \$(notdir \$(LINK_OBJS$Bld))\n", |
|
1121 ); |
|
1122 } |
|
1123 my $gen_src_file = ""; |
|
1124 if($NamedSymLkup){ |
|
1125 # pick the symbols and the dependencies. |
|
1126 &main::Output( |
|
1127 "\t$MWLD -S -show only,names,verbose -o \"\$(EPOCBLD$Bld)\\$ExportLibrary.sym\" \"\$(EPOCBLD$Bld)\\$Trg\"\n", |
|
1128 ); |
|
1129 |
|
1130 # Generate the source file with symbol and dependency information in the named data segment. |
|
1131 $gen_src_file = "${BaseTrg}_SYM_"; |
|
1132 |
|
1133 if($BasicTrgType=~/^EXE$/o){ |
|
1134 # For an EXE, generate the symbols as well as the dependencies |
|
1135 &main::Output( |
|
1136 "\tperl -S sym_lkup_util.pl -o \"\$(EPOCBLD$Bld)\\$gen_src_file.cpp\" -sym \"\$(EPOCBLD$Bld)\\$ExportLibrary.sym\" -map \"\$(EPOCBLD$Bld)\\$Trg.map\"\n" |
|
1137 ); |
|
1138 } |
|
1139 else { |
|
1140 # For DLLs, generate only the dependencies. |
|
1141 &main::Output( |
|
1142 "\tperl -S sym_lkup_util.pl -o \"\$(EPOCBLD$Bld)\\$gen_src_file.cpp\" -sym \"\$(EPOCBLD$Bld)\\$ExportLibrary.sym\" --ignore_export_dir\n" |
|
1143 ); |
|
1144 } |
|
1145 main::Output( |
|
1146 "\t\$(CW$Bld) -c \"\$(EPOCBLD$Bld)\\$gen_src_file.cpp\" -o \"\$(EPOCBLD$Bld)\\$gen_src_file.o\"\n", |
|
1147 ); |
|
1148 } |
|
1149 |
|
1150 # Perform the final link step |
|
1151 &main::Output( |
|
1152 "\t$MWLD " |
|
1153 ); |
|
1154 if ($BasicTrgType=~/^LIB$/o) { |
|
1155 &main::Output( |
|
1156 "-library " |
|
1157 ); |
|
1158 |
|
1159 &main::Output( "-l $stdcpp_tag_path ") if ($add_stdcpp_tag); |
|
1160 } |
|
1161 |
|
1162 if($NamedSymLkup){ |
|
1163 # Final linking and cleanup |
|
1164 main::Output( |
|
1165 "\$(LINK_FLAGS$Bld) -l \$(EPOCBLD$Bld) -search \$(notdir \$(LINK_OBJS$Bld))", |
|
1166 " \"\$(EPOCBLD$Bld)\\$gen_src_file.o\"\n", |
|
1167 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$gen_src_file.cpp\"\n", |
|
1168 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$gen_src_file.o\"\n", |
|
1169 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$ExportLibrary.sym\"\n", |
|
1170 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$Trg.map\"\n", |
|
1171 "\t\$(ERASE) \"\$(EPOCBLD$Bld)\\$Trg\"\n", |
|
1172 ); |
|
1173 } |
|
1174 else { |
|
1175 &main::Output( |
|
1176 "\$(LINK_FLAGS$Bld) -l \$(EPOCBLD$Bld) -search \$(notdir \$(LINK_OBJS$Bld))\n", |
|
1177 ); |
|
1178 } |
|
1179 |
|
1180 |
|
1181 if (&main::Plat eq 'TOOLS') { |
|
1182 &main::Output( |
|
1183 "\tcopy \"BLDTRGPATH$Trg\" \"",&main::EPOCToolsPath,"$Trg\"\n" |
|
1184 ); |
|
1185 } |
|
1186 if (&Winutl_CopyForStaticLinkage) { |
|
1187 &Generic_MakeWorkDir("MAKEWORK$Bld", "\$(EPOCTRG$Bld)"); |
|
1188 &main::Output( |
|
1189 "\n", |
|
1190 &Generic_Quote("\$(EPOCTRG$Bld)\\$Trg"), " : ", |
|
1191 &Generic_Quote("$BLDTRGPATH$Trg"), "\n", |
|
1192 "\t", &Generic_CopyAction(), |
|
1193 ); |
|
1194 } |
|
1195 |
|
1196 &main::Output( |
|
1197 "\n", |
|
1198 "\n" |
|
1199 ); |
|
1200 } |
|
1201 |
|
1202 sub PMStartSrcList { |
|
1203 |
|
1204 &main::Output( |
|
1205 "# SOURCES\n", |
|
1206 "\n" |
|
1207 ); |
|
1208 } |
|
1209 |
|
1210 sub PMBitMapBld { |
|
1211 |
|
1212 &Generic_BitMapBld; |
|
1213 |
|
1214 # Need to copy generic resource into emulated Z drive |
|
1215 |
|
1216 my $BitMapRef=&main::BitMapRef; |
|
1217 |
|
1218 my $ChopTrgPath=""; |
|
1219 if ($$BitMapRef{TrgPath}) { |
|
1220 $ChopTrgPath.="\\$$BitMapRef{TrgPath}"; |
|
1221 chop $ChopTrgPath; |
|
1222 } |
|
1223 |
|
1224 my @BldList=&main::BldList; |
|
1225 my $Bld; |
|
1226 foreach $Bld (@BldList) { |
|
1227 my $path="\$(EPOCTRG$Bld)$ChopTrgPath"; |
|
1228 &main::Output( |
|
1229 &Generic_Quote("$path\\$$BitMapRef{Trg}"), " : ", |
|
1230 &Generic_Quote("$$BitMapRef{GenericTrg}"), "\n", |
|
1231 "\t", &Generic_CopyAction(), |
|
1232 "\n" |
|
1233 ); |
|
1234 } |
|
1235 } |
|
1236 |
|
1237 sub PMResrcBld { |
|
1238 |
|
1239 &Generic_ResrcBld; |
|
1240 |
|
1241 # Need to copy generic resource into emulated Z drive |
|
1242 |
|
1243 my $ResourceRef=&main::ResourceRef; |
|
1244 my @BldList=&main::BldList; |
|
1245 |
|
1246 foreach my $Bld (@BldList) |
|
1247 { |
|
1248 if(! defined $$ResourceRef{Hdronly}) |
|
1249 { |
|
1250 &main::Output( |
|
1251 &Generic_Quote("\$(EPOCTRG$Bld)\\$$ResourceRef{Trg}"), " : ", |
|
1252 &Generic_Quote("$$ResourceRef{GenericTrg}"), "\n", |
|
1253 "\t", &Generic_CopyAction(), |
|
1254 "\n" |
|
1255 ); |
|
1256 } |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 sub PMAifBld { |
|
1261 |
|
1262 &Generic_AifBld; |
|
1263 |
|
1264 # Need to copy generic resource into emulated Z drive |
|
1265 |
|
1266 my $AifRef=&main::AifRef; |
|
1267 my $TrgDir=""; |
|
1268 if (&Generic_Definition("TRGDIR") ne "") { |
|
1269 $TrgDir="\\\$(TRGDIR)"; |
|
1270 } |
|
1271 |
|
1272 my @BldList=&main::BldList; |
|
1273 my $Bld; |
|
1274 foreach $Bld (@BldList) { |
|
1275 my $path="\$(EPOCTRG$Bld)$TrgDir"; |
|
1276 &main::Output( |
|
1277 &Generic_Quote("$path\\$$AifRef{Trg}"), " : ", |
|
1278 &Generic_Quote("$$AifRef{GenericTrg}"), "\n", |
|
1279 "\t", &Generic_CopyAction(), |
|
1280 "\n" |
|
1281 ); |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 |
|
1286 sub PMStartSrc { |
|
1287 my $Src=&main::Src; |
|
1288 |
|
1289 &main::Output( |
|
1290 "# Source $Src\n", |
|
1291 "\n" |
|
1292 ); |
|
1293 } |
|
1294 |
|
1295 sub PMSrcDepend { |
|
1296 my @BldList=&main::BldList; |
|
1297 my @DepList=&main::DepList; |
|
1298 my $BaseSrc=&main::BaseSrc; |
|
1299 $BaseSrc =~ s/\.UID/_UID_/i if ($BaseSrc eq $uidfile); |
|
1300 |
|
1301 return if (@DepList == 0); |
|
1302 |
|
1303 foreach (@BldList) { |
|
1304 &main::Output( |
|
1305 &Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc.o"), " \\\n", |
|
1306 ); |
|
1307 } |
|
1308 &main::Output( |
|
1309 ":" |
|
1310 ); |
|
1311 foreach (@DepList) { |
|
1312 &main::Output( |
|
1313 " \\\n\t", &Generic_Quote($_) |
|
1314 ); |
|
1315 } |
|
1316 &main::Output( |
|
1317 "\n", |
|
1318 "\n" |
|
1319 ); |
|
1320 } |
|
1321 |
|
1322 sub PMSrcBldDepend { |
|
1323 my $Bld=&main::Bld; |
|
1324 my @DepList=&main::DepList; |
|
1325 my $BaseSrc=&main::BaseSrc; |
|
1326 $BaseSrc =~ s/\.UID/_UID_/i if ($BaseSrc eq $uidfile); |
|
1327 |
|
1328 return if (@DepList == 0); |
|
1329 |
|
1330 &main::Output( |
|
1331 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"), " :", |
|
1332 ); |
|
1333 foreach (@DepList) { |
|
1334 &main::Output( |
|
1335 " \\\n\t", &Generic_Quote($_) |
|
1336 ); |
|
1337 } |
|
1338 &main::Output( |
|
1339 "\n", |
|
1340 "\n" |
|
1341 ); |
|
1342 } |
|
1343 |
|
1344 sub PMEndSrcBld { |
|
1345 my $BaseSrc=&main::BaseSrc; |
|
1346 $BaseSrc =~ s/\.UID/_UID_/i if ($BaseSrc eq $uidfile); |
|
1347 my $Bld=&main::Bld; |
|
1348 my $Plat=&main::Plat; |
|
1349 my $Src=&main::Src; |
|
1350 my $SrcPath=&main::SrcPath; |
|
1351 my $Ext=&main::ExtSrc; |
|
1352 my $Cia = (lc($Ext) eq '.cia') ? 1 : 0; |
|
1353 my $TrgType=&main::TrgType; |
|
1354 # Get the information regarding supporting Compiler Wrapper Option |
|
1355 my $IsCompilerWrapperOption=&main::CompilerWrapperOption(); |
|
1356 |
|
1357 if ($Cia) { |
|
1358 &main::Output( |
|
1359 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.o"), " : ", |
|
1360 &Generic_Quote("$SrcPath$Src"), "\n", |
|
1361 "\techo $Src\n", |
|
1362 "\t\$(CW$Bld) -lang c++ -o \"\$\@\" -c \"$SrcPath$Src\"\n", |
|
1363 "\n", |
|
1364 # assembler listing target - uses implicit rule to do disassembly |
|
1365 "LISTING$Bld$BaseSrc\_ : ", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.lis"), "\n", |
|
1366 "\t", &Generic_CopyAction("$SrcPath$BaseSrc\_.$Plat.lst"), |
|
1367 "\n" |
|
1368 ); |
|
1369 } else { |
|
1370 &main::Output( |
|
1371 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"), " : ", |
|
1372 &Generic_Quote("$SrcPath$Src"), "\n", |
|
1373 "\techo $Src\n", |
|
1374 "\t\$(CW$Bld) -o \"\$\@\" -c \"$SrcPath$Src\" " |
|
1375 ); |
|
1376 # When building for OE target type and source file is of C++ type, |
|
1377 # then pass macro "__wchar_t_defined" to indicate that datatype "wchar_t" is enabled. |
|
1378 if ( StdCppTarget() || $TrgType =~ /^(STDEXE|STDDLL|STDLIB)$/io ) |
|
1379 { |
|
1380 if (lc($Ext) =~ /^(.cpp|.cc|.cxx|.c\+\+)$/) |
|
1381 { |
|
1382 &main::Output( |
|
1383 " -d \"__wchar_t_defined\" " |
|
1384 ); |
|
1385 } |
|
1386 } |
|
1387 &main::Output( |
|
1388 "\n", |
|
1389 "\n" |
|
1390 ); |
|
1391 &main::Output( |
|
1392 # assembler listing target - uses implicit rule to do disassembly |
|
1393 "LISTING$Bld$BaseSrc : ", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.lis"), "\n", |
|
1394 "\t", &Generic_CopyAction("$SrcPath$BaseSrc.$Plat.lst"), |
|
1395 "\n" |
|
1396 ); |
|
1397 |
|
1398 # Output files if Compiler Wrapper Option is specified |
|
1399 if($IsCompilerWrapperOption) |
|
1400 { |
|
1401 my $Platcmpwrap=&main::Plat; |
|
1402 &main::Output( |
|
1403 "COMPWRAP$Bld$BaseSrc : ", |
|
1404 &Generic_Quote("$SrcPath$Src"), "\n", |
|
1405 "\techo Analysing $Src\n", |
|
1406 "\t\$(COMPWRAP) \$(CW$Bld) -o \"\$\@\" -c \"$SrcPath$Src\" ", |
|
1407 "\n\n" |
|
1408 ); |
|
1409 |
|
1410 } |
|
1411 } |
|
1412 } |
|
1413 |
|
1414 sub PMEndSrc { |
|
1415 |
|
1416 &main::Output( |
|
1417 "\n", |
|
1418 "\n" |
|
1419 ); |
|
1420 } |
|
1421 |
|
1422 sub PMEndSrcList { |
|
1423 |
|
1424 my $show_options = "source"; |
|
1425 $show_options = "source,unmangled,comments" if ($MWLD =~ /mwldsym2.exe/); |
|
1426 |
|
1427 &main::Output( |
|
1428 "\n", |
|
1429 "# Implicit rule for generating .lis files\n", |
|
1430 "\n", |
|
1431 ".SUFFIXES : .lis .o\n", |
|
1432 "\n", |
|
1433 ".o.lis:\n", |
|
1434 "\t$MWLD -S -show $show_options \$< -o \$\@\n", |
|
1435 "\n", |
|
1436 "\n" |
|
1437 ); |
|
1438 |
|
1439 if ($Win32Resrc) { |
|
1440 my @BldList=&main::BldList; |
|
1441 my @DepList=&main::Deps_GenDependsL($Win32Resrc); |
|
1442 |
|
1443 &main::Output( |
|
1444 "# Win32 Resource $Win32Resrc\n", |
|
1445 "\n", |
|
1446 "DEPEND=" |
|
1447 ); |
|
1448 foreach (@DepList) { |
|
1449 &main::Output( |
|
1450 " \\\n\t", &Generic_Quote($_) |
|
1451 ); |
|
1452 } |
|
1453 &main::Output( |
|
1454 "\n", |
|
1455 "\n" |
|
1456 ); |
|
1457 |
|
1458 my $Bld; |
|
1459 my $resbase=&main::Path_Split('Base',$Win32Resrc); |
|
1460 my $respath=&main::Path_Chop(&main::Path_Split('Path',$Win32Resrc)); |
|
1461 foreach $Bld (@BldList) { |
|
1462 &main::Output( |
|
1463 &Generic_Quote("\$(EPOCBLD$Bld)\\$resbase.res"), " : ", |
|
1464 &Generic_Quote($Win32Resrc), " \$(DEPEND)\n", |
|
1465 "\tmwwinrc -o \$\@ \"$Win32Resrc\"\n", |
|
1466 "\n" |
|
1467 ); |
|
1468 } |
|
1469 &main::Output( |
|
1470 "\n", |
|
1471 "\n" |
|
1472 ); |
|
1473 } |
|
1474 |
|
1475 # Deal with accumulated MAKEDIRS etc. |
|
1476 |
|
1477 &Generic_End; |
|
1478 } |
|
1479 |
|
1480 sub StdCppTarget() { |
|
1481 |
|
1482 # STDCPP is supported |
|
1483 return 0 if (! main::StdCppSupport()); |
|
1484 |
|
1485 if ( main::NoStdCpp()) { # MMP keyword NOSTDCPP set |
|
1486 return 0; |
|
1487 } |
|
1488 |
|
1489 if ( main::StdCpp() ) { # MMP keyword STDCPP set. |
|
1490 return 1; |
|
1491 } |
|
1492 else { |
|
1493 return ( main::TrgType() =~ /^(STDEXE|STDDLL|STDLIB)$/io ); |
|
1494 } |
|
1495 } |
|
1496 |
|
1497 |
|
1498 1; |