]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/process_files.pl
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 a copy of opensslconf.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 . "\"";
94 # OpenSSL1_1_1b doesn't support default rand-seed-os for UEFI
95 # UEFI only support --with-rand-seed=none
96 "--with-rand-seed=none"
98 die "OpenSSL Configure failed!\n";
100 # Generate opensslconf.h per config data
102 "perl -I. -Mconfigdata util/dofile.pl " .
103 "include/openssl/opensslconf.h.in " .
104 "> include/openssl/opensslconf.h"
106 die "Failed to generate opensslconf.h!\n";
109 die "Cannot change to base directory \"" . $basedir . "\"";
118 # Retrieve file lists from OpenSSL configdata
120 use configdata qw
/%unified_info/;
122 my @cryptofilelist = ();
123 my @sslfilelist = ();
124 foreach my $product ((@{$unified_info{libraries
}},
125 @{$unified_info{engines
}})) {
126 foreach my $o (@{$unified_info{sources
}->{$product}}) {
127 foreach my $s (@{$unified_info{sources
}->{$o}}) {
128 next if ($unified_info{generate
}->{$s});
129 next if $s =~ "crypto/bio/b_print.c";
131 # No need to add unused files in UEFI.
132 # So it can reduce porting time, compile time, library size.
133 next if $s =~ "crypto/rand/randfile.c";
134 next if $s =~ "crypto/store/";
136 if ($product =~ "libssl") {
137 push @sslfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
140 push @cryptofilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
146 # Update OpensslLib.inf with autogenerated file list
150 print "\n--> Updating OpensslLib.inf ... ";
152 if ( $_ =~ "# Autogenerated files list starts here" ) {
153 push @new_inf, $_, @cryptofilelist, @sslfilelist;
157 if ( $_ =~ "# Autogenerated files list ends here" ) {
167 my $new_inf_file = $inf_file . ".new";
168 open( FD
, ">" . $new_inf_file ) ||
170 print( FD
@new_inf ) ||
174 rename( $new_inf_file, $inf_file ) ||
175 die "rename $inf_file";
179 # Update OpensslLibCrypto.inf with auto-generated file list (no libssl)
181 $inf_file = "OpensslLibCrypto.inf";
183 # Read the contents of the inf file
186 open( FD
, "<" . $inf_file ) ||
187 die "Cannot open \"" . $inf_file . "\"!";
190 die "Cannot close \"" . $inf_file . "\"!";
193 print "\n--> Updating OpensslLibCrypto.inf ... ";
195 if ( $_ =~ "# Autogenerated files list starts here" ) {
196 push @new_inf, $_, @cryptofilelist;
200 if ( $_ =~ "# Autogenerated files list ends here" ) {
210 $new_inf_file = $inf_file . ".new";
211 open( FD
, ">" . $new_inf_file ) ||
213 print( FD
@new_inf ) ||
217 rename( $new_inf_file, $inf_file ) ||
218 die "rename $inf_file";
222 # Copy opensslconf.h generated from OpenSSL Configuration
224 print "\n--> Duplicating opensslconf.h into Include/openssl ... ";
225 copy
($OPENSSL_PATH . "/include/openssl/opensslconf.h",
226 $OPENSSL_PATH . "/../../Include/openssl/") ||
227 die "Cannot copy opensslconf.h!";
230 print "\nProcessing Files Done!\n";