Recognise invalid enable/disable options.
[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 $tarobjs{"mem_clr.c"} = 1;
20
21 foreach (split / /, $ENV{LINKDIRS} ) { $cdirs{$_} = 1 };
22
23 $cdirs{perlasm} = 1;
24
25 if (exists $ENV{NOEC2M})
26         {
27         delete $tarobjs{"bn_gf2m.c"};
28         delete $tarobjs{"ec2_mult.c"};
29         delete $tarobjs{"ec2_smpl.c"};
30         }
31
32 my %keep = 
33         (
34         "Makefile.fips" => 1,
35         "Makefile.shared" => 1,
36         "README.FIPS" => 1,
37         "e_os.h" => 1,
38         "e_os2.h" => 1,
39         "Configure" => 1,
40         "config" => 1,
41         );
42
43 while (<STDIN>)
44         {
45         chomp;
46         # Keep top level files in list
47         if (!/\// && -f $_)
48                 {
49                 next unless exists $keep{$_};
50                 }
51         else
52                 {
53                 next unless (/^(fips\/|crypto|util|test|include|ms)/);
54                 }
55         if (/^crypto\/([^\/]+)/)
56                 {
57                 # Skip unused directories under crypto/
58                 next if -d "crypto/$1" && !exists $cdirs{$1};
59                 # Keep assembly language dir, Makefile or certain extensions
60                 if (!/\/asm\// && !/\/Makefile$/ && !/\.(in|pl|h)$/)
61                         {
62                         # If C source file must be on list.
63                         next if !/(\w+\.c)$/ || !exists $tarobjs{$1};
64                         }
65                 }
66         if (/^test\//)
67                 {
68                 next unless /Makefile/ || /dummytest.c/;
69                 }
70         print "$_\n";
71         }
72 exit 1;