Import of old SSLeay release: SSLeay 0.8.1b
[openssl.git] / apps / progs.pl
1 #!/usr/local/bin/perl
2
3 $mkprog='mklinks';
4 $rmprog='rmlinks';
5
6 print "#ifndef NOPROTO\n";
7
8 grep(s/^asn1pars$/asn1parse/,@ARGV);
9
10 foreach (@ARGV)
11         { printf "extern int %s_main(int argc,char *argv[]);\n",$_; }
12 print "#else\n";
13 foreach (@ARGV)
14         { printf "extern int %s_main();\n",$_; }
15 print "#endif\n";
16
17
18 print <<'EOF';
19
20 #ifdef SSLEAY_SRC
21
22 #define FUNC_TYPE_GENERAL       1
23 #define FUNC_TYPE_MD            2
24 #define FUNC_TYPE_CIPHER        3
25
26 typedef struct {
27         int type;
28         char *name;
29         int (*func)();
30         } FUNCTION;
31
32 FUNCTION functions[] = {
33 EOF
34
35 foreach (@ARGV)
36         {
37         push(@files,$_);
38         $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
39         if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
40                 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; } 
41         elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) ||
42                 ($_ =~ /^req$/) || ($_ =~ /^ca$/) || ($_ =~ /^x509$/))
43                 { print "#ifndef NO_RSA\n${str}#endif\n";  }
44         elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
45                 { print "#ifndef NO_DSA\n${str}#endif\n"; }
46         elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/))
47                 { print "#ifndef NO_DH\n${str}#endif\n"; }
48         else
49                 { print $str; }
50         }
51
52 foreach ("md2","md5","sha","sha1","mdc2")
53         {
54         push(@files,$_);
55         printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_;
56         }
57
58 foreach (
59         "base64",
60         "des", "des3", "desx", "idea", "rc4", "rc2","bf",
61         "des-ecb", "des-ede",    "des-ede3",
62         "des-cbc", "des-ede-cbc","des-ede3-cbc",
63         "des-cfb", "des-ede-cfb","des-ede3-cfb",
64         "des-ofb", "des-ede-ofb","des-ede3-ofb",
65         "idea-cbc","idea-ecb",   "idea-cfb", "idea-ofb",
66         "rc2-cbc", "rc2-ecb",    "rc2-cfb",  "rc2-ofb",
67         "bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb")
68         {
69         push(@files,$_);
70
71         $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
72         if    ($_ =~ /des/)  { $t="#ifndef NO_DES\n${t}#endif\n"; }
73         elsif ($_ =~ /idea/) { $t="#ifndef NO_IDEA\n${t}#endif\n"; }
74         elsif ($_ =~ /rc4/)  { $t="#ifndef NO_RC4\n${t}#endif\n"; }
75         elsif ($_ =~ /rc2/)  { $t="#ifndef NO_RC2\n${t}#endif\n"; }
76         elsif ($_ =~ /bf/)   { $t="#ifndef NO_BLOWFISH\n${t}#endif\n"; }
77         print $t;
78         }
79
80 print "\t{0,NULL,NULL}\n\t};\n";
81 print "#endif\n\n";
82
83 open(OUT,">$mkprog") || die "unable to open '$prog':$!\n";
84 print OUT "#!/bin/sh\nfor i in ";
85 foreach (@files)
86         { print OUT $_." "; }
87 print OUT <<'EOF';
88
89 do
90 echo making symlink for $i
91 /bin/rm -f $i
92 ln -s ssleay $i
93 done
94 EOF
95 close(OUT);
96 chmod(0755,$mkprog);
97
98 open(OUT,">$rmprog") || die "unable to open '$prog':$!\n";
99 print OUT "#!/bin/sh\nfor i in ";
100 foreach (@files)
101         { print OUT $_." "; }
102 print OUT <<'EOF';
103
104 do
105 echo removing $i
106 /bin/rm -f $i
107 done
108 EOF
109 close(OUT);
110 chmod(0755,$rmprog);