]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/process_files.pl
254bc4dbcc5265f1718f91c4d1336cd966ef9e09
3 # This script runs the OpenSSL Configure script, then processes the
4 # resulting file list into our local OpensslLib[Crypto].inf and also
5 # takes copies of opensslconf.h and dso_conf.h.
7 # This only needs to be done once by a developer when updating to a
8 # new version of OpenSSL (or changing options, etc.). Normal users
9 # do not need to do this, since the results are stored in the EDK2
10 # git repository for them.
17 # Find the openssl directory name for use lib. We have to do this
18 # inside of BEGIN. The variables we create here, however, don't seem
19 # to be available to the main script, so we have to repeat the
27 $inf_file = "OpensslLib.inf";
29 # Read the contents of the inf file
30 open( FD
, "<" . $inf_file ) ||
31 die "Cannot open \"" . $inf_file . "\"!";
34 die "Cannot close \"" . $inf_file . "\"!";
37 if (/DEFINE\s+OPENSSL_PATH\s*=\s*([a-z]+)/) {
39 # We need to run Configure before we can include its result...
42 my $basedir = getcwd
();
44 chdir($OPENSSL_PATH) ||
45 die "Cannot change to OpenSSL directory \"" . $OPENSSL_PATH . "\"";
96 # OpenSSL1_1_1b doesn't support default rand-seed-os for UEFI
97 # UEFI only support --with-rand-seed=none
98 "--with-rand-seed=none"
100 die "OpenSSL Configure failed!\n";
102 # Generate opensslconf.h per config data
104 "perl -I. -Mconfigdata util/dofile.pl " .
105 "include/openssl/opensslconf.h.in " .
106 "> include/openssl/opensslconf.h"
108 die "Failed to generate opensslconf.h!\n";
110 # Generate dso_conf.h per config data
112 "perl -I. -Mconfigdata util/dofile.pl " .
113 "crypto/include/internal/dso_conf.h.in " .
114 "> include/internal/dso_conf.h"
116 die "Failed to generate dso_conf.h!\n";
119 die "Cannot change to base directory \"" . $basedir . "\"";
128 # Retrieve file lists from OpenSSL configdata
130 use configdata qw
/%unified_info/;
132 my @cryptofilelist = ();
133 my @sslfilelist = ();
134 foreach my $product ((@{$unified_info{libraries
}},
135 @{$unified_info{engines
}})) {
136 foreach my $o (@{$unified_info{sources
}->{$product}}) {
137 foreach my $s (@{$unified_info{sources
}->{$o}}) {
138 next if ($unified_info{generate
}->{$s});
139 next if $s =~ "crypto/bio/b_print.c";
141 # No need to add unused files in UEFI.
142 # So it can reduce porting time, compile time, library size.
143 next if $s =~ "crypto/rand/randfile.c";
144 next if $s =~ "crypto/store/";
145 next if $s =~ "crypto/err/err_all.c";
147 if ($product =~ "libssl") {
148 push @sslfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
151 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
158 # Update the perl script to generate the missing header files
161 for (sort keys %{$unified_info{dirinfo
}}){
170 @files = glob($_."/*.h");
171 push @headers, @files;
177 push @sslfilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
180 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
185 # Update OpensslLib.inf with autogenerated file list
189 print "\n--> Updating OpensslLib.inf ... ";
191 if ( $_ =~ "# Autogenerated files list starts here" ) {
192 push @new_inf, $_, @cryptofilelist, @sslfilelist;
196 if ( $_ =~ "# Autogenerated files list ends here" ) {
206 my $new_inf_file = $inf_file . ".new";
207 open( FD
, ">" . $new_inf_file ) ||
209 print( FD
@new_inf ) ||
213 rename( $new_inf_file, $inf_file ) ||
214 die "rename $inf_file";
218 # Update OpensslLibCrypto.inf with auto-generated file list (no libssl)
220 $inf_file = "OpensslLibCrypto.inf";
222 # Read the contents of the inf file
225 open( FD
, "<" . $inf_file ) ||
226 die "Cannot open \"" . $inf_file . "\"!";
229 die "Cannot close \"" . $inf_file . "\"!";
232 print "\n--> Updating OpensslLibCrypto.inf ... ";
234 if ( $_ =~ "# Autogenerated files list starts here" ) {
235 push @new_inf, $_, @cryptofilelist;
239 if ( $_ =~ "# Autogenerated files list ends here" ) {
249 $new_inf_file = $inf_file . ".new";
250 open( FD
, ">" . $new_inf_file ) ||
252 print( FD
@new_inf ) ||
256 rename( $new_inf_file, $inf_file ) ||
257 die "rename $inf_file";
261 # Copy opensslconf.h and dso_conf.h generated from OpenSSL Configuration
263 print "\n--> Duplicating opensslconf.h into Include/openssl ... ";
264 copy
($OPENSSL_PATH . "/include/openssl/opensslconf.h",
265 $OPENSSL_PATH . "/../../Include/openssl/") ||
266 die "Cannot copy opensslconf.h!";
268 print "\n--> Duplicating dso_conf.h into Include/internal ... ";
269 copy
($OPENSSL_PATH . "/include/internal/dso_conf.h",
270 $OPENSSL_PATH . "/../../Include/internal/") ||
271 die "Cannot copy dso_conf.h!";
274 print "\nProcessing Files Done!\n";