Avoid a race condition if another thread happens to remove the error
[openssl.git] / util / mkfiles.pl
1 #!/usr/local/bin/perl
2 #
3 # This is a hacked version of files.pl for systems that can't do a 'make files'.
4 # Do a perl util/mkminfo.pl >MINFO to build MINFO
5 # Written by Steve Henson 1999.
6
7 # List of directories to process
8
9 my @dirs = (
10 ".",
11 "crypto",
12 "crypto/md2",
13 "crypto/md5",
14 "crypto/sha",
15 "crypto/mdc2",
16 "crypto/hmac",
17 "crypto/ripemd",
18 "crypto/des",
19 "crypto/rc2",
20 "crypto/rc4",
21 "crypto/rc5",
22 "crypto/idea",
23 "crypto/bf",
24 "crypto/cast",
25 "crypto/bn",
26 "crypto/rsa",
27 "crypto/dsa",
28 "crypto/dso",
29 "crypto/dh",
30 "crypto/buffer",
31 "crypto/bio",
32 "crypto/stack",
33 "crypto/lhash",
34 "crypto/rand",
35 "crypto/err",
36 "crypto/objects",
37 "crypto/evp",
38 "crypto/asn1",
39 "crypto/pem",
40 "crypto/x509",
41 "crypto/x509v3",
42 "crypto/conf",
43 "crypto/txt_db",
44 "crypto/pkcs7",
45 "crypto/pkcs12",
46 "crypto/comp",
47 "ssl",
48 "rsaref",
49 "apps",
50 "test",
51 "tools"
52 );
53
54 foreach (@dirs) {
55         &files_dir ($_, "Makefile.ssl");
56 }
57
58 exit(0);
59
60 sub files_dir
61 {
62 my ($dir, $makefile) = @_;
63
64 my %sym;
65
66 open (IN, "$dir/$makefile") || die "Can't open $dir/$makefile";
67
68 my $s="";
69
70 while (<IN>)
71         {
72         chop;
73         s/#.*//;
74         if (/^(\S+)\s*=\s*(.*)$/)
75                 {
76                 $o="";
77                 ($s,$b)=($1,$2);
78                 for (;;)
79                         {
80                         if ($b =~ /\\$/)
81                                 {
82                                 chop($b);
83                                 $o.=$b." ";
84                                 $b=<IN>;
85                                 chop($b);
86                                 }
87                         else
88                                 {
89                                 $o.=$b." ";
90                                 last;
91                                 }
92                         }
93                 $o =~ s/^\s+//;
94                 $o =~ s/\s+$//;
95                 $o =~ s/\s+/ /g;
96
97                 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
98                 $sym{$s}=$o;
99                 }
100         }
101
102 print "RELATIVE_DIRECTORY=$dir\n";
103
104 foreach (sort keys %sym)
105         {
106         print "$_=$sym{$_}\n";
107         }
108 print "RELATIVE_DIRECTORY=\n";
109
110 close (IN);
111 }