imgtools/buildrom/tools/buildrom.pm
changeset 607 378360dbbdba
parent 590 360bd6b35136
parent 606 30b30f9da0b7
child 609 f76e0f94b7ab
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
    63 	$useinterpretsis = 0;
    63 	$useinterpretsis = 0;
    64 }
    64 }
    65 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
    65 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
    66 
    66 
    67 my $BuildromMajorVersion = 3 ;
    67 my $BuildromMajorVersion = 3 ;
    68 my $BuildromMinorVersion = 24;
    68 my $BuildromMinorVersion = 26;
    69 my $BuildromPatchVersion = 0;
    69 my $BuildromPatchVersion = 0;
    70 
    70 
    71 
    71 
    72 sub print_usage
    72 sub print_usage
    73 {
    73 {
   148    -l=xxx or -logimagecontents=xxx  -- extract all stub-sis and SWI certificate store file(s) only 
   148    -l=xxx or -logimagecontents=xxx  -- extract all stub-sis and SWI certificate store file(s) only 
   149                                     and log all the file(s) that are part of the Z drive image on to a log file.  
   149                                     and log all the file(s) that are part of the Z drive image on to a log file.  
   150    -I<directory>                    -- Use <directory> for the referenced IBY/OBY files
   150    -I<directory>                    -- Use <directory> for the referenced IBY/OBY files
   151    -argfile=xxx                     -- specify argument-file name containing list of command-line arguments to buildrom   
   151    -argfile=xxx                     -- specify argument-file name containing list of command-line arguments to buildrom   
   152    -lowmem                          -- use memory-mapped file for image build to reduce physical memory consumption   
   152    -lowmem                          -- use memory-mapped file for image build to reduce physical memory consumption   
   153    -chechcase                       -- check character case of path/name in oby/iby files, 
   153    -checkcase                       -- check character case of path/name in oby/iby files, 
   154                                     the result will be checkcase.log, this option is only valid on windows.
   154                                     the result will be checkcase.log, this option is only valid on windows.
   155    -workdir=xxx                     -- specify a directory to contain generated files.   
   155    -workdir=xxx                     -- specify a directory to contain generated files.   
   156 
   156 
   157 Popular -D defines to use include
   157 Popular -D defines to use include
   158 
   158 
   224 my $opt_cleancache = 0;
   224 my $opt_cleancache = 0;
   225 
   225 
   226 my $thisdir=cwd;
   226 my $thisdir=cwd;
   227 $thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
   227 $thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
   228 $thisdir.= "\/" unless $thisdir =~ /\/$/;
   228 $thisdir.= "\/" unless $thisdir =~ /\/$/;
   229 $thisdir=~s-^(.:)?\/--o;		    # remove drive letter and leading backslash
   229 $thisdir =~ s-\/-\\-g if (&is_windows);
   230 
   230 
   231 my $rominclude = $epocroot."epoc32\/rom\/include\/";
   231 my $rominclude = $epocroot."epoc32\/rom\/include\/";
   232 $rominclude = &get_epocdrive().$rominclude unless $rominclude =~ /^.:/;
   232 $rominclude = &get_epocdrive().$rominclude unless $rominclude =~ /^.:/;
   233 $rominclude =~s-\\-\/-g;
   233 $rominclude =~s-\\-\/-g;
   234 
   234 
   339 my $smrNoImageName = 0;
   339 my $smrNoImageName = 0;
   340 my $onlysmrimage = 1;
   340 my $onlysmrimage = 1;
   341 my $checkcase = 0;
   341 my $checkcase = 0;
   342 my $checkcase_platform = "";
   342 my $checkcase_platform = "";
   343 my $checkcase_test = 0;
   343 my $checkcase_test = 0;
   344 my $invokecmddir = "";
   344 my $opt_workdir = 0;
   345 
   345 
   346 sub match_obyfile
   346 sub match_obyfile
   347 {
   347 {
   348 	my ($obyfile) = @_;
   348 	my ($obyfile) = @_;
   349 	if (-f $obyfile)
   349 	if (-f $obyfile)
   352 		return 1;
   352 		return 1;
   353 	}
   353 	}
   354 
   354 
   355 	# search for the oby file in the list of include directories
   355 	# search for the oby file in the list of include directories
   356 	my @otherDirs = ($rominclude);
   356 	my @otherDirs = ($rominclude);
   357 	push (@otherDirs, $invokecmddir) if ($invokecmddir ne "");
       
   358 
   357 
   359 	if ($featureVariant{'VALID'})
   358 	if ($featureVariant{'VALID'})
   360 	{
   359 	{
   361 		my $dirRef = $featureVariant{'ROM_INCLUDES'};
   360 		my $dirRef = $featureVariant{'ROM_INCLUDES'};
   362 
   361 
   760 	# first searching argList for keepgoing option
   759 	# first searching argList for keepgoing option
   761 	foreach my $arg (@argList) {
   760 	foreach my $arg (@argList) {
   762 		if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i )
   761 		if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i )
   763 	  {
   762 	  {
   764 			$opt_k = 1;		
   763 			$opt_k = 1;		
   765 			next;
   764   		last;	
   766 	  }elsif ($arg =~ /^-workdir=(.*)/)
       
   767 		{
       
   768 			my $workdir=$1;
       
   769 			if( $workdir =~ m/ / )
       
   770 			{
       
   771 				print "* Warning: $workdir contains whitespace, hence the files will be created in default location \n";
       
   772 				$workdir = "";
       
   773 			}
       
   774 			if ($workdir ne "")
       
   775 			{
       
   776 				$invokecmddir = cwd;
       
   777 				$invokecmddir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
       
   778 				$invokecmddir.= "\/" unless $invokecmddir =~ /\/$/;
       
   779 				$workdir =~ s-\\-\/-g;
       
   780 				chdir "$workdir" or die "cannot change to directory $workdir\n";
       
   781 				$thisdir=cwd;
       
   782 				$thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
       
   783 				$thisdir.= "\/" unless $thisdir =~ /\/$/;
       
   784 				$thisdir=~s-^(.:)?\/--o;		    # remove drive letter and leading backslash
       
   785 			}
       
   786 			next;	
       
   787 		}
   765 		}
   788 	}
   766 	}
   789 	foreach my $arg (@argList)
   767 	foreach my $arg (@argList)
   790 	{
   768 	{
   791 	    if ($arg =~ /^-argfile=(.*)/) 
   769 	    if ($arg =~ /^-argfile=(.*)/) 
  1021 			$checkcase_test=1;
   999 			$checkcase_test=1;
  1022 			next;	
  1000 			next;	
  1023 		}
  1001 		}
  1024 		if ($arg =~ /^-workdir=(.*)/)
  1002 		if ($arg =~ /^-workdir=(.*)/)
  1025 		{
  1003 		{
       
  1004 			my $workdir = $1;
       
  1005 			if (!-d $workdir)
       
  1006 			{
       
  1007 				die "directory $workdir does not exist\n";
       
  1008 			}
       
  1009 			my $currentdir = cwd;
       
  1010 			chdir "$workdir" or die "cannot change to directory $workdir\n";
       
  1011 			$thisdir=cwd;
       
  1012 			$thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
       
  1013 			$thisdir.= "\/" unless $thisdir =~ /\/$/;
       
  1014 			if(&is_windows)
       
  1015 			{
       
  1016 				$thisdir =~ s-\/-\\-g;
       
  1017 			}
       
  1018 			$opt_workdir = 1;
       
  1019 			chdir "$currentdir";
  1026 			next;	
  1020 			next;	
  1027 		}
  1021 		}
  1028         if($arg =~/^-c(.*)/)
  1022         if($arg =~/^-c(.*)/)
  1029         {
  1023         {
  1030           if($1 eq 'none' )
  1024           if($1 eq 'none' )
  1251 # Concatentate the specified .oby files and pass them through cpp
  1245 # Concatentate the specified .oby files and pass them through cpp
  1252 # to get the raw ROM specification in tmp1.oby
  1246 # to get the raw ROM specification in tmp1.oby
  1253 
  1247 
  1254 sub preprocessing_phase
  1248 sub preprocessing_phase
  1255 {
  1249 {
  1256 	unlink "tmp1.oby";
  1250 	my $temp1OBYFile = $thisdir."tmp1.oby";
       
  1251 	unlink "$temp1OBYFile";
  1257 
  1252 
  1258 #	Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used
  1253 #	Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used
  1259 	if (defined ($featureXml))
  1254 	if (defined ($featureXml))
  1260 	{
  1255 	{
  1261 		$cppargs .= " -DROM_FEATURE_MANAGEMENT ";
  1256 		$cppargs .= " -DROM_FEATURE_MANAGEMENT ";
  1281 	}
  1276 	}
  1282 	else
  1277 	else
  1283 	{
  1278 	{
  1284 		# no feature variant so use the standard includes
  1279 		# no feature variant so use the standard includes
  1285 		$cppargs .= " -I. -I \"$rominclude\"";
  1280 		$cppargs .= " -I. -I \"$rominclude\"";
  1286 		$cppargs .= " -I \"$invokecmddir\"" if ($invokecmddir ne "");
  1281 	}
  1287 	}
  1282 
  1288 
  1283 	print "* cpp -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v);
  1289 	print "* cpp -Wno-endif-labels -o tmp1.oby $cppargs\n" if ($opt_v);
       
  1290 	
  1284 	
  1291 	is_existinpath("cpp", romutl::DIE_NOT_FOUND);
  1285 	is_existinpath("cpp", romutl::DIE_NOT_FOUND);
  1292 	$errors = 0;
  1286 	$errors = 0;
  1293 	open CPP, "| cpp -Wno-endif-labels -o tmp1.oby $cppargs" or die "* Can't execute cpp";
  1287 	open CPP, "| cpp -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp";
  1294 	foreach my $arg (@obyfiles)
  1288 	foreach my $arg (@obyfiles)
  1295 	{
  1289 	{
  1296 		print CPP "\n#line 1 \"$arg\"\n";
  1290 		print CPP "\n#line 1 \"$arg\"\n";
  1297 	
  1291 	
  1298 		if(open(OBY, $arg)) {
  1292 		if(open(OBY, $arg)) {
  1310 			}
  1304 			}
  1311 		}
  1305 		}
  1312 	}
  1306 	}
  1313 	close CPP;
  1307 	close CPP;
  1314 	my $cpp_status = $?;
  1308 	my $cpp_status = $?;
  1315 	die "* cpp failed\n" if ($cpp_status != 0 || !-f "tmp1.oby");
  1309 	die "* cpp failed\n" if ($cpp_status != 0 || !-f "$temp1OBYFile");
  1316 
  1310 
  1317 	my $temp1OBYFile = "tmp1.oby";
       
  1318 	if( defined ($image_content))
  1311 	if( defined ($image_content))
  1319 	{
  1312 	{
  1320 		#Read the OBY file that was generated by the pre-processor
  1313 		#Read the OBY file that was generated by the pre-processor
  1321 		&ReadPreprocessedFile($temp1OBYFile);
  1314 		&ReadPreprocessedFile($temp1OBYFile);
  1322 
  1315 
  1398 		$substitutionData{"RIGHT_NOW"} = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $mday, $mon+1, $year+1900, $hour, $min, $sec);
  1391 		$substitutionData{"RIGHT_NOW"} = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $mday, $mon+1, $year+1900, $hour, $min, $sec);
  1399 		$substitutionData{"EPOCROOT"} = $epocroot;
  1392 		$substitutionData{"EPOCROOT"} = $epocroot;
  1400 		@substitutionOrder = ("TODAY", "RIGHT_NOW", "EPOCROOT");
  1393 		@substitutionOrder = ("TODAY", "RIGHT_NOW", "EPOCROOT");
  1401 	}
  1394 	}
  1402 
  1395 
       
  1396 	my $temp1OBYFile = $thisdir."tmp1.oby";
  1403 	
  1397 	
  1404 	open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n");
  1398 	open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n");
  1405 	while ($line=<TMP1>)
  1399 	while ($line=<TMP1>)
  1406 	{
  1400 	{
  1407 
       
  1408 		if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i))
  1401 		if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i))
  1409 		{
  1402 		{
  1410 			$onlysmrimage = 0;
  1403 			$onlysmrimage = 0;
  1411 			last;
  1404 			last;
  1412 		}
  1405 		}
  1413 	}
  1406 	}
  1414 	close TMP1;	
  1407 	close TMP1;	
  1415 	if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) )
  1408 	if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) )
  1416 	{
  1409 	{
  1417 		my $defaultFeatureDbFlag = 0;
  1410 		my $defaultFeatureDbFlag = 0;
  1418 		open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n");
  1411 		open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n");
  1419 		while ($line=<TMP1>)
  1412 		while ($line=<TMP1>)
  1420 		{
  1413 		{
  1421 			if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i)
  1414 			if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i)
  1422 			{	
  1415 			{	
  1423 				# Get the default value for featuredatabasefile
  1416 				# Get the default value for featuredatabasefile
  1437 			print "Error: Neither option \"-fm|-nofm\" nor default value for featuredatabase file is provided.\n";
  1430 			print "Error: Neither option \"-fm|-nofm\" nor default value for featuredatabase file is provided.\n";
  1438 			exit(1);			
  1431 			exit(1);			
  1439 		}
  1432 		}
  1440 	}
  1433 	}
  1441 
  1434 
  1442 	open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n");
  1435 	open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n");
  1443 	while ($line=<TMP1>)
  1436 	while ($line=<TMP1>)
  1444 	{
  1437 	{
  1445 		track_source($line);
  1438 		track_source($line);
  1446 		$line =~ s-\\-\/-g;
  1439 		$line =~ s-\\-\/-g;
       
  1440 
       
  1441 		my $tempstring = $epocroot."epoc32";
       
  1442 		if(($line !~ /^\s*\#/) && ($line =~ /\/epoc32/i) 
       
  1443 		 && ($line !~ /EPOCROOT##\/?epoc32/i) && ($line !~ /$tempstring/i))
       
  1444 		{
       
  1445 			print "add EPOCROOT for line: $line\n" if ($opt_v);
       
  1446 	  	$line =~ s-\/epoc32-EPOCROOT##epoc32-ig;
       
  1447 		}
       
  1448 
  1447 		#
  1449 		#
  1448 		# Recognise keywords in lines that we process before substitution
  1450 		# Recognise keywords in lines that we process before substitution
  1449 		#
  1451 		#
  1450 		# # lineno "file" flagno
  1452 		# # lineno "file" flagno
  1451 		# DEFINE name replacement-with-0-spaces
  1453 		# DEFINE name replacement-with-0-spaces
  1800 }
  1802 }
  1801 
  1803 
  1802 sub dump_obydata
  1804 sub dump_obydata
  1803 {
  1805 {
  1804 	my ($dumpfile, $comment) = @_;
  1806 	my ($dumpfile, $comment) = @_;
       
  1807 	$dumpfile = $thisdir.$dumpfile;
  1805 	unlink($dumpfile);
  1808 	unlink($dumpfile);
  1806 	open DUMPFILE, ">$dumpfile" or die("* Can't create $dumpfile\n");
  1809 	open DUMPFILE, ">$dumpfile" or die("* Can't create $dumpfile\n");
  1807 	print "* Writing $dumpfile - $comment\n";
  1810 	print "* Writing $dumpfile - $comment\n";
  1808 	my $line;
  1811 	my $line;
  1809 	foreach $line (@obydata)
  1812 	foreach $line (@obydata)
  2534 			{
  2537 			{
  2535 				push @hidedatainspi, $hidedatafiles[$j]{data}; #push name of data file to be hidden onto array if correct romimage and spi type
  2538 				push @hidedatainspi, $hidedatafiles[$j]{data}; #push name of data file to be hidden onto array if correct romimage and spi type
  2536 			}
  2539 			}
  2537 		}
  2540 		}
  2538 		my @spiargs; #arguments passed to createSpi
  2541 		my @spiargs; #arguments passed to createSpi
  2539 		push @spiargs, ("-t$targetspi", "-d\/$thisdir", "-hide@hidedatainspi");
  2542 		push @spiargs, ("-t$targetspi", "-d$thisdir", "-hide@hidedatainspi");
  2540 		if($existingspi ne "") { push @spiargs, $existingspi; }
  2543 		if($existingspi ne "") { push @spiargs, $existingspi; }
  2541 		&spitool::createSpi(@spiargs, @dataforspi); # external call to 
  2544 		&spitool::createSpi(@spiargs, @dataforspi); # external call to 
  2542 	}
  2545 	}
  2543 }
  2546 }
  2544 
  2547 
  2700                                         next if (!$spipositionflag{$imageIdx});#This spi has already been entered into OBY.
  2703                                         next if (!$spipositionflag{$imageIdx});#This spi has already been entered into OBY.
  2701                                         my $spiIdx=0;
  2704                                         my $spiIdx=0;
  2702                                         while(defined $spiarray[$imageIdx][$spiIdx]) {
  2705                                         while(defined $spiarray[$imageIdx][$spiIdx]) {
  2703                                                 if($spiarray[$imageIdx][$spiIdx]{spifile} =~ /(.+)\.(.*)$/) {
  2706                                                 if($spiarray[$imageIdx][$spiIdx]{spifile} =~ /(.+)\.(.*)$/) {
  2704                                                         my $targetspi="$1-$imageIdx-$spiIdx\.$2";
  2707                                                         my $targetspi="$1-$imageIdx-$spiIdx\.$2";
  2705                                                         push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[$imageIdx][$spiIdx]{spi} . "\"\n";
  2708                                                         push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[$imageIdx][$spiIdx]{spi} . "\"\n";
  2706                                                 }
  2709                                                 }
  2707                                                 $spiIdx++;
  2710                                                 $spiIdx++;
  2708                                         }
  2711                                         }
  2709                                         if($spiIdx == 0){
  2712                                         if($spiIdx == 0){
  2710                                                 # If there is no plugin in this image, the SPI_POSITION statement is ignore.
  2713                                                 # If there is no plugin in this image, the SPI_POSITION statement is ignore.
  2727 					$flag=0;
  2730 					$flag=0;
  2728 					my $k=0;
  2731 					my $k=0;
  2729 					while(defined $spiarray[0][$k]) {
  2732 					while(defined $spiarray[0][$k]) {
  2730 						if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2733 						if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2731 							my $targetspi="$1-0-$k\.$2";
  2734 							my $targetspi="$1-0-$k\.$2";
  2732 							push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi .  "\"\n";
  2735 							push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi .  "\"\n";
  2733 						}
  2736 						}
  2734 						$k++;
  2737 						$k++;
  2735 					}
  2738 					}
  2736 				}
  2739 				}
  2737 				my $j=0;
  2740 				my $j=0;
  2738 				push @newobydata, "\n" . $line . "\n";			
  2741 				push @newobydata, "\n" . $line . "\n";			
  2739 				while(defined $spiarray[$romimage][$j]) { #put in SPI files for current ROM_IMAGE
  2742 				while(defined $spiarray[$romimage][$j]) { #put in SPI files for current ROM_IMAGE
  2740 					if($spiarray[$romimage][$j]{spifile} =~ /(.+)\.(.*)$/) {
  2743 					if($spiarray[$romimage][$j]{spifile} =~ /(.+)\.(.*)$/) {
  2741 						my $targetspi="$1-$romimage-$j\.$2";
  2744 						my $targetspi="$1-$romimage-$j\.$2";
  2742 						push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[$romimage][$j]{spidir} . $targetspi .  "\"\n";
  2745 						push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[$romimage][$j]{spidir} . $targetspi .  "\"\n";
  2743 					}
  2746 					}
  2744 					$j++;
  2747 					$j++;
  2745 				}
  2748 				}
  2746 			} elsif($line =~ /^\s*extensionrom/i) {
  2749 			} elsif($line =~ /^\s*extensionrom/i) {
  2747 				if($flag) { #put in SPI files
  2750 				if($flag) { #put in SPI files
  2748 					my $k=0;
  2751 					my $k=0;
  2749 					while(defined $spiarray[0][$k]) {
  2752 					while(defined $spiarray[0][$k]) {
  2750 						if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2753 						if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2751 							my $targetspi="$1-0-$k\.$2";
  2754 							my $targetspi="$1-0-$k\.$2";
  2752 							push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n";
  2755 							push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n";
  2753 						}
  2756 						}
  2754 						$k++;
  2757 						$k++;
  2755 					}
  2758 					}
  2756 					$flag = 0;
  2759 					$flag = 0;
  2757 				}
  2760 				}
  2764 		if($flag) { #put in SPI files for ROM_IMAGE[0] if it is the only ROM_IMAGE
  2767 		if($flag) { #put in SPI files for ROM_IMAGE[0] if it is the only ROM_IMAGE
  2765 			my $k=0;
  2768 			my $k=0;
  2766 			while(defined $spiarray[0][$k]) {
  2769 			while(defined $spiarray[0][$k]) {
  2767 				if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2770 				if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) {
  2768 					my $targetspi="$1-0-$k\.$2";
  2771 					my $targetspi="$1-0-$k\.$2";
  2769 					push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n";
  2772 					push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n";
  2770 				}
  2773 				}
  2771 				$k++;
  2774 				$k++;
  2772 			}
  2775 			}
  2773 		}
  2776 		}
  2774 		@obydata=@newobydata;
  2777 		@obydata=@newobydata;
  2938 		for(my $i=0;$i<scalar @featurefilearray;$i++)
  2941 		for(my $i=0;$i<scalar @featurefilearray;$i++)
  2939 		{
  2942 		{
  2940 			my $j=0;
  2943 			my $j=0;
  2941 			while(defined $featurefilearray[$i][$j])
  2944 			while(defined $featurefilearray[$i][$j])
  2942 			{
  2945 			{
  2943 				my $targetfeaturefile = $featurefilearray[$i][$j]{cfgfile};
  2946 				my $targetfeaturefile = $thisdir.$featurefilearray[$i][$j]{cfgfile};
  2944 				if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager))) 
  2947 				if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager))) 
  2945 				{
  2948 				{
  2946 					$featurefilearray[$i][$j]{cfgfile}= undef;
  2949 					$featurefilearray[$i][$j]{cfgfile}= undef;
  2947 					exit(1) if($strict);					
  2950 					exit(1) if($strict);					
  2948 				}
  2951 				}
  2969 					while(defined $featurefilearray[0][$k])
  2972 					while(defined $featurefilearray[0][$k])
  2970 					{
  2973 					{
  2971 						my $targetfeaturefile=$featurefilearray[0][$k]{cfgfile};
  2974 						my $targetfeaturefile=$featurefilearray[0][$k]{cfgfile};
  2972 						if (defined $targetfeaturefile) 
  2975 						if (defined $targetfeaturefile) 
  2973 						{
  2976 						{
  2974 							push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile .  "\"\n";							
  2977 							push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile .  "\"\n";							
  2975 						}
  2978 						}
  2976 						$k++;
  2979 						$k++;
  2977 					}
  2980 					}
  2978 				}
  2981 				}
  2979 				push @newobydata, "\n" . $line . "\n";			
  2982 				push @newobydata, "\n" . $line . "\n";			
  2992 					# list with mangled names. Hence, mangled name for feature files should not be put in ROM_IMAGE.
  2995 					# list with mangled names. Hence, mangled name for feature files should not be put in ROM_IMAGE.
  2993 					my $exattribute = "exattrib=U";
  2996 					my $exattribute = "exattrib=U";
  2994 
  2997 
  2995 					if (defined $targetfeaturefile)
  2998 					if (defined $targetfeaturefile)
  2996 					{
  2999 					{
  2997 						push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[$romimage][$j]{cfgdir} . $destinationfeaturefile .  "\"\t\t" . $exattribute . "\n";
  3000 						push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[$romimage][$j]{cfgdir} . $destinationfeaturefile .  "\"\t\t" . $exattribute . "\n";
  2998 					}
  3001 					}
  2999 					$j++;
  3002 					$j++;
  3000 				}
  3003 				}
  3001 			}
  3004 			}
  3002 			elsif($line !~ /^\s*(FEATURE)\s*/i && $line !~ /^\s*(EXCLUDE_FEATURE)\s*/i)
  3005 			elsif($line !~ /^\s*(FEATURE)\s*/i && $line !~ /^\s*(EXCLUDE_FEATURE)\s*/i)
  3013 			while(defined $featurefilearray[0][$k])
  3016 			while(defined $featurefilearray[0][$k])
  3014 			{
  3017 			{
  3015 				my $targetfeaturefile = $featurefilearray[0][$k]{cfgfile};
  3018 				my $targetfeaturefile = $featurefilearray[0][$k]{cfgfile};
  3016 				if (defined $targetfeaturefile)
  3019 				if (defined $targetfeaturefile)
  3017 				{
  3020 				{
  3018 					push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n";
  3021 					push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n";
  3019 				}
  3022 				}
  3020 				$k++;
  3023 				$k++;
  3021 			}
  3024 			}
  3022 		}
  3025 		}
  3023 		@obydata=@newobydata;
  3026 		@obydata=@newobydata;
  3126                   # SBSv1 variant binary or invariant binary
  3129                   # SBSv1 variant binary or invariant binary
  3127 				  $fileExists = get_BVbinname($altFile, $varname);
  3130 				  $fileExists = get_BVbinname($altFile, $varname);
  3128 				}
  3131 				}
  3129 				last if $fileExists;
  3132 				last if $fileExists;
  3130 			}
  3133 			}
  3131 			# for -workdir option, to support relative path to the call path
       
  3132 			if (!$fileExists && ($invokecmddir ne "") && ($filename !~ /^([\\\/]|.:)/))
       
  3133 			{
       
  3134 				if (-e $invokecmddir.$filename)
       
  3135 				{
       
  3136 					$fileExists = $invokecmddir.$filename;
       
  3137 				}
       
  3138 			}
       
  3139 			
  3134 			
  3140 			# edit the OBY line to use the actual file name which we found.
  3135 			# edit the OBY line to use the actual file name which we found.
  3141 			# (maybe) warn if an alternative to the original was selected.
  3136 			# (maybe) warn if an alternative to the original was selected.
  3142 			if ($fileExists)
  3137 			if ($fileExists)
  3143 			{
  3138 			{
  3158 			{
  3153 			{
  3159    				# No suitable alternative was found, so comment out the line unless
  3154    				# No suitable alternative was found, so comment out the line unless
  3160 				# it is a manatory ROMBUILD keyword, in which case it is better
  3155 				# it is a manatory ROMBUILD keyword, in which case it is better
  3161 				# to let ROMBUILD report the missing file rather than report the
  3156 				# to let ROMBUILD report the missing file rather than report the
  3162 				# missing keyword.
  3157 				# missing keyword.
  3163    				if ($what !~ /^bootbinary|variant|primary|secondary|hide/i)
  3158    				if ($what !~ /^bootbinary|variant|primary|secondary|hide|dir/i)
  3164 				{
  3159 				{
  3165    					$line = "REM MISSING " . $line;
  3160    					$line = "REM MISSING " . $line;
  3166    					print_source_error("Missing file: '$filename' in statement '$what='");
  3161    					print_source_error("Missing file: '$filename' in statement '$what='");
  3167 					print "\ttried @alternatives\n"  if ($opt_v && @alternatives > 1);
  3162 					print "\ttried @alternatives\n"  if ($opt_v && @alternatives > 1);
  3168    					# treat as an error if the strict option is selected.
  3163    					# treat as an error if the strict option is selected.
  3500   	}
  3495   	}
  3501 	elsif($line =~ /^\s*kerneltrace\s*=.*/i)
  3496 	elsif($line =~ /^\s*kerneltrace\s*=.*/i)
  3502 	{
  3497 	{
  3503 		return $line;
  3498 		return $line;
  3504 	}
  3499 	}
       
  3500 	elsif($line =~ /^\s*dir\s*=.*/i)
       
  3501 	{
       
  3502 		return $line;
       
  3503 	}
  3505 	elsif($line =~ /^\s*bootbinary\s*=(.*)/i)
  3504 	elsif($line =~ /^\s*bootbinary\s*=(.*)/i)
  3506 	{
  3505 	{
  3507 	}
  3506 	}
  3508 	if ($line =~ /^\s*(\S+)\s*=\s*(\S+)\s+"\/?(.*)"(.*)$/)
  3507 	if ($line =~ /^\s*(\S+)\s*=\s*(\S+)\s+"\/?(.*)"(.*)$/)
  3509 	{
  3508 	{
  3519 		$variant = $2;
  3518 		$variant = $2;
  3520 		$pcfile = $3;
  3519 		$pcfile = $3;
  3521 		$romfile = $4;
  3520 		$romfile = $4;
  3522 		$tail = $5;
  3521 		$tail = $5;
  3523 	}
  3522 	}
  3524 	elsif ($line =~ /(\S+)\s*=\s*"([^"]+)"\s+"\/?(.*)"(.*)$/)
  3523 	elsif ($line =~ /(\S+)\s*=\s*"([^"]+)"\s+"\/?(.*)"(.*)$/ 
       
  3524 			|| $line =~ /(\S+)\s*=\s*"([^"]+)"\s+\/?(\S+)(.*)$/)
  3525 	{
  3525 	{
  3526 		if ($line !~ /^REM MISSING/i)
  3526 		if ($line !~ /^REM MISSING/i)
  3527 		{
  3527 		{
  3528 			$type = $1;
  3528 			$type = $1;
  3529 			$variant = "";
  3529 			$variant = "";
  3808 	my $skippingBlanks=0;
  3808 	my $skippingBlanks=0;
  3809 	undef @newobydata;
  3809 	undef @newobydata;
  3810 	
  3810 	
  3811     if($opt_v)
  3811     if($opt_v)
  3812     {
  3812     {
  3813 	  my $logWin = "logwin.oby";
  3813 	  my $logWin = $thisdir."logwin.oby";
  3814 	  my $logLinux = "loglinux.oby";
  3814 	  my $logLinux = $thisdir."loglinux.oby";
  3815 	  unlink($logWin);
  3815 	  unlink($logWin);
  3816 	  unlink($logLinux);
  3816 	  unlink($logLinux);
  3817 	  open LOGWIN, ">$logWin" or die("* Can't create $logWin\n");
  3817 	  open LOGWIN, ">$logWin" or die("* Can't create $logWin\n");
  3818 	  open LOGLINUX, ">$logLinux" or die("* Can't create $logLinux\n");
  3818 	  open LOGLINUX, ">$logLinux" or die("* Can't create $logLinux\n");
  3819     }	
  3819     }	
  3845 			$skippingBlanks=0;
  3845 			$skippingBlanks=0;
  3846 		}
  3846 		}
  3847 		#
  3847 		#
  3848 		# Track ROMNAME, allowing overrides
  3848 		# Track ROMNAME, allowing overrides
  3849 		#
  3849 		#
  3850 		if ($line=~/romname\s*=\s*"?(\S+)\.(\S+)"?\s*/i)
  3850 		if ($line=~/romname\s*[=\s]\s*"?(\S+)\.(\S+)"?\s*/i)
  3851 		{
  3851 		{
  3852 			if ($romname ne "" && $opt_o eq "")
  3852 			if ($romname ne "" && $opt_o eq "")
  3853 			{
  3853 			{
  3854 				print_source_error("Overrides previous ROM name $romname");
  3854 				print_source_error("Overrides previous ROM name $romname");
  3855 			}
  3855 			}
  3856 			$rombasename = $1;
  3856 			$rombasename = $1;
  3857 			$romname = "$1.$2";
  3857 			$romname = "$1.$2";
       
  3858 			if ($opt_workdir)
       
  3859 			{
       
  3860 				$rombasename = $thisdir.$rombasename;
       
  3861 				$romname = $thisdir.$romname;
       
  3862 			}
  3858 			next;
  3863 			next;
  3859 		}
  3864 		}
  3860 		#
  3865 		#
  3861 		# ROM directory listing
  3866 		# ROM directory listing
  3862 		#
  3867 		#
  3897 	
  3902 	
  3898 	exit(1) if($errors && $strict);
  3903 	exit(1) if($errors && $strict);
  3899 	# Handle ROMNAME and possible -o override
  3904 	# Handle ROMNAME and possible -o override
  3900 	if ($opt_o ne "")
  3905 	if ($opt_o ne "")
  3901 	{
  3906 	{
       
  3907 		if ($opt_workdir && $opt_o !~ /^[\\\/]/ && $opt_o !~ /^.:/)
       
  3908 		{
       
  3909 			$opt_o = $thisdir.$opt_o;
       
  3910 		}
       
  3911 		if (&is_windows)
       
  3912 		{
       
  3913 			$opt_o =~ s-\/-\\-g;
       
  3914 		}else
       
  3915 		{
       
  3916 			$opt_o =~ s-\\-\/-g;
       
  3917 		}
  3902 		$romname=$opt_o;
  3918 		$romname=$opt_o;
  3903 		if ($opt_o=~/(\S+)\.(\S+)/)
  3919 		if ($opt_o=~/(\S+)\.(\S+)/)
  3904 		{
  3920 		{
  3905 			$rombasename=$1;
  3921 			$rombasename=$1;
  3906 		}
  3922 		}
  4667 				$errors++ if($strict);
  4683 				$errors++ if($strict);
  4668 				next; #go to the next patch dll data statement
  4684 				next; #go to the next patch dll data statement
  4669 			}
  4685 			}
  4670 			if( $aDllFile =~ /(.*)\.[^.]+$/ ){
  4686 			if( $aDllFile =~ /(.*)\.[^.]+$/ ){
  4671 				my $proxydsofile = "$1.dso";
  4687 				my $proxydsofile = "$1.dso";
  4672 				$proxydsofile =~ s-$abiDir\/(.*)\/-armv5\/LIB\/-ig;
  4688 				$proxydsofile =~ s-$abiDir\/(.*)\/-armv5\/lib\/-ig;
  4673 				open PIPE, "getexports -d $proxydsofile|" or die "Can't open file $proxydsofile\n";
  4689 				open PIPE, "getexports -d $proxydsofile|" or die "Can't open file $proxydsofile\n";
  4674 				while (<PIPE>){
  4690 				while (<PIPE>){
  4675 					my $line = $_;
  4691 					my $line = $_;
  4676 					if($line =~ /\s*(\S+)\s+(\d+)\s+((\S+)\s+(\d+))?/){
  4692 					if($line =~ /\s*(\S+)\s+(\d+)\s+((\S+)\s+(\d+))?/){
  4677 						my $symbol = $1;
  4693 						my $symbol = $1;