doc: document the %use fp macro package
[nasm/avx512.git] / syncfiles.pl
blob4da87f9c290ee8a76ab3053a9a8c8da609300192
1 #!/usr/bin/perl
2 ## --------------------------------------------------------------------------
3 ##
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.
7 ##
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.
18 ##
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($$) {
46 my($l, $h) = @_;
47 my($ps) = $$h{'path-separator'};
49 $l =~ s/\x01/$$h{'object-ending'}/g;
50 $l =~ s/\x03/$$h{'continuation'}/g;
52 if ($ps eq '') {
53 # Remove the path separator and the preceeding directory
54 $l =~ s/[^\s\=]*\x02//g;
55 } else {
56 # Convert the path separator
57 $l =~ s/\x02/$ps/g;
60 return $l;
63 @file_list = ();
65 $first = 1;
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
73 %hints = %def_hints;
74 while (defined($line = <FILE>)) {
75 if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
76 $hints{$1} = $2;
80 # Read and process the file
81 seek(FILE,0,0);
82 @lines = ();
83 $processing = 0;
84 while (defined($line = <FILE>)) {
85 chomp $line;
86 if ($processing) {
87 if ($line eq '#-- End File Lists --#') {
88 push(@lines, $line."\n");
89 $processing = 0;
90 } elsif ($first) {
91 my $xl = $line;
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);
100 push(@lines, $line);
102 } else {
103 push(@lines, $line."\n");
104 if ($line eq '#-- Begin File Lists --#') {
105 $processing = 1;
106 if (!$first) {
107 push(@lines, "# Edit in $first_file, not here!\n");
108 foreach $l (@file_list) {
109 push(@lines, do_transform($l, \%hints)."\n");
115 close(FILE);
117 # Write the file back out
118 if (!$first) {
119 open(FILE, "> $file\0") or die;
120 print FILE @lines;
121 close(FILE);
124 undef @lines;
125 $first = 0;