2008-06-16 07:54:29 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# Sync the output file list between Makefiles
|
|
|
|
# Use the mkdep.pl parameters to get the filename syntax
|
|
|
|
#
|
|
|
|
# The first file is the source file; the other ones target.
|
|
|
|
#
|
|
|
|
%def_hints = ('object-ending' => '.o',
|
|
|
|
'path-separator' => '/',
|
|
|
|
'continuation' => "\\");
|
|
|
|
|
|
|
|
sub do_transform($$) {
|
|
|
|
my($l, $h) = @_;
|
2008-06-16 09:33:03 +08:00
|
|
|
my($ps) = $$h{'path-separator'};
|
2008-06-16 07:54:29 +08:00
|
|
|
|
|
|
|
$l =~ s/\x01/$$h{'object-ending'}/g;
|
|
|
|
$l =~ s/\x03/$$h{'continuation'}/g;
|
|
|
|
|
2008-06-16 09:33:03 +08:00
|
|
|
if ($ps eq '') {
|
|
|
|
# Remove the path separator and the preceeding directory
|
2008-06-16 14:43:44 +08:00
|
|
|
$l =~ s/[^\s\=]*\x02//g;
|
2008-06-16 09:33:03 +08:00
|
|
|
} else {
|
|
|
|
# Convert the path separator
|
|
|
|
$l =~ s/\x02/$ps/g;
|
|
|
|
}
|
|
|
|
|
2008-06-16 07:54:29 +08:00
|
|
|
return $l;
|
|
|
|
}
|
|
|
|
|
|
|
|
@file_list = ();
|
|
|
|
|
|
|
|
$first = 1;
|
|
|
|
$first_file = $ARGV[0];
|
|
|
|
die unless (defined($first_file));
|
|
|
|
|
|
|
|
foreach $file (@ARGV) {
|
|
|
|
open(FILE, "< $file\0") or die;
|
|
|
|
|
|
|
|
# First, read the syntax hints
|
|
|
|
%hints = %def_hints;
|
|
|
|
while (defined($line = <FILE>)) {
|
2008-06-16 09:35:01 +08:00
|
|
|
if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
|
2008-06-16 07:54:29 +08:00
|
|
|
$hints{$1} = $2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read and process the file
|
|
|
|
seek(FILE,0,0);
|
|
|
|
@lines = ();
|
|
|
|
$processing = 0;
|
|
|
|
while (defined($line = <FILE>)) {
|
|
|
|
chomp $line;
|
|
|
|
if ($processing) {
|
2008-06-16 14:50:50 +08:00
|
|
|
if ($line eq '#-- End File Lists --#') {
|
2008-06-16 07:54:29 +08:00
|
|
|
push(@lines, $line."\n");
|
|
|
|
$processing = 0;
|
|
|
|
} elsif ($first) {
|
|
|
|
my $xl = $line;
|
|
|
|
my $oe = "\Q$hints{'object-ending'}";
|
|
|
|
my $ps = "\Q$hints{'path-separator'}";
|
|
|
|
my $cn = "\Q$hints{'continuation'}";
|
|
|
|
|
|
|
|
$xl =~ s/${oe}(\s|$)/\x01$1/g;
|
|
|
|
$xl =~ s/${ps}/\x02/g;
|
|
|
|
$xl =~ s/${cn}$/\x03/;
|
|
|
|
push(@file_list, $xl);
|
|
|
|
push(@lines, $line);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
push(@lines, $line."\n");
|
2008-06-16 14:50:50 +08:00
|
|
|
if ($line eq '#-- Begin File Lists --#') {
|
2008-06-16 07:54:29 +08:00
|
|
|
$processing = 1;
|
|
|
|
if (!$first) {
|
|
|
|
push(@lines, "# Edit in $first_file, not here!\n");
|
|
|
|
foreach $l (@file_list) {
|
|
|
|
push(@lines, do_transform($l, \%hints)."\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(FILE);
|
|
|
|
|
|
|
|
# Write the file back out
|
|
|
|
if (!$first) {
|
|
|
|
open(FILE, "> $file\0") or die;
|
|
|
|
print FILE @lines;
|
|
|
|
close(FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
undef @lines;
|
|
|
|
$first = 0;
|
|
|
|
}
|