1326c9856a30be22a82b6960b2fdb169d669dbbb
[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/md4",
14 "crypto/md5",
15 "crypto/sha",
16 "crypto/mdc2",
17 "crypto/hmac",
18 "crypto/ripemd",
19 "crypto/des",
20 "crypto/rc2",
21 "crypto/rc4",
22 "crypto/rc5",
23 "crypto/idea",
24 "crypto/bf",
25 "crypto/cast",
26 "crypto/aes",
27 "crypto/camellia",
28 "crypto/seed",
29 "crypto/bn",
30 "crypto/rsa",
31 "crypto/dsa",
32 "crypto/dso",
33 "crypto/dh",
34 "crypto/ec",
35 "crypto/ecdh",
36 "crypto/ecdsa",
37 "crypto/buffer",
38 "crypto/bio",
39 "crypto/stack",
40 "crypto/lhash",
41 "crypto/rand",
42 "crypto/err",
43 "crypto/objects",
44 "crypto/evp",
45 "crypto/asn1",
46 "crypto/pem",
47 "crypto/x509",
48 "crypto/x509v3",
49 "crypto/cms",
50 "crypto/conf",
51 "crypto/txt_db",
52 "crypto/pkcs7",
53 "crypto/pkcs12",
54 "crypto/comp",
55 "crypto/engine",
56 "crypto/ocsp",
57 "crypto/ui",
58 "crypto/krb5",
59 #"crypto/store",
60 "crypto/pqueue",
61 "crypto/whrlpool",
62 "crypto/ts",
63 "ssl",
64 "apps",
65 "engines",
66 "engines/ccgost",
67 "test",
68 "tools"
69 );
70
71 %top;
72
73 foreach (@dirs) {
74         &files_dir ($_, "Makefile");
75 }
76
77 exit(0);
78
79 sub files_dir
80 {
81 my ($dir, $makefile) = @_;
82
83 my %sym;
84
85 open (IN, "$dir/$makefile") || die "Can't open $dir/$makefile";
86
87 my $s="";
88
89 while (<IN>)
90         {
91         chop;
92         s/#.*//;
93         if (/^(\S+)\s*=\s*(.*)$/)
94                 {
95                 $o="";
96                 ($s,$b)=($1,$2);
97                 for (;;)
98                         {
99                         if ($b =~ /\\$/)
100                                 {
101                                 chop($b);
102                                 $o.=$b." ";
103                                 $b=<IN>;
104                                 chop($b);
105                                 }
106                         else
107                                 {
108                                 $o.=$b." ";
109                                 last;
110                                 }
111                         }
112                 $o =~ s/^\s+//;
113                 $o =~ s/\s+$//;
114                 $o =~ s/\s+/ /g;
115
116                 $o =~ s/\$[({]([^)}]+)[)}]/$top{$1} or $sym{$1}/ge;
117                 $sym{$s}=($top{$s} or $o);
118                 }
119         }
120
121 print "RELATIVE_DIRECTORY=$dir\n";
122
123 foreach (sort keys %sym)
124         {
125         print "$_=$sym{$_}\n";
126         }
127 if ($dir eq "." && defined($sym{"BUILDENV"}))
128         {
129         foreach (split(' ',$sym{"BUILDENV"}))
130                 {
131                 /^(.+)=/;
132                 $top{$1}=$sym{$1};
133                 }
134         }
135
136 print "RELATIVE_DIRECTORY=\n";
137
138 close (IN);
139 }