Security fixes brought forward from 0.9.7.
[openssl.git] / util / files.pl
1 #!/usr/local/bin/perl
2 #
3 # used to generate the file MINFO for use by util/mk1mf.pl
4 # It is basically a list of all variables from the passed makefile
5 #
6
7 $s="";
8 while (<>)
9         {
10         chop;
11         s/#.*//;
12         if (/^(\S+)\s*=\s*(.*)$/)
13                 {
14                 $o="";
15                 ($s,$b)=($1,$2);
16                 for (;;)
17                         {
18                         if ($b =~ /\\$/)
19                                 {
20                                 chop($b);
21                                 $o.=$b." ";
22                                 $b=<>;
23                                 chop($b);
24                                 }
25                         else
26                                 {
27                                 $o.=$b." ";
28                                 last;
29                                 }
30                         }
31                 $o =~ s/^\s+//;
32                 $o =~ s/\s+$//;
33                 $o =~ s/\s+/ /g;
34
35                 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
36                 $sym{$s}=$o;
37                 }
38         }
39
40 $pwd=`pwd`; chop($pwd);
41
42 if ($sym{'TOP'} eq ".")
43         {
44         $n=0;
45         $dir=".";
46         }
47 else    {
48         $n=split(/\//,$sym{'TOP'});
49         @_=split(/\//,$pwd);
50         $z=$#_-$n+1;
51         foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
52         chop($dir);
53         }
54
55 print "RELATIVE_DIRECTORY=$dir\n";
56
57 foreach (sort keys %sym)
58         {
59         print "$_=$sym{$_}\n";
60         }
61 print "RELATIVE_DIRECTORY=\n";