Only copy headers if they've changed.
[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/modes",
30 "crypto/cmac",
31 "crypto/bn",
32 "crypto/rsa",
33 "crypto/dsa",
34 "crypto/dso",
35 "crypto/dh",
36 "crypto/ec",
37 "crypto/ecdh",
38 "crypto/ecdsa",
39 "crypto/buffer",
40 "crypto/bio",
41 "crypto/stack",
42 "crypto/lhash",
43 "crypto/rand",
44 "crypto/err",
45 "crypto/objects",
46 "crypto/evp",
47 "crypto/asn1",
48 "crypto/pem",
49 "crypto/x509",
50 "crypto/x509v3",
51 "crypto/cms",
52 "crypto/conf",
53 "crypto/jpake",
54 "crypto/txt_db",
55 "crypto/pkcs7",
56 "crypto/pkcs12",
57 "crypto/comp",
58 "crypto/engine",
59 "crypto/ocsp",
60 "crypto/ui",
61 "crypto/krb5",
62 #"crypto/store",
63 "crypto/pqueue",
64 "crypto/whrlpool",
65 "crypto/ts",
66 "crypto/srp",
67 "fips",
68 "fips/aes",
69 "fips/cmac",
70 "fips/des",
71 "fips/dsa",
72 "fips/dh",
73 "fips/ecdh",
74 "fips/ecdsa",
75 "fips/hmac",
76 "fips/rand",
77 "fips/rsa",
78 "fips/utl",
79 "fips/sha",
80 "ssl",
81 "apps",
82 "engines",
83 "engines/ccgost",
84 "test",
85 "tools"
86 );
87
88 %top;
89
90 my $fipscanisteronly = 0;
91
92 foreach (@dirs) {
93         next if ($fipscanisteronly && !(-d $_));
94         &files_dir ($_, "Makefile");
95 }
96
97 exit(0);
98
99 sub files_dir
100 {
101 my ($dir, $makefile) = @_;
102
103 my %sym;
104
105 open (IN, "$dir/$makefile") || die "Can't open $dir/$makefile";
106
107 my $s="";
108
109 while (<IN>)
110         {
111         chop;
112         s/#.*//;
113         if (/^(\S+)\s*=\s*(.*)$/)
114                 {
115                 $o="";
116                 ($s,$b)=($1,$2);
117                 for (;;)
118                         {
119                         if ($b =~ /\\$/)
120                                 {
121                                 chop($b);
122                                 $o.=$b." ";
123                                 $b=<IN>;
124                                 chop($b);
125                                 }
126                         else
127                                 {
128                                 $o.=$b." ";
129                                 last;
130                                 }
131                         }
132                 $o =~ s/^\s+//;
133                 $o =~ s/\s+$//;
134                 $o =~ s/\s+/ /g;
135
136                 $o =~ s/\$[({]([^)}]+)[)}]/$top{$1} or $sym{$1}/ge;
137                 $sym{$s}=($top{$s} or $o);
138                 }
139         }
140
141 print "RELATIVE_DIRECTORY=$dir\n";
142
143 foreach (sort keys %sym)
144         {
145         print "$_=$sym{$_}\n";
146         }
147 if ($dir eq "." && defined($sym{"BUILDENV"}))
148         {
149         foreach (split(' ',$sym{"BUILDENV"}))
150                 {
151                 /^(.+)=/;
152                 $top{$1}=$sym{$1};
153                 }
154         }
155
156 print "RELATIVE_DIRECTORY=\n";
157
158 close (IN);
159 if ($dir eq "." && $sym{FIPSCANISTERONLY} eq "y")
160         {
161         $fipscanisteronly = 1;
162         }
163 }