2 ## --------------------------------------------------------------------------
4 ## Copyright 1996-2009 The NASM Authors - All Rights Reserved
5 ## See the file AUTHORS included with the NASM distribution for
6 ## the specific copyright holders.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted provided that the following
10 ## conditions are met:
12 ## * Redistributions of source code must retain the above copyright
13 ## notice, this list of conditions and the following disclaimer.
14 ## * Redistributions in binary form must reproduce the above
15 ## copyright notice, this list of conditions and the following
16 ## disclaimer in the documentation and/or other materials provided
17 ## with the distribution.
19 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20 ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ## --------------------------------------------------------------------------
36 # Sync the output file list between Makefiles
37 # Use the mkdep.pl parameters to get the filename syntax
39 # The first file is the source file; the other ones target.
41 %def_hints = ('object-ending' => '.o',
42 'path-separator' => '/',
43 'continuation' => "\\");
45 sub do_transform
($$) {
47 my($ps) = $$h{'path-separator'};
49 $l =~ s/\x01/$$h{'object-ending'}/g;
50 $l =~ s/\x03/$$h{'continuation'}/g;
53 # Remove the path separator and the preceeding directory
54 $l =~ s/[^\s\=]*\x02//g;
56 # Convert the path separator
66 $first_file = $ARGV[0];
67 die unless (defined($first_file));
69 foreach $file (@ARGV) {
70 open(FILE
, "< $file\0") or die;
72 # First, read the syntax hints
74 while (defined($line = <FILE
>)) {
75 if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
80 # Read and process the file
84 while (defined($line = <FILE
>)) {
87 if ($line eq '#-- End File Lists --#') {
88 push(@lines, $line."\n");
92 my $oe = "\Q$hints{'object-ending'}";
93 my $ps = "\Q$hints{'path-separator'}";
94 my $cn = "\Q$hints{'continuation'}";
96 $xl =~ s/${oe}(\s|$)/\x01$1/g;
97 $xl =~ s/${ps}/\x02/g;
98 $xl =~ s/${cn}$/\x03/;
99 push(@file_list, $xl);
103 push(@lines, $line."\n");
104 if ($line eq '#-- Begin File Lists --#') {
107 push(@lines, "# Edit in $first_file, not here!\n");
108 foreach $l (@file_list) {
109 push(@lines, do_transform
($l, \
%hints)."\n");
117 # Write the file back out
119 open(FILE
, "> $file\0") or die;