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) 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
>)) {
86 if (defined($processing)) {
87 if ($line =~ /^\#-- End ([^-\#]*[^-#\s]) --\#$/) {
88 if ($1 ne $processing) {
89 die "$0: $file: Mismatched Begin and End lines (\"$processing\" -> \"$1\"\n";
91 push(@lines, $line."\n");
95 my $oe = "\Q$hints{'object-ending'}";
96 my $ps = "\Q$hints{'path-separator'}";
97 my $cn = "\Q$hints{'continuation'}";
99 $xl =~ s/${oe}(\s|$)/\x01$1/g;
100 $xl =~ s/${ps}/\x02/g;
101 $xl =~ s/${cn}$/\x03/;
102 push(@
{$line_lists{$processing}}, $xl);
106 push(@lines, $line."\n");
107 if ($line =~ '#-- Begin ([^-\#]*[^-#\s]) --#') {
110 if (defined($line_lists{$processing})) {
111 die "$0: $file: Repeated Begin block: $processing\n";
113 $line_lists{$processing} = [];
115 if (!defined($line_lists{$processing})) {
116 die "$0: $file: Begin block without template\n";
118 push(@lines, "# Edit in $first_file, not here!\n");
119 foreach $l (@
{$line_lists{$processing}}) {
120 push(@lines, do_transform
($l, \
%hints)."\n");
128 # Write the file back out
130 open(FILE
, '>', $file) or die;