sbsv1_os/e32toolp/platform/cl_x86.pm
changeset 0 83f4b4db085c
child 10 d4b442d23379
child 37 be14ecca790f
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     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_x86;
       
    18 
       
    19 # declare variables global for module
       
    20 
       
    21 
       
    22 require Exporter;
       
    23 @ISA=qw(Exporter);
       
    24 @EXPORT=qw(
       
    25 	PMHelp_Mmp
       
    26 
       
    27 	PMCheckPlatformL
       
    28 
       
    29 	PMPlatProcessMmp
       
    30 	
       
    31 	PMStartBldList
       
    32 		PMBld
       
    33 	PMStartSrcList
       
    34 		PMBitMapBld
       
    35 		PMResrcBld
       
    36 		PMAifBld
       
    37 		PMStartSrc
       
    38 		PMSrcDepend
       
    39 			PMSrcBldDepend
       
    40 			PMEndSrcBld
       
    41 		PMEndSrc
       
    42 	PMEndSrcList
       
    43 );
       
    44 
       
    45 use strict;
       
    46 use Winutl;
       
    47 use cl_generic;
       
    48 use Genutl;
       
    49 use Pathutl;
       
    50 
       
    51 use constant NOCOMPRESSIONMETHOD => 0;
       
    52 use constant INFLATECOMPRESSIONMETHOD => 1;
       
    53 use constant BYTEPAIRCOMPRESSIONMETHOD => 2;
       
    54 
       
    55 use constant NOTPAGED => 0;
       
    56 use constant UNPAGED => 1;
       
    57 use constant PAGED => 2;
       
    58 sub PMHelp_Mmp {
       
    59 	&Winutl_Help_Mmp;
       
    60 }
       
    61 
       
    62 sub PMCheckPlatformL {
       
    63 }
       
    64 
       
    65 sub PMPlatProcessMmp (@) {
       
    66 
       
    67 }
       
    68 
       
    69 sub PMStartBldList($) {
       
    70 	my ($makecmd) = @_;
       
    71 	die "Cannot generate $makecmd makefiles\n" if ($makecmd ne "nmake");
       
    72 	my $BaseTrg=&main::BaseTrg;
       
    73 	my @BldList=&main::BldList;
       
    74 	my @ChopSysIncPaths=&main::Path_Chop(&main::SysIncPaths);
       
    75 	my @ChopUserIncPaths=&main::Path_Chop(&main::UserIncPaths);
       
    76 	my $DefFile=&main::DefFile;
       
    77 	my $BasicTrgType=&main::BasicTrgType;
       
    78 	my $LinkAs=&main::LinkAs;
       
    79 	my $ExportLibrary=&main::ExportLibrary;
       
    80 	my $NoExportLibrary=&main::NoExportLibrary;
       
    81 	my $LibPath=&main::LibPath;
       
    82 	my @MacroList=&main::MacroList();
       
    83 	my $VariantFile=&main::VariantFile();
       
    84 	my $Plat=&main::Plat;
       
    85 	my $Trg=&main::Trg;
       
    86 	my $TrgType=&main::TrgType;
       
    87 	my @UidList=&main::UidList;	
       
    88 	my $WarningLevel=&main::CompilerOption("MSVC");
       
    89 	my %Version = &main::Version();
       
    90 	my $ExtraExportLibrary;
       
    91 	my $PrimaryExportLibrary = $ExportLibrary;
       
    92 	unless ($Version{explicit}) {
       
    93 		$ExtraExportLibrary = $ExportLibrary;
       
    94 		$ExtraExportLibrary =~ s/\{(\d|a|b|c|d|e|f){8}\}//i;
       
    95 		$PrimaryExportLibrary = $ExtraExportLibrary;
       
    96 	}
       
    97 
       
    98 	&Generic_Header(0,$makecmd);	# define standard things using absolute paths
       
    99 
       
   100 #	set up LinkAs
       
   101 	$UidList[2]=~/^0x(.*)$/o;
       
   102 	if ($1 ne '00000000') { # have to make sure than series of noughts in brackets doesn't appear in name for null uids
       
   103 		$LinkAs=join '', &main::Path_Split('Base',$LinkAs),"[$1]",&main::Path_Split('Ext',$LinkAs);
       
   104 	}
       
   105 
       
   106 	my $TrgDir="";
       
   107 
       
   108 	&main::Output(
       
   109 		"INCDIR  ="
       
   110 	);
       
   111 	if($VariantFile){
       
   112         my $VariantFileFileName  = Path_Split('FILE',$VariantFile);
       
   113         &main::Output(
       
   114               " /FI \"$VariantFileFileName\"",
       
   115               );
       
   116 
       
   117 	}
       
   118 
       
   119 	foreach (@ChopUserIncPaths,@ChopSysIncPaths) {
       
   120 		&main::Output(
       
   121 			" /I \"$_\""
       
   122 		);
       
   123 	}
       
   124 	&main::Output(
       
   125 		"\n",
       
   126 		"\n"
       
   127 	);
       
   128 
       
   129 	&main::Output(
       
   130 		"CLFLAGS = /nologo /Zp4 $WarningLevel /Zm256"
       
   131 		);	
       
   132 	&main::Output(
       
   133 		" /X"
       
   134 		);
       
   135 	&main::Output(
       
   136 		"\n",
       
   137 		"\n"
       
   138 	);
       
   139 
       
   140 	&main::Output(
       
   141 		"CLDEFS  ="
       
   142 	);
       
   143 	foreach(@MacroList) {
       
   144 		&main::Output(
       
   145 			" /D \"$_\""
       
   146 		);
       
   147 	}
       
   148 	&main::Output(
       
   149 		" \$(USERDEFS)\n",
       
   150 		"\n"
       
   151 	);
       
   152 
       
   153 	foreach (@BldList) {
       
   154 		&main::Output(
       
   155 			"CL$_ = cl.exe"
       
   156 		);
       
   157 		if (/DEB$/o) {
       
   158 			&main::Output(
       
   159 				' /Od /Gs0x10000 /Gy /GR- /GX-'
       
   160 			);
       
   161 #			euser change to apply inlining on the _NAKED functions
       
   162 			if ($BaseTrg=~/^EUSER$/oi) {
       
   163 				&main::Output(
       
   164 					' /Ob1'
       
   165 				);
       
   166 			}
       
   167 		}
       
   168 		elsif (/REL$/o) {
       
   169 #			euser change to prevent minimum size optimisation from disrupting the maths functions
       
   170 				&main::Output(
       
   171 					' /O1 /Op /Gs0x10000 /Gy /GF /GR- /GX-'
       
   172 				);
       
   173 		}
       
   174 		&main::Output(
       
   175 			' $(CLFLAGS)'
       
   176 		);
       
   177 		foreach (&main::MacroList($_)) {
       
   178 			&main::Output(
       
   179 				" /D $_"
       
   180 			);
       
   181 		}
       
   182 		&main::Output(
       
   183 			" \$(CLDEFS) \$(INCDIR)\n"
       
   184 		);
       
   185 	}
       
   186 	&main::Output(
       
   187 		"\n",
       
   188 		"\n"
       
   189 	);
       
   190 	
       
   191 	foreach (@BldList) {
       
   192 		&main::Output(
       
   193 			"$_ :"
       
   194 		);
       
   195 		if ($BasicTrgType !~ /^IMPLIB$/io) {
       
   196 			&main::Output (
       
   197 				" \\\n",
       
   198 				"\t\"\$(EPOCTRG$_)\\$TrgDir$Trg\""
       
   199 			);
       
   200 		}
       
   201 
       
   202 #		lib has to come after the main target so that a .DEF file will be generated if the project is not frozen
       
   203 		if ($DefFile and not &main::ExportUnfrozen) {
       
   204 			&main::Output(
       
   205 				" \\\n",
       
   206 				"\tLIBRARY\n"
       
   207 			);
       
   208 		}
       
   209 		&main::Output(
       
   210 			"\n",
       
   211 			"\n"
       
   212 		);
       
   213 	}
       
   214 
       
   215 
       
   216 	# Resource building is done entirely via cl_generic.pm
       
   217 	
       
   218 	foreach (@BldList) {
       
   219 		my $makework="MAKEWORK$_";
       
   220 		&main::Output(
       
   221 			"\n",
       
   222 			"RESOURCE$_ : $makework"
       
   223 		);
       
   224 	}
       
   225 	&main::Output(
       
   226 		"\n",
       
   227 		"\n",
       
   228 	);
       
   229 
       
   230 	&main::Output(
       
   231 		"LIBRARY : MAKEWORKLIBRARY"
       
   232 	);
       
   233 	if ($BasicTrgType=~/^LIB$/o) {
       
   234 #		code to ensure that the static libraries for all builds are built at the library stage
       
   235 		foreach (@BldList) {
       
   236 			&main::Output(
       
   237 				" $_"
       
   238 			);
       
   239 		}
       
   240 	}
       
   241 	elsif ($DefFile and !$NoExportLibrary) {
       
   242 		unless (&main::ExportUnfrozen) {
       
   243 			if (-e $DefFile) { # effectively "if project frozen ..."
       
   244 				&main::Output(
       
   245 					" \"\$(EPOCLIB)\\UREL\\$PrimaryExportLibrary.LIB\"\n"
       
   246 				);
       
   247 			}
       
   248 			else {
       
   249 				&main::Output(
       
   250 					"\n",
       
   251 					"\t\@echo WARNING: Not attempting to create \"\$(EPOCLIB)\\UREL\\$PrimaryExportLibrary.LIB\".\n",
       
   252 					"\t\@echo When exports are frozen in \"$DefFile\", regenerate Makefile.\n"
       
   253 				);
       
   254 			}
       
   255 		}
       
   256 		else {
       
   257 			&main::Output(
       
   258 				"\n",
       
   259 				"\t\@echo Not attempting to create \"\$(EPOCLIB)UREL\\$PrimaryExportLibrary.LIB\"\n",
       
   260 				"\t\@echo from frozen .DEF file, since EXPORTUNFROZEN specified.\n"
       
   261 			);
       
   262 		}
       
   263 		&main::Output(
       
   264 			"\n",
       
   265 			"\n",
       
   266 			"# REAL TARGET - LIBRARY\n",
       
   267 			"\n",
       
   268 			"\"\$(EPOCLIB)\\UREL\\$ExportLibrary.LIB\" : \"$DefFile\"\n",
       
   269 			"\tperl -S prepdef.pl \"$DefFile\" \"\$(EPOCBLD)\\$ExportLibrary.prep.def\"\n",
       
   270 			"\tlib.exe /nologo /machine:i386 /nodefaultlib /subsystem:native /name:\"$LinkAs\" /def:\"\$(EPOCBLD)\\$ExportLibrary.prep.def\" /out:\"\$(EPOCLIB)\\UREL\\$ExportLibrary.LIB\"\n",
       
   271 			"\tdel \"\$(EPOCLIB)\\UREL\\$ExportLibrary.exp\"\n"
       
   272 		);
       
   273 		if ($ExtraExportLibrary) {
       
   274 			&main::Output(
       
   275 				"\n",
       
   276 				&Generic_Quote("\$(EPOCLIB)\\UREL\\$ExtraExportLibrary.lib"), " : ",
       
   277 				&Generic_Quote("\$(EPOCLIB)\\UREL\\$ExportLibrary.lib"), "\n",
       
   278 				"\tcopy ", &Generic_Quote("\$(EPOCLIB)\\UREL\\$ExportLibrary.lib"), " \$@\n"
       
   279 			);
       
   280 		}
       
   281 	}
       
   282 	&main::Output(
       
   283 		"\n",
       
   284 		"\n",
       
   285 		"FREEZE :\n"
       
   286 	);
       
   287 	if ($DefFile and $BasicTrgType !~ /^IMPLIB$/io) {
       
   288 		&main::Output(
       
   289 #			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
       
   290 			"\tperl -w -S efreeze.pl \$(EFREEZE_ALLOW_REMOVE) \"$DefFile\" \"\$(EPOCBLD)\\$ExportLibrary.def\" \n"
       
   291 		);
       
   292 	}
       
   293 	&main::Output(
       
   294 		"\n",
       
   295 		"CLEANLIBRARY :\n"
       
   296 	);
       
   297 	if ($DefFile and !$NoExportLibrary) {
       
   298 		&main::Output(
       
   299 			"\t-\$(ERASE) \"\$(EPOCLIB)\\UREL\\$ExportLibrary.LIB\"\n"
       
   300 		);
       
   301 		if ($ExtraExportLibrary) {
       
   302 			&main::Output(
       
   303 				"\t-\$(ERASE) \"\$(EPOCLIB)\\UREL\\$ExtraExportLibrary.LIB\"\n"
       
   304 			);
       
   305 		}
       
   306 	}
       
   307 	&Generic_MakeWorkDir('MAKEWORKLIBRARY',"${LibPath}UREL");
       
   308 
       
   309 	&Generic_Releaseables;
       
   310 }
       
   311 
       
   312 sub PMBld {
       
   313 
       
   314 	my @ASSPLibList=&main::ASSPLibList;
       
   315 	my @SrcList=&main::SrcList;
       
   316 	my $BaseTrg=&main::BaseTrg;
       
   317 	my $Bld=&main::Bld;
       
   318 	my $DefFile=&main::DefFile;
       
   319 	my $EPOCIncPath=&main::EPOCIncPath;
       
   320 	my $FirstLib=&main::FirstLib;
       
   321 	my $BasicTrgType=&main::BasicTrgType;
       
   322 	my @LibList;
       
   323 	my $LinkAs=&main::LinkAs;
       
   324 	my $ExportLibrary=&main::ExportLibrary;
       
   325 	my $NoExportLibrary=&main::NoExportLibrary;
       
   326 	my $LibPath=&main::LibPath;
       
   327 	my $RelPath=&main::RelPath;
       
   328 	my @StatLibList=&main::StatLibList;
       
   329 	my $Trg=&main::Trg;
       
   330 	my $TrgPath=&main::TrgPath;
       
   331 	my $TrgType=&main::TrgType;
       
   332 	my @UidList=&main::UidList;	
       
   333 	my $HasExports=0;
       
   334 	if (-e $DefFile or scalar(&main::Exports)!=0) {
       
   335 		$HasExports=1;
       
   336 	}
       
   337 	my %Version = &main::Version();
       
   338 	my $ExtraExportLibrary;
       
   339 	unless ($Version{explicit}) {
       
   340 		$ExtraExportLibrary = $ExportLibrary;
       
   341 		$ExtraExportLibrary =~ s/\{(\d|a|b|c|d|e|f){8}\}//i;
       
   342 	}
       
   343 
       
   344 	my $WarningLevel='/WARN:3';
       
   345 	$WarningLevel='/WARN:1';    # avoid LNK4005 warnings about unused libraries
       
   346 
       
   347 	if ($Bld =~ /DEB/) {
       
   348 		@LibList=&main::DebugLibList;
       
   349 	} else {
       
   350 		@LibList=&main::LibList;
       
   351 	}
       
   352 
       
   353 #	set up $LinkAs
       
   354 	$UidList[2]=~/^0x(.*)$/o;
       
   355 	if ($1 ne '00000000') {	# have to make sure than series of noughts in brackets doesn't appear in name for null uids
       
   356 		$LinkAs=join '', &main::Path_Split('Base',$LinkAs),"[$1]",&main::Path_Split('Ext',$LinkAs);
       
   357 	}
       
   358 
       
   359 	my $BLDTRGPATH = "\$(EPOCTRG$Bld)\\";
       
   360 	my $BLDDATAPATH = "\$(EPOCTRG$Bld)\\";
       
   361 	my $Entry="";
       
   362 	my $Include="";
       
   363 	my $EntrySymbol='';
       
   364 	if ($BasicTrgType=~/^DLL$/o) {
       
   365 		$Entry="_E32Dll";
       
   366 		$Include="/include:\"__E32Dll\"";
       
   367 		$EntrySymbol='_E32Dll';
       
   368 	}
       
   369 	elsif ($BasicTrgType=~/^EXE$/o) {
       
   370 		$Entry="_E32Startup";
       
   371 		$Include="/include:\"__E32Startup\"";
       
   372 		$EntrySymbol='_E32Startup';
       
   373 	}
       
   374 	my $AbsentSubst = '';
       
   375 	if ($EntrySymbol) {
       
   376 		$AbsentSubst = " -absent $EntrySymbol";
       
   377 	}
       
   378 
       
   379 	# REAL TARGETS
       
   380 	#-------------
       
   381 	&main::Output(
       
   382 		"# REAL TARGET - BUILD VARIANT $Bld\n",
       
   383 		"\n"
       
   384 	);
       
   385 
       
   386 #	releasables
       
   387 	my @releasables;
       
   388  	push @releasables, "$RelPath$Trg" if ($BasicTrgType !~ /^IMPLIB$/io);
       
   389    	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   390  		push @releasables, "$RelPath$Trg.MAP";
       
   391 	}
       
   392 	if (-e $DefFile and !$NoExportLibrary) { # effectively "if project frozen ..."
       
   393  		push @releasables, "$LibPath$ExportLibrary.LIB";
       
   394  		push @releasables, "$LibPath$ExtraExportLibrary.LIB" if ($ExtraExportLibrary);
       
   395 	}
       
   396 
       
   397 	&main::Output(
       
   398 		"WHAT$Bld : WHATGENERIC\n",
       
   399 		"\n",
       
   400 		"CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld\n",
       
   401 		"\n",
       
   402 		"CLEANBUILD$Bld : \n",
       
   403 		"\t\@perl -w -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n",
       
   404 		"\t-\$(ERASE) \"$BLDTRGPATH$BaseTrg.ILK\"\n",
       
   405 		"\n",
       
   406 		"CLEANRELEASE$Bld : CLEANGENERIC\n",
       
   407 		"\n"
       
   408 	);
       
   409  	&Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releasables);
       
   410 
       
   411 	&Generic_MakeWorkDir("MAKEWORK$Bld", &main::BldPath);
       
   412 	&Generic_MakeWorkDir("MAKEWORK$Bld", $BLDTRGPATH);
       
   413 
       
   414  	return if ($BasicTrgType =~ /^IMPLIB$/io);
       
   415 
       
   416 	&main::Output(
       
   417 		"LISTING$Bld : MAKEWORK$Bld"
       
   418 	);
       
   419 	foreach (@SrcList) {
       
   420 		my $BaseSrc = &main::Path_Split('Base', $_);
       
   421 		my $Ext = &main::Path_Split('Ext', $_);
       
   422 		$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   423    		&main::Output(
       
   424 			" \\\n\tLISTING$Bld$BaseSrc"
       
   425    		);
       
   426    	}
       
   427 	&main::Output(
       
   428 		"\n",
       
   429 		"\n"
       
   430 	);
       
   431 
       
   432 	&main::Output(
       
   433 		"LIBS="
       
   434 	);
       
   435 	foreach (@StatLibList) {
       
   436 		&main::Output(
       
   437 			" \\\n\t\"\$(EPOCSTATLINK$Bld)\\$_\""
       
   438 		);
       
   439 	}
       
   440 	foreach (@ASSPLibList) {
       
   441 		&main::Output(
       
   442 			" \\\n\t\"\$(EPOCASSPLINK$Bld)\\$_\""
       
   443 		);
       
   444 	}
       
   445 	foreach (@LibList) {
       
   446 		&main::Output(
       
   447 			" \\\n\t\"\$(EPOCLINK$Bld)\\$_\""
       
   448 		);
       
   449 	}
       
   450 	&main::Output(
       
   451 		"\n",
       
   452 		"\n"
       
   453 	);
       
   454 
       
   455 	&main::Output(
       
   456 		"LINK_OBJS="
       
   457 	);
       
   458 	foreach (@SrcList) {
       
   459 		my $BaseSrc = &main::Path_Split('Base', $_);
       
   460 		my $Ext = &main::Path_Split('Ext', $_);
       
   461 		$BaseSrc.='_' if (lc($Ext) eq '.cia');
       
   462    		&main::Output(
       
   463 			" \\\n",
       
   464 			"\t\"\$(EPOCBLD$Bld)\\$BaseSrc.obj\""
       
   465    		);
       
   466    	}
       
   467 	&main::Output(
       
   468 		"\n",
       
   469 		"\n"
       
   470 	);
       
   471 
       
   472 	if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o || $TrgType=~/^EXEDLL$/o) {
       
   473 		&main::OutFormat(
       
   474 			"STAGE1_LINK_FLAGS="
       
   475 		);
       
   476 		&main::OutFormat(
       
   477 			"\"\$(EPOCSTATLINK$Bld)\\$FirstLib\" /PDB:NONE"
       
   478 		);
       
   479 		if ($BasicTrgType=~/^(DLL)$/o) {	# Add the DLL stub
       
   480 			&main::OutFormat(
       
   481 				" \"\$(EPOCSTATLINK$Bld)\\EDLLSTUB.LIB\""
       
   482 			);
       
   483 		}
       
   484 		&main::OutFormat(
       
   485 			" \$(LIBS) /nologo /entry:$Entry /subsystem:native"
       
   486 		);
       
   487 		if ($BasicTrgType=~/^DLL$/o) {
       
   488 			&main::OutFormat(
       
   489 				" /dll"
       
   490 			);
       
   491 		}
       
   492 		if ($Bld=~/DEB$/o) {
       
   493 			&main::OutFormat(
       
   494 				' /debug'
       
   495 			);
       
   496 		}
       
   497 		&main::OutFormat(
       
   498 			" /incremental:no /machine:IX86 /nodefaultlib $Include /out:\"\$(EPOCBLD$Bld)\\$Trg\" $WarningLevel",
       
   499 			" /implib:\"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"",
       
   500 			' /ignore:4089',		# LNK4089: all references to "dynamic-link library" discarded by /OPT:REF
       
   501 			' /ignore:4005'			# LNK4005: no objects used from XXX
       
   502 		);
       
   503 		&main::Output(
       
   504 			"\n",
       
   505 			"\n"
       
   506 		);
       
   507 	}
       
   508 
       
   509 	&main::OutFormat(
       
   510 		'LINK_FLAGS='
       
   511 	);
       
   512 	if ($BasicTrgType=~/^(EXE|DLL)$/o) {
       
   513 		&main::OutFormat(
       
   514 			" \"\$(EPOCSTATLINK$Bld)\\$FirstLib\" /PDB:NONE "
       
   515 		);
       
   516 		if ($BasicTrgType=~/^(DLL)$/o) {	# Add the DLL stub
       
   517 			&main::OutFormat(
       
   518 				" \"\$(EPOCSTATLINK$Bld)\\EDLLSTUB.LIB\""
       
   519 			);
       
   520 		}
       
   521 	}
       
   522 	&main::OutFormat(
       
   523 		' $(LIBS) /nologo'
       
   524 	);
       
   525 	if ($BasicTrgType=~/^(EXE|DLL)$/o) {
       
   526 		&main::OutFormat(
       
   527 			" /fixed:no "
       
   528 		);
       
   529 		&main::OutFormat(
       
   530 			" /entry:$Entry"
       
   531 		);
       
   532 	}
       
   533 	&main::OutFormat(
       
   534 		' /subsystem:native'
       
   535 	);
       
   536 	if ($BasicTrgType=~/^DLL$/o) {
       
   537 		if ($HasExports) {
       
   538 			&main::OutFormat(
       
   539 				" /dll \"\$(EPOCBLD$Bld)\\$ExportLibrary.exp\""
       
   540 			);
       
   541 		} else {
       
   542 			&main::OutFormat(
       
   543 				" /dll"
       
   544 			);
       
   545 		}
       
   546 	} elsif ($TrgType=~/^EXEXP$/o || $TrgType=~/^EXEDLL$/o) {
       
   547 		&main::OutFormat(
       
   548 			" \"\$(EPOCBLD$Bld)\\$ExportLibrary.exp\""
       
   549 		);
       
   550 	}
       
   551 	if (&main::HeapSize) {
       
   552 		my %HeapSize=&main::HeapSize;
       
   553 		&main::OutFormat(
       
   554 			' /heap:',$HeapSize{Max},',',$HeapSize{Min}
       
   555 		);
       
   556 	}
       
   557 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   558 		if ($Bld=~/DEB$/o) {
       
   559 			&main::OutFormat(
       
   560 				' /debug'
       
   561 			);
       
   562 		}
       
   563 		elsif ($Bld=~/REL$/o) {
       
   564 			&main::OutFormat(
       
   565 				' /incremental:no'
       
   566 			);
       
   567 		}
       
   568 	}
       
   569 	&main::OutFormat(
       
   570 		' /machine:IX86',
       
   571 		' /ignore:4089',	# LNK4089: all references to "dynamic-link library" discarded by /OPT:REF
       
   572 		' /ignore:4005'		# LNK4005: no objects used from XXX
       
   573 	);
       
   574 	&main::OutFormat(
       
   575 		" /nodefaultlib $Include"
       
   576 	);
       
   577 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   578 		&main::OutFormat(
       
   579 			" /out:\"\$(EPOCBLD$Bld)\\$Trg\"",
       
   580 			" /implib:\"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\""
       
   581 		);
       
   582 		&main::OutFormat(
       
   583 			" $WarningLevel"
       
   584 		);
       
   585 	} else {
       
   586 		&main::OutFormat(
       
   587 			" /out:\"$BLDTRGPATH$Trg\""
       
   588 		);
       
   589 	}
       
   590 	&main::Output(
       
   591 		"\n",
       
   592 		"\n"
       
   593 	);
       
   594 
       
   595 	&main::Output(
       
   596 		"\"$BLDTRGPATH$Trg\" : \$(LINK_OBJS)"
       
   597 	);
       
   598 	if (-e $DefFile) { # effectively "if project frozen ..."
       
   599 		&main::Output(
       
   600 			" \"$DefFile\""
       
   601 		);
       
   602 	}
       
   603 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   604 		&main::Output(
       
   605 			" \"\$(EPOCSTATLINK$Bld)\\$FirstLib\""
       
   606 		);
       
   607 	}
       
   608 	&main::Output(
       
   609 		" \$(LIBS)\n"
       
   610 	);
       
   611 
       
   612 
       
   613 #	Link by name first time round for dlls
       
   614 	if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o || $TrgType=~/^EXEDLL$/o) {
       
   615 		&main::Output(
       
   616 			"\techo $Entry>\"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\"\n",
       
   617 			"\tlink.exe \@<<\n",
       
   618 			"\t\t\$(STAGE1_LINK_FLAGS) /order:@\"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\" \$(LINK_OBJS)\n",
       
   619 			"<<\n",
       
   620 			"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\"\n",
       
   621 			"\tdel \"\$(EPOCBLD$Bld)\\$Trg\"\n",
       
   622 #			"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.exp\"\n"
       
   623 		);
       
   624 
       
   625 	if ($HasExports) {
       
   626 	#		Generate an export info file
       
   627 			&main::Output(
       
   628 				"\tdumpbin /exports /out:\"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\" \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n",
       
   629 				"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n"
       
   630 			);
       
   631 
       
   632 	#		call makedef to reorder the export information
       
   633 			&main::Output(
       
   634 	#			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
       
   635 				"\tperl -w -S makedef.pl $AbsentSubst -Inffile \"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\""
       
   636 			);
       
   637 			if (-e $DefFile) { # effectively "if project frozen ..."
       
   638 				&main::Output(
       
   639 					" -Frzfile \"$DefFile\""
       
   640 				);
       
   641 			}
       
   642 			# freeze ordinals, a maximum of 2, for polymorphic dlls
       
   643 			my $Ordinal;
       
   644 			my $Num=1;
       
   645 			foreach $Ordinal (&main::Exports) {
       
   646 #				replace "$" with "$$" so that NMAKE doesn't think there's a macro in the function name
       
   647 				$Ordinal=~s-\$-\$\$-go;
       
   648 				&main::Output(
       
   649 					" -$Num $Ordinal"
       
   650 				);
       
   651 				$Num++;
       
   652 			}
       
   653 			&main::Output(
       
   654 				" \"\$(EPOCBLD)\\$ExportLibrary.def\" \n",
       
   655 				"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.inf\"\n"
       
   656 			);
       
   657 
       
   658 			# create the export object from the .DEF file
       
   659 			&main::Output(
       
   660 				"\tlib.exe  /nologo /machine:i386 /nodefaultlib /subsystem:native /name:\"$LinkAs\" /def:\"\$(EPOCBLD)\\$ExportLibrary.def\" /out:\"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n"
       
   661 			);
       
   662 			if (&main::ExportUnfrozen) {
       
   663 				&main::Output(
       
   664 				"\tcopy \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\" \"\$(EPOCLIB)\\UREL\\$ExportLibrary.lib\"\n"
       
   665 				);
       
   666 				if ($ExtraExportLibrary) {
       
   667 					&main::Output(
       
   668 						"\n",
       
   669 						"\tcopy \"\$(EPOCLIB)\\UREL\\$ExportLibrary.lib\" ",
       
   670 						"\"\$(EPOCLIB)\\UREL\\$ExtraExportLibrary.lib\"",
       
   671 						"\n"
       
   672 					);						
       
   673 				}				
       
   674 			}
       
   675 			&main::Output(
       
   676 				"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.lib\"\n"
       
   677 			);
       
   678 		}
       
   679 	}
       
   680 
       
   681 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   682 		&main::Output(
       
   683 			"\techo $Entry>\"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\"\n",
       
   684 			"\tlink.exe /order:@\"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\" /MAPINFO:EXPORTS /MAP:\"$RelPath$Trg.MAP\" \@<<\n"
       
   685 		);
       
   686 	}
       
   687 	elsif ($BasicTrgType=~/^LIB$/o) {
       
   688 		&main::Output(
       
   689 			"\tlib.exe \@<<\n"
       
   690 		);
       
   691 	}
       
   692 	&main::Output(
       
   693 		"\t\t\$(LINK_FLAGS) \$(LINK_OBJS)\n",
       
   694 		"<<\n"
       
   695 	);
       
   696 
       
   697 	if ($BasicTrgType=~/^(DLL|EXE)$/o) {
       
   698 		&main::Output(
       
   699 			"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.ord\"\n"
       
   700 		);
       
   701 		if ($BasicTrgType=~/^DLL$/o || $TrgType=~/^EXEXP$/o || $TrgType=~/^EXEDLL$/o) {
       
   702 			if ($HasExports) {
       
   703 				&main::Output(
       
   704 					"\tdel \"\$(EPOCBLD$Bld)\\$ExportLibrary.exp\"\n"
       
   705 				);
       
   706 			}
       
   707 		}
       
   708 		&main::Output(
       
   709 			"\tperl -S findimp.pl \"$RelPath$Trg.MAP\" \"\$(EPOCBLD$Bld)\\$ExportLibrary.imp\"\n"
       
   710 		);
       
   711 		&main::Output(
       
   712 			"\tpetran -x86imp=\"\$(EPOCBLD$Bld)\\$ExportLibrary.imp\" -version ", &Genutl_VersionToUserString(%Version), " -sid ", &main::SecureId(), " \"\$(EPOCBLD$Bld)\\$Trg\" \$\@ \\\n",
       
   713 			"\t\t"
       
   714 		);
       
   715 		if (&main::AllowDllData) {
       
   716 			&main::Output(
       
   717 				' -allow'
       
   718 			);
       
   719 		}
       
   720 		if (not &main::CallDllEntryPoints) {
       
   721 			&main::Output(
       
   722 				' -nocall'
       
   723 			);
       
   724 		}
       
   725 		if (&main::DataLinkAddress) {
       
   726 			&main::Output(
       
   727 				' -datalinkaddress ',&main::DataLinkAddress
       
   728 			);
       
   729 		}
       
   730 		if (&main::FixedProcess) {
       
   731 			&main::Output(
       
   732 				' -fixed'
       
   733 			);
       
   734 		}
       
   735 		if (&main::HeapSize) {
       
   736 			my %HeapSize=&main::HeapSize;
       
   737 			&main::Output(
       
   738 				' -heap ',$HeapSize{Min},' ',$HeapSize{Max}
       
   739 			);
       
   740 		}
       
   741 		if (&main::ProcessPriority) {
       
   742 			&main::Output(
       
   743 				' -priority ',&main::ProcessPriority
       
   744 			);
       
   745 		}
       
   746 		if (&main::SmpSafe) {
       
   747 			&main::Output(
       
   748 				' -smpsafe'
       
   749 			);
       
   750 		}
       
   751 		if (&main::StackSize) {
       
   752 			&main::Output(
       
   753 				' -stack ',&main::StackSize
       
   754 			);
       
   755 		}
       
   756 		my $i=1;
       
   757 		foreach (@UidList) {
       
   758 			&main::Output(
       
   759 				" -uid$i $_"
       
   760 			);
       
   761 			$i++;
       
   762 		}
       
   763 		if(&main::VendorId) {
       
   764 			&main::Output(
       
   765 				' -vid ',&main::VendorId
       
   766 			);
       
   767 		}
       
   768 		&main::Output(
       
   769 			' -capability ',&main::Capability,
       
   770 		);
       
   771 		if (&main::CompressTarget)
       
   772 		    {
       
   773 		    &main::Output(
       
   774 		    " -nocompress"
       
   775 		    );
       
   776 		    }
       
   777 		else
       
   778 		    {
       
   779 		    if(&main::CompressTargetMode == NOCOMPRESSIONMETHOD)
       
   780 			{
       
   781 				# Do nothing
       
   782 			}
       
   783 		    elsif(&main::CompressTargetMode == INFLATECOMPRESSIONMETHOD)
       
   784 			{
       
   785 			&main::Output(
       
   786 				" -compressionmethod deflate"
       
   787 			);
       
   788 			}
       
   789 		    elsif(&main::CompressTargetMode == BYTEPAIRCOMPRESSIONMETHOD)
       
   790 			{
       
   791 			&main::Output(
       
   792 				" -compressionmethod bytepair"
       
   793 			);
       
   794 			}
       
   795 
       
   796 		    }
       
   797 		if (&main::CodePagingTargetMode == UNPAGED) {
       
   798 			&main::Output(
       
   799 				' -codepaging unpaged'
       
   800 			);
       
   801 		}
       
   802 		elsif (&main::CodePagingTargetMode == PAGED) {
       
   803 			&main::Output(
       
   804 				' -codepaging paged'
       
   805 			);
       
   806 		}
       
   807 
       
   808 		if (&main::DataPagingTargetMode == UNPAGED) {
       
   809 			&main::Output(
       
   810 				' -datapaging unpaged'
       
   811 			);
       
   812 		}
       
   813 		elsif (&main::DataPagingTargetMode == PAGED) {
       
   814 			&main::Output(
       
   815 				' -datapaging paged'
       
   816 			);
       
   817 		}
       
   818 		&main::Output("\n");
       
   819 		&main::Output(
       
   820 			"\tdel \"\$(EPOCBLD$Bld)\\$Trg\"\n"
       
   821 		);
       
   822 	}
       
   823 
       
   824 	&main::Output(
       
   825 		"\n",
       
   826 		"\n"
       
   827 	);
       
   828 }
       
   829 
       
   830 sub PMStartSrcList {
       
   831 
       
   832 	&main::Output(
       
   833 		"# SOURCES\n",
       
   834 		"\n"
       
   835 	);
       
   836 }
       
   837 
       
   838 sub PMBitMapBld {
       
   839 
       
   840 	&Generic_BitMapBld;
       
   841 
       
   842 }
       
   843 
       
   844 sub PMResrcBld {
       
   845 
       
   846 	&Generic_ResrcBld;
       
   847 
       
   848 }
       
   849 
       
   850 sub PMAifBld {
       
   851 
       
   852 	&Generic_AifBld;
       
   853 
       
   854 }
       
   855 
       
   856 sub PMStartSrc {
       
   857 	my $Src=&main::Src;
       
   858 
       
   859 	&main::Output(
       
   860 		"# Source $Src\n",
       
   861 		"\n"
       
   862 	);
       
   863 }
       
   864 
       
   865 sub PMSrcDepend {
       
   866 	my @BldList=&main::BldList;	
       
   867 	my @DepList=&main::DepList;
       
   868 
       
   869 	&main::Output(
       
   870 		"DEPEND="
       
   871 	);
       
   872 	foreach (@DepList) {
       
   873 		&main::Output(
       
   874 		" \\\n\t\"$_\""
       
   875 		);
       
   876 	}
       
   877 	&main::Output(
       
   878 		"\n",
       
   879 		"\n"
       
   880 	);
       
   881 	foreach (@BldList) {
       
   882 		&main::Output(
       
   883 			"DEPEND$_=\$(DEPEND)\n",
       
   884 			"\n"
       
   885 		);
       
   886 	}
       
   887 	&main::Output(
       
   888 		"\n"
       
   889 	);
       
   890 }
       
   891 
       
   892 sub PMSrcBldDepend {
       
   893 	my $Bld=&main::Bld;
       
   894 	my @DepList=&main::DepList;
       
   895 
       
   896 	&main::Output(
       
   897 		"DEPEND$Bld="
       
   898 	);
       
   899 	foreach (@DepList) {
       
   900 		&main::Output(
       
   901 			" \\\n\t\"$_\""
       
   902 		);
       
   903 	}
       
   904 	&main::Output(
       
   905 		"\n",
       
   906 		"\n"
       
   907 	);
       
   908 }
       
   909 
       
   910 sub PMEndSrcBld {
       
   911 	my $BaseSrc=&main::BaseSrc;
       
   912 	my $Bld=&main::Bld;
       
   913 	my $Plat=&main::Plat;
       
   914 	my $Src=ucfirst lc &main::Src;
       
   915 	my $SrcPath=&main::SrcPath;
       
   916 	my $Ext=&main::ExtSrc;
       
   917 	my $Cia = (lc($Ext) eq '.cia') ? 1 : 0;
       
   918 
       
   919 	if ($Cia) {
       
   920 		&main::Output(
       
   921 			"\"\$(EPOCBLD$Bld)\\$BaseSrc\_.obj\" \"\$(EPOCBLD$Bld)\\$BaseSrc\_.sbr\" : \"$SrcPath$Src\" \$(DEPEND$Bld)\n",
       
   922 			"\tperl -S tranasm_x86.pl \"$SrcPath$Src\" \"\$(EPOCBLD$Bld)\\$BaseSrc\_.transd.cia\"\n",
       
   923 			"\t\$(CL$Bld) /I \"$SrcPath\.\" /TP /Fo\"\$(EPOCBLD$Bld)\\$BaseSrc\_.obj\" /GF /c \"\$(EPOCBLD$Bld)\\$BaseSrc\_.transd.cia\"\n",
       
   924 			"\n",
       
   925 #			assembler listing target
       
   926 			"LISTING$Bld$BaseSrc\_ : \"\$(EPOCBLD$Bld)\\$BaseSrc\_.lis\"\n",
       
   927 			"\tcopy \$? \"$SrcPath$BaseSrc\_.$Plat.lst\"\n",
       
   928 			"\n",
       
   929 			"\"\$(EPOCBLD$Bld)\\$BaseSrc\_.lis\": \"$SrcPath$Src\" \$(DEPEND$Bld)\n",
       
   930 			"\t\$(CL$Bld) /TP /FAsc /Fa\"\$\@\" /Fo\"\$(EPOCBLD$Bld)\\$BaseSrc\_.obj\" /GF /c \"$SrcPath$Src\"\n",
       
   931 			"\n"
       
   932 		);
       
   933 	} else {
       
   934 		&main::Output(
       
   935 			"\"\$(EPOCBLD$Bld)\\$BaseSrc.obj\" \"\$(EPOCBLD$Bld)\\$BaseSrc.sbr\" : \"$SrcPath$Src\" \$(DEPEND$Bld)\n",
       
   936 			"\t\$(CL$Bld) /Fo\"\$(EPOCBLD$Bld)/\" /GF /c \"$SrcPath$Src\"\n",
       
   937 			"\n",
       
   938 #			assembler listing target
       
   939 			"LISTING$Bld$BaseSrc : \"\$(EPOCBLD$Bld)\\$BaseSrc.lis\"\n",
       
   940 			"\tcopy \$? \"$SrcPath$BaseSrc.$Plat.lst\"\n",
       
   941 			"\n",
       
   942 			"\"\$(EPOCBLD$Bld)\\$BaseSrc.lis\": \"$SrcPath$Src\" \$(DEPEND$Bld)\n",
       
   943 			"\t\$(CL$Bld) /FAsc /Fa\"\$\@\" /Fo\"\$(EPOCBLD$Bld)/\" /GF /c \"$SrcPath$Src\"\n",
       
   944 			"\n"
       
   945 		);
       
   946 	}
       
   947 }
       
   948 
       
   949 sub PMEndSrc {
       
   950 
       
   951 	&main::Output(
       
   952 		"\n",
       
   953 		"\n"
       
   954 	);
       
   955 }
       
   956 
       
   957 sub PMEndSrcList {
       
   958 
       
   959 	# Deal with accumulated MAKEDIRS etc.
       
   960 
       
   961 	&Generic_End;
       
   962 }
       
   963 
       
   964 1;