sbsv1_os/e32toolp/makmake/mmp.pm
changeset 0 83f4b4db085c
child 1 d4b442d23379
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 # Processes an mmp file and sets up subroutines to return the data
       
    15 # 
       
    16 #
       
    17 
       
    18 package Mmp;
       
    19 
       
    20 require Exporter;
       
    21 @ISA=qw(Exporter);
       
    22 
       
    23 @EXPORT=qw(
       
    24 	Mmp_SetVerbose
       
    25 	Mmp_ProcessL
       
    26 
       
    27 	Mmp_ABI
       
    28 	Mmp_AifStruct
       
    29 	Mmp_AllowDllData
       
    30 	Mmp_CompressTarget
       
    31 	Mmp_ASSPExports
       
    32 	Mmp_ASSPLibList
       
    33 	Mmp_BuildAsARM
       
    34 	Mmp_BitMapStruct 
       
    35 	Mmp_CallDllEntryPoints
       
    36 	Mmp_Capability
       
    37 	Mmp_CapabilityFlags
       
    38 	Mmp_DataLinkAddress
       
    39 	Mmp_DebugLibList 
       
    40 	Mmp_Def
       
    41 	Mmp_DocHash
       
    42 	Mmp_ExportUnfrozen
       
    43 	Mmp_FirstLib
       
    44 	Mmp_FixedProcess
       
    45 	Mmp_HeapSize
       
    46 	Mmp_LibList 
       
    47 	Mmp_LinkAs
       
    48 	Mmp_LinkAsBase
       
    49 	Mmp_ExportLibrary
       
    50 	Mmp_NewLib
       
    51 	Mmp_NoExportLibrary
       
    52 	Mmp_Macros
       
    53 	Mmp_MmpFlag
       
    54 	Mmp_PlatTxt2D
       
    55 	Mmp_ProcessPriority
       
    56 	Mmp_ResourceStruct 
       
    57 	Mmp_SmpSafe
       
    58 	Mmp_RamTargets
       
    59 	Mmp_RomTargets
       
    60 	Mmp_SourceStruct 
       
    61 	Mmp_StackSize
       
    62 	Mmp_StatLibList 
       
    63 	Mmp_SysIncPaths
       
    64 	Mmp_Trg
       
    65 	Mmp_TrgType
       
    66 	Mmp_UidList
       
    67 	Mmp_UserIncPaths
       
    68 	Mmp_SrcDbg
       
    69 	Mmp_StdCpp
       
    70 	Mmp_NoStdCpp
       
    71 	Mmp_WarningLevel
       
    72 	Mmp_LinkerOptions
       
    73 	Mmp_Reset
       
    74 	Mmp_Uids
       
    75 	Mmp_Version
       
    76 	Mmp_SecureId
       
    77 	Mmp_VendorId
       
    78 	Mmp_Replace
       
    79 	Mmp_ARMFPU	
       
    80 	Mmp_SetIgnoreMissingDef 
       
    81 	Mmp_StringTable
       
    82 	Mmp_CompressTargetMode
       
    83 	Mmp_CodePagingTargetMode
       
    84 	Mmp_DataPagingTargetMode
       
    85 	Mmp_CheckSourceMMPMetaData
       
    86 	Mmp_CheckSourceMMPIncludes
       
    87 	Mmp_IsWideCharMain
       
    88 	Mmp_IsDebuggable
       
    89 	Mmp_IsFeatureVariant
       
    90 	Mmp_TestedMacros
       
    91 );
       
    92 
       
    93 use strict;
       
    94 
       
    95 use Genutl;
       
    96 use Prepfile;
       
    97 use Pathutl;
       
    98 use Trgtype;
       
    99 use CheckSource;
       
   100 use Cwd;
       
   101 
       
   102 my %ProcessPriorityNames = (
       
   103 	LOW=>'Low',
       
   104 	BACKGROUND=>'Background',
       
   105 	FOREGROUND=>'Foreground',
       
   106 	HIGH=>'High',
       
   107 	WINDOWSERVER=>'WindowServer',
       
   108 	FILESERVER=>'FileServer',
       
   109 	REALTIMESERVER=>'RealTimeServer',
       
   110 	SUPERVISOR=>'SuperVisor'
       
   111 );
       
   112 
       
   113 my %CapabilityNames;
       
   114 
       
   115 my %Mode;
       
   116 
       
   117 my $ABI;
       
   118 my @AifStruct;
       
   119 my $AllowDllData=0;
       
   120 
       
   121 use constant COMPRESS => 0;
       
   122 use constant NOCOMPRESS => 1;
       
   123 my $CompressTarget=COMPRESS;	# compress the target binary (negative logic)
       
   124 use constant NOCOMPRESSIONMETHOD => 0;
       
   125 use constant INFLATECOMPRESSIONMETHOD => 1;
       
   126 use constant BYTEPAIRCOMPRESSIONMETHOD => 2;
       
   127 my $CompressTargetMethod=NOCOMPRESSIONMETHOD;   #NONE
       
   128 
       
   129 my $ASSPABISwitch=0;
       
   130 my $ASSPExports=0;
       
   131 my @ASSPLibList;
       
   132 my @BitMapStruct;
       
   133 my $BuildAsARM=0;
       
   134 my $CallDllEntryPoints=0;
       
   135 my $Capability;
       
   136 my @CapabilityFlags=(0,0);
       
   137 my %CurSource;
       
   138 my $DataLinkAddress='';
       
   139 my @DebugLibList;
       
   140 my %Def;
       
   141 $Def{Path}='';
       
   142 $Def{Base}='';
       
   143 $Def{Ext}='';
       
   144 my %DocHash;
       
   145 my $ExportUnfrozen=0;
       
   146 my $FirstLib;
       
   147 my $FixedProcess=0;
       
   148 my %HeapSize;
       
   149 my @LangList;
       
   150 my @LibList;
       
   151 my $LinkAs;
       
   152 my $LinkAsBase;
       
   153 my $ExportLibrary;
       
   154 my $NoExportLibrary;
       
   155 my @Macros;
       
   156 my %MmpFlag;
       
   157 my $NewLib;
       
   158 my @PlatTxt2D;
       
   159 my $ProcessPriority='';
       
   160 my @ResourceStruct;
       
   161 my @RamTargets;
       
   162 my @RomTargets=({}); # include default
       
   163 my $SmpSafe = 0;
       
   164 my @SourceStruct;
       
   165 my $StackSize='';
       
   166 my @StatLibList;
       
   167 my $StdCpp = 0;
       
   168 my $NoStdCpp = 0;
       
   169 my @SysIncPaths;
       
   170 my $Trg;
       
   171 my %TrgType;
       
   172 my @UidList;
       
   173 my @UserIncPaths;
       
   174 my $SrcDbg=0;
       
   175 my %Compiler;
       
   176 my %LinkerOptions;
       
   177 my %Version;
       
   178 my $SecureId;
       
   179 my $VendorId;
       
   180 my %Replace;
       
   181 my $ARMFPU;
       
   182 my $IgnoreMissingDef=0;
       
   183 my @StringTableStruct;
       
   184 my $CodePagingTargetMode;	# 0-N/A, 1-UNPAGED, 2-PAGED
       
   185 my $DataPagingTargetMode;	# 0-N/A, 1-UNPAGED, 2-PAGED
       
   186 my $WideCharMain=0;
       
   187 my $IsDebuggable;	# 0-NON_DEBUGGABLE, 1-DEBUGGABLE,2-DEBUGGABLE_UDEBONLY
       
   188 my $FeatureVariant=0;
       
   189 use constant NOTPAGED => 0;
       
   190 use constant UNPAGED => 1;
       
   191 use constant PAGED => 2;
       
   192 use constant NON_DEBUGGABLE => 0;
       
   193 use constant DEBUGGABLE => 1;
       
   194 use constant DEBUGGABLE_UDEBONLY => 2;
       
   195 my %CheckSourceMMPMetaData;
       
   196 my %CheckSourceMMPIncludes;
       
   197 my %mmptestedMacrosHash;
       
   198 
       
   199 # List of deprecated 2nd UIDs. These are checked in a Secure Platform
       
   200 my %deprecatedUIDs=
       
   201     (
       
   202     "0x10005e32" => "Unmigrated FEP detected from use of UID 0x10005e32 ",
       
   203     "0x10004cc1" => "Unmigrated Application Initaliser (CEikLibrary deriver) detected from use of UID 0x10004cc1 ",
       
   204     "0x10003a30" => "Unmigrated Conarc plugin detected from use of UID 0x10003a30",
       
   205     "0x10003a19" => "Unmigrated Recogniser detected from use of UID 0x10003a19",
       
   206     "0x10003a37" => "Unmigrated Recogniser detected from use of UID 0x10003a37",
       
   207     "0x10003a34" => "Unmigrated CTL detected from use of UID 0x10003a34"
       
   208     );
       
   209 
       
   210 
       
   211 sub Mmp_Reset() {
       
   212 	undef $ABI;
       
   213 	undef @AifStruct;
       
   214 	$AllowDllData=0;
       
   215 	$CompressTarget=COMPRESS;
       
   216     $CompressTargetMethod=NOCOMPRESSIONMETHOD;
       
   217 	$ASSPABISwitch=0;
       
   218 	$ASSPExports=0;
       
   219 	$BuildAsARM=0;
       
   220 	undef @ASSPLibList;
       
   221 	undef @BitMapStruct;
       
   222 	$CallDllEntryPoints=0;
       
   223 	undef $Capability;
       
   224 	@CapabilityFlags=(0,0);
       
   225 	undef $VendorId;
       
   226 	$DataLinkAddress='';
       
   227 	undef @DebugLibList;
       
   228 	undef %Def;
       
   229 	$Def{Path}='';
       
   230 	$Def{Base}='';
       
   231 	$Def{Ext}='';
       
   232 	undef %DocHash;
       
   233 	$ExportUnfrozen=0;
       
   234 	undef $FirstLib;
       
   235 	$FixedProcess=0;
       
   236 	undef %HeapSize;
       
   237 	undef @LangList;
       
   238 	undef @LibList;
       
   239 	undef $LinkAs;
       
   240 	undef $LinkAsBase;
       
   241 	undef $ExportLibrary;
       
   242 	undef @Macros;
       
   243 	undef %MmpFlag;
       
   244 	undef $NewLib;
       
   245 	undef @PlatTxt2D;
       
   246 	$ProcessPriority='';
       
   247 	undef @ResourceStruct;
       
   248 	undef @RamTargets;
       
   249 	@RomTargets=({}); # include default
       
   250 	undef @SourceStruct;   
       
   251 	$StackSize='';
       
   252 	undef @StatLibList;
       
   253 	$SmpSafe = 0;
       
   254 	$StdCpp = 0;
       
   255 	$NoStdCpp = 0;
       
   256 	undef @SysIncPaths;
       
   257 	undef $Trg;
       
   258 	undef %TrgType;
       
   259 	undef @UidList;
       
   260 	undef @UserIncPaths;
       
   261 	$SrcDbg=0;
       
   262 	undef %Compiler;
       
   263 	undef %LinkerOptions;
       
   264     undef %Version;
       
   265     $IgnoreMissingDef=0;
       
   266     undef $ARMFPU;
       
   267 	undef @StringTableStruct;
       
   268 	$CodePagingTargetMode=0;	# default N/A
       
   269 	$DataPagingTargetMode=0;	# default N/A
       
   270 	$IsDebuggable=0; # Default = 0 (Not debuggable)
       
   271 	undef %mmptestedMacrosHash;
       
   272 }
       
   273 
       
   274 BEGIN {
       
   275 	$Mode{'Verbose'}=0;
       
   276 
       
   277 	%CapabilityNames = (
       
   278 
       
   279 		TCB =>					(1<<0),
       
   280 		COMMDD =>				(1<<1),
       
   281 		POWERMGMT =>			(1<<2),
       
   282 		MULTIMEDIADD =>			(1<<3),
       
   283 		READDEVICEDATA =>		(1<<4),
       
   284 		WRITEDEVICEDATA =>		(1<<5),
       
   285 		DRM =>					(1<<6),
       
   286 		TRUSTEDUI =>			(1<<7),
       
   287 		PROTSERV =>				(1<<8),
       
   288 		DISKADMIN =>			(1<<9),
       
   289 		NETWORKCONTROL =>		(1<<10),
       
   290 		ALLFILES =>				(1<<11),
       
   291 		SWEVENT =>				(1<<12),
       
   292 		NETWORKSERVICES =>		(1<<13),
       
   293 		LOCALSERVICES =>		(1<<14),
       
   294 		READUSERDATA =>			(1<<15),
       
   295 		WRITEUSERDATA =>		(1<<16),
       
   296 		LOCATION =>				(1<<17),
       
   297 		SURROUNDINGSDD =>		(1<<18),
       
   298 		USERENVIRONMENT =>		(1<<19),
       
   299 #old capability names have zero value
       
   300 		ROOT =>				0,
       
   301 		MEDIADD =>			0,
       
   302 		READSYSTEMDATA =>	0,
       
   303 		WRITESYSTEMDATA =>	0,
       
   304 		SOUNDDD =>			0,
       
   305 		UIDD =>				0,
       
   306 		KILLANYPROCESS =>	0,
       
   307 		DEVMAN =>			0,
       
   308 		PHONENETWORK =>		0,
       
   309 		LOCALNETWORK =>		0
       
   310 	);
       
   311 	my $all=0;
       
   312 	foreach (keys %CapabilityNames)
       
   313 		{
       
   314 		$all = $all | $CapabilityNames{$_};
       
   315 		}
       
   316 	$CapabilityNames{"ALL"} = $all;
       
   317 }
       
   318 
       
   319 sub Mmp_SetVerbose () {
       
   320 	$Mode{'Verbose'}=1;
       
   321 }
       
   322 
       
   323 sub Mmp_SetIgnoreMissingDef() {
       
   324     $IgnoreMissingDef = 1;
       
   325 }
       
   326 
       
   327 sub Mmp_ProcessL ($$$$) {
       
   328 	my ($EPOCPath, $MMPFILE, $Plat_ref, $BuildIncList)=@_;
       
   329 	my $emulator = $$Plat_ref{OS} ne 'EPOC32';
       
   330 
       
   331 	if ($Mode{Verbose}) {
       
   332 		&Prepfile_SetVerbose;
       
   333 	}
       
   334 
       
   335 	# Generate macro usage information and add variant build includes
       
   336 	my $options = '-dU';
       
   337 	foreach ( @$BuildIncList )
       
   338 		{
       
   339 		$options .= ' -I ' . &Path_PrefixWithDriveAndQuote($_);
       
   340 		}
       
   341 
       
   342 #	preprocess the project description file
       
   343 	my @Mmp2D;
       
   344 	Prepfile_SetCmdOptions($options);
       
   345 	eval { &Prepfile_ProcessL(\@Mmp2D, $MMPFILE, &main::VariantFile(), @{$$Plat_ref{MmpMacros}}); };
       
   346 	Prepfile_SetCmdOptions('');
       
   347 	die $@ if $@;
       
   348 
       
   349 	my @checkSourceMacros;
       
   350 	foreach (@{$$Plat_ref{MmpMacros}}) {
       
   351 		$_=uc $_;
       
   352 		push @checkSourceMacros, " $_=_____$_";
       
   353 	}
       
   354 
       
   355 	my $current = cwd;
       
   356 	$current =~ s/\//\\/g;
       
   357 	$current =~ s/^[a-zA-Z]://;
       
   358 
       
   359 	# Mimic what the current parsing routine does in terms of include paths and .mmp files
       
   360 	my @checkSourceUserIncludePaths;
       
   361 	push @checkSourceUserIncludePaths, "$ENV{EPOCROOT}epoc32\\include";
       
   362 	push @checkSourceUserIncludePaths, "\.";
       
   363 	push @checkSourceUserIncludePaths, $current;
       
   364 	my @checkSourceSystemIncludePaths = ();
       
   365 
       
   366 	CheckSource_Includes($MMPFILE, %CheckSourceMMPIncludes, &main::VariantFile(), @checkSourceMacros, @checkSourceUserIncludePaths, @checkSourceSystemIncludePaths, $CheckSource_NoUserSystemDistinction);
       
   367 
       
   368 	my $NoStrictDef=0;
       
   369 	my $TrgPath='';
       
   370 	my $TrgType;
       
   371 
       
   372 	my $MmpPath=&Path_Split('Path', $MMPFILE);
       
   373 
       
   374 	my @MmpDie=();
       
   375 	my @MmpWarn=();
       
   376 	my @MmpDiagnostic=();
       
   377 	my @MmpMigrationNote=();
       
   378 
       
   379 	my (%CheckAif, %CheckASSPLib, %CheckDoc, %CheckLang, %CheckLib, %CheckMacro, %CheckResrc, %CheckSrc, %CheckStatLib, %CheckSysInc, %CheckSysResrc, %CheckUserInc);
       
   380 
       
   381 	my ($CheckDef);
       
   382 
       
   383 	my ($CheckRamTargets, $CheckRomTargets);
       
   384 
       
   385 	my ($OtherPlatSwitch, $PlatTxtSwitch);
       
   386 
       
   387 	my (%CurBitMap, $CurBitMapSrcPath);
       
   388 	$CurBitMapSrcPath=$MmpPath;
       
   389 
       
   390 	my (%CurResource, %ResourceCheckLang);
       
   391 
       
   392 	my %CurStringTable;
       
   393 	my ($CurSrcPath, $MmpMacro, $Line);
       
   394 	$CurSrcPath=$MmpPath;
       
   395 
       
   396 #	include the .MMP file as a document
       
   397 	@{$DocHash{$MmpPath}}=(&Path_Split('File', $MMPFILE));
       
   398 	$CheckDoc{$MMPFILE}='zero - specified by default';
       
   399 
       
   400 # process the data structure
       
   401 	my $CurFile=$MMPFILE;
       
   402 	LINE: foreach $Line (@Mmp2D) {
       
   403 		my $LineNum=shift @$Line;
       
   404 		$_=shift @$Line;
       
   405 		if ($LineNum eq '#') {
       
   406 			$CurFile=$_;
       
   407 			next LINE;
       
   408 		}
       
   409 
       
   410 		# Get details of tested macros affecting the MMP file
       
   411 		# We get this from -dU preprocessor option
       
   412 		if (/^#define$/ && "@$Line" =~ /^(\w+(?:\([^\)]*\))?)(?:\s(\S.*?))?\s*$/)
       
   413 			{
       
   414 			# Record macro details for defined tested macro
       
   415 			$mmptestedMacrosHash{$1} = $2 ? "\'$2\'" : 'defined';
       
   416 			next LINE;
       
   417 			}
       
   418 		elsif (/^#undef$/)
       
   419 			{
       
   420 			# Record macro details for undefined tested macro
       
   421 			$mmptestedMacrosHash{"@$Line"} = 'undefined';
       
   422 			next LINE;
       
   423 			}
       
   424 				
       
   425 		$CurFile = &Path_Norm ($CurFile);
       
   426 		
       
   427 		$_=uc $_;
       
   428 
       
   429 		my $mainElement = $_;
       
   430 		
       
   431 		if ($PlatTxtSwitch) {
       
   432 			if (/^END$/o) {
       
   433 				$PlatTxtSwitch=0;
       
   434 				next LINE;
       
   435 			}
       
   436 			push @PlatTxt2D, [ "$CurFile($LineNum)", $_, @$Line ];
       
   437 			next LINE;
       
   438 		}
       
   439 		if ($OtherPlatSwitch) {
       
   440 			if (/^END$/o) {
       
   441 				$OtherPlatSwitch=0;
       
   442 				next LINE;
       
   443 			}
       
   444 			next LINE;
       
   445 		}
       
   446 		# ----------- handle body of START BITMAP ... END -------------
       
   447 		if (%CurBitMap) {
       
   448 			if (/^SOURCE$/o) {
       
   449 				unless (@$Line>1) {
       
   450 					push @MmpDie, "$CurFile($LineNum) : Not enough arguments for Bitmap keyword SOURCE\n";
       
   451 				}
       
   452 				my $cldepth = shift @$Line;
       
   453 				my @ClDepths = split(/,/, $cldepth);
       
   454 				foreach (@ClDepths) {
       
   455 					$_ = lc $_; # bmconv can't handle upper-case 'C's
       
   456 					unless (/^c?\d\d?a?$/o) {
       
   457 						push @MmpDie, "$CurFile($LineNum) : BITMAP color depth \"$_\" - unexpected format\n";
       
   458 					}
       
   459 				}
       
   460 				@ClDepths = (@ClDepths) x @$Line;	# make a sufficiently long list of color depths
       
   461 				foreach (@$Line) {
       
   462 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "BITMAP SOURCE", $_, $LineNum, $CheckSource_PhysicalCheck, $CurBitMapSrcPath);
       
   463 					$_ = &Path_Norm($_);
       
   464 					
       
   465 					$_=lc $_;	# bmconv generates a header with case-sensitive enums
       
   466 					my $bitmap = "$CurBitMapSrcPath$_";
       
   467 					push @{$CurBitMap{Source}}, { # sources must be kept in order
       
   468 						Src=>$bitmap,
       
   469 						ClDepth=>shift @ClDepths	# take next color depth from the list
       
   470 					};
       
   471 					unless (-e $bitmap) {
       
   472 						push @MmpWarn, "$CurFile($LineNum) : BITMAP source \"$CurBitMapSrcPath$_\" not found\n";
       
   473 					}
       
   474 				}
       
   475 				next LINE;
       
   476 			}
       
   477 			if (/^END$/o) {
       
   478 				$CurBitMapSrcPath=$MmpPath;
       
   479 				my %BitMap=%CurBitMap;
       
   480 				undef %CurBitMap;
       
   481 				push @BitMapStruct, \%BitMap;
       
   482 				next LINE;
       
   483 			}
       
   484 			if (/^SOURCEPATH$/o) {
       
   485 				unless ($CurBitMapSrcPath=shift @$Line) {
       
   486 					push @MmpDie, "$CurFile($LineNum) : No path specified with Bitmap keyword SOURCEPATH\n";
       
   487 					next LINE;
       
   488 				}
       
   489 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "BITMAP SOURCEPATH", $CurBitMapSrcPath, $LineNum, $CheckSource_PhysicalCheck);
       
   490 				$CurBitMapSrcPath = &Path_Norm($CurBitMapSrcPath);
       
   491 				
       
   492 				$CurBitMapSrcPath=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
   493 				$CurBitMapSrcPath=&Path_MakeAbs($CurFile,$CurBitMapSrcPath);
       
   494 				if (@$Line) {
       
   495 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for Bitmap keyword SOURCEPATH\n";
       
   496 				}
       
   497 				next LINE;
       
   498 			}
       
   499 			if (/^HEADER$/o) {
       
   500 				if ($CurBitMap{Hdr}) {
       
   501 					push @MmpWarn, "$CurFile($LineNum) : Bitmap HEADER already specified at line $CurBitMap{Hdr}\n";
       
   502 					next LINE;
       
   503 				}
       
   504 				$CurBitMap{Hdr}="$CurFile($LineNum)";
       
   505 				if (@$Line) {
       
   506 					push @MmpWarn, "$CurFile($LineNum) : Bitmap keyword HEADER takes no arguments\n";
       
   507 				}
       
   508 				next LINE;
       
   509 			}
       
   510 
       
   511 
       
   512 			if (/^TARGETPATH$/o) {
       
   513 				if ($CurBitMap{TrgPath}) {
       
   514 					push @MmpWarn, "$CurFile($LineNum) : Bitmap TARGETPATH already specified\n";
       
   515 					next LINE;
       
   516 				}
       
   517 				unless ($CurBitMap{TrgPath}=shift @$Line) {
       
   518 					push @MmpDie, "$CurFile($LineNum) : No path specified with Bitmap keyword TARGETPATH\n";
       
   519 					next LINE;
       
   520 				}
       
   521 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "BITMAP TARGETPATH", $CurBitMap{TrgPath}, $LineNum);
       
   522 				$CurBitMap{TrgPath} = &Path_Norm($CurBitMap{TrgPath});
       
   523 
       
   524 				$CurBitMap{TrgPath}=~s-^\\(.*)$-$1-o;        # remove leading backslash, if any
       
   525 				$CurBitMap{TrgPath}=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
   526 				$CurBitMap{TrgPath}="z\\$CurBitMap{TrgPath}";
       
   527 				if (@$Line) {
       
   528 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for Bitmap keyword TARGETPATH\n";
       
   529 				}
       
   530 				next LINE;
       
   531 			}
       
   532 			push @MmpWarn, "$CurFile($LineNum) : Unrecognised Bitmap Keyword \"$_\"\n";
       
   533 		}
       
   534 		
       
   535 		# ----------- handle body of START RESOURCE ... END -------------
       
   536 		if (%CurResource) {
       
   537 			if (/^END$/o) {
       
   538 				$CurResource{SrcPath}=$CurSrcPath;
       
   539 				my %Resource=%CurResource;
       
   540 				undef %CurResource;
       
   541 				push @ResourceStruct, \%Resource;
       
   542 				undef %ResourceCheckLang;
       
   543 				next LINE;
       
   544 			}
       
   545 			if (/^HEADER$/o) {
       
   546 				if ($CurResource{Hdr}) {
       
   547 					push @MmpWarn, "$CurFile($LineNum) : Resource HEADER already specified at line $CurResource{Hdr}\n";
       
   548 					next LINE;
       
   549 				}
       
   550 				elsif ($CurResource{Hdronly}) {
       
   551 					push @MmpWarn, "$CurFile($LineNum) : Resource HEADERONLY already specified at line $CurResource{Hdr}\n";
       
   552 					next LINE;
       
   553 				}
       
   554 				$CurResource{Hdr}="$CurFile($LineNum)";
       
   555 				if (@$Line) {
       
   556 					push @MmpWarn, "$CurFile($LineNum) : Resource keyword HEADER takes no arguments\n";
       
   557 				}
       
   558 				next LINE;
       
   559 			}
       
   560 			if (/^HEADERONLY$/o) {
       
   561 				if ($CurResource{Hdronly}) {
       
   562 					push @MmpWarn, "$CurFile($LineNum) : Resource HEADERONLY already specified at line $CurResource{Hdr}\n";
       
   563 					next LINE;
       
   564 				}
       
   565 				elsif ($CurResource{Hdr}) {
       
   566 					push @MmpWarn, "$CurFile($LineNum) : Resource HEADER already specified at line $CurResource{Hdr}\n";
       
   567 					next LINE;
       
   568 				}
       
   569 				$CurResource{Hdronly}="$CurFile($LineNum)";
       
   570 				if (@$Line) {
       
   571 					push @MmpWarn, "$CurFile($LineNum) : Resource keyword HEADERONLY takes no arguments\n";
       
   572 				}
       
   573 				next LINE;
       
   574 			}
       
   575 
       
   576 			if (/^LANG$/o) {
       
   577 				if (@$Line) {
       
   578 					my $Candidate;
       
   579 					foreach $Candidate (@$Line) {
       
   580 						if ($ResourceCheckLang{$Candidate}) {
       
   581 							push @MmpWarn, "$CurFile($LineNum) : Duplicate Language \"$Candidate\" at line $ResourceCheckLang{$Candidate}\n";
       
   582 							next; 
       
   583 						}
       
   584 						push @{$CurResource{Lang}}, $Candidate;
       
   585 						$ResourceCheckLang{$Candidate}="$CurFile($LineNum)";
       
   586 					}
       
   587 					next LINE;
       
   588 				}
       
   589 				push @MmpWarn, "$CurFile($LineNum) : No Languages specified for keyword LANG\n";
       
   590 				next LINE;
       
   591 			}
       
   592 			if (/^TARGET$/o) {
       
   593 				if ($CurResource{BaseTrg}) {
       
   594 					push @MmpWarn, "$CurFile($LineNum) : Resource TARGET already specified\n";
       
   595 					next LINE;
       
   596 				}
       
   597 			    my $src=shift @$Line;
       
   598 			    CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "RESOURCE TARGET", $src, $LineNum);
       
   599 			    
       
   600 			    $src = &Path_Norm($src);
       
   601 				$CurResource{BaseTrg}=&Path_Split('Base',$src);
       
   602 				unless ($CurResource{BaseTrg}) {
       
   603 					push @MmpDie, "$CurFile($LineNum) : No name specified with Resource keyword TARGET\n";
       
   604 					next LINE;
       
   605 				}
       
   606 				if (@$Line) {
       
   607 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for Resource keyword TARGET\n";
       
   608 				}
       
   609 				next LINE;
       
   610 			}
       
   611 			if (/^TARGETPATH$/o) {
       
   612 				if ($CurResource{TrgPath}) {
       
   613 					push @MmpWarn, "$CurFile($LineNum) : Resource TARGETPATH already specified\n";
       
   614 					next LINE;
       
   615 				}
       
   616 				unless ($CurResource{TrgPath}=shift @$Line) {
       
   617 					push @MmpDie, "$CurFile($LineNum) : No path specified with Resource keyword TARGETPATH\n";
       
   618 					next LINE;
       
   619 				}
       
   620 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "RESOURCE TARGETPATH", $CurResource{TrgPath}, $LineNum);
       
   621 				$CurResource{TrgPath} = &Path_Norm($CurResource{TrgPath});
       
   622 				
       
   623 				$CurResource{TrgPath}=~s-^\\(.*)$-$1-o;        # remove leading backslash, if any
       
   624 				$CurResource{TrgPath}=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
   625 				$CurResource{TrgPath}="z\\$CurResource{TrgPath}";
       
   626 				if (@$Line) {
       
   627 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for Resource keyword TARGETPATH\n";
       
   628 				}
       
   629 				next LINE;
       
   630 			}
       
   631 			if (/^UID$/o) {
       
   632 				if (@$Line) {
       
   633 					if (scalar @$Line>2) {
       
   634 						push @MmpWarn, "$CurFile($LineNum) : Can't specify more than 2 Uids\n";
       
   635 						next LINE;
       
   636 					}
       
   637 					foreach (@$Line) {
       
   638 						$_=&Genutl_AnyToHex($_);
       
   639 						if (defined $_) {
       
   640 							push @{$CurResource{Uids}}, $_;
       
   641 							next;
       
   642 						}
       
   643 						push @MmpDie, "$CurFile($LineNum) : Uid doesn't fit expected number format\n";
       
   644 						next LINE;
       
   645 					}
       
   646 					next LINE;
       
   647 				}
       
   648 				push @MmpWarn, "$CurFile($LineNum) : No Uids specified for Resource keyword UID\n";
       
   649 				next LINE;
       
   650 			}
       
   651 			if (/^DEPENDS$/o) {
       
   652 				# Note that DEPENDS lines are tolerated, but ignored - these are only relevant to build systems
       
   653 				# other than ABLD
       
   654 				next LINE;
       
   655 			}
       
   656 			
       
   657 			push @MmpWarn, "$CurFile($LineNum) : Unrecognised Resource Keyword \"$_\"\n";
       
   658 		}
       
   659 		if (/^WCHARENTRYPOINT$/o) {
       
   660 			if (@$Line) {
       
   661 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
   662 			}
       
   663 			if ($TrgType=~/^STDEXE$/io) {
       
   664 				$WideCharMain=1;	
       
   665 			}
       
   666 			else{
       
   667 				push @MmpWarn, "$CurFile($LineNum) : WCHARENTRYPOINT is supported only for Target Type STDEXE\n";
       
   668 			}
       
   669 			next LINE;
       
   670 		}
       
   671 		# ----------- handle body of START STRINGTABLE ... END -------------
       
   672 		if(%CurStringTable)
       
   673 		{	
       
   674 			if (/^END$/o) {
       
   675 				my %stringtable = %CurStringTable;
       
   676 				push @StringTableStruct, \%stringtable;
       
   677 				undef %CurStringTable;
       
   678 				next LINE;
       
   679 			}
       
   680 			if (/^EXPORTPATH/o) {
       
   681 				if (scalar @$Line != 1) {
       
   682 					push @MmpDie, "$CurFile($LineNum) : Wrong number of arguments for EXPORTPATH\n";
       
   683 				} 
       
   684 				if(defined $CurStringTable{ExportPath})	{
       
   685 					push @MmpDie, "$CurFile($LineNum) : Redefinition of EXPORTPATH\n";
       
   686 				}
       
   687 				else {
       
   688 				    my $src=shift @$Line;
       
   689 					$CurStringTable{ExportPath} = $src;
       
   690 
       
   691 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "STRINGTABLE EXPORTPATH", $CurStringTable{ExportPath}, $LineNum);
       
   692 					
       
   693 					$CurStringTable{ExportPath} = &Path_Norm($CurStringTable{ExportPath});					
       
   694 
       
   695 					$CurStringTable{ExportPath} =~ s/\\$//o;   # ensure path doesn't end with a backslash (cl_generic.pm will add one)
       
   696 					$CurStringTable{ExportPath} = &Path_MakeEAbs($EPOCPath,$CurFile,$CurStringTable{ExportPath});
       
   697 
       
   698 				}
       
   699 				next LINE;
       
   700 			}
       
   701 			if (/^HEADERONLY$/o) {
       
   702 				if ($CurStringTable{Hdronly}) {
       
   703 					push @MmpWarn, "$CurFile($LineNum) : Stringtable HEADERONLY already specified\n";
       
   704 					next LINE;
       
   705 				}
       
   706 				$CurStringTable{Hdronly}="$CurFile($LineNum)";
       
   707 				if (@$Line) {
       
   708 					push @MmpWarn, "$CurFile($LineNum) : Stringtable keyword HEADERONLY takes no arguments\n";
       
   709 				}
       
   710 				next LINE;
       
   711 			}
       
   712 		}
       
   713 		# ----------- handle top-level MMP file -------------------	
       
   714 		if (/^START$/) {
       
   715 			unless ($_=uc shift @$Line) {
       
   716 				push @MmpWarn, "$CurFile($LineNum) : No Argument specified for START block\n";
       
   717 				next LINE;
       
   718 			}
       
   719 			foreach $MmpMacro (@{$$Plat_ref{MmpMacros}}) {
       
   720 				if ($_ eq $MmpMacro) {
       
   721 					$PlatTxtSwitch="$CurFile($LineNum)";
       
   722 					next LINE;
       
   723 				}
       
   724 			}
       
   725 			if ($_ eq 'BITMAP') {
       
   726 				unless ($CurBitMap{Trg}=shift @$Line) {
       
   727 					push @MmpWarn, "$CurFile($LineNum) : No Bitmap Target specified\n";
       
   728 					$CurBitMap{Trg}='NoTargetSpecified';
       
   729 				}
       
   730 				if (@$Line) {
       
   731 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for START BITMAP clause\n";
       
   732 				}
       
   733 
       
   734 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "START BITMAP", $CurBitMap{Trg}, $LineNum);
       
   735 				$CurBitMap{Trg} = &Path_Norm($CurBitMap{Trg});
       
   736 				next LINE;
       
   737 			}
       
   738 			if ($_ eq 'RESOURCE') {
       
   739 				if (scalar @$Line != 1) {
       
   740 					push @MmpWarn, "$CurFile($LineNum) : Wrong number of arguments for START RESOURCE clause\n";
       
   741 				} 
       
   742 				else {
       
   743 				    my $src=shift @$Line;
       
   744 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "START RESOURCE", $src, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
   745 					$src = &Path_Norm($src);
       
   746 				    
       
   747 					$CurResource{Source}="$CurSrcPath$src";
       
   748 				}
       
   749 
       
   750 				
       
   751 				next LINE;
       
   752 			}
       
   753 			if ($_ eq 'STRINGTABLE') {
       
   754 				if (scalar @$Line != 1) {
       
   755 					push @MmpWarn, "$CurFile($LineNum) : Wrong number of arguments for START STRINGTABLE clause\n";
       
   756 				} 
       
   757 				else {
       
   758 				    my $Candidate = shift @$Line;
       
   759 				    CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "START STRINGTABLE", $Candidate, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
   760 					$Candidate = &Path_Norm($Candidate);
       
   761 				    
       
   762 					$Candidate =~ s/^\\//;	# remove leading \, if any	
       
   763 					$CurStringTable{BaseTrg}=&Path_Split('Base',$Candidate);
       
   764 					my $path=&Path_Split('Path',$Candidate);
       
   765 					if($path){
       
   766 					  $CurStringTable{STPath}=&Path_MakeAbs($CurSrcPath,&Path_Split('Path',$Candidate));
       
   767 					}
       
   768 					else {
       
   769 					  $CurStringTable{STPath}=$CurSrcPath;
       
   770 					}
       
   771 					$CurStringTable{STFile}=&Path_Split('File',$Candidate);
       
   772 
       
   773 				}
       
   774 				next LINE;
       
   775 			}
       
   776 			$OtherPlatSwitch="$CurFile($LineNum)";
       
   777 			next LINE;
       
   778 		}
       
   779 
       
   780 		if (/^AIF$/o) {
       
   781 			my ($trg, $dir, $file, $clDepth, @bitmaps)=@$Line;
       
   782 			unless ($file) { # bitmaps aren't essential
       
   783 				push @MmpDie, "$CurFile($LineNum) : Not enough arguments for keyword AIF\n";
       
   784 				next LINE;
       
   785 			}
       
   786 			my %Data;
       
   787 			$Data{Trg} = $trg;	# Defect: may include directory
       
   788 			$dir=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
   789 			$Data{Source}=&Path_MakeAbs($CurFile, "$dir$file");
       
   790 			unless (-e "$Data{Source}") {
       
   791 				push @MmpWarn, "$CurFile($LineNum) : AIF source \"$Data{Source}\" not found\n";
       
   792 			}
       
   793 			if ($CheckAif{$Data{Trg}}) {
       
   794 				push @MmpDie, "$CurFile($LineNum) : Duplicate Aif \"$Data{Trg}\" at line $CheckAif{$Data{Trg}}\n";
       
   795 				next LINE;
       
   796 			}
       
   797 			$CheckAif{$Data{Trg}}="$CurFile($LineNum)";
       
   798 			push @AifStruct, \%Data;
       
   799 			next LINE unless (@bitmaps);
       
   800 			# handle bitmaps
       
   801 			my @ClDepths = split(/,/, $clDepth);
       
   802 			foreach (@ClDepths) {
       
   803 				$_ = lc $_; # bmconv can't handle upper-case 'C's
       
   804 				unless (/^c?\d\d?$/o) {
       
   805 					push @MmpDie, "$CurFile($LineNum) : AIF color depth \"$_\" - unexpected format\n";
       
   806 				}
       
   807 			}
       
   808 			@ClDepths = (@ClDepths) x @bitmaps;	# make a sufficiently long list of color depths
       
   809 			foreach $file (@bitmaps) {
       
   810 				if ($file !~ /^\\/) {
       
   811 					$file = &Path_MakeAbs($CurFile, "$dir$file");
       
   812 				}
       
   813 				push @{$Data{BitMaps}}, { # sources must be kept in order
       
   814 					Src=>$file,
       
   815 					ClDepth=>shift @ClDepths	# take next color depth from the list
       
   816 				};
       
   817 				unless (-e $file) {
       
   818 					push @MmpWarn, "$CurFile($LineNum) : AIF source \"$file\" not found\n";
       
   819 				}
       
   820 			}
       
   821 			next LINE;
       
   822 		}
       
   823 		if (/^ASSPABI$/o) {
       
   824 			if (@$Line) {
       
   825 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
   826 			}
       
   827 			$ASSPABISwitch=1;
       
   828 			next LINE;
       
   829 		}
       
   830 		if (/^ASSPEXPORTS$/o) {
       
   831 			if (@$Line) {
       
   832 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
   833 			}
       
   834 			$ASSPExports=1;
       
   835 			next LINE;
       
   836 		}
       
   837 		if (/^ASSPLIBRARY$/o) {
       
   838 			if (@$Line) {
       
   839 				my $Candidate;
       
   840 				foreach $Candidate (@$Line) {
       
   841 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum);
       
   842 					$Candidate = &Path_Norm($Candidate);
       
   843 					
       
   844 					unless ($emulator or &Genutl_ParseVersionedName(\$Candidate)) {
       
   845 						push @MmpWarn, "$CurFile($LineNum) : Bad version in ASSPLIBRARY\n";
       
   846 					}
       
   847 					if ($CheckASSPLib{$Candidate}) {
       
   848 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Library \"$Candidate\" at line $CheckASSPLib{$Candidate}\n";
       
   849 						next; 
       
   850 					}
       
   851 					
       
   852 					push @ASSPLibList, $Candidate;
       
   853 					$CheckASSPLib{$Candidate}="$CurFile($LineNum)";
       
   854 				}
       
   855 				next LINE;
       
   856 			}
       
   857 			push @MmpWarn, "$CurFile($LineNum) : No Libraries specified for keyword ASSPLIBRARY\n";
       
   858 			next LINE;
       
   859 		}
       
   860 		if (/^CAPABILITY$/o) {
       
   861 			if (defined($Capability)) {
       
   862 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine CAPABILITY\n";
       
   863 				next LINE;
       
   864 			}
       
   865 			if (scalar @$Line == 0) {
       
   866 				push @MmpWarn, "$CurFile($LineNum) : Wrong number of arguments for CAPABILITY\n";
       
   867 				next LINE;
       
   868 			}
       
   869 			foreach my $capname (@$Line) {
       
   870 				my $invert = 0;
       
   871 				if ($capname =~ /^-(\w*)/) {
       
   872 					$invert = 0xffffffff;
       
   873 					$capname = $1;
       
   874 				}
       
   875 				my $capFlag = 0;
       
   876 				if (defined($CapabilityNames{uc $capname})) {
       
   877 					$capFlag = $CapabilityNames{uc $capname};
       
   878 					if (not $capFlag) {
       
   879 						push @MmpDiagnostic, "$CurFile($LineNum) : Use of old capability name, \"$capname\" ignored\n";
       
   880 						next;
       
   881 					}
       
   882 					if ("ALL" eq uc $capname and $invert) {
       
   883 						push @MmpWarn, "Capability '-ALL' not allowed";
       
   884 						next;
       
   885 					}
       
   886 				}
       
   887 				elsif ("NONE" eq uc $capname) {
       
   888 					if($invert) {
       
   889 						push @MmpWarn, "Capability '-NONE' not allowed";
       
   890 						next;
       
   891 					}
       
   892 				}
       
   893 				else {
       
   894 					push @MmpWarn, "$CurFile($LineNum) : Unknown capability \"$capname\" ignored\n";
       
   895 					next;
       
   896 				}
       
   897 				# append name to capability string
       
   898 				if (defined($Capability) and not $invert) { $Capability .= "+"; }
       
   899 				if($invert) { $Capability .= "-"; }
       
   900 				$Capability .= $capname;
       
   901 
       
   902 				# add capability mask to flags
       
   903 				$CapabilityFlags[0] = $CapabilityFlags[0] ^ $invert;
       
   904 				$CapabilityFlags[0] = $CapabilityFlags[0] | $capFlag;
       
   905 				$CapabilityFlags[0] = $CapabilityFlags[0] ^ $invert;
       
   906 				$CapabilityFlags[1] = 0;
       
   907 				next;
       
   908 			}
       
   909 			next LINE;
       
   910 		}
       
   911 		if (/^DEBUGLIBRARY$/o) {
       
   912 			if (@$Line) {
       
   913 				my $Candidate;
       
   914 				foreach $Candidate (@$Line) {
       
   915 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum);
       
   916 					$Candidate = &Path_Norm($Candidate);
       
   917 					
       
   918 					unless ($emulator or &Genutl_ParseVersionedName(\$Candidate)) {
       
   919 						push @MmpWarn, "$CurFile($LineNum) : Bad version in DEBUGLIBRARY\n";
       
   920 					}
       
   921 					if ($CheckLib{$Candidate}) {
       
   922 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Library \"$Candidate\" at line $CheckLib{$Candidate}\n";
       
   923 						next; 
       
   924 					}
       
   925 					
       
   926 					push @DebugLibList, $Candidate;
       
   927 					$CheckLib{$Candidate}="$CurFile($LineNum)";
       
   928 				}
       
   929 				next LINE;
       
   930 			}
       
   931 			push @MmpWarn, "$CurFile($LineNum) : No Libraries specified for keyword DEBUGLIBRARY\n";
       
   932 			next LINE;
       
   933 		}
       
   934 		if (/^DEFFILE$/o)  {
       
   935 			if ($CheckDef) {
       
   936 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine DEFFILE\n";
       
   937 				next LINE;
       
   938 			}
       
   939 			$CheckDef=1;
       
   940 			unless ($_=shift @$Line) {
       
   941 				push @MmpWarn, "$CurFile($LineNum) : No file specified for keyword DEFFILE\n";
       
   942 				next LINE;
       
   943 			}
       
   944 
       
   945 			$Def{CheckSource_MMPEntry} = $_;		
       
   946 			$Def{CheckSource_LineNumber} = $LineNum;
       
   947 			$Def{CheckSource_MMPFile} = $CurFile;
       
   948 			
       
   949 			$_ = &Path_Norm($_);
       
   950 			
       
   951 			$Def{Base}=&Path_Split('Base',$_);
       
   952 			$Def{Ext}=&Path_Split('Ext',$_);
       
   953 			$Def{Path}=&Path_Split('Path',$_);
       
   954 			
       
   955 			if ($Def{Path}) {
       
   956 				$Def{Path}=&Path_MakeEAbs($EPOCPath,$CurFile,$Def{Path});
       
   957 			}
       
   958 
       
   959 			if ($Def{Base} =~ /\{|\}/) {
       
   960 				push @MmpDie, "$CurFile($LineNum) : Bad DEFFILE name\n";
       
   961 			}
       
   962 			next LINE;
       
   963 		}
       
   964 		if (/^DOCUMENT$/o) {
       
   965 			if (@$Line) {
       
   966 				my $Candidate;
       
   967 				foreach $Candidate (@$Line) {
       
   968 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
   969 					$Candidate = &Path_Norm($Candidate);
       
   970 					
       
   971 					if ($CheckDoc{"$CurSrcPath$Candidate"}) {
       
   972 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Document \"$CurSrcPath$Candidate\" at line ", $CheckDoc{"$CurSrcPath$Candidate"}, "\n";
       
   973 						next; 
       
   974 					}
       
   975 					unless (-e "$CurSrcPath$Candidate") {
       
   976 						push @MmpWarn, "$CurFile($LineNum) : DOCUMENT \"$CurSrcPath$Candidate\" not found\n";
       
   977 					}
       
   978 					
       
   979 					push @{$DocHash{$CurSrcPath}}, $Candidate;
       
   980 					$CheckDoc{"$CurSrcPath$Candidate"}="$CurFile($LineNum)";
       
   981 				}
       
   982 				next LINE;
       
   983 			}
       
   984 			push @MmpWarn, "$CurFile($LineNum) : No Files specified for keyword DOCUMENT\n";
       
   985 			next LINE;
       
   986 		}
       
   987 		if (/^EPOCALLOWDLLDATA$/o) {
       
   988 			if (@$Line) {
       
   989 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
   990 			}
       
   991 			$AllowDllData=1;
       
   992 			next LINE;
       
   993 		}
       
   994 		if (/^ALWAYS_BUILD_AS_ARM$/o) {
       
   995 			if (@$Line) {
       
   996 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
   997 			}
       
   998 			$BuildAsARM=1;
       
   999 			next LINE;
       
  1000 		}
       
  1001 		if (/^EPOCCALLDLLENTRYPOINTS$/o) {
       
  1002 			if (@$Line) {
       
  1003 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1004 			}
       
  1005 			$CallDllEntryPoints=1;
       
  1006 			next LINE;
       
  1007 		}
       
  1008 		if (/^EPOCDATALINKADDRESS$/o) {
       
  1009 			if (@$Line) { 
       
  1010 				my $temp=&main::Genutl_AnyToHex(shift @$Line);
       
  1011 				if (defined $temp) {
       
  1012 					$DataLinkAddress=$temp;
       
  1013 					next LINE;
       
  1014 				}
       
  1015 				push @MmpDie, "$CurFile($LineNum) : Data link address doesn't fit expected number format\n";
       
  1016 			}
       
  1017 			push @MmpWarn, "$CurFile($LineNum) : No data link address specified for keyword $_\n";
       
  1018 			next LINE;
       
  1019 		}
       
  1020 		if (/^EPOCFIXEDPROCESS$/o) {
       
  1021 			if (@$Line) {
       
  1022 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1023 			}
       
  1024 			$FixedProcess=1;
       
  1025 			next LINE;
       
  1026 		}
       
  1027 		if (/^EPOCHEAPSIZE$/o) {
       
  1028 			if (@$Line) {
       
  1029 				my $tempMin=&main::Genutl_AnyToHex(shift @$Line);
       
  1030 				if (defined $tempMin) {
       
  1031 					if (@$Line) {
       
  1032 						my $tempMax=&main::Genutl_AnyToHex(shift @$Line);
       
  1033 						if (defined $tempMax) {
       
  1034 							$HeapSize{Min}=$tempMin;
       
  1035 							$HeapSize{Max}=$tempMax;
       
  1036 							next LINE;
       
  1037 						}
       
  1038 						push @MmpDie, "$CurFile($LineNum) : maximum heap size doesn't fit expected number format\n";
       
  1039 						next LINE;
       
  1040 					}
       
  1041 					push @MmpDie, "$CurFile($LineNum) : No maximum heap size specified for keyword $_\n";
       
  1042 					next LINE;
       
  1043 				}
       
  1044 				push @MmpDie, "$CurFile($LineNum) : minimum heap size doesn't fit expected number format\n";
       
  1045 				next LINE;
       
  1046 			}
       
  1047 			push @MmpWarn, "$CurFile($LineNum) : No minimum heap size specified for keyword $_\n";
       
  1048 			next LINE;
       
  1049 		}
       
  1050 		if (/^EPOCPROCESSPRIORITY$/o) {
       
  1051 			if ($ProcessPriority) {
       
  1052 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine EPOCPROCESSPRIORITY\n";
       
  1053 				next LINE;
       
  1054 			}
       
  1055 			if ($ProcessPriority=shift @$Line) {
       
  1056 				if (defined($ProcessPriorityNames{uc $ProcessPriority})) {
       
  1057 					$ProcessPriority = $ProcessPriorityNames{uc $ProcessPriority}; # canonical form
       
  1058 					next LINE;
       
  1059 				}
       
  1060 				push @MmpDie, "$CurFile($LineNum) : ProcessPriority \"$ProcessPriority\" not supported\n";
       
  1061 				next LINE;
       
  1062 			}
       
  1063 			push @MmpWarn, "$CurFile($LineNum) : No Priority specified for keyword EPOCPROCESSPRIORITY\n";
       
  1064 			next LINE;
       
  1065 		}
       
  1066 		if (/^EPOCSTACKSIZE$/o) {
       
  1067 			if (@$Line) {
       
  1068 				my $temp=&main::Genutl_AnyToHex(shift @$Line);
       
  1069 				if (defined $temp) {
       
  1070 					$StackSize=$temp;
       
  1071 					next LINE;
       
  1072 				}
       
  1073 				push @MmpDie, "$CurFile($LineNum) : Stack size doesn't fit expected number format\n";
       
  1074 				next LINE;
       
  1075 			}
       
  1076 			push @MmpWarn, "$CurFile($LineNum) : No stack size specified for keyword STACKSIZE\n";
       
  1077 			next LINE;
       
  1078 		}
       
  1079 		if (/^COMPRESSTARGET$/o) {
       
  1080 			if (@$Line) {
       
  1081 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1082 			}
       
  1083 			$CompressTarget=COMPRESS;
       
  1084             $CompressTargetMethod=NOCOMPRESSIONMETHOD; # means 'use default'
       
  1085 			next LINE;
       
  1086 		}
       
  1087 		if (/^NOCOMPRESSTARGET$/o) {
       
  1088 			if (@$Line) {
       
  1089 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1090 			}
       
  1091 			$CompressTarget=NOCOMPRESS;
       
  1092             $CompressTargetMethod=NOCOMPRESSIONMETHOD;
       
  1093 			next LINE;
       
  1094 		}
       
  1095         if (/^INFLATECOMPRESSTARGET$/o) {
       
  1096 			if (@$Line) {
       
  1097 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1098 			}
       
  1099             $CompressTarget=COMPRESS;
       
  1100 			$CompressTargetMethod=INFLATECOMPRESSIONMETHOD;
       
  1101 			next LINE;
       
  1102 		}
       
  1103 		if (/^BYTEPAIRCOMPRESSTARGET$/o) {
       
  1104 			if (@$Line) {
       
  1105 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1106 			}
       
  1107             $CompressTarget=COMPRESS;
       
  1108 			$CompressTargetMethod=BYTEPAIRCOMPRESSIONMETHOD;
       
  1109 			next LINE;
       
  1110 		}
       
  1111 		if (/^EXPORTUNFROZEN$/o) {
       
  1112 			if (@$Line) {
       
  1113 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1114 			}
       
  1115 			$ExportUnfrozen=1;
       
  1116 			next LINE;
       
  1117 		}
       
  1118 		if (/^FIRSTLIB$/o) {
       
  1119 			if ($FirstLib) {
       
  1120 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine FIRSTLIB\n";
       
  1121 				next LINE;
       
  1122 			}
       
  1123 			if ($FirstLib=shift @$Line) {
       
  1124 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $FirstLib, $LineNum);
       
  1125 				$FirstLib = &Path_Norm($FirstLib);
       
  1126 				next LINE;
       
  1127 			}
       
  1128 			
       
  1129 			push @MmpWarn, "$CurFile($LineNum) : Nothing specified for keyword FIRSTLIB\n";
       
  1130 			next LINE;
       
  1131 		}
       
  1132 		if (/^LANG$/o) {
       
  1133 			if (@$Line) {
       
  1134 				my $Candidate;
       
  1135 				foreach $Candidate (@$Line) {
       
  1136 					if ($CheckLang{$Candidate}) {
       
  1137 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Language \"$Candidate\" at line $CheckLang{$Candidate}\n";
       
  1138 						next; 
       
  1139 					}
       
  1140 					push @LangList, $Candidate;
       
  1141 					$CheckLang{$Candidate}="$CurFile($LineNum)";
       
  1142 				}
       
  1143 				next LINE;
       
  1144 			}
       
  1145 			push @MmpWarn, "$CurFile($LineNum) : No Languages specified for keyword LANG\n";
       
  1146 			next LINE;
       
  1147 		}
       
  1148 		if (/^LIBRARY$/o) {
       
  1149 			if (@$Line) {
       
  1150 				my $Candidate;
       
  1151 				foreach $Candidate (@$Line) {
       
  1152 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum);
       
  1153 					$Candidate = &Path_Norm($Candidate);
       
  1154 					
       
  1155 					unless ($emulator or &Genutl_ParseVersionedName(\$Candidate)) {
       
  1156 						push @MmpWarn, "$CurFile($LineNum) : Bad version in LIBRARY\n";
       
  1157 					}
       
  1158 					if ($CheckLib{$Candidate}) {
       
  1159 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Library \"$Candidate\" at line $CheckLib{$Candidate}\n";
       
  1160 						next; 
       
  1161 					}
       
  1162 					
       
  1163 					push @LibList, $Candidate;
       
  1164 					push @DebugLibList, $Candidate;	    # appears in both
       
  1165 					$CheckLib{$Candidate}="$CurFile($LineNum)";
       
  1166 				}
       
  1167 				next LINE;
       
  1168 			}
       
  1169 			push @MmpWarn, "$CurFile($LineNum) : No Libraries specified for keyword LIBRARY\n";
       
  1170 			next LINE;
       
  1171 		}
       
  1172 		if (/^LINKAS$/o) {
       
  1173 			if ($LinkAs) {
       
  1174 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine LINKAS\n";
       
  1175 				next LINE;
       
  1176 			}
       
  1177 			if ($LinkAs=shift @$Line) {
       
  1178 				next LINE;
       
  1179 			}
       
  1180 			push @MmpWarn, "$CurFile($LineNum) : No name specified for keyword LINKAS\n";
       
  1181 			next LINE;
       
  1182 		}
       
  1183 		if (/^EXPORTLIBRARY$/o) {
       
  1184 			if ($NoExportLibrary) {
       
  1185 				push @MmpDie, "$CurFile($LineNum) : Can't specify both EXPORTLIBRARY and NOEXPORTLIBRARY\n";
       
  1186 				next LINE;
       
  1187 			}
       
  1188 			if ($ExportLibrary) {
       
  1189 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine EXPORTLIBRARY\n";
       
  1190 				next LINE;
       
  1191 			}
       
  1192 			if ($ExportLibrary=shift @$Line) {
       
  1193 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $ExportLibrary, $LineNum);
       
  1194 				$ExportLibrary = &Path_Norm($ExportLibrary);
       
  1195 				$ExportLibrary=&Path_Split('Base',$ExportLibrary);
       
  1196 				next LINE;
       
  1197 			}
       
  1198 			push @MmpWarn, "$CurFile($LineNum) : No name specified for keyword EXPORTLIBRARY\n";
       
  1199 			next LINE;
       
  1200 		}
       
  1201 		if (/^NOEXPORTLIBRARY$/o) {
       
  1202 			if ($ExportLibrary) {
       
  1203 				push @MmpDie, "$CurFile($LineNum) : Can't specify both EXPORTLIBRARY and NOEXPORTLIBRARY\n";
       
  1204 				next LINE;
       
  1205 			}
       
  1206 			$NoExportLibrary = 1;
       
  1207 			next LINE;
       
  1208 		}
       
  1209 		if (/^NEWLIB$/o) {
       
  1210 			if ($NewLib) {
       
  1211 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine NEWLIB\n";
       
  1212 				next LINE;
       
  1213 			}
       
  1214 			if ($NewLib = shift @$Line) {
       
  1215 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $NewLib, $LineNum);
       
  1216 				$NewLib = &Path_Norm($NewLib);
       
  1217 				next LINE;
       
  1218 			}
       
  1219 			push @MmpWarn, "$CurFile($LineNum) : No library specified for keyword NEWLIB\n";
       
  1220 			next LINE;
       
  1221 		}
       
  1222 		if (/^MACRO$/o) {
       
  1223 			if (@$Line) {
       
  1224 				my $Candidate;
       
  1225 				foreach $Candidate (@$Line) {
       
  1226 					if ($CheckMacro{$Candidate}) {
       
  1227 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Macro \"$Candidate\" at line $CheckMacro{$Candidate}\n";
       
  1228 						next; 
       
  1229 					}
       
  1230 					push @Macros, $Candidate;
       
  1231 					$CheckMacro{$Candidate}="$CurFile($LineNum)";
       
  1232 				}
       
  1233 				next LINE;
       
  1234 			}
       
  1235 			next LINE; 
       
  1236 		}
       
  1237 		if (/^NOSTRICTDEF$/o) {
       
  1238 			if ($NoStrictDef) {
       
  1239 				push @MmpWarn, "$CurFile($LineNum) : NOSTRICTDEF already set\n";
       
  1240 				next LINE;
       
  1241 			}
       
  1242 			if (@$Line) {
       
  1243 				push @MmpWarn, "$CurFile($LineNum) : Keyword NOSTRICTDEF takes no arguments\n";
       
  1244 			}
       
  1245 			$NoStrictDef=1;
       
  1246 			next LINE;
       
  1247 		}
       
  1248 		if (/^RAMTARGET$/o) {
       
  1249 			if ($CheckRamTargets) {
       
  1250 				push @MmpWarn, "$CurFile($LineNum) : RAM targets already specified at line $CheckRamTargets\n";
       
  1251 				next LINE;
       
  1252 			}
       
  1253 			$CheckRamTargets="$CurFile($LineNum)";
       
  1254 			unless (@$Line) {
       
  1255 				push @MmpWarn, "$CurFile($LineNum) : No targets specified for keyword RAMTARGET\n";
       
  1256 				next LINE;
       
  1257 			}
       
  1258 			if ($$Line[0] eq '+') {
       
  1259 				my %Data=();
       
  1260 				push @RamTargets, \%Data;	# include default
       
  1261 				shift @$Line;
       
  1262 			}
       
  1263 			my $Elem;
       
  1264 			foreach $Elem (@$Line) {
       
  1265 				my %Data=();
       
  1266 				$Data{File}=&Path_Split('File',$Elem);
       
  1267 				$Data{Path}=&Path_Split('Path',$Elem);
       
  1268 				push @RamTargets, \%Data;
       
  1269 			}
       
  1270 			next LINE;
       
  1271 		}
       
  1272 		if (/^RESOURCE$/o) {
       
  1273 			if (@$Line) {
       
  1274 				my $Candidate;
       
  1275 				foreach $Candidate (@$Line) {			
       
  1276 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
  1277 					$Candidate = &Path_Norm($Candidate);
       
  1278 					
       
  1279 					if ($CheckResrc{$Candidate}) {
       
  1280 						push @MmpDie, "$CurFile($LineNum) : Duplicate Resource $Candidate at line $CheckResrc{$Candidate}\n";
       
  1281 						next;
       
  1282 					}
       
  1283 					
       
  1284 					$CheckResrc{$Candidate}="$CurFile($LineNum)";
       
  1285 					my $source="$CurSrcPath$Candidate";
       
  1286 					unless (-e $source) {
       
  1287 						push @MmpWarn, "$CurFile($LineNum) : RESOURCE source \"$source\" not found\n";
       
  1288 					}
       
  1289 					
       
  1290 					$CurResource{BaseTrg}=&Path_Split('Base',$Candidate);
       
  1291 					$CurResource{Source}=$source;
       
  1292 					$CurResource{Hdr}="$CurFile($LineNum)";
       
  1293 					# $CurResource{TrgPath} will be filled in at the end;
       
  1294 					my %Resource=%CurResource;
       
  1295 					undef %CurResource;
       
  1296 					push @ResourceStruct, \%Resource;
       
  1297 				}
       
  1298 				next LINE;
       
  1299 			}
       
  1300 			push @MmpWarn, "$CurFile($LineNum) : No Resources specified for keyword RESOURCE\n";
       
  1301 			next LINE; 
       
  1302 		}
       
  1303 		if (/^ROMTARGET$/o) {
       
  1304 			if ($CheckRomTargets) {
       
  1305 				push @MmpWarn, "$CurFile($LineNum) : ROM targets already specified at line $CheckRomTargets\n";
       
  1306 				next LINE;
       
  1307 			}
       
  1308 			$CheckRomTargets="$CurFile($LineNum)";
       
  1309 			unless (@$Line) {
       
  1310 				@RomTargets=();
       
  1311 				next LINE;
       
  1312 			}
       
  1313 			if ($$Line[0] eq '+') {
       
  1314 				shift @$Line;
       
  1315 			}
       
  1316 			else {
       
  1317 				@RomTargets=(); # remove default
       
  1318 			}
       
  1319 			my $Elem;
       
  1320 			foreach $Elem (@$Line) {
       
  1321 				my %Data=();
       
  1322 				$Data{File}=&Path_Split('File',$Elem);
       
  1323 				$Data{Path}=&Path_Split('Path',$Elem);
       
  1324 				push @RomTargets, \%Data;
       
  1325 			}
       
  1326 			next LINE;
       
  1327 		}
       
  1328 		if (/^SMPSAFE$/o) {
       
  1329 			if (@$Line) {
       
  1330 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1331 			}
       
  1332 			$SmpSafe = 1;
       
  1333 			next LINE;
       
  1334 		}
       
  1335 		if (/^SOURCE$/o) {
       
  1336 			if (@$Line) {
       
  1337 				my $Candidate;
       
  1338 				foreach $Candidate (@$Line) {
       
  1339 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
  1340 					$Candidate = &Path_Norm($Candidate);
       
  1341 					
       
  1342 					$Candidate =~ s/^\\//;	# remove leading \, if any	
       
  1343 					$CurSource{BaseTrg}=&Path_Split('Base',$Candidate);
       
  1344 					my $path=&Path_Split('Path',$Candidate);
       
  1345 					if($path){
       
  1346 					  $CurSource{SrcPath}=&Path_MakeAbs($CurSrcPath,&Path_Split('Path',$Candidate));
       
  1347 					}
       
  1348 					else {
       
  1349 					  $CurSource{SrcPath}=$CurSrcPath;
       
  1350 					}
       
  1351 					$CurSource{CurFile}=&Path_Split('File',$Candidate);
       
  1352 
       
  1353 					my %Source=%CurSource;
       
  1354 					undef %CurSource;
       
  1355 					push @SourceStruct, \%Source;
       
  1356 					
       
  1357 				}
       
  1358 				next LINE;
       
  1359 			}
       
  1360 			push @MmpWarn, "$CurFile($LineNum) : No Sources specified for keyword SOURCE\n";
       
  1361 			next LINE; 
       
  1362 		}
       
  1363 		if (/^SOURCEPATH$/o) {
       
  1364 			if ($CurSrcPath=shift @$Line) {
       
  1365 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $CurSrcPath, $LineNum, $CheckSource_PhysicalCheck);				
       
  1366 				$CurSrcPath = &Path_Norm($CurSrcPath);
       
  1367 				
       
  1368 				$CurSrcPath=~s-^(.*[^\\])$-$1\\-o;	# in case no terminating backslash
       
  1369 				$CurSrcPath=&Path_MakeEAbs($EPOCPath,$CurFile,$CurSrcPath);
       
  1370 				if (-d &Path_Chop($CurSrcPath)) {
       
  1371 					next LINE;
       
  1372 				}
       
  1373 				push @MmpWarn, "$CurFile($LineNum) : SOURCEPATH \"$CurSrcPath\" not found\n";
       
  1374 				next LINE;
       
  1375 			}
       
  1376 			push @MmpDie, "$CurFile($LineNum) : No Source Path specified for keyword SOURCEPATH\n";
       
  1377 			next LINE;
       
  1378 		}
       
  1379 		if (/^STATICLIBRARY$/o) {
       
  1380 			if (@$Line) {
       
  1381 				my $Candidate;
       
  1382 				foreach $Candidate (@$Line) {
       
  1383 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum);
       
  1384 					$Candidate = &Path_Norm($Candidate);
       
  1385 					
       
  1386 					if ($CheckStatLib{$Candidate}) {
       
  1387 						push @MmpWarn, "$CurFile($LineNum) : Duplicate Library \"$Candidate\" at line $CheckStatLib{$Candidate}\n";
       
  1388 						next;
       
  1389 					}
       
  1390 					
       
  1391 					push @StatLibList, $Candidate;
       
  1392 					$CheckStatLib{$Candidate}="$CurFile($LineNum)";
       
  1393 				}
       
  1394 				next LINE;
       
  1395 			}
       
  1396 			push @MmpWarn, "$CurFile($LineNum) : No Libraries specified for keyword STATICLIBRARY\n";
       
  1397 			next LINE;
       
  1398 		}
       
  1399 		if (/^STDCPP$/o) {
       
  1400 			if (@$Line) {
       
  1401 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1402 			}
       
  1403 			$StdCpp=1;
       
  1404 			next LINE;
       
  1405 		}
       
  1406   		if (/^NOSTDCPP$/o) {
       
  1407   			if (@$Line) {
       
  1408   				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1409   			}
       
  1410   			$NoStdCpp=1;
       
  1411   			next LINE;
       
  1412   		}
       
  1413 		if (/^STRICTDEPEND$/o) {
       
  1414 			if ($MmpFlag{StrictDepend}) {
       
  1415 				push @MmpWarn, "$CurFile($LineNum) : STRICTDEPEND already set\n";
       
  1416 				next LINE;
       
  1417 			}
       
  1418 			if (@$Line) {
       
  1419 				push @MmpWarn, "$CurFile($LineNum) : Keyword STRICTDEPEND takes no arguments\n";
       
  1420 			}
       
  1421 			$MmpFlag{StrictDepend}=1;
       
  1422 			next LINE;
       
  1423 		}
       
  1424 		if (/^SYSTEMINCLUDE$/o){
       
  1425 			if (@$Line) {
       
  1426 				my $Candidate;
       
  1427 				foreach $Candidate (@$Line) {
       
  1428 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck);
       
  1429 					$Candidate = &Path_Norm($Candidate);
       
  1430 					
       
  1431 					$Candidate=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
  1432 					$Candidate=&Path_MakeEAbs($EPOCPath,$CurFile,$Candidate);
       
  1433 					if ($CheckSysInc{$Candidate}) {
       
  1434 						next; 
       
  1435 					}
       
  1436 					push @SysIncPaths,$Candidate;
       
  1437 					$CheckSysInc{$Candidate}="$CurFile($LineNum)";
       
  1438 					if (-d &Path_Chop($Candidate)) {
       
  1439 						next;
       
  1440 					}
       
  1441 					push @MmpWarn, "$CurFile($LineNum) : SYSTEMINCLUDE path \"$Candidate\" not found\n";
       
  1442 				}
       
  1443 				next LINE;
       
  1444 			}
       
  1445 			push @MmpWarn, "$CurFile($LineNum) : No Paths specified for keyword SYSTEMINCLUDE\n";
       
  1446 			next LINE;
       
  1447 		}
       
  1448 		if (/^SYSTEMRESOURCE$/o) {
       
  1449 			if (@$Line) {
       
  1450 				my $Candidate;
       
  1451 				foreach $Candidate (@$Line) {
       
  1452 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck, $CurSrcPath);
       
  1453 					$Candidate = &Path_Norm($Candidate);
       
  1454 					
       
  1455 					if ($CheckSysResrc{$Candidate}) {
       
  1456 						push @MmpDie, "$CurFile($LineNum) : Duplicate Resource \"$Candidate\" at line $CheckSysResrc{$Candidate}\n";
       
  1457 						next; 
       
  1458 					}
       
  1459 					$CheckSysResrc{$Candidate}="$CurFile($LineNum)";
       
  1460 					my $source="$CurSrcPath$Candidate";
       
  1461 					unless (-e $source) {
       
  1462 						push @MmpWarn, "$CurFile($LineNum) : SYSTEMRESOURCE source \"$source\" not found\n";
       
  1463 					}
       
  1464 					$CurResource{BaseTrg}=&Path_Split('Base',$Candidate);
       
  1465 					$CurResource{Source}=$source;
       
  1466 					$CurResource{Hdr}="$CurFile($LineNum)";
       
  1467 					$CurResource{TrgPath}="z\\system\\data\\";	# needs to match e32env.pm
       
  1468 					my %Resource=%CurResource;
       
  1469 					undef %CurResource;
       
  1470 					push @ResourceStruct, \%Resource;
       
  1471 				}
       
  1472 				if (&main::EPOCSecurePlatform()) {    
       
  1473 					push @MmpMigrationNote, "Obsolete SYSTEMRESOURCE keyword specified in \"$MMPFILE\"";
       
  1474 				}
       
  1475 				next LINE;
       
  1476 			}
       
  1477 			push @MmpWarn, "$CurFile($LineNum) : No Resources specified for keyword SYSTEMRESOURCE\n";
       
  1478 			next LINE; 
       
  1479 		}
       
  1480 		if (/^TARGET$/o) {
       
  1481 			if ($Trg) {
       
  1482 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine TARGET\n";
       
  1483 				next LINE;
       
  1484 			}
       
  1485 			if ($Trg=shift @$Line) {
       
  1486 				CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Trg, $LineNum);
       
  1487 				$Trg = &Path_Norm($Trg);
       
  1488 				next LINE;
       
  1489 			}
       
  1490 			push @MmpWarn, "$CurFile($LineNum) : No Target specified for keyword TARGET\n";
       
  1491 			next LINE;
       
  1492 		}
       
  1493 		if (/^TARGETPATH$/o) {
       
  1494 			if ($TrgPath) {
       
  1495 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine TARGETPATH\n";
       
  1496 				next LINE;
       
  1497 			}
       
  1498 			unless ($TrgPath=shift @$Line) {
       
  1499 				push @MmpWarn, "$CurFile($LineNum) : No Path specified for keyword TARGETPATH\n";
       
  1500 				next LINE;
       
  1501 			}
       
  1502 
       
  1503 			CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $TrgPath, $LineNum);
       
  1504 			$TrgPath = &Path_Norm($TrgPath);
       
  1505 			
       
  1506 			$TrgPath=~s-^\\(.*)$-$1-o;
       
  1507 			$TrgPath=~s-^(.*[^\\])$-$1\\-o;
       
  1508 			$TrgPath="z\\$TrgPath";
       
  1509 			if (@$Line) {
       
  1510 				push @MmpWarn, "$CurFile($LineNum) : Too many arguments for keyword TARGETPATH\n";
       
  1511 			}
       
  1512 			next LINE;
       
  1513 		}
       
  1514 		if (/^TARGETTYPE$/o) {
       
  1515 			if ($TrgType) {
       
  1516 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine TARGETTYPE\n";
       
  1517 				next LINE;
       
  1518 			}
       
  1519 			unless ($TrgType=shift @$Line) {
       
  1520 				push @MmpWarn, "$CurFile($LineNum) : No Type specified for keyword TARGETTYPE\n";
       
  1521 				next LINE;
       
  1522 			}
       
  1523 			eval { &Trg_GetL($TrgType, \%TrgType); };
       
  1524 			if ($@) {
       
  1525 				push @MmpDie, "$CurFile($LineNum) : $@";
       
  1526 			}
       
  1527 			next LINE;
       
  1528 		}
       
  1529 		if (/^UID$/o) {
       
  1530 			if (@$Line) {
       
  1531 				foreach (@$Line) {
       
  1532 					if ($#UidList>=1) {
       
  1533 						push @MmpWarn, "$CurFile($LineNum) : Can't specify more than 2 Uids\n";
       
  1534 						next LINE;
       
  1535 					}
       
  1536 					$_=&Genutl_AnyToHex($_);
       
  1537 					if (defined $_) {
       
  1538 						push @UidList, $_;
       
  1539 						next;
       
  1540 					}
       
  1541 					push @MmpDie, "$CurFile($LineNum) : Uid doesn't fit expected number format\n";
       
  1542 					next LINE;
       
  1543 				}
       
  1544 				next LINE;
       
  1545 			}
       
  1546 			push @MmpWarn, "$CurFile($LineNum) : No Uids specified for keyword UID\n";
       
  1547 			next LINE;
       
  1548 		}
       
  1549 		if (/^SECUREID$/o) {
       
  1550 			if ($SecureId) {
       
  1551 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine SECUREID\n";
       
  1552 				next LINE;
       
  1553 			}
       
  1554 			if (@$Line) {
       
  1555 				$SecureId = &Genutl_AnyToHex(shift @$Line);
       
  1556 				if (!defined $SecureId) {
       
  1557 					push @MmpDie, "$CurFile($LineNum) : SECUREID doesn't fit expected number format\n";
       
  1558 					next LINE;
       
  1559 				}
       
  1560 				if (@$Line) {
       
  1561 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for keyword SECUREID\n";
       
  1562 				}
       
  1563 				next LINE;
       
  1564 			}
       
  1565 			push @MmpWarn, "$CurFile($LineNum) : Missing argument for keyword SECUREID\n";
       
  1566 			next LINE;
       
  1567 		}
       
  1568 		if (/^VENDORID$/o) {
       
  1569 			if (defined($VendorId)) {
       
  1570 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine VENDORID\n";
       
  1571 				next LINE;
       
  1572 			}
       
  1573 			if (@$Line) {
       
  1574 				$VendorId = &Genutl_AnyToHex(shift @$Line);
       
  1575 				if (!defined $VendorId) {
       
  1576 					push @MmpDie, "$CurFile($LineNum) : VENDORID doesn't fit expected number format\n";
       
  1577 					next LINE;
       
  1578 				}
       
  1579 				if (@$Line) {
       
  1580 					push @MmpWarn, "$CurFile($LineNum) : Too many arguments for keyword VENDORID\n";
       
  1581 				}
       
  1582 				next LINE;
       
  1583 			}
       
  1584 			push @MmpWarn, "$CurFile($LineNum) : Missing argument for keyword VENDORID\n";
       
  1585 			next LINE;
       
  1586 		}
       
  1587 		if (/^USERINCLUDE$/o) {
       
  1588 			if (@$Line) {
       
  1589 				my $Candidate;
       
  1590 				foreach $Candidate (@$Line) {
       
  1591 					CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, $mainElement, $Candidate, $LineNum, $CheckSource_PhysicalCheck);
       
  1592 					$Candidate = &Path_Norm($Candidate);
       
  1593 					
       
  1594 					$Candidate=~s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
  1595 					$Candidate=&Path_MakeEAbs($EPOCPath,$CurFile,$Candidate);
       
  1596 					if ($CheckUserInc{$Candidate}) {
       
  1597 						next; 
       
  1598 					}
       
  1599 					push @UserIncPaths,$Candidate;
       
  1600 					$CheckUserInc{$Candidate}="$CurFile($LineNum)";
       
  1601 					if (-d &Path_Chop($Candidate)) {
       
  1602 						next;
       
  1603 					}
       
  1604 					push @MmpWarn, "$CurFile($LineNum) : USERINCLUDE path \"$Candidate\" not found\n";
       
  1605 				}
       
  1606 				next LINE;
       
  1607 			}
       
  1608 			push @MmpWarn, "$CurFile($LineNum) : No Paths specified for keyword USERINCLUDE\n";
       
  1609 			next LINE;
       
  1610 		}
       
  1611 		if (/^SRCDBG$/o) {
       
  1612 			if (@$Line) {
       
  1613 				push @MmpWarn, "$CurFile($LineNum) : Keyword $_ takes no arguments\n";
       
  1614 			}
       
  1615 			$SrcDbg=1;
       
  1616 			next LINE;
       
  1617 		}
       
  1618 		if (/^VERSION$/o) {
       
  1619 			if (%Version) {
       
  1620 				push @MmpDie, "$CurFile($LineNum) : Attempt to redefine VERSION\n";
       
  1621 				next LINE;
       
  1622 			}
       
  1623 			unless (@$Line) {
       
  1624 				push @MmpDie, "$CurFile($LineNum) : Missing argument to VERSION\n";
       
  1625 				next LINE;
       
  1626 			}
       
  1627 			%Version = &Genutl_StringToVersion(shift @$Line);
       
  1628 			if (!%Version) {
       
  1629 				push @MmpDie, "$CurFile($LineNum) : Bad VERSION number\n";
       
  1630 				next LINE;
       
  1631 			}
       
  1632 			if (@$Line) {
       
  1633 				if ((lc $$Line[0]) eq 'explicit') {
       
  1634 					$Version{explicit} = 1;
       
  1635 					shift @$Line;
       
  1636 				}
       
  1637 				if (scalar(@$Line)) {
       
  1638 					push @MmpDie, "$CurFile($LineNum) : Garbage after VERSION number\n";
       
  1639 				}
       
  1640 			}
       
  1641 			next LINE;
       
  1642 		}
       
  1643 		
       
  1644 		if (/^OPTION$/oi ) {
       
  1645 			if (@$Line >= 2) {
       
  1646 				my $compilerkey= uc shift @$Line;
       
  1647 				if (!defined($Compiler{$compilerkey})) {
       
  1648 					# first use of "OPTION xxx"
       
  1649 					$Compiler{$compilerkey}=shift @$Line;
       
  1650 				}
       
  1651 				# concatenate extra stuff
       
  1652 				while (@$Line) {
       
  1653 					$Compiler{$compilerkey}.=" ".shift @$Line;
       
  1654 				}
       
  1655 				next LINE;
       
  1656 			}
       
  1657 			push @MmpWarn, "$CurFile($LineNum) : Keyword OPTION requires at least two arguments\n";
       
  1658 			next LINE;
       
  1659 			}
       
  1660 		if (/^LINKEROPTION$/oi ) {
       
  1661 			if (@$Line >= 2) {
       
  1662 			        # first parameter is the compiler
       
  1663 				my $compilerkey= uc shift @$Line;
       
  1664 				if (!defined($Compiler{$compilerkey})) {
       
  1665 					# first use of "LINKEROPTION xxx"
       
  1666 					$LinkerOptions{$compilerkey}=shift @$Line;
       
  1667 				}
       
  1668 				# concatenate extra stuff
       
  1669 				while (@$Line) {
       
  1670 					$LinkerOptions{$compilerkey}.=" ".shift @$Line;
       
  1671 				}
       
  1672 				next LINE;
       
  1673 			}
       
  1674 			push @MmpWarn, "$CurFile($LineNum) : Keyword LINKEROPTION requires at least two arguments\n";
       
  1675 			next LINE;
       
  1676 			}
       
  1677 		if (/^OPTION_Replace$/oi ) {
       
  1678 			if (@$Line >= 2) {
       
  1679 				my $compilerkey= uc shift @$Line;
       
  1680 				my $repOptions= shift @$Line;
       
  1681 				while (@$Line) 
       
  1682 				{
       
  1683 					$repOptions.= " ".shift @$Line;
       
  1684 				}
       
  1685 				$repOptions =~ s/=\s*/=/g;
       
  1686 				push @{$Replace{$compilerkey}},$repOptions;
       
  1687 				
       
  1688 				next LINE;
       
  1689 			}
       
  1690 			push @MmpWarn, "$CurFile($LineNum) : Keyword OPTION_Replace requires at least two arguments\n";
       
  1691 			next LINE;
       
  1692 			}
       
  1693 		if (/^ARMFPU$/oi) {
       
  1694 			if ($ARMFPU) {
       
  1695 				push @MmpWarn, "$CurFile($LineNum) : Attempt to redefine ARMFPU\n";
       
  1696 				next LINE;
       
  1697 			}
       
  1698 			if ($ARMFPU=shift @$Line) {
       
  1699 				if (($ARMFPU !~ /^SOFTVFP$/oi) && ($ARMFPU !~ /^VFPV2$/oi)) {
       
  1700 					push @MmpWarn, "$CurFile($LineNum) : ARMFPU can only specify SOFTVFP or VFPV2 as an argument\n";
       
  1701 					undef $ARMFPU;
       
  1702 				}
       
  1703 				next LINE;
       
  1704 			}
       
  1705 			push @MmpWarn, "$CurFile($LineNum) : ARMFPU must specify either SOFTVFP or VFPV2 as an argument\n";
       
  1706 			next LINE;
       
  1707 		}
       
  1708 		if( /^PAGED$/o) {
       
  1709 			if ($CodePagingTargetMode == PAGED or $DataPagingTargetMode == PAGED) {
       
  1710 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1711 			}
       
  1712 			if ($CodePagingTargetMode == UNPAGED or $DataPagingTargetMode == UNPAGED) {
       
  1713 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1714 			}
       
  1715 			$CodePagingTargetMode = PAGED;
       
  1716 			$DataPagingTargetMode = PAGED;
       
  1717 			next LINE;
       
  1718 			}
       
  1719 		if( /^UNPAGED$/o) {
       
  1720 			if ($CodePagingTargetMode == UNPAGED or $DataPagingTargetMode == UNPAGED) {
       
  1721 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1722 			}
       
  1723 			if ($CodePagingTargetMode == PAGED or $DataPagingTargetMode == PAGED) {
       
  1724 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1725 			}
       
  1726 			$CodePagingTargetMode = UNPAGED;
       
  1727 			$DataPagingTargetMode = UNPAGED;
       
  1728 			next LINE;
       
  1729 			}
       
  1730 		if( /^PAGEDCODE$/o) {
       
  1731 			if ($CodePagingTargetMode == PAGED) {
       
  1732 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1733 			}
       
  1734 			if ($CodePagingTargetMode == UNPAGED) {
       
  1735 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1736 			}
       
  1737 			$CodePagingTargetMode = PAGED;
       
  1738 			next LINE;
       
  1739 			}
       
  1740 		if( /^UNPAGEDCODE$/o) {
       
  1741 			if ($CodePagingTargetMode == UNPAGED) {
       
  1742 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1743 			}
       
  1744 			if ($CodePagingTargetMode == PAGED) {
       
  1745 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1746 			}
       
  1747 			$CodePagingTargetMode = UNPAGED;
       
  1748 			next LINE;
       
  1749 			}
       
  1750 		if( /^PAGEDDATA$/o) {
       
  1751 			if ($DataPagingTargetMode == PAGED) {
       
  1752 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1753 			}
       
  1754 			if ($DataPagingTargetMode == UNPAGED) {
       
  1755 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1756 			}
       
  1757 			$DataPagingTargetMode = PAGED;
       
  1758 			next LINE;
       
  1759 			}
       
  1760 		if( /^UNPAGEDDATA$/o) {
       
  1761 			if ($DataPagingTargetMode == UNPAGED) {
       
  1762 				push @MmpWarn, "$CurFile($LineNum) : duplicate paging setting\n";
       
  1763 			}
       
  1764 			if ($DataPagingTargetMode == PAGED) {
       
  1765 				push @MmpWarn, "$CurFile($LineNum) : conflict paging setting\n";
       
  1766 			}
       
  1767 			$DataPagingTargetMode = UNPAGED;
       
  1768 			next LINE;
       
  1769 			}
       
  1770 		if( /^DEBUGGABLE_UDEBONLY$/o) {
       
  1771 			$IsDebuggable = DEBUGGABLE_UDEBONLY;
       
  1772 			next LINE;
       
  1773 			}
       
  1774 		if( /^DEBUGGABLE$/o) {
       
  1775 			if ($IsDebuggable != DEBUGGABLE_UDEBONLY)
       
  1776 			{
       
  1777 				$IsDebuggable = DEBUGGABLE;
       
  1778 			}
       
  1779 			next LINE;
       
  1780 			}
       
  1781 		if( /^FEATUREVARIANT$/o) {
       
  1782 			push @MmpDie, "$CurFile($LineNum) : FEATUREVARIANT specified multiple times" if ($FeatureVariant);
       
  1783 			$FeatureVariant = 1;
       
  1784 			next LINE;
       
  1785 			}
       
  1786 
       
  1787 		push @MmpWarn, "$CurFile($LineNum) : Unrecognised Keyword \"$_\"\n";
       
  1788 	}
       
  1789 
       
  1790 	undef $Line;
       
  1791 	undef $MmpMacro;
       
  1792 
       
  1793 
       
  1794 	# test the mmp contents
       
  1795 	#----------------------
       
  1796 	if ($PlatTxtSwitch || $OtherPlatSwitch)	{
       
  1797 		push @MmpDie, $PlatTxtSwitch ? $PlatTxtSwitch : $OtherPlatSwitch, ": Unterminated START ... END block\n";
       
  1798 	}
       
  1799 	undef $PlatTxtSwitch;
       
  1800 	undef $OtherPlatSwitch;
       
  1801 
       
  1802 	# Check the consistency of the mmp file contents
       
  1803 	unless ($Trg) {
       
  1804 		unless($TrgType=~/^NONE$/io){
       
  1805 			push @MmpDie, "ERROR: No Target specified\n";
       
  1806 		}
       
  1807 	}
       
  1808 	unless ($TrgType) {
       
  1809 		push @MmpDie, "ERROR: No TargetType specified\n";
       
  1810 	}
       
  1811   	if( $StdCpp && $NoStdCpp ) {
       
  1812   		push @MmpWarn, "WARNING: Keyword statement STDCPP not permitted with keyword NOSTDCPP.\n";
       
  1813   		push @MmpWarn, "WARNING: Keyword statements STDCPP and NOSTDCPP ignored.\n";
       
  1814   		$StdCpp = 0;
       
  1815   		$NoStdCpp = 0;
       
  1816   	}
       
  1817 
       
  1818 	if (($TrgType =~ /^LIB$/io) && (scalar(@DebugLibList) || scalar(@LibList) || scalar(@StatLibList))) {
       
  1819 		push @MmpWarn, "WARNING: Library statements (DEBUGLIBRARY, LIBRARY or STATICLIBRARY) not permitted with TARGETTYPE LIB.";
       
  1820 		push @MmpWarn, "WARNING: Library statements (DEBUGLIBRARY, LIBRARY or STATICLIBRARY) ignored.\n";
       
  1821 		undef @DebugLibList;
       
  1822 		undef @LibList;
       
  1823 		undef @StatLibList;
       
  1824 	}
       
  1825 
       
  1826 	if ($TrgType =~ /^LIB$/io && $NewLib) {
       
  1827 		push @MmpWarn, "WARNING: Library statement NEWLIB not permitted with TARGETTYPE LIB.";
       
  1828 		push @MmpWarn, "WARNING: Library statement NEWLIB ignored.\n";
       
  1829 		undef @DebugLibList;
       
  1830 		undef @LibList;
       
  1831 		undef @StatLibList;
       
  1832 	}
       
  1833 
       
  1834 	if ($TrgType =~ /^STD(EXE|DLL)$/io && $NewLib) {
       
  1835 		push @MmpWarn, "WARNING: Library statement NEWLIB not permitted with TARGETTYPE STD*.";
       
  1836 		push @MmpWarn, "WARNING: Library statement NEWLIB ignored.\n";
       
  1837 		undef @DebugLibList;
       
  1838 		undef @LibList;
       
  1839 		undef @StatLibList;
       
  1840 	}
       
  1841 
       
  1842 	if (($TrgType=~/^IMPLIB$/io) || ($TrgType=~/^NONE$/io)) {
       
  1843 		push @MmpDie, "ERROR: SOURCE not permitted with TARGETTYPE $TrgType\n" if (@SourceStruct);
       
  1844 	} elsif (!@SourceStruct) {
       
  1845 		push @MmpDie, "ERROR: No Sources specified\n";
       
  1846 	}
       
  1847 	if ($TrgType{NeedUID3} && $#UidList<1) {
       
  1848 		push @MmpWarn, "WARNING: No Uid3 specified in \"$MMPFILE\" for TargetType \"$TrgType\"\n";
       
  1849 	}
       
  1850 	if ($Trg && $Trg=~/\{|\}/) {
       
  1851 		push @MmpDie, "ERROR: Bad TARGET name specified\n";
       
  1852 	}
       
  1853 	if ($ExportLibrary and $ExportLibrary=~/\{|\}/) {
       
  1854 		push @MmpDie, "ERROR: Bad EXPORTLIBRARY name specified\n";
       
  1855 	}
       
  1856 	if ($LinkAs and $LinkAs=~/\{|\}/) {
       
  1857 		push @MmpDie, "ERROR: Bad LINKAS name specified\n";
       
  1858 	}
       
  1859 	# Make sure a valid compression method has been chosen if target is going to be paged
       
  1860 	if ($CodePagingTargetMode == PAGED && $CompressTarget == COMPRESS) {
       
  1861 		if ($CompressTargetMethod == INFLATECOMPRESSIONMETHOD) {
       
  1862 			push @MmpWarn, "Incompatible keywords! The INFLATECOMPRESSTARGET is not allowed with PAGED!\n";
       
  1863 			push @MmpWarn, "Changing compression method to BYTEPAIRCOMPRESSTARGET\n";
       
  1864 		}
       
  1865 		$CompressTargetMethod = BYTEPAIRCOMPRESSIONMETHOD;
       
  1866 	}
       
  1867 
       
  1868   # Ensure 2nd UID is not deprecated
       
  1869   if (&main::EPOCSecurePlatform() && $TrgType{Basic} eq "DLL")
       
  1870     {
       
  1871     $deprecatedUIDs{"0x100039ce"} = "Unmigrated dll style application detected from use of UID 0x100039ce";
       
  1872     }
       
  1873   
       
  1874   # Do not need UIDs for a resource only (i.e. TARGETTYPE is "none") mmp file
       
  1875   if  ((!$TrgType=~/^NONE$/io) && &main::EPOCSecurePlatform() && defined($deprecatedUIDs{$UidList[0]}))
       
  1876     {
       
  1877     push @MmpMigrationNote, "$deprecatedUIDs{$UidList[0]}\n";
       
  1878     }
       
  1879 
       
  1880 #	PUT IN SOME DEFAULTS
       
  1881 
       
  1882 	if ($TrgPath eq '') {
       
  1883 		# set up default path from $TrgType 
       
  1884 		$TrgPath = $TrgType{Path};
       
  1885 	}
       
  1886 	my $ResourceTrgPath = $TrgType{ResourcePath};
       
  1887 	if ($ResourceTrgPath eq '') {
       
  1888 		$ResourceTrgPath = $TrgPath;	# default to TrgPath, as before
       
  1889 	}
       
  1890 	unless (%Version) {
       
  1891 	    if ($$Plat_ref{DefFile} =~ /^\s*EABI\s*/i ) {
       
  1892 			$Version{major} = 10;	# Start major versions at 10 for EABI to allow coexistence with GCC98r2 ABI
       
  1893 		} else {
       
  1894 			$Version{major} = 1;
       
  1895 		}
       
  1896 		$Version{minor} = 0;
       
  1897 	}
       
  1898 
       
  1899 	# check for languages
       
  1900 	@LangList=('SC') unless @LangList;
       
  1901 
       
  1902   if (&main::EPOCSecurePlatform() && !defined($Capability) &&
       
  1903     (($TrgType{Basic} eq "DLL") || (uc($TrgType) eq "EXEXP")))
       
  1904     {
       
  1905     push @MmpMigrationNote, "No Capabilities set in \"$MMPFILE\" for TargetType: $TrgType\n";
       
  1906     }
       
  1907 
       
  1908 	# Supply default capability mask if not set explicitly, and convert to hex string
       
  1909 	$Capability = "none" unless (defined($Capability));
       
  1910 	$CapabilityFlags[0] = 0 unless (defined($CapabilityFlags[0]));
       
  1911         $CapabilityFlags[1] = 0 unless (defined($CapabilityFlags[1]));
       
  1912 
       
  1913         $CapabilityFlags[0] = sprintf("0x%08x", $CapabilityFlags[0]);
       
  1914         $CapabilityFlags[1] = sprintf("0x%08x", $CapabilityFlags[1]);
       
  1915 
       
  1916 #	ensure all bitmaps have targetpaths and check for duplicate bitmaps
       
  1917 	my %BitMapCheck;
       
  1918 	my $BitMapRef;
       
  1919 	foreach $BitMapRef (@BitMapStruct) {
       
  1920 		unless ($$BitMapRef{TrgPath}) {
       
  1921 			$$BitMapRef{TrgPath}=$ResourceTrgPath;
       
  1922 		}
       
  1923 		if ($BitMapCheck{"$$BitMapRef{TrgPath}$$BitMapRef{Trg}"}) {
       
  1924 			push @MmpDie, "ERROR: Duplicate bitmap target \"$$BitMapRef{TrgPath}$$BitMapRef{Trg}\"\n";
       
  1925 			next;
       
  1926 		}
       
  1927 		$BitMapCheck{"$$BitMapRef{TrgPath}$$BitMapRef{Trg}"}=1;
       
  1928 	}
       
  1929 
       
  1930 #	ensure all resources have targetpaths, expand language list and check for duplicates
       
  1931 	my %ResourceCheck;
       
  1932 	my $ResourceRef;
       
  1933 	my @PerLanguageResourceStruct;
       
  1934 	foreach $ResourceRef (@ResourceStruct) {
       
  1935 					
       
  1936 		unless ($$ResourceRef{BaseTrg}) {
       
  1937 			$$ResourceRef{BaseTrg}=&Path_Split('Base',$$ResourceRef{Source});
       
  1938 		}
       
  1939 		unless ($$ResourceRef{TrgPath}) {
       
  1940 			$$ResourceRef{TrgPath}=$ResourceTrgPath;
       
  1941 		}
       
  1942 		unless ($$ResourceRef{Lang}) {
       
  1943 			@{$$ResourceRef{Lang}}=@LangList;
       
  1944 		}
       
  1945 		# generate one instance per language.
       
  1946 		my @list = @{$$ResourceRef{Lang}};
       
  1947 		my $base = "$$ResourceRef{TrgPath}$$ResourceRef{BaseTrg}";
       
  1948 		foreach my $lang (@list) {
       
  1949 			my %newResourceRef = %{$ResourceRef};
       
  1950 			$newResourceRef{Lang} = $lang;
       
  1951 			$newResourceRef{Trg} = $base.lc("\.R$lang");
       
  1952 			push @PerLanguageResourceStruct, \%newResourceRef;
       
  1953 		}
       
  1954 	}
       
  1955 	@ResourceStruct = @PerLanguageResourceStruct;
       
  1956 	undef @PerLanguageResourceStruct;
       
  1957 	
       
  1958 	foreach $ResourceRef (@ResourceStruct) {
       
  1959 		if ($ResourceCheck{"$$ResourceRef{TrgPath}$$ResourceRef{Trg}"}) {
       
  1960 			push @MmpDie, "ERROR: Duplicate Resource target \"$$ResourceRef{TrgPath}$$ResourceRef{Trg}\"\n";
       
  1961 			next;
       
  1962 		}
       
  1963 		$ResourceCheck{"$$ResourceRef{TrgPath}$$ResourceRef{Trg}"}=1;
       
  1964 	}
       
  1965 
       
  1966 	my $Plat=&main::Plat;
       
  1967 
       
  1968 	if (@MmpDie || @MmpWarn || @MmpDiagnostic || @MmpMigrationNote) {
       
  1969 		warn "\nMMPFILE \"$MMPFILE\"\n";
       
  1970 		if (@MmpDiagnostic) {
       
  1971 			warn
       
  1972 				"DIAGNOSTIC MESSAGE(S)\n",
       
  1973 				@MmpDiagnostic,
       
  1974 				"\n"
       
  1975 			;
       
  1976 			}
       
  1977 
       
  1978 		foreach my $printedWarning (@MmpWarn)
       
  1979 			{
       
  1980 			print "WARNING: $printedWarning\n";
       
  1981 			}
       
  1982 		foreach my $printedError (@MmpDie)
       
  1983 			{
       
  1984 			print "FATAL ERROR: $printedError\n";
       
  1985 			}
       
  1986 
       
  1987 		foreach my $printedMigrationNote (@MmpMigrationNote)
       
  1988 			{
       
  1989 			print "MIGRATION_NOTE: $printedMigrationNote\n";
       
  1990 			}		
       
  1991 
       
  1992 		if (@MmpDie)
       
  1993 			{
       
  1994 			die;
       
  1995 			}
       
  1996 	}
       
  1997 
       
  1998 
       
  1999 #	COMPLETE THE UID LIST
       
  2000 
       
  2001 	while ($#UidList<1) {
       
  2002 		push @UidList, '0x00000000';
       
  2003 	}
       
  2004 
       
  2005 	# check the second UID, or set it
       
  2006 	if ($TrgType{UID2}) {
       
  2007 		if ($UidList[0]=~/^0x00000000$/o) {
       
  2008 			# put in second uid for known targetypes without them
       
  2009 			$UidList[0]=$TrgType{UID2};
       
  2010 		}
       
  2011 		elsif ($UidList[0] ne $TrgType{UID2}) {
       
  2012 			# text comparison is OK here because UIDs have both been through AnyToHex function
       
  2013 			if ($UidList[0] ne '0x01111111') {
       
  2014 				# issue warning (but not if UID == 0x01111111 (to allow test code to deliberately set incorrect UID)
       
  2015 				warn(
       
  2016 					"WARNING: Second Uid is $UidList[0], but\n",
       
  2017 					" expected value for Target Type $TrgType is $TrgType{UID2}\n"
       
  2018 				);
       
  2019 			}
       
  2020 		}
       
  2021 	}
       
  2022 
       
  2023 #	Put in the first UID in the list
       
  2024 	if ($TrgType{Basic}=~/^DLL$/o) {
       
  2025 		unshift @UidList, '0x10000079';
       
  2026 	}
       
  2027 	elsif ($TrgType{Basic}=~/^(EXE)$/o) {
       
  2028 		unshift @UidList, '0x1000007a';
       
  2029 	}
       
  2030 	elsif ($TrgType{Basic}=~/^(EXEDLL)$/o) {
       
  2031 # EXE on EPOC32, DLL on Emulator
       
  2032 # NOTE: On EKA1 EXEDLL used EXE UID1 on emulator
       
  2033 # On EKA2 this is unacceptable
       
  2034 		if (!$emulator) {
       
  2035 			unshift @UidList, '0x1000007a';
       
  2036 		} else {
       
  2037 			unshift @UidList, '0x10000079';
       
  2038 		}
       
  2039 	}
       
  2040 	else {
       
  2041 		unshift @UidList, '0x00000000';
       
  2042 	}
       
  2043 
       
  2044 # If no SID specified use UID3
       
  2045 	$SecureId = $UidList[2] unless(defined $SecureId);
       
  2046 
       
  2047 #	SORT OUT TARGET TYPE DATA STRUCTURE
       
  2048 
       
  2049 	# set the target path
       
  2050 	if ($TrgPath) {
       
  2051 		$TrgType{Path}=$TrgPath;
       
  2052 	}
       
  2053 
       
  2054 #	put in the $Linkas default
       
  2055 	if (!$LinkAs and $TrgType=~/^IMPLIB$/io) {
       
  2056 		$LinkAs = $Trg;
       
  2057 		$LinkAs =~ s/\.lib$/\.dll/i;
       
  2058 	} else {
       
  2059 		$LinkAs = $Trg unless $LinkAs;
       
  2060 	}
       
  2061 	$LinkAsBase = $LinkAs;
       
  2062 	unless ($emulator) {
       
  2063 		$LinkAs = &DecorateWithVersion($LinkAs, %Version);
       
  2064 	}
       
  2065 
       
  2066 # If explicit version add to target
       
  2067 	if ($Version{explicit} && !$emulator) {
       
  2068 		$Trg = &DecorateWithVersion($Trg, %Version);
       
  2069 	}
       
  2070 
       
  2071 
       
  2072 #	Reconcile any EXEDLL targettypes - must be done after first UIDs put in the list
       
  2073 #	and after the $LinkAs keyword has been defined/defaulted
       
  2074 	if ($TrgType{Basic} eq 'EXEDLL') {
       
  2075 		$TrgType{Basic} = $emulator ? 'DLL' : 'EXE';
       
  2076 		$Trg=&Path_Split('Base',$Trg).'.EXE';
       
  2077 		$LinkAsBase=&Path_Split('Base',$LinkAsBase).'.EXE';
       
  2078 		$LinkAs=&Path_Split('Base',$LinkAs).'.EXE';
       
  2079 	}
       
  2080 
       
  2081 #	put in the $ExportLibrary default
       
  2082 	$ExportLibrary=&Path_Split('Base',$Trg) unless $ExportLibrary;
       
  2083 	unless ($emulator) {
       
  2084 		$ExportLibrary = &DecorateWithVersion($ExportLibrary, %Version);
       
  2085 	}
       
  2086 
       
  2087 #	Get the EPOC entrypoint static library
       
  2088 	unless ($FirstLib) {
       
  2089 		unless ($TrgType{FirstLib}) {
       
  2090 			$FirstLib="E$TrgType{Basic}.LIB";
       
  2091 		}
       
  2092 		else {
       
  2093 			$FirstLib=$TrgType{FirstLib};
       
  2094 		}
       
  2095 	}
       
  2096 
       
  2097 
       
  2098 #	 WORK OUT THE ASSP IMPLICATIONS
       
  2099 
       
  2100 #	Nullify ASSP-specific API things for WINS/WINC since the API should always be
       
  2101 #	the same for WINC as for WINS,
       
  2102 	if ($emulator) {
       
  2103 		$ASSPABISwitch=0;
       
  2104 		$ASSPExports=0;
       
  2105 		unshift @LibList, @ASSPLibList;
       
  2106 		unshift @DebugLibList, @ASSPLibList;	# keep DebugLibList in sync with LibList
       
  2107 		@ASSPLibList=();
       
  2108 	}
       
  2109 	else {
       
  2110 #		Force ASSPABISwitch for known kernel components or if ASSPEXPORTS or ASSPLIBRARY specified in .MMP file
       
  2111 		if ($TrgType{Kernel} or $ASSPExports or @ASSPLibList) {
       
  2112 			$ASSPABISwitch=1;
       
  2113 		}
       
  2114 	}
       
  2115 
       
  2116 #	Switch the ABI if necessary
       
  2117 	unless ($ASSPABISwitch) {
       
  2118 #		apply the standard ABI
       
  2119 		$ABI=$$Plat_ref{ABI};
       
  2120 	}
       
  2121 	else {
       
  2122 #		kernel-specific stuff
       
  2123 #		check that the platform is not generic
       
  2124 		if ($$Plat_ref{Generic}) {
       
  2125 			die "ERROR: Can't apply ASSPABI, ASSPEXPORTS or ASSPLIBRARY for generic platform \"$$Plat_ref{Name}\n";
       
  2126 		}
       
  2127 
       
  2128 #		apply the ASSP-specific ABI
       
  2129 		$ABI=$$Plat_ref{ASSPABI};
       
  2130 	}
       
  2131 
       
  2132 #	COMPLETE THE .DEF FILE STRUCTURE
       
  2133 
       
  2134 	# apply the default .DEF filename, and
       
  2135 	# check as far as possible that the project is frozen
       
  2136 	if (($TrgType{NeedDeffile} or $CheckDef)) {
       
  2137 		unless ($Def{Path} and $Def{Path} !~ /\\\~\\$/) {
       
  2138 			my $augment;
       
  2139 			if ($ASSPExports) {
       
  2140 			    if ($$Plat_ref{DefFile} =~ /^\s*EABI\s*/i ) {
       
  2141 					$augment = $$Plat_ref{ASSP};
       
  2142 			    } else {
       
  2143 					$augment = "B$$Plat_ref{ASSP}";
       
  2144 			    }
       
  2145 			} else {
       
  2146 			    if ($$Plat_ref{DefFile} =~ /^\s*EABI\s*/i ) {
       
  2147 					$augment = lc($$Plat_ref{DefFile});
       
  2148 			    } else {
       
  2149 					$augment = lc("B$$Plat_ref{DefFile}");
       
  2150 			    }
       
  2151 			}
       
  2152 			if ($Def{Path} =~ /\\\~\\$/) {
       
  2153 				$Def{Path} =~ s/\\\~\\$/\\$augment\\/;
       
  2154 			} else {
       
  2155 				$Def{Path}=&Path_Strip(&Path_Split('Path',$MMPFILE)."..\\$augment\\");
       
  2156 			}
       
  2157 		}
       
  2158 		unless ($Def{Base}) {
       
  2159 			$Def{Base} = &Path_Split('Base',$LinkAsBase);
       
  2160 		}
       
  2161 		unless ($Def{Ext}) {
       
  2162 			$Def{Ext}='.def';
       
  2163 		}
       
  2164 #		now that we've dumped narrow, treat the 'u' basename suffix as part of the frozen
       
  2165 #		.DEF file basename.  Once we've dumped the suffix we won't have to store the extension
       
  2166 #		separately either
       
  2167 		if (!$emulator && $Version{explicit}) {
       
  2168 			$Def{Base} .= &Genutl_VersionToFileAugment(%Version);
       
  2169 		} elsif (!$NoStrictDef) {
       
  2170 			$Def{Base}.='u';
       
  2171 		}
       
  2172 
       
  2173 		if ($Def{CheckSource_MMPEntry})
       
  2174 		{
       
  2175 			my $type = "DEFFILE";
       
  2176 			$type .= " (NOSTRICTDEF)" if ($NoStrictDef);
       
  2177 			
       
  2178 			# for GCCXML and X86GCC, ignore check source errors for missing .def file
       
  2179 			my $checkdef = (($IgnoreMissingDef) && ($Def{Path} =~ /[\\\/]bmarm[\\\/]/ || $$Plat_ref{Name} eq "X86GCC" || $$Plat_ref{Name} eq "X86GMP")) ? 0 : 1;
       
  2180 			
       
  2181 			if( $checkdef ) {
       
  2182 			  CheckSource_MetaData(%CheckSourceMMPMetaData, $Def{CheckSource_MMPFile}, $type, $Def{CheckSource_MMPEntry}, $Def{CheckSource_LineNumber}, $CheckSource_PhysicalCheck, $Def{Path});
       
  2183 			}
       
  2184 		}
       
  2185 			
       
  2186 #		check deffile exists,
       
  2187         unless (-e "$Def{Path}$Def{Base}$Def{Ext}") {
       
  2188             if($IgnoreMissingDef == 0) {
       
  2189                 warn "WARNING: Frozen .def file $Def{Path}$Def{Base}$Def{Ext} not found - project not frozen\n";
       
  2190             }
       
  2191      	}
       
  2192 	}
       
  2193 }
       
  2194 
       
  2195 sub Mmp_ABI () {
       
  2196 	$ABI;
       
  2197 }
       
  2198 sub Mmp_AifStruct () {
       
  2199 	\@AifStruct;
       
  2200 }
       
  2201 sub Mmp_AllowDllData () {
       
  2202 	$AllowDllData;
       
  2203 }
       
  2204 sub Mmp_CompressTarget () {
       
  2205 	$CompressTarget;
       
  2206 }
       
  2207 sub Mmp_CompressTargetMode () {
       
  2208 	$CompressTargetMethod;
       
  2209 }
       
  2210 sub Mmp_ASSPExports () {
       
  2211 	$ASSPExports;
       
  2212 }
       
  2213 sub Mmp_ASSPLibList () {
       
  2214 	@ASSPLibList;
       
  2215 }
       
  2216 sub Mmp_BitMapStruct () {
       
  2217 	\@BitMapStruct;
       
  2218 }
       
  2219 sub Mmp_BuildAsARM () {
       
  2220 	$BuildAsARM;
       
  2221 }
       
  2222 sub Mmp_CallDllEntryPoints () {
       
  2223 	$CallDllEntryPoints;
       
  2224 }
       
  2225 sub Mmp_Capability () {
       
  2226 	$Capability;
       
  2227 }
       
  2228 sub Mmp_CapabilityFlags () {
       
  2229 	@CapabilityFlags;
       
  2230 }
       
  2231 sub Mmp_DataLinkAddress () {
       
  2232 	$DataLinkAddress;
       
  2233 }
       
  2234 sub Mmp_DebugLibList () {
       
  2235 	\@DebugLibList;
       
  2236 }
       
  2237 sub Mmp_Def () {
       
  2238 	\%Def;
       
  2239 }
       
  2240 sub Mmp_DocHash () {
       
  2241 	\%DocHash;
       
  2242 }
       
  2243 sub Mmp_ExportUnfrozen () {
       
  2244 	$ExportUnfrozen;
       
  2245 }
       
  2246 sub Mmp_FirstLib () {
       
  2247 	$FirstLib;
       
  2248 }
       
  2249 sub Mmp_FixedProcess () {
       
  2250 	$FixedProcess;
       
  2251 }
       
  2252 sub Mmp_HeapSize () {
       
  2253 	\%HeapSize;
       
  2254 }
       
  2255 sub Mmp_LibList () {
       
  2256 	\@LibList;
       
  2257 }
       
  2258 sub Mmp_LinkAs () {
       
  2259 	$LinkAs;
       
  2260 }
       
  2261 sub Mmp_LinkAsBase () {
       
  2262 	$LinkAsBase;
       
  2263 }
       
  2264 sub Mmp_ExportLibrary () {
       
  2265 	$ExportLibrary;
       
  2266 }
       
  2267 sub Mmp_NoExportLibrary () {
       
  2268 	$NoExportLibrary;
       
  2269 }
       
  2270 sub Mmp_NewLib () {
       
  2271 	$NewLib;
       
  2272 }
       
  2273 sub Mmp_Macros () {
       
  2274 	@Macros;
       
  2275 }
       
  2276 sub Mmp_MmpFlag () {
       
  2277 	\%MmpFlag;
       
  2278 }
       
  2279 sub	Mmp_PlatTxt2D () {
       
  2280 	@PlatTxt2D;
       
  2281 }
       
  2282 sub Mmp_ProcessPriority () {
       
  2283 	$ProcessPriority;
       
  2284 }
       
  2285 sub Mmp_RamTargets () {
       
  2286 	@RamTargets;
       
  2287 }
       
  2288 sub Mmp_ResourceStruct () {
       
  2289 	\@ResourceStruct;
       
  2290 }
       
  2291 sub Mmp_RomTargets () {
       
  2292 	@RomTargets;
       
  2293 }
       
  2294 sub Mmp_SourceStruct () {
       
  2295 	\@SourceStruct;
       
  2296 }
       
  2297 sub Mmp_StackSize () {
       
  2298 	$StackSize;
       
  2299 }
       
  2300 sub Mmp_StatLibList () {
       
  2301 	@StatLibList;
       
  2302 }
       
  2303 sub Mmp_StdCpp () {
       
  2304 	$StdCpp;
       
  2305 }
       
  2306 sub Mmp_NoStdCpp () {
       
  2307 	$NoStdCpp;
       
  2308 }
       
  2309 sub Mmp_SysIncPaths () {
       
  2310 	@SysIncPaths;
       
  2311 }
       
  2312 sub Mmp_Trg () {
       
  2313 	$Trg;
       
  2314 }
       
  2315 sub Mmp_TrgType () {
       
  2316 	\%TrgType;
       
  2317 }
       
  2318 sub Mmp_UidList () {
       
  2319 	@UidList;
       
  2320 }
       
  2321 sub Mmp_UserIncPaths () {
       
  2322 	@UserIncPaths;
       
  2323 }
       
  2324 sub Mmp_SrcDbg () {
       
  2325 	$SrcDbg;
       
  2326 }
       
  2327 
       
  2328 sub Mmp_WarningLevel() {
       
  2329      %Compiler; 
       
  2330 } 
       
  2331 
       
  2332 sub Mmp_LinkerOptions() {
       
  2333     %LinkerOptions
       
  2334 }
       
  2335 
       
  2336 sub Mmp_Version() {
       
  2337 	%Version;
       
  2338 }
       
  2339 
       
  2340 sub Mmp_SecureId() {
       
  2341 	$SecureId;
       
  2342 }
       
  2343 
       
  2344 sub Mmp_VendorId () {
       
  2345 	$VendorId;
       
  2346 }
       
  2347 
       
  2348 sub DecorateWithVersion($$) {
       
  2349 	my ($name, %ver) = @_;
       
  2350 	my $base = &Path_Split('Base', $name);
       
  2351 	my $ext = &Path_Split('Ext', $name);
       
  2352 	unless ($base =~ /\{(\d|a|b|c|d|e|f){8}\}$/i) {
       
  2353 		$base .= &Genutl_VersionToFileAugment(%Version);
       
  2354 	}
       
  2355 	return "$base$ext";
       
  2356 }
       
  2357 
       
  2358 sub Mmp_Replace() {
       
  2359 	%Replace;
       
  2360 }
       
  2361 
       
  2362 sub Mmp_SmpSafe() {
       
  2363 	$SmpSafe;
       
  2364 }
       
  2365 
       
  2366 sub Mmp_StringTable() {
       
  2367 	\@StringTableStruct;
       
  2368 }
       
  2369 sub Mmp_ARMFPU() {
       
  2370 	$ARMFPU;
       
  2371 }
       
  2372 
       
  2373 sub Mmp_CheckSourceMMPMetaData() {
       
  2374 	%CheckSourceMMPMetaData;
       
  2375 }
       
  2376 
       
  2377 sub Mmp_CheckSourceMMPIncludes() {
       
  2378 	%CheckSourceMMPIncludes;
       
  2379 }
       
  2380 
       
  2381 sub Mmp_CodePagingTargetMode() {
       
  2382 	$CodePagingTargetMode;
       
  2383 }
       
  2384 
       
  2385 sub Mmp_DataPagingTargetMode() {
       
  2386 	$DataPagingTargetMode;
       
  2387 }
       
  2388 
       
  2389 sub Mmp_IsWideCharMain() {
       
  2390 	$WideCharMain;
       
  2391 }
       
  2392 
       
  2393 sub Mmp_IsDebuggable() {
       
  2394 	$IsDebuggable;
       
  2395 }
       
  2396 
       
  2397 sub Mmp_IsFeatureVariant() {
       
  2398 	$FeatureVariant;
       
  2399 }
       
  2400 
       
  2401 # Return the macros tested in the MMP file
       
  2402 sub Mmp_TestedMacros() {
       
  2403 	return \%mmptestedMacrosHash;
       
  2404 }
       
  2405 
       
  2406 1;