f660c20412ada9168d5a4b4c0649390b20733f6f
[openssl.git] / util / fipsdist.pl
1
2 # FIPS distribution filter. 
3 # Takes tarball listing and removes unnecessary files and directories.
4 #
5
6
7 my $objs = "";
8 foreach (split / /, "FIPS_EX_OBJ AES_ENC BN_ASM DES_ENC SHA1_ASM_OBJ MODES_ASM_OBJ")
9         {
10         $objs .= " $ENV{$_}";
11         }
12
13
14 my @objlist = split / /, $objs;
15
16 foreach (@objlist) { $tarobjs{"$1.c"} = 1 if /([^\/]+).o$/};
17
18 $tarobjs{"ncbc_enc.c"} = 1;
19
20 foreach (split / /, $ENV{LINKDIRS} ) { $cdirs{$_} = 1 };
21
22 $cdirs{perlasm} = 1;
23
24 if (exists $ENV{NOEC2M})
25         {
26         delete $tarobjs{"bn_gf2m.c"};
27         delete $tarobjs{"ec2_mult.c"};
28         delete $tarobjs{"ec2_smpl.c"};
29         }
30
31 my %keep = 
32         (
33         "Makefile.fips" => 1,
34         "Makefile.shared" => 1,
35         "README.FIPS" => 1,
36         "e_os.h" => 1,
37         "e_os2.h" => 1,
38         "Configure" => 1,
39         "config" => 1,
40         );
41
42 while (<STDIN>)
43         {
44         chomp;
45         # Keep top level files in list
46         if (!/\// && -f $_)
47                 {
48                 next unless exists $keep{$_};
49                 }
50         else
51                 {
52                 next unless (/^(fips\/|crypto|util|test|include|ms)/);
53                 }
54         if (/^crypto\/([^\/]+)/)
55                 {
56                 # Skip unused directories under crypto/
57                 next if -d "crypto/$1" && !exists $cdirs{$1};
58                 # Keep assembly language dir, Makefile or certain extensions
59                 if (!/\/asm\// && !/\/Makefile$/ && !/\.(in|pl|h)$/)
60                         {
61                         # If C source file must be on list.
62                         next if !/(\w+\.c)$/ || !exists $tarobjs{$1};
63                         }
64                 }
65         if (/^test\//)
66                 {
67                 next unless /Makefile/ || /dummytest.c/;
68                 }
69         print "$_\n";
70         }
71 exit 1;