sbsv1/abld/platform/cl_generic.pm
changeset 599 fa7a3cc6effd
equal deleted inserted replaced
596:9f25be3da657 599:fa7a3cc6effd
       
     1 # Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # this package contains generic routines to handle bits of makefiles which are
       
    15 # common to all of the platforms. Currently it deals with AIF, MBM amd RSC files.
       
    16 # 
       
    17 #
       
    18 
       
    19 package cl_generic;
       
    20 
       
    21 require Exporter;
       
    22 @ISA=qw(Exporter);
       
    23 @EXPORT=qw(
       
    24 	Generic_Define
       
    25 	Generic_Definition
       
    26 	Generic_MakeWorkDir
       
    27 	Generic_MakeWorkFile
       
    28 	Generic_Quote
       
    29 	Generic_Header
       
    30 	Generic_Releaseables
       
    31 	Generic_BitMapBld
       
    32 	Generic_ResrcBld
       
    33 	Generic_AifBld
       
    34 	Generic_End
       
    35 	Generic_CopyAction
       
    36 	Generic_WhatCleanTargets
       
    37 	Generic_WhatTargets
       
    38 	Generic_CleanTargets
       
    39 );
       
    40 
       
    41 use File::Basename;
       
    42 use lockit_info;
       
    43 use CheckSource;
       
    44 use E32Variant;
       
    45 
       
    46 my $SavedBldPath;
       
    47 my $MakefileType=0;	# 0=NMAKE, 1=MAKE
       
    48 my %CheckSourceResourceIncludes;
       
    49 
       
    50 sub Generic_Header ($$;$) {
       
    51 	my ($UseRltPaths, $makefileType, $supportAbsPathConversion) = @_;
       
    52 	
       
    53 	$MakefileType=($makefileType eq "nmake")? 0:1;
       
    54 
       
    55 	my $LibSubDir="UDEB";
       
    56 	if (&main::PlatOS eq 'EPOC32') {
       
    57 		$LibSubDir="UREL";
       
    58 	}
       
    59 	elsif (&main::PlatOS eq 'TOOLS2') {
       
    60 		$LibSubDir="LIB";
       
    61 	}
       
    62 
       
    63 	my $BldPath=&main::BldPath;
       
    64 
       
    65 	if ( LocalBuildPathExists() ) {
       
    66 		$BldPath = ConvertToLocalBuild($BldPath);
       
    67 	}
       
    68 
       
    69 	# Get the information regarding supporting Compiler Wrapper option
       
    70 	my $IsCompilerWrapperOption=&main::CompilerWrapperOption();
       
    71 	my $RelPath=&main::RelPath;
       
    72 	my $LibPath=&main::LibPath;
       
    73 	my $LinkPath=&main::LinkPath;
       
    74 	my $StatLinkPath=&main::StatLinkPath;
       
    75 	my $ASSPLinkPath=&main::ASSPLinkPath;
       
    76 
       
    77 	$SavedBldPath=&main::Path_Chop($BldPath);
       
    78 
       
    79 	if ($UseRltPaths) {
       
    80 
       
    81 		if ( ! LocalBuildPathExists() ) {
       
    82 			# Local build does not exists so keep relative path.
       
    83 			$BldPath     =&main::Path_RltToWork($BldPath);
       
    84 		}
       
    85 
       
    86 		$RelPath     =&main::Path_RltToWork($RelPath);
       
    87 		$LibPath     =&main::Path_RltToWork($LibPath);
       
    88 		$LinkPath    =&main::Path_RltToWork($LinkPath);
       
    89 		$StatLinkPath=&main::Path_RltToWork($StatLinkPath);
       
    90 		$ASSPLinkPath=&main::Path_RltToWork($ASSPLinkPath);
       
    91 	}
       
    92 
       
    93 	$BldPath=&main::Path_Chop($BldPath);
       
    94 	$RelPath=&main::Path_Chop($RelPath);
       
    95 	$LibPath=&main::Path_Chop($LibPath);
       
    96 	$LinkPath=&main::Path_Chop($LinkPath);
       
    97 	$StatLinkPath=&main::Path_Chop($StatLinkPath);
       
    98 	$ASSPLinkPath=&main::Path_Chop($ASSPLinkPath);
       
    99 
       
   100 	my $EPOCDataPath=&main::Path_Chop(&main::EPOCDataPath);
       
   101 	my $EPOCIncPath=&main::Path_Chop(&main::EPOCIncPath);
       
   102 	my $DataPath=&main::Path_Chop(&main::DataPath);
       
   103 	my $TrgPath=&main::Path_Chop(&main::TrgPath);
       
   104 
       
   105 	my $erasedefn = "\@erase";
       
   106 	$erasedefn = "\@erase 2>>nul" if ($ENV{OS} eq "Windows_NT");
       
   107 
       
   108 	&main::Output(
       
   109 		"\n",
       
   110 		'# CWD ',             &main::Path_WorkPath, "\n",
       
   111 		'# MMPFile ',         &main::MmpFile,       "\n",
       
   112 		'# Target ',          &main::Trg,           "\n",
       
   113 		'# TargetType ',      &main::TrgType,       "\n",
       
   114 		'# BasicTargetType ', &main::BasicTrgType,  "\n",
       
   115 		'# MakefileType ', ($MakefileType==1)? "GNU":"NMAKE", "\n"
       
   116 	);
       
   117 
       
   118 	my @BldList=&main::BldList;
       
   119 	my %featureVariantInfo = &main::FeatureVariantInfo;
       
   120 	
       
   121 	if (%featureVariantInfo)
       
   122 		{
       
   123 		&main::Output("# FeatureVariantName ", $featureVariantInfo{NAME}, "\n");
       
   124 
       
   125 		foreach (@BldList)
       
   126 			{
       
   127 			&main::Output("# FeatureVariant".$_."Label ", $featureVariantInfo{$_."_LABEL"}, "\n");
       
   128 			}
       
   129 		}
       
   130 		
       
   131 	&main::Output(
       
   132 		"\n",
       
   133 		"ERASE = $erasedefn\n",
       
   134 		"\n"
       
   135 	);
       
   136 
       
   137 	# Include function to perform optional DOS to Unix slash conversion
       
   138 	# on absolute paths if requested from backend.
       
   139 	if ($supportAbsPathConversion) {
       
   140 		&main::Output(
       
   141 			"ifeq \"\$(UNIX_SLASH_FOR_CC_ABS_PATHS)\" \"1\"\n",
       
   142 			"define absolutePaths\n",
       
   143 			"\$(subst \\,\/,\$1)\n",
       
   144 			"endef\n",
       
   145 			"else\n",
       
   146 			"define absolutePaths\n",
       
   147 			"\$1\n",
       
   148 			"endef\n",
       
   149 			"endif\n",
       
   150 			"\n"
       
   151 		);
       
   152 	}
       
   153 
       
   154 	&main::Output(
       
   155 		"# EPOC DEFINITIONS\n",
       
   156 		"\n"
       
   157 	);
       
   158 	
       
   159 	Generic_Define("EPOCBLD",  $BldPath);
       
   160 	if (defined $ENV{PBUILDPID}) {
       
   161 		my $BldPathP = $BldPath . '$(PBUILDPID)';
       
   162 		Generic_Define("EPOCBLDP", $BldPathP);
       
   163 	} else {
       
   164 		Generic_Define("EPOCBLDP", $BldPath);
       
   165 	}
       
   166 	Generic_Define("EPOCTRG",  $RelPath);
       
   167 	Generic_Define("EPOCLIB",  $LibPath);
       
   168 	Generic_Define("EPOCLINK", $LinkPath);
       
   169 	Generic_Define("EPOCSTATLINK", $StatLinkPath);
       
   170 	Generic_Define("EPOCBSFSTATLINK", $RelPath);
       
   171 	Generic_Define("EPOCASSPLINK", $ASSPLinkPath);
       
   172 
       
   173 	Generic_Define("EPOCDATA", $EPOCDataPath);
       
   174 	Generic_Define("EPOCINC",  $EPOCIncPath);
       
   175 	Generic_Define("TRGDIR",   $TrgPath);
       
   176 	Generic_Define("DATADIR",  $DataPath);
       
   177 	
       
   178 
       
   179 	foreach (@BldList) {
       
   180 		&main::Output("\n");
       
   181 
       
   182 		my $bldOffset = "";
       
   183 		$bldOffset .= $featureVariantInfo{$_."_LABEL"}."\\" if (%featureVariantInfo && !$featureVariantInfo{INVARIANT});
       
   184 			
       
   185 		Generic_Define("EPOCBLD$_", "\$(EPOCBLD)\\".$bldOffset.lc($_));
       
   186 		if (defined $ENV{PBUILDPID}) {
       
   187 			Generic_Define("EPOCBLDP$_", "\$(EPOCBLDP)\\".$bldOffset.lc($_));
       
   188 		} else {
       
   189 			Generic_Define("EPOCBLDP$_", "\$(EPOCBLD)\\".$bldOffset.lc($_));
       
   190 		}
       
   191 		Generic_Define("EPOCTRG$_", "\$(EPOCTRG)\\".lc($_));
       
   192 		Generic_Define("EPOCLIB$_", "\$(EPOCLIB)\\".lc($LibSubDir));
       
   193 		Generic_Define("EPOCLINK$_", "\$(EPOCLINK)\\".lc($LibSubDir));
       
   194 		Generic_Define("EPOCSTATLINK$_", "\$(EPOCSTATLINK)\\".lc($_));
       
   195 		Generic_Define("EPOCBSFSTATLINK$_","\$(EPOCBSFSTATLINK)\\".lc($_));
       
   196 		Generic_Define("EPOCASSPLINK$_", "\$(EPOCASSPLINK)\\".lc($LibSubDir));
       
   197 	}
       
   198 	
       
   199 	# Compiler Wrapper option support 
       
   200 	# Generate the information Compiler Wrapper options in second level make file.
       
   201 	if($IsCompilerWrapperOption)
       
   202 	{
       
   203 		&main::Output(
       
   204 			"\n\n",
       
   205 			"#COMPILER WRAPPER OPTION DEFINITIONS\n",
       
   206 			"COMPWRAP = ",
       
   207 			"$ENV{ABLD_COMPWRAP}", # Extract the tool name from environment variable
       
   208 			"\n\n"
       
   209 		);
       
   210 	}
       
   211 	# Compiler Wrapper option
       
   212 	
       
   213 	my $gccxml;
       
   214 	if (&main::Plat =~ /gccxml/i){
       
   215 		$gccxml = &main::Plat;
       
   216 	}
       
   217 	
       
   218 	my $edg;
       
   219 	if (&main::Plat =~ /edg/i){
       
   220 		$edg = &main::Plat;
       
   221 	}
       
   222 	
       
   223 	&main::Output(
       
   224 		"\n",
       
   225 		"# EPOC PSEUDOTARGETS\n",
       
   226 		"\n"
       
   227 	);
       
   228 
       
   229 	foreach (@BldList) {
       
   230 		if(!$edg){
       
   231 			&main::Output(
       
   232 				"$_ : MAKEWORK$_ RESOURCE$_\n\n"
       
   233 			);
       
   234 		}
       
   235 		else {
       
   236 			&main::Output(
       
   237 				"$_ : MAKEWORK$_ \n\n"
       
   238 			);
       
   239 		}
       
   240 	}
       
   241 
       
   242 	&main::Output(	# ALL comes after DEB: because first target in makefile is the default
       
   243 		"ALL :"
       
   244 	);
       
   245 	foreach (@BldList) {
       
   246 		&main::Output(
       
   247 			" $_"
       
   248 		);
       
   249 	}
       
   250 	# # Compiler Wrapper option support 
       
   251 	if($IsCompilerWrapperOption)
       
   252 	{
       
   253 		&main::Output(	# ALL comes after DEB: because first target in makefile is the default
       
   254 			"\n\nCOMPWRAPALL : COMPWRAPUREL COMPWRAPUDEB"
       
   255 		);
       
   256 
       
   257 	}
       
   258 
       
   259 	&main::Output(
       
   260 		"\n",
       
   261 		"\n",
       
   262 		"CLEAN CLEANALL : CLEANBUILD CLEANRELEASE CLEANLIBRARY\n",
       
   263 		"\n"
       
   264 	);
       
   265 	my $pseudoTarget;
       
   266 	foreach $pseudoTarget ("WHAT", "RESOURCE", "CLEANBUILD", "CLEANRELEASE", 
       
   267 				"MAKEWORK", "LISTING")
       
   268 		{
       
   269 		if(($gccxml && $pseudoTarget eq "RESOURCE") ||
       
   270 		!($gccxml || $edg)){
       
   271 
       
   272 			&main::Output(
       
   273 				"\n",
       
   274 				"\n",
       
   275 				"$pseudoTarget $pseudoTarget","ALL :"
       
   276 			);
       
   277 			foreach (@BldList) {
       
   278 				&main::Output(
       
   279 					" $pseudoTarget$_"
       
   280 				);
       
   281 			}
       
   282 		}	
       
   283 	}
       
   284 	if($gccxml){
       
   285 		&main::Output(
       
   286 		"\n",
       
   287 		"\n",
       
   288 		);
       
   289 	}
       
   290 
       
   291 	if(!($gccxml || $edg)){
       
   292 		&main::Output(
       
   293 			"\n",
       
   294 			"\n",
       
   295 			"MAKEWORK : MAKEWORKLIBRARY\n",
       
   296 			"\n"
       
   297 		);
       
   298 	}
       
   299 	if(!$edg){
       
   300 		foreach (@BldList) {
       
   301 			&main::Output(
       
   302 				"RESOURCE$_ "
       
   303 			);
       
   304 		}
       
   305 		&main::Output(
       
   306 			": GENERIC_RESOURCE\n",
       
   307 			"\n"
       
   308 		);
       
   309 	}
       
   310 }
       
   311 
       
   312 # Quote name if necessary, according to the type of Makefile
       
   313 
       
   314 sub Generic_Quote ($) {
       
   315 	my ($name)=@_;
       
   316 	if ($MakefileType==1) {
       
   317 		# GNU make wants backslash before each space
       
   318 		$name =~ s/ /\\ /go;
       
   319 	} else {
       
   320 		# NMAKE prefers quotes around all filenames
       
   321 		$name = "\"$name\"";
       
   322 	}
       
   323 	return $name;
       
   324 }
       
   325 
       
   326 # Generic file copying action, which uses built-in variables quoted appropriately
       
   327 #
       
   328 # GNU make variables may contain spaces, but perl.exe will be executed directly
       
   329 # and so doesn't need any quotes.
       
   330 
       
   331 sub Generic_CopyAction($) {
       
   332 	my ($target) = @_;
       
   333 	my $source = '$?';
       
   334 	$target = '$@' if (!defined $target);
       
   335 	return "perl -S ecopyfile.pl $source $target\n";
       
   336 }
       
   337 
       
   338 # Record necessary directories, for eventual emkdir.pl rules
       
   339 # Also need to record related defines, to eliminate duplicates
       
   340 
       
   341 my %DirDefines;
       
   342 sub expandDefines ($) {
       
   343 	my ($value)=@_;
       
   344 	while ($value =~ /^(.*?)\$\((\w+)\)(.*)$/) {
       
   345 		last if ($2 eq 'PBUILDPID');
       
   346 		$value="$1$DirDefines{$2}$3";
       
   347 	}
       
   348 	return $value;
       
   349 }
       
   350 sub Generic_Define ($$;$) {
       
   351 	my ($name, $value, $trailer)=@_;
       
   352 	$trailer="" if (! defined $trailer);
       
   353 	&main::Output(
       
   354 		"$name = $value$trailer\n"
       
   355 	);
       
   356 	$DirDefines{$name}=expandDefines($value);
       
   357 }
       
   358 sub Generic_Definition ($) {
       
   359 	return $DirDefines{$_[0]};
       
   360 }
       
   361 
       
   362 my %MkDirs;
       
   363 sub Generic_MkDir ($) {
       
   364 	my $dir=&main::Path_Chop(&expandDefines($_[0]));
       
   365 	$dir = lc $dir;
       
   366 	$dir =~ s/\$\(pbuildpid\)/\$\(PBUILDPID\)/g;
       
   367 	$MkDirs{$dir}=1;
       
   368 	return $dir;
       
   369 }
       
   370 
       
   371 # Accumulate MAKEWORK targets and lists of directories,
       
   372 # automatically filling in the rest of the details.
       
   373 #
       
   374 my %MakeWork;
       
   375 sub Generic_MakeWorkDir($$) {
       
   376 	my ($work, $dir) = @_;
       
   377 
       
   378 	if ( LocalBuildPathExists() ) {
       
   379 		$dir = ConvertToLocalBuild($dir);
       
   380 	}
       
   381 
       
   382 	my $workhash;
       
   383 	if (defined $MakeWork{$work}) {
       
   384 		$workhash=$MakeWork{$work};
       
   385 	} else {
       
   386 		my %newhash;
       
   387 		$workhash=\%newhash;
       
   388 		$MakeWork{$work}=$workhash;
       
   389 	}
       
   390 	my $normdir=lc &main::Path_Chop(&expandDefines($dir));
       
   391 	$normdir =~ s/\$\(pbuildpid\)/\$\(PBUILDPID\)/g;
       
   392 	$$workhash{$normdir} ||= &Generic_MkDir($dir);
       
   393 }
       
   394 
       
   395 sub Generic_MakeWorkFile($$) {
       
   396 	my ($work, $file) = @_;
       
   397 	my $dir=&main::Path_Split('Path',&expandDefines($file));
       
   398 	&Generic_MakeWorkDir($work,$dir);
       
   399 }
       
   400 
       
   401 
       
   402 sub Generic_WhatTargets($$@)
       
   403 {
       
   404 	my ($prefix, $whattarget, @files)=@_;
       
   405 	
       
   406 	if ((scalar @files) == 0) {
       
   407 		&main::Output(
       
   408 			"\n",
       
   409 			"\n$whattarget :\n",
       
   410 			"\t\@rem none\n"
       
   411 		);
       
   412 	} else {
       
   413 # emit list of releasables in batches to avoid overflowing the 2048 character 
       
   414 # batch file line limit doing echo or erase...
       
   415 
       
   416 		my $count=1;
       
   417 		my $length=0;
       
   418 		&main::Output(
       
   419 			"\n",
       
   420 			"${prefix}_RELEASEABLES$count="
       
   421 		);
       
   422 
       
   423 		my $File;
       
   424 
       
   425 		foreach $File (sort @files) {
       
   426 			my $name = &Generic_Quote($File);
       
   427 			my $namelen = length($name)+3;	# for space, newline and tab
       
   428 			if ($length+$namelen > 1700) {	# very conservative limit
       
   429 				$count++;
       
   430 				$length=0;
       
   431 				&main::Output(
       
   432 					"\n",
       
   433 					"${prefix}_RELEASEABLES$count="
       
   434 				);
       
   435 			}
       
   436 			&main::Output(
       
   437 				" \\\n\t", $name
       
   438 			);
       
   439 			$length += $namelen;
       
   440 		}
       
   441 		&main::Output(
       
   442 			"\n",
       
   443 			"\n",
       
   444 			"$whattarget:\n"
       
   445 		);
       
   446 		my $filecount=1;
       
   447 		while ($filecount<=$count) {
       
   448 			&main::Output(
       
   449 				"\t\@echo \$(${prefix}_RELEASEABLES$filecount)\n"
       
   450 			);
       
   451 			$filecount++;
       
   452 		}
       
   453 	}
       
   454 
       
   455 	&main::Output(
       
   456 		"\n",
       
   457 	);
       
   458 }
       
   459 	
       
   460 sub Generic_CleanTargets($$@) {
       
   461 	my ($prefix, $cleantarget, @files)=@_;
       
   462 	
       
   463 	if ((scalar @files) == 0) {
       
   464 		&main::Output(
       
   465 			"\n",
       
   466 			"\n$cleantarget :\n",
       
   467 			"\t\@rem none\n"
       
   468 		);
       
   469 	} else {
       
   470 # emit list of releasables in batches to avoid overflowing the 2048 character 
       
   471 # batch file line limit doing echo or erase...
       
   472 
       
   473 		my $count=1;
       
   474 		my $length=0;
       
   475 		&main::Output(
       
   476 			"\n",
       
   477 			"${prefix}_CLEANTARGETS$count="
       
   478 		);
       
   479 
       
   480 		my $File;
       
   481 
       
   482 		foreach $File (sort @files) {
       
   483 			my $name = &Generic_Quote($File);
       
   484 			my $namelen = length($name)+3;	# for space, newline and tab
       
   485 			if ($length+$namelen > 1700) {	# very conservative limit
       
   486 				$count++;
       
   487 				$length=0;
       
   488 				&main::Output(
       
   489 					"\n",
       
   490 					"${prefix}_CLEANTARGETS$count="
       
   491 				);
       
   492 			}
       
   493 			if (!main::NoExportLibrary || ($name !~ /.dso$/i && $name !~ /.lib$/i))
       
   494 			{
       
   495 				&main::Output(
       
   496 					" \\\n\t", $name
       
   497 				);
       
   498 				$length += $namelen;
       
   499 			}
       
   500 		}
       
   501 		&main::Output(
       
   502 			"\n",
       
   503 			"\n",
       
   504 			"$cleantarget:\n",
       
   505 		);
       
   506 		my $filecount=1;
       
   507 		while ($filecount<=$count) {
       
   508 			&main::Output(
       
   509 				"\t-\$(ERASE) \$(${prefix}_CLEANTARGETS$filecount)\n"
       
   510 			);
       
   511 			$filecount++;
       
   512 		}
       
   513 	}
       
   514 
       
   515 	&main::Output(
       
   516 		"\n",
       
   517 	);
       
   518 }
       
   519 
       
   520 sub Generic_WhatCleanTargets($$$@) {
       
   521 	my ($prefix, $whattarget, $cleantarget, @files)=@_;
       
   522 	
       
   523 	if ((scalar @files) == 0) {
       
   524 		&main::Output(
       
   525 			"\n",
       
   526 			"\n$whattarget $cleantarget :\n",
       
   527 			"\t\@rem none\n"
       
   528 		);
       
   529 	} else {
       
   530 # emit list of releasables in batches to avoid overflowing the 2048 character 
       
   531 # batch file line limit doing echo or erase...
       
   532 
       
   533 		my $count=1;
       
   534 		my $length=0;
       
   535 		&main::Output(
       
   536 			"\n",
       
   537 			"${prefix}_RELEASEABLES$count="
       
   538 		);
       
   539 
       
   540 		my $File;
       
   541 
       
   542 		foreach $File (sort @files) {
       
   543 			my $name = &Generic_Quote($File);
       
   544 			my $namelen = length($name)+3;	# for space, newline and tab
       
   545 			if ($length+$namelen > 1700) {	# very conservative limit
       
   546 				$count++;
       
   547 				$length=0;
       
   548 				&main::Output(
       
   549 					"\n",
       
   550 					"${prefix}_RELEASEABLES$count="
       
   551 				);
       
   552 			}
       
   553 			&main::Output(
       
   554 				" \\\n\t", $name
       
   555 			);
       
   556 			$length += $namelen;
       
   557 		}
       
   558 		&main::Output(
       
   559 			"\n",
       
   560 			"\n",
       
   561 			"$whattarget:\n"
       
   562 		);
       
   563 		my $filecount=1;
       
   564 		while ($filecount<=$count) {
       
   565 			&main::Output(
       
   566 				"\t\@echo \$(${prefix}_RELEASEABLES$filecount)\n"
       
   567 			);
       
   568 			$filecount++;
       
   569 		}
       
   570 		&main::Output(
       
   571 			"\n",
       
   572 			"$cleantarget:\n",
       
   573 		);
       
   574 		$filecount=1;
       
   575 		while ($filecount<=$count) {
       
   576 			&main::Output(
       
   577 				"\t-\$(ERASE) \$(${prefix}_RELEASEABLES$filecount)\n"
       
   578 			);
       
   579 			$filecount++;
       
   580 		}
       
   581 	}
       
   582 
       
   583 	&main::Output(
       
   584 		"\n",
       
   585 	);
       
   586 }
       
   587 
       
   588 # accumulated list of generic releasables
       
   589 my %Files;	
       
   590 sub Generic_End {
       
   591 	&Generic_WhatCleanTargets("GENERIC","WHATGENERIC","CLEANGENERIC", keys %Files);
       
   592 	
       
   593 	&main::Output(
       
   594 		"# Rules to create all necessary directories\n",
       
   595 	);
       
   596 
       
   597 	foreach (sort keys %MakeWork) {
       
   598 		my $workhash = $MakeWork{$_};
       
   599 		&main::Output(
       
   600 			"\n$_ :",
       
   601 		);
       
   602 		foreach (sort keys %$workhash) {
       
   603 			my $withcase=$$workhash{$_};
       
   604 			if ($withcase =~ /\$\(PBUILDPID\)\\/) {
       
   605 				&main::Output(
       
   606 					" \\\n",
       
   607 					"\t\$(if \$(PBUILDPID),", &Generic_Quote($withcase), ")"
       
   608 				);
       
   609 			} else {
       
   610 				&main::Output(
       
   611 					" \\\n",
       
   612 					"\t", &Generic_Quote($withcase)
       
   613 				);
       
   614 			}
       
   615 		}
       
   616 		&main::Output(
       
   617 			"\n"
       
   618 		);
       
   619 	}
       
   620 	&main::Output(
       
   621 		"\n",
       
   622 		"\n"
       
   623 	);
       
   624 
       
   625 	my $dir;
       
   626 	foreach $dir (sort keys %MkDirs) {
       
   627 		if ($dir =~ /\$\(PBUILDPID\)\\/) {
       
   628 			&main::Output(
       
   629 				"\$(if \$(PBUILDPID),", &Generic_Quote($dir),") \\\n",
       
   630 			);
       
   631 		} else {
       
   632 			&main::Output(
       
   633 				&Generic_Quote($dir)," \\\n",
       
   634 			);
       
   635 		}
       
   636 	}
       
   637 	&main::Output(
       
   638 		":\n",
       
   639 		"\tperl -S emkdir.pl \$\@\n",
       
   640 		"\n"
       
   641 	);
       
   642 
       
   643 	&main::Output(
       
   644 		"CHECKSOURCE :\n",
       
   645 	);
       
   646 
       
   647 	&main::Output (CheckSource_MakefileOutput(&main::CheckSourceMMPIncludes));
       
   648 	&main::Output (CheckSource_MakefileOutput(%CheckSourceResourceIncludes));
       
   649 	&main::Output (CheckSource_MakefileOutput(&main::CheckSourceMMPMetaData));
       
   650 
       
   651 	my $cs_targetprefix = "";
       
   652 	$cs_targetprefix = "U" unless (&main::Plat =~ /tools/i);
       
   653 
       
   654 	&main::Output(
       
   655 		"\nCHECKSOURCE".$cs_targetprefix."REL :\n",
       
   656 	);
       
   657 
       
   658 	&main::Output (CheckSource_MakefileOutput(&main::CheckSourceURELIncludes));
       
   659 
       
   660 	&main::Output(
       
   661 		"\nCHECKSOURCE".$cs_targetprefix."DEB :\n",
       
   662 	);
       
   663 
       
   664 	&main::Output (CheckSource_MakefileOutput(&main::CheckSourceUDEBIncludes));
       
   665 
       
   666 }
       
   667 
       
   668 sub Generic_Releaseables {
       
   669 
       
   670 	my $ResrcPath=&main::TrgPath;
       
   671 	my $dir;
       
   672 	my $EPOCIncPath=&main::EPOCIncPath;
       
   673 
       
   674 	&Generic_MakeWorkDir('GENERIC_MAKEWORK',$SavedBldPath);	    # used for temp directory in epocrc.pl
       
   675 			
       
   676 	my $AifStructRef=&main::AifStructRef;
       
   677 	my $AifRef;
       
   678 	foreach $AifRef (@$AifStructRef) {
       
   679 # regression change - workaround lack of AIF directory
       
   680 		$$AifRef{TrgFile}=&main::Path_Split('File',$$AifRef{Trg});  # record for later
       
   681 		my $path=&main::Path_Split('Path',"$ResrcPath$$AifRef{Trg}");  
       
   682 		my $file="\$(EPOCDATA)\\$ResrcPath$$AifRef{Trg}";
       
   683 		my $xip="_xip";
       
   684 		my $base=&main::Path_Split('Base',"$file");
       
   685 		my $root=&main::Path_Split('Path',"$file");
       
   686 		my $ext=&main::Path_Split('Ext',"$file");
       
   687 		my $file_xip="$root"."$base$xip$ext";	# since XIP AIF format is generated
       
   688 		if ($path eq "") {
       
   689 			# no target path for the AIF file, so not a releasable
       
   690 			$file="$SavedBldPath\\$$AifRef{Trg}";
       
   691 		} else {
       
   692 			$Files{$file}=1;
       
   693 			$Files{$file_xip}=1;
       
   694 		}
       
   695 		$$AifRef{GenericTrg}=$file;	    # record for later
       
   696 		&Generic_MakeWorkFile('GENERIC_MAKEWORK',$file);
       
   697 	}
       
   698 
       
   699 	my $BitMapStructRef=&main::BitMapStructRef;
       
   700 	my $BitMapRef;
       
   701 	foreach $BitMapRef (@$BitMapStructRef) {
       
   702 		my $path=$$BitMapRef{TrgPath};
       
   703 		my $file="\$(EPOCDATA)\\$path$$BitMapRef{Trg}";
       
   704 		$$BitMapRef{GenericTrg}=$file;	    # record for later
       
   705 		$Files{$file}=1;
       
   706 		&Generic_MakeWorkFile('GENERIC_MAKEWORK',$file);
       
   707 		if ($$BitMapRef{Hdr}) {
       
   708 			my $mbg=&main::Path_Split('Base', $$BitMapRef{Trg});
       
   709 			$mbg="\$(EPOCINC)\\$mbg.mbg";
       
   710 			&Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath);
       
   711 			$Files{$mbg}=1;
       
   712 		}
       
   713 	}
       
   714 
       
   715 	my $ResourceStructRef=&main::ResourceStructRef;
       
   716 	my $ResourceRef;
       
   717 	foreach $ResourceRef (@$ResourceStructRef) {
       
   718 		if(defined $$ResourceRef{Hdronly})
       
   719 			{
       
   720 				my $rsg="\$(EPOCINC)\\$$ResourceRef{BaseTrg}.rsg";
       
   721 				$$ResourceRef{GenericTrg}=$rsg;	# record for later
       
   722 
       
   723 				&Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath);
       
   724 				$Files{$rsg}=1;			
       
   725 			}
       
   726 		else
       
   727 			{
       
   728 				my $file="\$(EPOCDATA)\\$$ResourceRef{Trg}";
       
   729 				$$ResourceRef{GenericTrg}=$file;	# record for later
       
   730 				$Files{$file}=1;
       
   731 				&Generic_MakeWorkFile('GENERIC_MAKEWORK',$file);
       
   732 				if ($$ResourceRef{Hdr}) {
       
   733 					my $rsg="\$(EPOCINC)\\$$ResourceRef{BaseTrg}.rsg";
       
   734 					&Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath);
       
   735 					$Files{$rsg}=1;
       
   736 				}
       
   737 			}
       
   738 	}
       
   739 
       
   740 # Do StringTable 'export'
       
   741 	my @stringTables = &main::StringTables();
       
   742 	foreach my $stringtable (@stringTables)
       
   743 	{
       
   744 		if(defined $stringtable->{ExportPath})
       
   745 		{
       
   746 			$Files{$stringtable->{ExportPath}."\\".$stringtable->{BaseTrg}.".h"} = 1;
       
   747 		}
       
   748 	}
       
   749 
       
   750 
       
   751 	&main::Output(
       
   752 		"GENERIC_RESOURCE : GENERIC_MAKEWORK\n",
       
   753 		"\n"
       
   754 	);
       
   755 
       
   756 }
       
   757 
       
   758 sub Generic_BitMapBld {
       
   759 
       
   760 	my $BitMapRef=&main::BitMapRef;
       
   761 	my $quotedTrg=&Generic_Quote($$BitMapRef{GenericTrg});
       
   762 	my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); ## required for Lockit
       
   763 
       
   764 	&main::Output(
       
   765 		"# BitMap $$BitMapRef{Trg}\n",
       
   766 		"\n",
       
   767 		"GENERIC_RESOURCE : $quotedTrg\n",
       
   768 		"\n",
       
   769 		"$quotedTrg :"
       
   770 	);
       
   771 
       
   772 #	must lower-case header here since bmconv generates a header with case-sensitive enums accordingly
       
   773 	my $BitMapHdr=join('', &main::EPOCIncPath, &main::Path_Split('Base', $$BitMapRef{Trg}), '.mbg');
       
   774 	my $TmpBitMapHdr=join('', &main::BldPath, &main::Path_Split('Base', $$BitMapRef{Trg}), '.mbg');
       
   775 
       
   776 	my $SrcRef;
       
   777 	foreach $SrcRef (@{$$BitMapRef{Source}}) {
       
   778 	
       
   779 		if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
       
   780 			%Files = &Lockit_Releasables($WorkPath, $$BitMapRef{Trg}, \%Files, basename($$SrcRef{Src}),"","");		
       
   781 		}
       
   782 		else {
       
   783 			%Files = &Lockit_Releasables($WorkPath, $$BitMapRef{Trg}, \%Files, basename($$SrcRef{Src}));
       
   784 		}
       
   785 		&main::Output(
       
   786 			" \\\n  ", &Generic_Quote($$SrcRef{Src})
       
   787 		);
       
   788 	}
       
   789 	&main::Output(
       
   790 		"\n",
       
   791 		"\tperl -S epocmbm.pl -h\"$TmpBitMapHdr\"",
       
   792 		"\t-o\"$$BitMapRef{GenericTrg}\"",
       
   793 		"\t-l\"\\$$BitMapRef{TrgPath}:$WorkPath\"",
       
   794 		"\\\n\t\t"
       
   795 	);
       
   796 	&main::Output(
       
   797 		" -b\""
       
   798 	);
       
   799 	foreach $SrcRef (@{$$BitMapRef{Source}}) {
       
   800 		&main::Output(
       
   801 			"\\\n\t\t/$$SrcRef{ClDepth}$$SrcRef{Src}"
       
   802 		);
       
   803 	}
       
   804 
       
   805 
       
   806 	&main::Output(
       
   807 		"\" \\\n\t\t"
       
   808 	);
       
   809 
       
   810 	&main::Output(
       
   811 		" -l\"\\$$BitMapRef{TrgPath}:$WorkPath\"\n"
       
   812 	);
       
   813 
       
   814 	if ($$BitMapRef{Hdr}) {
       
   815 		&main::Output(
       
   816 			"\tperl -S ecopyfile.pl \"$TmpBitMapHdr\" \"$BitMapHdr\"\n",
       
   817 		);
       
   818 	}
       
   819 	&main::Output(
       
   820 		"\n"
       
   821 	);
       
   822 }
       
   823 
       
   824 sub Generic_ResrcBld {
       
   825 	my $ResourceRef=&main::ResourceRef;
       
   826 	my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); # required for Lockit
       
   827 	my @RcompMacro=&main::MmpMacros;
       
   828 
       
   829 	&main::Output(
       
   830 		"# Resource $$ResourceRef{Trg}\n",
       
   831 		"\n"
       
   832 	);
       
   833 	my @DepList=&main::DepList;
       
   834 
       
   835 	&main::Output(
       
   836 		"DEPEND="
       
   837 	);
       
   838 	foreach (@DepList) {
       
   839 		&main::Output(
       
   840 			" \\\n",
       
   841 			"\t", &Generic_Quote($_)
       
   842 		);
       
   843 	}
       
   844 	&main::Output(
       
   845 		"\n",
       
   846 		"\n"
       
   847 	);
       
   848 
       
   849 	my $BaseResrc= $$ResourceRef{BaseTrg};
       
   850 	my $SrcPath=&main::Path_Split('Path', $$ResourceRef{Source});
       
   851 
       
   852 	my $AbsSrc;
       
   853 	my $AbsSrcPath;
       
   854 	
       
   855 	my $ResrcHdr=join '', &main::EPOCIncPath(), $BaseResrc, '.rsg';
       
   856 	my $AbsResrcHdr;
       
   857 	my $PlatName=&main::PlatName;
       
   858 
       
   859 	my @ChopAbsSysIncPaths;
       
   860 	my @ChopAbsUserIncPaths;
       
   861 
       
   862 	@ChopAbsSysIncPaths=&main::Path_Chop(&main::Path_AbsToWork(&main::ResourceSysIncPaths));
       
   863 	@ChopAbsUserIncPaths=&main::Path_Chop(&main::Path_AbsToWork(&main::UserIncPaths));
       
   864 
       
   865 	$AbsSrc=&main::Path_AbsToWork($$ResourceRef{Source});
       
   866 	$AbsSrcPath=&main::Path_AbsToWork($SrcPath);
       
   867 	$AbsResrcHdr=&main::Path_AbsToWork($ResrcHdr);
       
   868 
       
   869 	my $ChopAbsSrcPath=&main::Path_Chop($AbsSrcPath);
       
   870 
       
   871 	my $EPOCDataDir = &main::Path_Chop($$ResourceRef{TrgPath});
       
   872 	
       
   873 	my $RscOption= "";
       
   874 	my $HeaderOption = "";
       
   875 	my $HeaderCopyCmd = "";
       
   876     if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha'))  {
       
   877 	if ($$ResourceRef{Hdr} || $$ResourceRef{Hdronly}) {
       
   878 		$HeaderOption = " -h\"$SavedBldPath\\$BaseResrc$$ResourceRef{Lang}.rsg\"";
       
   879 		$HeaderCopyCmd = "\tperl -S ecopyfile.pl \"$SavedBldPath\\$BaseResrc$$ResourceRef{Lang}.rsg\" \"$ResrcHdr\"\n";
       
   880 	}
       
   881 	
       
   882 	}
       
   883 	else {
       
   884 	if ($$ResourceRef{Hdr} || $$ResourceRef{Hdronly}) {
       
   885 		$HeaderOption = " -h\"$SavedBldPath\\$BaseResrc.rsg\"";
       
   886 		$HeaderCopyCmd = "\tperl -S ecopyfile.pl \"$SavedBldPath\\$BaseResrc.rsg\" \"$ResrcHdr\"\n";
       
   887 	}
       
   888 	}
       
   889 	if (! $$ResourceRef{Hdronly}) {
       
   890 		$RscOption = " -o\$\@ ";
       
   891 	}
       
   892 	
       
   893 	my $Uidsref=$$ResourceRef{Uids};
       
   894 	my @Uids=();
       
   895 	@Uids = @{$Uidsref} if (defined($Uidsref));
       
   896 	my $Uidsarg="";
       
   897 	if ($#Uids>0) {
       
   898 		$Uidsarg="-uid2 $Uids[0] -uid3 $Uids[1]";
       
   899 	}
       
   900 	elsif ($#Uids==0) {
       
   901 		$Uidsarg="-uid2 $Uids[0] ";
       
   902 	}
       
   903 	if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha'))  {
       
   904 		%Files = &Lockit_Releasables($WorkPath, $$ResourceRef{Source}, \%Files, "", $$ResourceRef{Lang}) unless $$ResourceRef{Hdronly};
       
   905 	}
       
   906 	else {			
       
   907 		%Files = &Lockit_Releasables($WorkPath,$$ResourceRef{Source}, \%Files, "") unless $$ResourceRef{Hdronly};
       
   908 	}
       
   909 	my $quotedTrg=&Generic_Quote($$ResourceRef{GenericTrg});
       
   910 	&main::Output(
       
   911 		"GENERIC_RESOURCE : $quotedTrg\n",
       
   912 		"\n",
       
   913 		"$quotedTrg : ", &Generic_Quote($AbsSrc), " \$(DEPEND)\n",
       
   914 		"\tperl -S epocrc.pl -m045,046,047 -I \"$ChopAbsSrcPath\""
       
   915 	);
       
   916 	foreach (@ChopAbsUserIncPaths) {
       
   917 		&main::Output(
       
   918 			" -I \"$_\""
       
   919 		);
       
   920 	}
       
   921 	&main::Output(
       
   922 		" -I-"
       
   923 	);
       
   924 	foreach (@ChopAbsSysIncPaths) {
       
   925 		&main::Output(
       
   926 			" -I \"$_\""
       
   927 		);
       
   928 	}
       
   929 	foreach(@RcompMacro) {
       
   930 		&main::Output(
       
   931 			" -D$_ "
       
   932 		);
       
   933 	}
       
   934 	&main::Output(
       
   935 		" -DLANGUAGE_$$ResourceRef{Lang} -u \"$AbsSrc\" ",
       
   936 		" $Uidsarg ",
       
   937 		"$RscOption $HeaderOption -t\"$SavedBldPath\""
       
   938 	);
       
   939 
       
   940 	if (!$$ResourceRef{Hdronly}) {
       
   941 		&main::Output(
       
   942 			" -l\"$EPOCDataDir:$WorkPath\""
       
   943 		);				
       
   944 	}
       
   945 
       
   946 	if (&main::ResourceVariantFile()) {
       
   947 		&main::Output(
       
   948 			" -preinclude\"".&main::ResourceVariantFile()."\""
       
   949 		);
       
   950 	}
       
   951 	if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
       
   952 		if ((lc $$ResourceRef{Lang}) eq "sc") {
       
   953 	
       
   954 			&main::Output(
       
   955 				"\n",
       
   956 				$HeaderCopyCmd,
       
   957 			);
       
   958 		}
       
   959 		&main::Output(		
       
   960 		"\n"
       
   961 		);
       
   962 	
       
   963 	}
       
   964 	else {
       
   965 		&main::Output(
       
   966 			"\n",
       
   967 			$HeaderCopyCmd,
       
   968 			"\n"
       
   969 		);
       
   970 	}
       
   971 
       
   972 	my @macros;
       
   973 	push @macros, "LANGUAGE_$$ResourceRef{Lang}", "_UNICODE";
       
   974 	my @userIncludes = &main::Path_Chop(&main::Path_AbsToWork(&main::UserIncPaths));
       
   975 	unshift (@userIncludes, $AbsSrcPath);	
       
   976 	my @systemIncludes = &main::Path_Chop(&main::Path_AbsToWork(&main::ResourceSysIncPaths));
       
   977 
       
   978 	CheckSource_Includes($AbsSrc, %CheckSourceResourceIncludes, &Variant_GetMacroHRHFile(), @macros, @userIncludes, @systemIncludes);
       
   979 }
       
   980 
       
   981 sub Generic_AifBld {
       
   982 
       
   983 	my $AifRef=&main::AifRef;
       
   984 	my $ResrcPath=&main::TrgPath;
       
   985 
       
   986 	&main::Output(
       
   987 		"# Aif $$AifRef{Trg}\n",
       
   988 		"\n"
       
   989 	);
       
   990 	my @DepList=&main::DepList;
       
   991 
       
   992 	&main::Output(
       
   993 		"DEPEND="
       
   994 	);
       
   995 	foreach (@DepList) {
       
   996 		&main::Output(
       
   997 			" \\\n",
       
   998 			"\t", &Generic_Quote($_)
       
   999 		);
       
  1000 	}
       
  1001 	&main::Output(
       
  1002 		"\n",
       
  1003 		"\n"
       
  1004 	);
       
  1005 
       
  1006 	my @ChopRTWSysIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::ResourceSysIncPaths));
       
  1007 	my @ChopRTWUserIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::UserIncPaths));
       
  1008 	my $BaseResrc=&main::Path_Split('Base',$$AifRef{Source});
       
  1009 
       
  1010 	my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); # required for Lockit
       
  1011 	my $quotedTrg=&Generic_Quote($$AifRef{GenericTrg});
       
  1012 	&main::Output(
       
  1013 		"GENERIC_RESOURCE : $quotedTrg\n",
       
  1014 		"\n",
       
  1015 		"$quotedTrg : ", &Generic_Quote("$$AifRef{Source}"), " \$(DEPEND)"
       
  1016 	);
       
  1017 	if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
       
  1018 	%Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, "", "");
       
  1019 	}
       
  1020 	else 
       
  1021 	{
       
  1022 	%Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, "");
       
  1023 	}
       
  1024 	my $bitmapArg = "";
       
  1025 	if ($$AifRef{BitMaps}) { # bitmaps aren't essential
       
  1026 		$bitmapArg = "\\\n\t\t-b\"";
       
  1027 		foreach my $BitMapRef (@{$$AifRef{BitMaps}}) {
       
  1028 			my $BitMap = &main::Path_Split('File', $$BitMapRef{Src});
       
  1029 			if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
       
  1030 			%Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, $BitMap, "");
       
  1031 			}
       
  1032 			else
       
  1033 			{
       
  1034 			%Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, $BitMap);
       
  1035 			}
       
  1036 			&main::Output(
       
  1037 				" ", &Generic_Quote("$$BitMapRef{Src}")
       
  1038 			);
       
  1039 			$bitmapArg .= "\\\n\t\t/$$BitMapRef{ClDepth}$$BitMapRef{Src}";
       
  1040 		}
       
  1041 		$bitmapArg .= "\" ";
       
  1042 	}
       
  1043 	&main::Output(
       
  1044 		"\n",
       
  1045 		"\tperl -S epocaif.pl -o\$\@ ",
       
  1046 		"\"$$AifRef{Source}\" ",
       
  1047 		"\\\n\t\t",
       
  1048 		"-t\"$SavedBldPath\" ",
       
  1049 		" -l\"\$(TRGDIR):$WorkPath\"",
       
  1050 		$bitmapArg,
       
  1051 		"\\\n\t\t"
       
  1052 	);
       
  1053 	foreach (@ChopRTWUserIncPaths) {
       
  1054 		&main::Output(
       
  1055 			" -I \"$_\""
       
  1056 		);
       
  1057 	}
       
  1058 	&main::Output(
       
  1059 		" -I-"
       
  1060 	);
       
  1061 	foreach (@ChopRTWSysIncPaths) {
       
  1062 		&main::Output(
       
  1063 			" -I \"$_\""
       
  1064 		);
       
  1065 	}
       
  1066 	&main::Output(
       
  1067 		"\n",
       
  1068 		"\n"
       
  1069 	);
       
  1070 }
       
  1071 
       
  1072 
       
  1073 
       
  1074 #
       
  1075 # Check to see that LOCAL_BUILD_PATH exists.
       
  1076 #
       
  1077 
       
  1078 sub LocalBuildPathExists() 
       
  1079 {
       
  1080 	if ( defined( $ENV{LOCAL_BUILD_PATH} ) ) {
       
  1081 		return 1;
       
  1082 	}
       
  1083 	else {
       
  1084 		return 0;
       
  1085 	}
       
  1086 }
       
  1087 
       
  1088 
       
  1089 #
       
  1090 # Take the build path and ensure that it is now local. 
       
  1091 #
       
  1092 
       
  1093 
       
  1094 sub ConvertToLocalBuild($)
       
  1095 {
       
  1096 	my ($BldPath)=@_;
       
  1097 
       
  1098 	my $sub_replacement = $ENV{"LOCAL_BUILD_PATH"};
       
  1099 	if ( !ValidBuildPath($sub_replacement) ) {
       
  1100 		&FatalError(" Invalid Local Build Path : LOCAL_BUILD_PATH = \"$BldPath\"  must be in format drive:dir_name1 " );
       
  1101 	}
       
  1102 	else
       
  1103 	{
       
  1104 		# Replace the \epoc32\build with local setting
       
  1105 		my $epocroot=$ENV{"EPOCROOT"};
       
  1106 		
       
  1107 		my $sub_match = "\Q${epocroot}\EEPOC32\\\\BUILD";
       
  1108 		$BldPath =~ s/${sub_match}/${sub_replacement}/;
       
  1109 	}
       
  1110 
       
  1111 	return $BldPath
       
  1112 }
       
  1113 
       
  1114 
       
  1115 
       
  1116 #
       
  1117 # Checks that the path is at least of the form drive:path_name
       
  1118 # If no drive: then the makefiles will be produced but not work. 
       
  1119 #
       
  1120 
       
  1121 
       
  1122 sub ValidBuildPath($)
       
  1123 {
       
  1124 	my ($BldPath)=@_;
       
  1125 
       
  1126 	if ( $BldPath =~/^[a-zA-z]{1}:{1}.*$/) {
       
  1127 		# Must have at least d:
       
  1128 		return 1;
       
  1129 	}
       
  1130 	else {
       
  1131 		return 0;
       
  1132 	}
       
  1133 
       
  1134 }
       
  1135 
       
  1136 1;
       
  1137