3 # Sync the output file list between Makefiles
4 # Use the mkdep.pl parameters to get the filename syntax
6 # The first file is the source file; the other ones target.
8 %def_hints = ('object-ending' => '.o',
9 'path-separator' => '/',
10 'continuation' => "\\");
12 sub do_transform
($$) {
14 my($ps) = $$h{'path-separator'};
16 $l =~ s/\x01/$$h{'object-ending'}/g;
17 $l =~ s/\x03/$$h{'continuation'}/g;
20 # Remove the path separator and the preceeding directory
21 $l =~ s/[^\s\=]*\x02//g;
23 # Convert the path separator
33 $first_file = $ARGV[0];
34 die unless (defined($first_file));
36 foreach $file (@ARGV) {
37 open(FILE
, "< $file\0") or die;
39 # First, read the syntax hints
41 while (defined($line = <FILE
>)) {
42 if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
47 # Read and process the file
51 while (defined($line = <FILE
>)) {
54 if ($line eq '#-- End File Lists --#') {
55 push(@lines, $line."\n");
59 my $oe = "\Q$hints{'object-ending'}";
60 my $ps = "\Q$hints{'path-separator'}";
61 my $cn = "\Q$hints{'continuation'}";
63 $xl =~ s/${oe}(\s|$)/\x01$1/g;
64 $xl =~ s/${ps}/\x02/g;
65 $xl =~ s/${cn}$/\x03/;
66 push(@file_list, $xl);
70 push(@lines, $line."\n");
71 if ($line eq '#-- Begin File Lists --#') {
74 push(@lines, "# Edit in $first_file, not here!\n");
75 foreach $l (@file_list) {
76 push(@lines, do_transform
($l, \
%hints)."\n");
84 # Write the file back out
86 open(FILE
, "> $file\0") or die;