sbsv1/abld/platform/cl_x86gcc.pm
changeset 607 378360dbbdba
parent 599 fa7a3cc6effd
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 # Copyright (c) 1997-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_x86gcc;
       
    18 
       
    19 
       
    20 my $GccPrefix='';
       
    21 my $ToolPrefix='';
       
    22 
       
    23 my $HelperLib='';
       
    24 my %PlatOpt=(
       
    25 	'Dlltool'=>'',
       
    26 	'Entry'=>'--entry',
       
    27 	'Gcc'=>'',
       
    28 	'Ld'=>'',
       
    29 	'Petran'=>'',
       
    30 	'Optimize'=>'-O'
       
    31 );
       
    32 my $Dlltool;
       
    33 my $Archive;
       
    34 my $Link;
       
    35 my $Objcopy;
       
    36 
       
    37 
       
    38 require Exporter;
       
    39 @ISA=qw(Exporter);
       
    40 @EXPORT=qw(
       
    41 	PMHelp_Mmp
       
    42 
       
    43 	PMPlatProcessMmp
       
    44 
       
    45 	PMUnderlyingABI
       
    46 
       
    47 	PMStartBldList
       
    48 		PMBld
       
    49 	PMStartSrcList
       
    50 		PMBitMapBld
       
    51 		PMResrcBld
       
    52 		PMAifBld
       
    53 		PMStartSrc
       
    54 		PMSrcDepend
       
    55 			PMSrcBldDepend
       
    56 			PMEndSrcBld
       
    57 		PMEndSrc
       
    58 	PMEndSrcList
       
    59 	PMPrefixFile
       
    60 );
       
    61 
       
    62 use cl_generic;
       
    63 use Genutl;
       
    64 
       
    65 use constant NOCOMPRESSIONMETHOD => 0;
       
    66 use constant INFLATECOMPRESSIONMETHOD => 1;
       
    67 use constant BYTEPAIRCOMPRESSIONMETHOD => 2;
       
    68 
       
    69 use constant NOTPAGED => 0;
       
    70 use constant UNPAGED => 1;
       
    71 use constant PAGED => 2;
       
    72 
       
    73 
       
    74 sub PMHelp_Mmp {
       
    75 	&Winutl_Help_Mmp;
       
    76 }
       
    77 
       
    78 sub PMCheckPlatformL {
       
    79 }
       
    80 sub PMPlatProcessMmp (@) {
       
    81 	my $MMPFILE=&main::MmpFile;
       
    82 
       
    83 	# set up START MARM ... END block module variables
       
    84 	my @MmpWarn=();
       
    85 	my $Line;
       
    86 	LINE: foreach $Line (@_) {
       
    87 		my $LineInfo=shift @$Line;
       
    88 		$_=shift @$Line;
       
    89 		push @MmpWarn, "$LineInfo : Unrecognised Keyword \"$_\"\n";
       
    90 	}
       
    91 
       
    92 	undef $Line;
       
    93 	if (@MmpWarn) {
       
    94 		warn
       
    95 			"\nMMPFILE \"$MMPFILE\"\n",
       
    96 			"START .. END BLOCK WARNINGS(S)\n",
       
    97 			@MmpWarn,
       
    98 			"\n"
       
    99 		;
       
   100 	}
       
   101 	undef @MmpWarn;
       
   102 }
       
   103 
       
   104 
       
   105 sub SystemTarget() {
       
   106 	return 1 if &main::SystemTrg;
       
   107 	my $ExportLibrary=&main::ExportLibrary;
       
   108 	# N.B. should get better way to detect kernel probably!!
       
   109 	return 1 if ($ExportLibrary =~ /EKERN/i);
       
   110 	
       
   111 	return 0;
       
   112 }
       
   113 
       
   114 
       
   115 
       
   116 
       
   117 
       
   118 sub PMUnderlyingABI($) {
       
   119 	my ($ABI) = @_;
       
   120 	if ($ABI eq 'X86gcc') {
       
   121 			return 'X86gcc';
       
   122 	}
       
   123 	return $ABI;
       
   124 }
       
   125 
       
   126 my $Makecmd;
       
   127 my %ABILibPath=();
       
   128 my $genDefFile;
       
   129 sub PMStartBldList($) {
       
   130 	($Makecmd) = @_;
       
   131 	my $ABI=&main::ABI;
       
   132 	my $UnderlyingABI=PMUnderlyingABI($ABI);
       
   133 	my $BaseTrg=&main::BaseTrg;
       
   134 	my $BasicTrgType=&main::BasicTrgType;
       
   135 	my @BldList=&main::BldList;
       
   136 	my @ChopRTWSysIncPaths=&main::Path_Chop(&main::SysIncPaths);
       
   137 	my @ChopRTWUserIncPaths=&main::Path_Chop(&main::UserIncPaths);
       
   138 	my $DefFile=&main::DefFile;
       
   139 	my $EPOCPath=&main::EPOCPath;
       
   140 	my $LinkAs=&main::LinkAs;
       
   141 	my $LibPath=&main::LibPath;
       
   142 	my @MacroList=&main::MacroList();
       
   143 	my $VariantFile=&main::VariantFile();
       
   144 	my $Plat=&main::Plat;
       
   145 	my $Trg=&main::Trg;
       
   146 	my $TrgType=&main::TrgType;
       
   147 	my @UidList=&main::UidList;	
       
   148 	my $WarningLevel=&main::CompilerOption("GCC");
       
   149 	my $ExportLibrary=&main::ExportLibrary;
       
   150 	my $NoExportLibrary=&main::NoExportLibrary;
       
   151 	my $SystemTrg = SystemTarget();
       
   152 	my %Version = &main::Version();
       
   153 	my $ExtraExportLibrary;
       
   154 	my $PrimaryExportLibrary = $ExportLibrary;
       
   155 	unless ($Version{explicit}) {
       
   156 		$ExtraExportLibrary = $ExportLibrary;
       
   157 		$ExtraExportLibrary =~ s/\{(\d|a|b|c|d|e|f){8}\}//i;
       
   158 		$PrimaryExportLibrary = $ExtraExportLibrary;
       
   159 	}
       
   160 
       
   161 #	set up LinkAs
       
   162 	$UidList[2]=~/^0x(.*)$/o;
       
   163 	if ($1 ne '00000000') { # have to make sure than series of noughts in brackets doesn't appear in name for null uids
       
   164 		$LinkAs=join '', &main::Path_Split('Base',$LinkAs),"[$1]",&main::Path_Split('Ext',$LinkAs);
       
   165 	}
       
   166 
       
   167 #	set up dlltool flag hash
       
   168 	my %ABIDlltool=(
       
   169 		X86gcc=>' -m i386' 
       
   170 	);
       
   171 
       
   172 #	work out the flags for various platforms
       
   173 	if ($ABI eq 'X86gcc') {
       
   174 		$PlatOpt{Gcc}='-c  -masm=intel -B\\epoc32\\gcc_mingw\\_p';
       
   175 		$PlatOpt{Dlltool}=$ABIDlltool{X86gcc};
       
   176 	}
       
   177 
       
   178 
       
   179 	else {
       
   180 		&main::FatalError("Platform module - ABI \"$ABI\" unrecognised");
       
   181 	}
       
   182 	
       
   183 
       
   184 #	set up CompatibleABI lib path hash
       
   185 	my %ABIRTWLibPath=();
       
   186 	
       
   187 
       
   188 
       
   189 	$Dlltool=$ToolPrefix.'dlltool';
       
   190 	$Archive=$ToolPrefix.'ar';
       
   191 	$Link=$ToolPrefix.'ld';
       
   192 	$Objcopy=$ToolPrefix.'objcopy';
       
   193 
       
   194 	&Generic_Header(0,$Makecmd);	# define standard things using absolute paths
       
   195 
       
   196 	&main::Output(
       
   197 		"\n",
       
   198 		"# must set both PATH to make it work correctly\n",
       
   199 		"Path:=",&main::Path_Drive,$EPOCPath,"gcc_mingw\\bin;\$(Path)\n",
       
   200 		"PATH:=\$(Path)\n",
       
   201 		"\n"
       
   202 	);
       
   203 
       
   204 
       
   205 	&main::Output(
       
   206 		"INCDIR  ="
       
   207 	);
       
   208 
       
   209 	foreach (@ChopRTWUserIncPaths) {
       
   210 		&main::Output(
       
   211 			" -I \"$_\""
       
   212 		);
       
   213 	}
       
   214 	foreach (@ChopRTWSysIncPaths) {
       
   215 		&main::Output(
       
   216 			" -isystem \"$_\""
       
   217 		);
       
   218 	}
       
   219 
       
   220 	&main::Output(
       
   221 		"\\\n -include \"", $EPOCPath, "include\\gcc.h\"",
       
   222 		"\n",
       
   223 		"\n"
       
   224 	);
       
   225 
       
   226 	&main::Output(
       
   227 		"GCCFLAGS=$PlatOpt{Gcc} \\\n",
       
   228 		"\n"
       
   229 	);
       
   230 
       
   231 	&main::Output(
       
   232 		"GCCDEFS ="
       
   233 	);
       
   234 	foreach(@MacroList) {
       
   235 		&main::Output(
       
   236 			" -D$_"
       
   237 		);
       
   238 	}
       
   239 	&main::Output(
       
   240 		" -D PRODUCT_INCLUDE=\"\\\"$VariantFile\\\"\"",
       
   241 		" \$(USERDEFS)\n",
       
   242 		"\n"
       
   243 	);
       
   244 
       
   245 	foreach (@BldList) {
       
   246 		&main::Output(
       
   247 			"GCC$_ = ${GccPrefix}g++"
       
   248 		);
       
   249 		if (/REL$/o) {
       
   250 			&main::Output(
       
   251 				      ' ',
       
   252 				      $PlatOpt{Optimize}
       
   253 			);
       
   254 		}
       
   255 		elsif (/DEB$/o) {
       
   256 			&main::Output(
       
   257 				' -g'
       
   258 			);
       
   259 			#unless (&main::SrcDbg) {
       
   260 			#   &main::Output(
       
   261 			#   	' ', $PlatOpt{Optimize}
       
   262 			#  );
       
   263 			#}
       
   264 		}
       
   265 		&main::Output(
       
   266 			' $(GCCFLAGS)'
       
   267 		);
       
   268 		foreach (&main::MacroList($_)) {
       
   269 			&main::Output(
       
   270 				" -D$_"
       
   271 			);
       
   272 		}
       
   273 		&main::Output(
       
   274 			" \$(GCCDEFS)\n"
       
   275 		);
       
   276 	}
       
   277 	&main::Output(
       
   278 		"\n",
       
   279 		"\n"
       
   280 	);
       
   281 	
       
   282 	foreach (@BldList) {
       
   283 		&main::Output(
       
   284 			"$_ :"
       
   285 		);
       
   286 
       
   287 		if ($BasicTrgType !~ /IMPLIB/io) {
       
   288 			&main::Output (
       
   289 				#" \\\n\t \"",
       
   290 				" \\\n\t ",
       
   291 				&Generic_Quote("\$(EPOCTRG$_)\\$Trg")
       
   292 				#"\""
       
   293 			);
       
   294 		}
       
   295 
       
   296 #		lib has to come after the main target so that a .DEF file will be generated if the project is not frozen
       
   297 		if ($DefFile and not &main::ExportUnfrozen) {
       
   298 			&main::Output(
       
   299 				" \\\n",
       
   300 				"\tLIBRARY\n"
       
   301 			);
       
   302 		}
       
   303 		&main::Output(
       
   304 			"\n",
       
   305 			"\n"
       
   306 		);
       
   307 	}
       
   308 
       
   309 	# Resource building is done entirely via cl_generic.pm
       
   310 	
       
   311 	foreach (@BldList) {
       
   312 		&main::Output(
       
   313 			"\n",
       
   314 			"RESOURCE$_ : MAKEWORK$_"
       
   315 		);
       
   316 	}
       
   317 	&main::Output(
       
   318 		"\n",
       
   319 		"\n",
       
   320 	);
       
   321 
       
   322 	if (!-e $DefFile && scalar(&main::Exports)!=0)
       
   323 	{
       
   324 		# There are mandatory exports - generate a def file using the mandatory exports.
       
   325 		$genDefFile = "\$(EPOCBLD)\\$ExportLibrary.gen.def";
       
   326 	}
       
   327 	
       
   328 	if (-e $DefFile || defined($genDefFile)) { # effectively "if project frozen ..."
       
   329 		
       
   330 		#	Establish the entry point symbol
       
   331 		my $EntrySymbol;
       
   332 		if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEDLL$/o ) {
       
   333 			$EntrySymbol = '_E32Dll';
       
   334 		}
       
   335 		elsif ($BasicTrgType=~/^EXE$/o || $TrgType=~/^EXEXP$/o ) {
       
   336 			$EntrySymbol = '_E32Startup';
       
   337 		}
       
   338 				
       
   339 		&main::Output("\n", &Generic_Quote("\$(EPOCBLD)\\$ExportLibrary.prep.def"), " : ");
       
   340 		my $defFileToUse;
       
   341 		if (defined($genDefFile))
       
   342 		{
       
   343 			# The generated def file is not a dependency of the prep.def - don't add anyting after the ':' char
       
   344 			&main::Output("\n\tperl -S gendef.pl $genDefFile ", join(' ', &main::Exports), "\n");
       
   345 			$defFileToUse = $genDefFile;
       
   346 		}
       
   347 		else
       
   348 		{
       
   349 			&main::Output(&Generic_Quote($DefFile), "\n");
       
   350 			$defFileToUse = "\$<";
       
   351 		}
       
   352 		&main::Output("\tperl -S prepdef.pl $defFileToUse \$@ nodatasizes $EntrySymbol\n\n");
       
   353 		
       
   354 		&main::Output(
       
   355 			&Generic_Quote("\$(EPOCBLD)\\$ExportLibrary.lib.exp"), " : ", &Generic_Quote("\$(EPOCBLD)\\$ExportLibrary.prep.def"), "\n",
       
   356 			"\t$Dlltool $PlatOpt{Dlltool} --input-def \"\$<\"  --dllname \"$LinkAs\"  -e \"\$@\"  \n",			
       
   357 			"\t-\$(ERASE) \"\$(EPOCBLD)\\tmp.txt \"\n\n"
       
   358 		);
       
   359 	}
       
   360 	
       
   361 	&main::Output(
       
   362 		"LIBRARY : MAKEWORKLIBRARY"
       
   363 	);
       
   364 	if ($BasicTrgType=~/^LIB$/o) {
       
   365 #		code to ensure that the static libraries for all builds are built at the library stage
       
   366 		foreach (@BldList) {
       
   367 			&main::Output(
       
   368 				" $_"
       
   369 			);
       
   370 		}
       
   371 	}
       
   372 	elsif ($DefFile and !$NoExportLibrary) {
       
   373 		unless (&main::ExportUnfrozen) {
       
   374 			if (-e $DefFile) { # effectively "if project frozen ..."
       
   375 				&main::Output(
       
   376 					" ", &Generic_Quote("\$(EPOCLIB)\\LIB\\$PrimaryExportLibrary.lib")
       
   377 				);
       
   378 				&main::Output(
       
   379 					"\n"
       
   380 				);
       
   381 			} else {
       
   382 				&main::Output(
       
   383 					"\n",
       
   384 					"\t\@echo WARNING: Not attempting to create any import libraries.\n",
       
   385 					"\t\@echo When exports are frozen in \"$DefFile\", regenerate Makefile.\n"
       
   386 				);
       
   387 			}
       
   388 		}
       
   389 		else {
       
   390 			&main::Output(
       
   391 				"\n",
       
   392 				"\t\@echo Not attempting to create \"\$(EPOCLIB)\\LIB\\$PrimaryExportLibrary.lib\"\n",
       
   393 				"\t\@echo from frozen .DEF file, since EXPORTUNFROZEN specified.\n"
       
   394 			);
       
   395 		}
       
   396 
       
   397 
       
   398 
       
   399 		&main::Output(
       
   400 			"\n",
       
   401 			"\n",
       
   402 			"# REAL TARGET - LIBRARY\n",
       
   403 		);
       
   404 		
       
   405 		&main::Output(
       
   406 			"\n",
       
   407 			&Generic_Quote("\$(EPOCLIB)\\LIB\\$ExportLibrary.lib"), " : ",
       
   408 			&Generic_Quote("\$(EPOCBLD)\\$ExportLibrary.prep.def"), "\n",
       
   409 			"\t$Dlltool $PlatOpt{Dlltool} --input-def \"\$<\"  --dllname \"$LinkAs\"  --output-lib \"\$@\" \n",
       
   410 			"\t-\$(ERASE) \"\$(EPOCBLD)\\tmp.txt \"\n"
       
   411 		);
       
   412 		if ($ExtraExportLibrary) {
       
   413 			&main::Output(
       
   414 				"\n",
       
   415 				&Generic_Quote("\$(EPOCLIB)\\LIB\\$ExtraExportLibrary.lib"), " : ",
       
   416 				&Generic_Quote("\$(EPOCLIB)\\LIB\\$ExportLibrary.lib"), "\n",
       
   417 				"\tcopy \$< \$@\n"
       
   418 			);
       
   419 		}
       
   420 	}
       
   421 
       
   422 
       
   423 	&main::Output(
       
   424 		"\n",
       
   425 		"CLEANLIBRARY :\n"
       
   426 	);
       
   427 	if ($DefFile and !$NoExportLibrary) {
       
   428 		&main::Output(
       
   429 			"\t-\$(ERASE) \"\$(EPOCLIB)\\LIB\\$ExportLibrary.lib \"\n"
       
   430 		);
       
   431 		if ($ExtraExportLibrary) {
       
   432 			&main::Output(
       
   433 				"\t-\$(ERASE) \"\$(EPOCLIB)\\LIB\\$ExtraExportLibrary.lib \"\n"
       
   434 			);
       
   435 		}
       
   436 
       
   437 	}
       
   438 
       
   439 	&main::Output(
       
   440 		"\n",
       
   441 		"\n"
       
   442 	);
       
   443 	&Generic_MakeWorkDir('MAKEWORKLIBRARY',"${LibPath}LIB");
       
   444 
       
   445 	&Generic_Releaseables;
       
   446 }
       
   447 
       
   448 
       
   449 sub PMBld {
       
   450 
       
   451 	my @ASSPLibList=&main::ASSPLibList;
       
   452 	my @SrcList=&main::SrcList;
       
   453 	my $BaseTrg=&main::BaseTrg;
       
   454 	my $Bld=&main::Bld;
       
   455 	my $ChopBldPath=&main::Path_Chop(&main::BldPath);
       
   456 	my $DefFile=&main::DefFile;
       
   457 	my $EPOCIncPath=&main::EPOCIncPath;
       
   458 	my $FirstLib=&main::FirstLib;
       
   459 	my $BasicTrgType=&main::BasicTrgType;
       
   460 	my @LibList;
       
   461 	my $LibPath=&main::LibPath;
       
   462 	my $LinkAs=&main::LinkAs;
       
   463 	my $ChopRelPath=&main::Path_Chop(&main::RelPath);
       
   464 	my $RelPath=&main::RelPath;
       
   465 	my @StatLibList=&main::StatLibList;
       
   466 	my $StatLinkPath=&main::StatLinkPath;
       
   467 	my $Trg=&main::Trg;
       
   468 	my $TrgType=&main::TrgType;
       
   469 	my @UidList=&main::UidList;
       
   470 	my $ExportLibrary=&main::ExportLibrary;
       
   471 	my $NoExportLibrary=&main::NoExportLibrary;
       
   472 	my $SystemTrg = SystemTarget();
       
   473 	my %Version = &main::Version();
       
   474 	my $ExtraExportLibrary;
       
   475 	unless ($Version{explicit}) {
       
   476 		$ExtraExportLibrary = $ExportLibrary;
       
   477 		$ExtraExportLibrary =~ s/\{(\d|a|b|c|d|e|f){8}\}//i;
       
   478 	}
       
   479 
       
   480 	if ($Bld =~ /DEB/) {
       
   481 		@LibList = &main::DebugLibList;
       
   482 	} else {
       
   483 		@LibList = &main::LibList;
       
   484 	}
       
   485 
       
   486 #	set up $LinkAs
       
   487 	$UidList[2]=~/^0x(.*)$/o;
       
   488 	if ($1 ne '00000000') {	# have to make sure than series of noughts in brackets doesn't appear in name for null uids
       
   489 		$LinkAs=join '', &main::Path_Split('Base',$LinkAs),"[$1]",&main::Path_Split('Ext',$LinkAs);
       
   490 	}
       
   491 	
       
   492 
       
   493 
       
   494 
       
   495 
       
   496 	# REAL TARGETS
       
   497 	#-------------
       
   498 	&main::Output(
       
   499 		"# REAL TARGET - BUILD VARIANT $Bld\n",
       
   500 		"\n"
       
   501 	);
       
   502 
       
   503 
       
   504 #	releasables
       
   505 	my @releaseables;
       
   506 	
       
   507 
       
   508 	push @releaseables, "$RelPath$Trg" if ($BasicTrgType!~/^IMPLIB$/io);
       
   509 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   510 		push @releaseables, "$RelPath$Trg.MAP";
       
   511 	}
       
   512 	if (-e $DefFile and !$NoExportLibrary) { # effectively "if project frozen ..."
       
   513 		push @releaseables, "$LibPath$ExportLibrary.lib";
       
   514 		push @releaseables, "$LibPath$ExtraExportLibrary.lib" if ($ExtraExportLibrary);
       
   515 	}
       
   516 	
       
   517 	&main::Output(
       
   518 		"WHAT$Bld : WHATGENERIC\n",
       
   519 		"\n",
       
   520 		"CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld CLEANLIBRARY\n ",
       
   521 		"\n",
       
   522 		"CLEANBUILD$Bld : \n",
       
   523 		"\t\@perl -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n",
       
   524 		"\n",
       
   525 		"CLEANRELEASE$Bld : CLEANGENERIC\n",
       
   526 		"\n"
       
   527 	);
       
   528 	&Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releaseables);
       
   529 
       
   530 	&Generic_MakeWorkDir("MAKEWORK$Bld",$ChopBldPath);
       
   531 	&Generic_MakeWorkDir("MAKEWORK$Bld",$ChopRelPath);
       
   532 
       
   533 	return if ($BasicTrgType=~/^IMPLIB$/io);
       
   534 
       
   535 	&main::Output(
       
   536 		"LISTING$Bld : MAKEWORK$Bld"
       
   537 	);
       
   538 	foreach (@SrcList) {
       
   539 		my $BaseSrc = &main::Path_Split('Base', $_);
       
   540 		my $Ext = &main::Path_Split('Ext', $_);
       
   541 		$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   542    		&main::Output(
       
   543 			" \\\n\tLISTING$Bld$BaseSrc"
       
   544    		);
       
   545    	}
       
   546 	&main::Output(
       
   547 		"\n",
       
   548 		"\n"
       
   549 	);
       
   550 
       
   551 	&main::Output(
       
   552 		"LIBS$Bld="
       
   553 	);
       
   554 
       
   555 	
       
   556 	if ($BasicTrgType=~/^DLL$/o) { # Add the DLL stub library
       
   557 		&main::Output(
       
   558 			" \\\n\t",
       
   559 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\EDLLSTUB.LIB")
       
   560 		);
       
   561 	}
       
   562 
       
   563 	
       
   564 	if ($HelperLib) {
       
   565 		&main::Output(
       
   566 			" \\\n\t",
       
   567 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\$HelperLib")
       
   568 		);
       
   569 	}
       
   570 	foreach (@StatLibList) {
       
   571 		&main::Output(
       
   572 			" \\\n\t",
       
   573 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_")
       
   574 		);
       
   575 	}
       
   576 
       
   577 
       
   578 	foreach (@ASSPLibList) {
       
   579 		&main::Output(
       
   580 			" \\\n\t",
       
   581 			&Generic_Quote("\$(EPOCASSPLINK$Bld)\\$_")
       
   582 		);
       
   583 	}
       
   584 	foreach (@LibList) {
       
   585 		&main::Output(
       
   586 			" \\\n\t",
       
   587 			&Generic_Quote("\$(EPOCLINK)\\LIB\\$_")
       
   588 		);
       
   589 	}
       
   590 	&main::Output(
       
   591 		"\n",
       
   592 		"\n"
       
   593 	);
       
   594 
       
   595 
       
   596 	&main::Output(
       
   597 		"LINKLIBS$Bld="
       
   598 	);
       
   599 	
       
   600 	
       
   601 	if ($BasicTrgType=~/^DLL$/o) { # Add the DLL stub library
       
   602 		&main::Output(
       
   603 			" \\\n\t \"",
       
   604 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\EDLLSTUB.LIB"),
       
   605 			" \""
       
   606 		);
       
   607 	}
       
   608 
       
   609 	
       
   610 	if ($HelperLib) {
       
   611 		&main::Output(
       
   612 			" \\\n\t \"",
       
   613 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\$HelperLib"),
       
   614 			" \""
       
   615 		);
       
   616 	}
       
   617 	foreach (@StatLibList) {
       
   618 		&main::Output(
       
   619 			" \\\n\t \"",
       
   620 			&Generic_Quote("\$(EPOCSTATLINK$Bld)\\$_"),
       
   621 			" \""
       
   622 		);
       
   623 	}
       
   624 
       
   625 
       
   626 	foreach (@ASSPLibList) {
       
   627 		&main::Output(
       
   628 			" \\\n\t \"",
       
   629 			&Generic_Quote("\$(EPOCASSPLINK$Bld)\\$_"),
       
   630 			" \""
       
   631 		);
       
   632 	}
       
   633 	foreach (@LibList) {
       
   634 		&main::Output(
       
   635 			" \\\n\t \"",
       
   636 			&Generic_Quote("\$(EPOCLINK)\\LIB\\$_"),
       
   637 			" \""
       
   638 		);
       
   639 	}
       
   640 	&main::Output(
       
   641 		"\n",
       
   642 		"\n"
       
   643 	);
       
   644 
       
   645 #	Establish the entry point symbol
       
   646 	my $EntrySymbol;
       
   647 	if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEDLL$/o ) {
       
   648 		$EntrySymbol = '_E32Dll';
       
   649 	}
       
   650 	elsif ($BasicTrgType=~/^EXE$/o || $TrgType=~/^EXEXP$/o ) {
       
   651 		$EntrySymbol = '_E32Startup';
       
   652 	}
       
   653 	
       
   654 	&main::Output(
       
   655 		&Generic_Quote("\$(EPOCTRG$Bld)\\$Trg"), " : ",
       
   656 		&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg.in")
       
   657 	);
       
   658 	
       
   659 	if (-e $DefFile || defined($genDefFile)) { # effectively "if project frozen ..."
       
   660 		&main::Output(
       
   661 			" ", &Generic_Quote("\$(EPOCBLD)\\$ExportLibrary.lib.exp")
       
   662 		);
       
   663 	}
       
   664 	if ($BasicTrgType=~/^(EXE|DLL)$/o) {
       
   665 		&main::Output(
       
   666 			" ", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$FirstLib")
       
   667 		);
       
   668 	}
       
   669 	
       
   670 	if ($TrgType=~/^EXEXP$/o) {
       
   671 		&main::Output(
       
   672 			" ", &Generic_Quote("\$(EPOCSTATLINK$Bld)\\$FirstLib")
       
   673 		);
       
   674 	}
       
   675 	&main::Output(
       
   676 		" \$(LIBS$Bld)\n"
       
   677 	);
       
   678 
       
   679 
       
   680 
       
   681 
       
   682 	if ($BasicTrgType=~/^(DLL|EXE)/o) {
       
   683 
       
   684 
       
   685 #		call ld to link the target
       
   686 		&main::Output(
       
   687 			"\t$Link $PlatOpt{Ld}  -nostdlib   "
       
   688 		);
       
   689 
       
   690 
       
   691 
       
   692 	if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o || $TrgType=~/^EXEDLL$/o) {
       
   693 			if (-e $DefFile || defined($genDefFile)) {
       
   694 				&main::Output(
       
   695 				"\"\$(EPOCBLD)\\$ExportLibrary.lib.exp \" \\\n"
       
   696 				
       
   697 				);		
       
   698 			}		
       
   699 			if ($BasicTrgType=~/^DLL$/o) {
       
   700 				&main::Output(
       
   701 					"--dll $PlatOpt{Entry} _$EntrySymbol  \\\n"
       
   702 				);
       
   703 			}
       
   704 			else{
       
   705 				&main::Output(
       
   706 					" $PlatOpt{Entry} _$EntrySymbol  \\\n"
       
   707 				);
       
   708 						
       
   709 			}
       
   710 		}
       
   711 		elsif ($BasicTrgType=~/^EXE$/o) {
       
   712 			&main::Output(
       
   713 				" $PlatOpt{Entry} _$EntrySymbol  \\\n"
       
   714 			);
       
   715 		}
       
   716 		
       
   717 #		--whole-archive is required here apparently because of a defect in the gcc toolchain
       
   718 #		the flag can probably be removed with a later version of gcc
       
   719 		&main::Output(
       
   720 			"\t\t-Map \"\$(EPOCTRG$Bld)\\$Trg.map \" -o \"\$(EPOCBLD$Bld)\\$Trg \" \\\n",
       
   721 			"\t\t\"\$(EPOCSTATLINK$Bld)\\$FirstLib \" --whole-archive \"\$(EPOCBLD$Bld)\\$BaseTrg.in \" \\\n",
       
   722 			"\t\t--no-whole-archive"
       
   723 		);
       
   724 		
       
   725 
       
   726 		&main::Output(
       
   727 			" \$(LINKLIBS$Bld) \$(USERLDFLAGS)\n"
       
   728 		);
       
   729 		
       
   730 
       
   731 		if (&main::CompressTarget) {
       
   732 			&main::Output(
       
   733 			"\tpetran $PlatOpt{Petran} -version ", &Genutl_VersionToUserString(%Version), " -sid ", &main::SecureId(), " -nocompress " ,  " \"\$(EPOCBLD$Bld)\\$Trg\" \"\$\@\" \\\n",
       
   734 			"\t\t"
       
   735 			);
       
   736 		}
       
   737 		else {
       
   738 			if(&main::CompressTargetMode==NOCOMPRESSIONMETHOD){
       
   739 				&main::Output(
       
   740 					"\tpetran $PlatOpt{Petran} -version ", &Genutl_VersionToUserString(%Version), " -sid ", &main::SecureId(), " \"\$(EPOCBLD$Bld)\\$Trg\" \"\$\@\" \\\n",
       
   741 					"\t\t"
       
   742 				);
       
   743 			}
       
   744 			elsif(&main::CompressTargetMode==INFLATECOMPRESSIONMETHOD){
       
   745 				&main::Output(
       
   746 					"\tpetran $PlatOpt{Petran} -version ", &Genutl_VersionToUserString(%Version), " -sid ", &main::SecureId(), " ", "  -compressionmethod deflate", " \"\$(EPOCBLD$Bld)\\$Trg\" \"\$\@\" \\\n",
       
   747 					"\t\t"
       
   748 				);
       
   749 			}
       
   750 			elsif(&main::CompressTargetMode==BYTEPAIRCOMPRESSIONMETHOD){
       
   751 				&main::Output(
       
   752 					"\tpetran $PlatOpt{Petran} -version ", &Genutl_VersionToUserString(%Version), " -sid ", &main::SecureId(), " ", "  -compressionmethod bytepair", " \"\$(EPOCBLD$Bld)\\$Trg\" \"\$\@\" \\\n",
       
   753 					"\t\t"
       
   754 				);
       
   755 			}
       
   756 		}
       
   757 
       
   758 # ALWAYS ALLOW WRITEABLE DATA... PART OF THE VTABLE IMPORT WORKAROUND
       
   759 #		if (&main::AllowDllData) {
       
   760 			&main::Output(
       
   761 				' -allow'
       
   762 			);
       
   763 #		}
       
   764 		if (not &main::CallDllEntryPoints) {
       
   765 			&main::Output(
       
   766 				' -nocall'
       
   767 			);
       
   768 		}
       
   769 		if (&main::DataLinkAddress) {
       
   770 			&main::Output(
       
   771 				' -datalinkaddress ',&main::DataLinkAddress
       
   772 			);
       
   773 		}
       
   774 		if (&main::FixedProcess) {
       
   775 			&main::Output(
       
   776 				' -fixed'
       
   777 			);
       
   778 		}
       
   779 		if (&main::HeapSize) {
       
   780 			my %HeapSize=&main::HeapSize;
       
   781 			&main::Output(
       
   782 				' -heap ',$HeapSize{Min},' ',$HeapSize{Max}
       
   783 			);
       
   784 		}
       
   785 		if (&main::ProcessPriority) {
       
   786 			&main::Output(
       
   787 				' -priority ',&main::ProcessPriority
       
   788 			);
       
   789 		}
       
   790 		if (&main::SmpSafe) {
       
   791 			&main::Output(
       
   792 				' -smpsafe'
       
   793 			);
       
   794 		}
       
   795 		if (&main::StackSize) {
       
   796 			&main::Output(
       
   797 				' -stack ',&main::StackSize
       
   798 			);
       
   799 		}
       
   800 
       
   801 		if (&main::CodePagingTargetMode == UNPAGED) {
       
   802 			&main::Output(
       
   803 				' -codepaging unpaged'
       
   804 			);
       
   805 		}
       
   806 		elsif (&main::CodePagingTargetMode == PAGED) {
       
   807 			&main::Output(
       
   808 				' -codepaging paged'
       
   809 			);
       
   810 		}
       
   811 
       
   812 		if (&main::DataPagingTargetMode == UNPAGED) {
       
   813 			&main::Output(
       
   814 				' -datapaging unpaged'
       
   815 			);
       
   816 		}
       
   817 		elsif (&main::DataPagingTargetMode == PAGED) {
       
   818 			&main::Output(
       
   819 				' -datapaging paged'
       
   820 			);
       
   821 		}
       
   822 
       
   823 		my $i=1;
       
   824 		foreach (@UidList) {
       
   825 			&main::Output(
       
   826 				" -uid$i $_"
       
   827 			);
       
   828 			$i++;
       
   829 		}
       
   830 		if(&main::VendorId) {
       
   831 			&main::Output(
       
   832 				' -vid ',&main::VendorId
       
   833 			);
       
   834 		}
       
   835 		&main::Output(
       
   836 			' -capability ',&main::Capability,
       
   837 		);
       
   838 	}
       
   839 	elsif ($BasicTrgType=~/^LIB$/o) {
       
   840 		&main::Output(
       
   841 			"\tcopy \"\$(EPOCBLD$Bld)\\$BaseTrg.in\" \"\$(EPOCSTATLINK$Bld)\\$Trg\"\n"
       
   842 		);
       
   843 	}
       
   844 
       
   845 	&main::Output(
       
   846 		"\n"
       
   847 	);
       
   848 
       
   849 
       
   850 	# TARGET *.IN
       
   851 	#------------
       
   852 	if (scalar @SrcList >100) {
       
   853 		# deal with very long lists by splitting them into 150 file pieces, which allows
       
   854 		# about 200 bytes per filename if the underlying max size is 32K
       
   855 		#
       
   856 		my $counter1=100;	# i.e. trigger new variable immediately
       
   857 		my $counter2=0;
       
   858 		my @objvarlist=();
       
   859 		foreach (@SrcList) {
       
   860 			if ($counter1==100) {
       
   861 				$counter1=0;
       
   862 				$counter2++;
       
   863 				my $objvar = "OBJECTS$Bld$counter2";
       
   864 				push @objvarlist, " \$($objvar)";
       
   865 				&main::Output(
       
   866 					"\n",
       
   867 					"$objvar="
       
   868 				);
       
   869 			}
       
   870 			my $BaseSrc = &main::Path_Split('Base', $_);
       
   871 			my $Ext = &main::Path_Split('Ext', $_);
       
   872 			$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   873 			&main::Output(
       
   874 				" \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o")
       
   875 			);
       
   876 			$counter1++;
       
   877 		}
       
   878 		&main::Output(
       
   879 			"\n",
       
   880 			"\n",
       
   881 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg.in"), " : ", @objvarlist,"\n",
       
   882 			"\tif exist \"\$\@\" del \"\$\@\"\n"
       
   883 		);
       
   884 		foreach (@objvarlist) {
       
   885 			# Add the files to the list in groups
       
   886 			&main::Output(
       
   887 				"\t$Archive cr \"\$\@ \" $_  \n"
       
   888 			);
       
   889 		}
       
   890 		&main::Output(
       
   891 			"\n\n"
       
   892 		);
       
   893 	} else {
       
   894 		# shorter lists remain unchanged
       
   895 		# 
       
   896 		&main::Output(
       
   897 			"OBJECTS$Bld="
       
   898 		);
       
   899 		foreach (@SrcList) {
       
   900 			my $BaseSrc = &main::Path_Split('Base', $_);
       
   901 			my $Ext = &main::Path_Split('Ext', $_);
       
   902 			$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   903 			&main::Output(
       
   904 				" \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o")
       
   905 			);
       
   906 		}
       
   907 		&main::Output(
       
   908 			"\n",
       
   909 			"\n"
       
   910 		);
       
   911 		
       
   912 		##Version of object list with quotes
       
   913 		&main::Output(
       
   914 			"ARCHIVEOBJECTS$Bld="
       
   915 		);
       
   916 		foreach (@SrcList) {
       
   917 			my $BaseSrc = &main::Path_Split('Base', $_);
       
   918 			my $Ext = &main::Path_Split('Ext', $_);
       
   919 			$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   920 			&main::Output(
       
   921 				" \\\n\t \"", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"),
       
   922 				" \""
       
   923 			);
       
   924 		}
       
   925 		&main::Output(
       
   926 			"\n",
       
   927 			"\n"
       
   928 		);
       
   929 						
       
   930 		&main::Output(
       
   931 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg.in"), " : \$(OBJECTS$Bld)\n",
       
   932 			"\tif exist \"\$\@\" del \"\$\@\"\n",
       
   933 			"\t$Archive cr \"\$\@ \" \$(ARCHIVEOBJECTS$Bld)  \n",
       
   934 			"\n\n"
       
   935 		);
       
   936 	}
       
   937 }
       
   938 
       
   939 
       
   940 sub PMStartSrcList {
       
   941 
       
   942 	&main::Output(
       
   943 		"# SOURCES\n",
       
   944 		"\n"
       
   945 	);
       
   946 }
       
   947 
       
   948 sub PMBitMapBld {
       
   949 
       
   950 	&Generic_BitMapBld;
       
   951 	
       
   952 }
       
   953 
       
   954 sub PMResrcBld {
       
   955 
       
   956 	&Generic_ResrcBld;
       
   957 
       
   958 }
       
   959 
       
   960 sub PMAifBld {
       
   961 
       
   962 	&Generic_AifBld;
       
   963 
       
   964 }
       
   965 
       
   966 sub PMStartSrc {
       
   967 	my $Src=&main::Src;
       
   968 
       
   969 	&main::Output(
       
   970 		"# Source $Src\n",
       
   971 		"\n"
       
   972 	);
       
   973 }
       
   974 
       
   975 sub PMSrcDepend {
       
   976 	my @BldList=&main::BldList;	
       
   977 	my @DepList=&main::DepList;
       
   978 	my $BaseSrc=&main::BaseSrc;
       
   979 	my $ExtSrc=&main::ExtSrc;
       
   980 	my $cia = (lc($ExtSrc) eq '.cia') ? "_" : "";
       
   981 
       
   982 	return if (@DepList == 0);
       
   983 
       
   984 	foreach (@BldList) {
       
   985 		&main::Output(
       
   986 			&Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.lis"), " ",
       
   987 			&Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.o"), " \\\n",
       
   988 		);
       
   989 	}
       
   990 	&main::Output(
       
   991 		":"
       
   992 	);
       
   993 	foreach (@DepList) {
       
   994 		&main::Output(
       
   995 		" \\\n\t", &Generic_Quote($_)
       
   996 		);
       
   997 	}
       
   998 	&main::Output(
       
   999 		"\n",
       
  1000 		"\n"
       
  1001 	);
       
  1002 }
       
  1003 
       
  1004 sub PMSrcBldDepend {
       
  1005 	my $Bld=&main::Bld;
       
  1006 	my @DepList=&main::DepList;
       
  1007 	my $BaseSrc=&main::BaseSrc;
       
  1008 	my $ExtSrc=&main::ExtSrc;
       
  1009 	my $cia = (lc($ExtSrc) eq '.cia') ? "_" : "";
       
  1010 
       
  1011 	return if (@DepList == 0);
       
  1012 
       
  1013 	&main::Output(
       
  1014 		&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.lis"), " ",
       
  1015 		&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.o"), " :",
       
  1016 	);
       
  1017 	foreach (@DepList) {
       
  1018 		&main::Output(
       
  1019 			" \\\n\t", &Generic_Quote($_)
       
  1020 		);
       
  1021 	}
       
  1022 	&main::Output(
       
  1023 		"\n",
       
  1024 		"\n"
       
  1025 	);
       
  1026 }
       
  1027 
       
  1028 sub SelectLangOptions {
       
  1029 	my ($Ext) = @_;
       
  1030 	if ($Ext=~/^.c$/) {
       
  1031 		return '-x c';
       
  1032 	}
       
  1033 	return '-fno-rtti -fno-exceptions -fcheck-new';
       
  1034 }
       
  1035 
       
  1036 sub PMEndSrcBld {
       
  1037 	my $ABI=&main::ABI;
       
  1038 	my $BaseSrc=&main::BaseSrc;
       
  1039 	my $Bld=&main::Bld;
       
  1040 	my $Src=ucfirst lc &main::Src;
       
  1041 	my $SrcPath=&main::SrcPath;
       
  1042 	my $Ext = &main::Path_Split('Ext', $Src);
       
  1043 	my $Cia = (lc($Ext) eq '.cia') ? 1 : 0;
       
  1044 	my $LangOptions = &SelectLangOptions($Ext);
       
  1045 
       
  1046 	my $RTWSrcPath=&main::Path_Chop(&main::Path_RltToWork($SrcPath));
       
  1047 
       
  1048 	# Use GCC trick to get assembler source files preprocessed with CPP
       
  1049 	$Src =~ s/\.s$/.S/i;
       
  1050 
       
  1051 	if ($Cia) {
       
  1052 		&main::Output(
       
  1053 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.o"), " : ",
       
  1054 			&Generic_Quote("$SrcPath$Src"), "\n",
       
  1055 			"\techo $Src\n",
       
  1056 			"\t\$(GCC$Bld) -fomit-frame-pointer -O1 -x c++  -D__CIA__ -I \"$RTWSrcPath\" \$(INCDIR)  -o \$\@ \"$RTWSrcPath\\$Src\"\n",
       
  1057 			"\n",
       
  1058 	#		generate an assembly listing target too
       
  1059 			"LISTING$Bld$BaseSrc\_ : ", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.lis"), "\n",
       
  1060 			"\t", &Generic_CopyAction("$SrcPath$BaseSrc\_.$ABI.lst"),
       
  1061 			"\n",
       
  1062 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.lis"), " : ",
       
  1063 			&Generic_Quote("$SrcPath$Src"), "\n",
       
  1064 			"\t\$(GCC$Bld) -fomit-frame-pointer -O1 -x c++  -D__CIA__ -Wa,-adln -I \"$RTWSrcPath\" \$(INCDIR)  -o nul: \"$RTWSrcPath\\$Src\" > \$\@\n",
       
  1065 			"\n"
       
  1066 		);
       
  1067 	} else {
       
  1068 		&main::Output(
       
  1069 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"), " : ",
       
  1070 			&Generic_Quote("$SrcPath$Src"), "\n",
       
  1071 			"\techo $Src\n",
       
  1072 			"\t\$(GCC$Bld) $LangOptions -I \"$RTWSrcPath\" \$(INCDIR) -o \$\@ \"$RTWSrcPath\\$Src\"\n",
       
  1073 			"\n",
       
  1074 	#		generate an assembly listing target too
       
  1075 			"LISTING$Bld$BaseSrc : ", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.lis"), "\n",
       
  1076 			"\t", &Generic_CopyAction("$SrcPath$BaseSrc.$ABI.lst"),
       
  1077 			"\n",
       
  1078 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.lis"), " : ",
       
  1079 			&Generic_Quote("$SrcPath$Src"), "\n",
       
  1080 			"\t\$(GCC$Bld) $LangOptions -Wa,-adln -I \"$RTWSrcPath\" \$(INCDIR)  -o nul: \"$RTWSrcPath\\$Src\" > \$\@\n",
       
  1081 			"\n"
       
  1082 		);
       
  1083 	}
       
  1084 }
       
  1085 
       
  1086 sub PMEndSrc {
       
  1087 
       
  1088 	&main::Output(
       
  1089 		"\n",
       
  1090 		"\n"
       
  1091 	);
       
  1092 }
       
  1093 
       
  1094 sub PMEndSrcList {
       
  1095 
       
  1096 	# Deal with accumulated MAKEDIRS etc.
       
  1097 
       
  1098 	&Generic_End;
       
  1099 }
       
  1100 
       
  1101 sub PMPrefixFile 
       
  1102 { 
       
  1103     return &Generic_Quote(&main::Path_Drive.&main::EPOCIncPath."gcc.h");
       
  1104 }
       
  1105 
       
  1106 1;
       
  1107