]>
Commit | Line | Data |
---|---|---|
d02b48c6 RE |
1 | #!/usr/local/bin/perl |
2 | # | |
3 | # see PROBLEMS for instructions on what sort of things to do when | |
4 | # tracking a bug --tjh | |
5 | # | |
6 | # extra options | |
7 | # -DRSAref build to use RSAref | |
8 | # -DNO_IDEA build with no IDEA algorithm | |
9 | # -DNO_RC4 build with no RC4 algorithm | |
10 | # -DNO_RC2 build with no RC2 algorithm | |
11 | # -DNO_BF build with no Blowfish algorithm | |
12 | # -DNO_DES build with no DES/3DES algorithm | |
13 | # -DNO_MD2 build with no MD2 algorithm | |
14 | # | |
15 | # DES_PTR use pointer lookup vs arrays in the DES in crypto/des/des_locl.h | |
16 | # DES_RISC1 use different DES_ENCRYPT macro that helps reduce register | |
17 | # dependancies but needs to more registers, good for RISC CPU's | |
18 | # DES_RISC2 A different RISC variant. | |
19 | # DES_UNROLL unroll the inner DES loop, sometimes helps, somtimes hinders. | |
20 | # DES_INT use 'int' instead of 'long' for DES_LONG in crypto/des/des.h | |
21 | # This is used on the DEC Alpha where long is 8 bytes | |
22 | # and int is 4 | |
23 | # BN_LLONG use the type 'long long' in crypto/bn/bn.h | |
58964a49 RE |
24 | # MD2_CHAR use 'char' instead of 'int' for MD2_INT in crypto/md2/md2.h |
25 | # MD2_LONG use 'long' instead of 'int' for MD2_INT in crypto/md2/md2.h | |
d02b48c6 RE |
26 | # IDEA_SHORT use 'short' instead of 'int' for IDEA_INT in crypto/idea/idea.h |
27 | # IDEA_LONG use 'long' instead of 'int' for IDEA_INT in crypto/idea/idea.h | |
28 | # RC2_SHORT use 'short' instead of 'int' for RC2_INT in crypto/rc2/rc2.h | |
29 | # RC2_LONG use 'long' instead of 'int' for RC2_INT in crypto/rc2/rc2.h | |
30 | # RC4_CHAR use 'char' instead of 'int' for RC4_INT in crypto/rc4/rc4.h | |
31 | # RC4_LONG use 'long' instead of 'int' for RC4_INT in crypto/rc4/rc4.h | |
58964a49 | 32 | # RC4_INDEX define RC4_INDEX in crypto/rc4/rc4_locl.h. This turns on |
d02b48c6 RE |
33 | # array lookups instead of pointer use. |
34 | # BF_PTR use 'pointer arithmatic' for Blowfish (unsafe on Alpha). | |
35 | # BF_PTR2 use a pentium/intel specific version. | |
58964a49 RE |
36 | # MD5_ASM use some extra md5 assember, |
37 | # SHA1_ASM use some extra sha1 assember, must define L_ENDIAN for x86 | |
38 | # RMD160_ASM use some extra ripemd160 assember, | |
39 | # BN_ASM use some extra bn assember, | |
d02b48c6 RE |
40 | |
41 | $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL"; | |
42 | ||
43 | # MD2_CHAR slags pentium pros | |
44 | $x86_gcc_opts="RC4_INDEX MD2_INT BF_PTR2"; | |
45 | ||
46 | # MODIFY THESE PARAMETERS IF YOU ARE GOING TO USE THE 'util/speed.sh SCRIPT | |
47 | # Don't worry about these normally | |
48 | ||
49 | $tcc="cc"; | |
50 | $tflags="-fast -Xa"; | |
51 | $tbn_mul=""; | |
52 | $tlib="-lnsl -lsocket"; | |
53 | #$bits1="SIXTEEN_BIT "; | |
54 | #$bits2="THIRTY_TWO_BIT "; | |
55 | $bits1="THIRTY_TWO_BIT "; | |
56 | $bits2="SIXTY_FOUR_BIT "; | |
57 | ||
58964a49 RE |
58 | $x86_sol_asm="asm/bn86-sol.o:asm/dx86-sol.o asm/yx86-sol.o:asm/bx86-sol.o:asm/mx86-sol.o:asm/sx86-sol.o:asm/cx86-sol.o:asm/rx86-sol.o:asm/rm86-sol.o:asm/r586-sol.o"; |
59 | $x86_elf_asm="asm/bn86-elf.o:asm/dx86-elf.o asm/yx86-elf.o:asm/bx86-elf.o:asm/mx86-elf.o:asm/sx86-elf.o:asm/cx86-elf.o:asm/rx86-elf.o:asm/rm86-elf.o:asm/r586-elf.o"; | |
60 | $x86_out_asm="asm/bn86-out.o:asm/dx86-out.o asm/yx86-out.o:asm/bx86-out.o:asm/mx86-out.o:asm/sx86-out.o:asm/cx86-out.o:asm/rx86-out.o:asm/rm86-out.o:asm/r586-out.o"; | |
61 | $x86_bsdi_asm="asm/bn86bsdi.o:asm/dx86bsdi.o asm/yx86bsdi.o:asm/bx86bsdi.o:asm/mx86bsdi.o:asm/sx86bsdi.o:asm/cx86bsdi.o:asm/rx86bsdi.o:asm/rm86bsdi.o:asm/r586bsdi.o"; | |
62 | ||
63 | # -DB_ENDIAN slows things down on a sparc for md5, but helps sha1. | |
64 | # So the md5_locl.h file has an undef B_ENDIAN if sun is defined | |
d02b48c6 RE |
65 | |
66 | #config-string CC : CFLAGS : LDFLAGS : special header file mods:bn_asm \ | |
67 | # des_asm:bf_asm | |
68 | %table=( | |
69 | #"b", "$tcc:$tflags:$tlib:$bits1:$tbn_mul::", | |
70 | #"bl-4c-2c", "$tcc:$tflags:$tlib:${bits1}BN_LLONG RC4_CHAR MD2_CHAR:$tbn_mul::", | |
71 | #"bl-4c-ri", "$tcc:$tflags:$tlib:${bits1}BN_LLONG RC4_CHAR RC4_INDEX:$tbn_mul::", | |
72 | #"b2-is-ri-dp", "$tcc:$tflags:$tlib:${bits2}IDEA_SHORT RC4_INDEX DES_PTR:$tbn_mul::", | |
73 | ||
74 | # A few of my development configs | |
75 | "purify", "purify gcc:-g -DPURIFY -Wall:-lsocket -lnsl::::", | |
58964a49 | 76 | "debug", "gcc:-DREF_CHECK -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:::::", |
d02b48c6 RE |
77 | "dist", "cc:-O -DNOPROTO::::", |
78 | ||
79 | # Basic configs that should work on any box | |
80 | "gcc", "gcc:-O3::BN_LLONG:::", | |
81 | "cc", "cc:-O -DNOPROTO -DNOCONST:::::", | |
82 | ||
58964a49 | 83 | |
d02b48c6 | 84 | # My solaris setups |
58964a49 RE |
85 | "solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DBN_ASM:-lsocket -lnsl:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_sol_asm:", |
86 | "solaris-sparc-gcc","gcc:-O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:::", | |
d02b48c6 RE |
87 | # DO NOT use /xO[34] on sparc with SC3.0. |
88 | # It is broken, and will not pass the tests | |
89 | "solaris-sparc-cc","cc:-fast -O -Xa -DB_ENDIAN:\ | |
90 | -lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_UNROLL BF_PTR:asm/sparc.o::", | |
91 | # SC4.0 is ok, better than gcc, except for the bignum stuff. | |
92 | # -fast slows things like DES down quite a lot | |
93 | "solaris-sparc-sc4","cc:-xO5 -Xa -DB_ENDIAN:-lsocket -lnsl:\ | |
94 | BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparc.o::", | |
95 | "solaris-usparc-sc4","cc:-xtarget=ultra -xarch=v8plus -Xa -xO5 -DB_ENDIAN:\ | |
96 | -lsocket -lnsl:\ | |
97 | BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparc.o::", | |
98 | ||
99 | # Sunos configs, assuming sparc for the gcc one. | |
100 | "sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::DES_UNROLL:::", | |
101 | "sunos-gcc","gcc:-O3 -mv8::BN_LLONG RC4_CHAR DES_UNROLL DES_PTR DES_RISC1:::", | |
102 | ||
103 | # SGI configurations. If the box is rather old (r3000 cpu), you will | |
104 | # probably have to remove the '-mips2' flag. I've only been using | |
105 | # IRIX 5.[23]. | |
106 | #"irix-gcc","gcc:-O2 -mips2::BN_LLONG RC4_INDEX RC4_CHAR:::", | |
107 | "irix-gcc","gcc:-O2 -DTERMIOS -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR:::", | |
108 | "irix-cc", "cc:-O2 -DTERMIOS -DB_ENDIAN::DES_PTR DES_RISC2 DES_UNROLL BF_PTR:asm/r3000.o::", | |
109 | "debug-irix-cc", "cc:-w2 -g -DCRYPTO_MDEBUG -DTERMIOS -DB_ENDIAN:::asm/r3000.o::", | |
110 | ||
111 | # HPUX config. I've been building on HPUX 9, so the options may be | |
112 | # different on version 10. The pa-risc2.o assember file is 2 times | |
113 | # faster than the old asm/pa-risc.o version but it may not run on old | |
114 | # PA-RISC CPUs. If you have problems, swap back to the old one. | |
115 | # Both were generated by gcc, so use the C version with the PA-RISC specific | |
116 | # options turned on if you are using gcc. | |
117 | "hpux-cc", "cc:-DB_ENDIAN -D_HPUX_SOURCE -Aa -Ae +ESlit +O4 -Wl,-a,archive::DES_PTR DES_UNROLL DES_RISC1:asm/pa-risc2.o::", | |
118 | "hpux-kr-cc", "cc:-DB_ENDIAN -DNOCONST -DNOPROTO -D_HPUX_SOURCE::DES_PTR DES_UNROLL:asm/pa-risc2.o::", | |
119 | "hpux-gcc", "gcc:-DB_ENDIAN -O3::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::", | |
120 | ||
121 | # Dec Alpha, OSF/1 - the alpha400-cc is the flags for a 21164A with | |
122 | # the new compiler | |
123 | "alpha-gcc","gcc:-O3::SIXTY_FOUR_BIT_LONGS DES_INT DES_PTR DES_RISC2:asm/alpha.o::", | |
124 | "alpha-cc", "cc:-O2::SIXTY_FOUR_BIT_LONGS DES_INT DES_PTR DES_RISC2:asm/alpha.o::", | |
125 | "alpha400-cc", "cc:-arch host -tune host -fast -std -O4 -inline speed::SIXTY_FOUR_BIT_LONG:asm/alpha.o::", | |
126 | ||
127 | # The intel boxes :-), It would be worth seeing if bsdi-gcc can use the | |
58964a49 RE |
128 | # bn86-elf.o file file since it is hand tweaked assembler. |
129 | "linux-elf", "gcc:-DL_ENDIAN -DTERMIO -DBN_ASM -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", | |
130 | "debug-linux-elf","gcc:-DREF_CHECK -DBN_ASM -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall:-lefence:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", | |
131 | "linux-aout", "gcc:-DL_ENDIAN -DTERMIO -DBN_ASM -O3 -fomit-frame-pointer -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm", | |
132 | "NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::", | |
133 | "NetBSD-m86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::", | |
134 | "NetBSD-x86", "gcc:-DTERMIOS -DBN_ASM -D_ANSI_SOURCE -O3 -fomit-frame-pointer -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:", | |
135 | "FreeBSD", "gcc:-DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm", | |
136 | #"bsdi-gcc", "gcc:-O3 -ffast-math -DBN_ASM -DL_ENDIAN -DPERL5 -m486::RSA_LLONG $x86_gc_des $x86_gcc_opts:$x86_bsdi_asm", | |
137 | "nextstep", "cc:-O3 -Wall -DBN_ASM::BN_LLONG $x86_gcc_des $x86_gcc_opts:::", | |
138 | # NCR MP-RAS UNIX ver 02.03.01 | |
139 | "ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw:-lsocket -lnsl:$x86_gcc_des $x86_gcc_opts:::", | |
d02b48c6 RE |
140 | |
141 | # UnixWare 2.0 | |
58964a49 RE |
142 | "unixware-2.0","cc:-O -DFILIO_H:-lsocket -lnsl:$x86_gcc_des $x86_gcc_opts:::", |
143 | "unixware-2.0-pentium","cc:-O -DFILIO_H -Kpentium -Kthread:-lsocket -lnsl:MD2_CHAR RC4_INDEX $x86_des_des::", | |
d02b48c6 RE |
144 | |
145 | # IBM's AIX. | |
146 | "aix-cc", "cc:-O -DAIX -DB_ENDIAN::BN_LLONG RC4_CHAR:::", | |
147 | "aix-gcc", "gcc:-O2 -DAIX -DB_ENDIAN::BN_LLONG RC4_CHAR:::", | |
148 | ||
58964a49 RE |
149 | # |
150 | # Cray T90 (SDSC) | |
151 | # It's Big-endian, but the algorithms work properly when B_ENDIAN is NOT | |
152 | # defined. The T90 ints and longs are 8 bytes long, and apparently the | |
153 | # B_ENDIAN code assumes 4 byte ints. Fortunately, the non-B_ENDIAN and | |
154 | # non L_ENDIAN code aligns the bytes in each word correctly. | |
155 | # | |
156 | # The BIT_FIELD_LIMITS define is to avoid two fatal compiler errors: | |
157 | #'Taking the address of a bit field is not allowed. ' | |
158 | #'An expression with bit field exists as the operand of "sizeof" ' | |
159 | # (written by Wayne Schroeder <schroede@SDSC.EDU>) | |
160 | "cray-t90-cc", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::SIXTY_FOUR_BIT_LONG DES_INT:::", | |
161 | ||
d02b48c6 RE |
162 | # DGUX, 88100. |
163 | "dgux-R3-gcc", "gcc:-O3 -fomit-frame-pointer::RC4_INDEX DES_UNROLL:::", | |
164 | "dgux-R4-gcc", "gcc:-O3 -fomit-frame-pointer:-lnsl -lsocket:RC4_INDEX:RC4_INDEX DES_UNROLL:::", | |
58964a49 | 165 | "dgux-R4-x86-gcc", "gcc:-O3 -DBN_ASM -fomit-frame-pointer -DL_ENDIAN:-lnsl -lsocket:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", |
d02b48c6 RE |
166 | |
167 | # SCO 5 | |
168 | "sco5-cc", "cc:-O:-lsocket:$x86_gcc_des $x86_gcc_opts:::", # des options? | |
169 | ||
170 | # Sinix RM400 | |
171 | "SINIX-N","/usr/ucb/cc:-O2 -misaligned:-lucb:RC4_INDEX RC4_CHAR:::", | |
172 | ||
173 | # Windows NT, Microsoft Visual C++ 4.0 | |
174 | ||
175 | # hmm... bug in perl under NT, I need to concatinate :-( | |
176 | "VC-NT","cl:::BN_LLONG RC4_INDEX ".$x86_gcc_opts.":::", | |
177 | "VC-WIN32","cl:::BN_LLONG RC4_INDEX ".$x86_gcc_opts.":::", | |
178 | "VC-WIN16","cl:::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::", | |
179 | "VC-W31-16","cl:::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", | |
180 | "VC-W31-32","cl:::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::", | |
181 | "VC-MSDOS","cl:::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", | |
182 | ||
183 | # Borland C++ 4.5 | |
184 | "BC-32","bcc32:::DES_PTR RC4_INDEX:::", | |
185 | "BC-16","bcc:::BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT:::", | |
186 | ); | |
187 | ||
188 | $postfix="org"; | |
189 | $Makefile="Makefile.ssl"; | |
190 | $des_locl="crypto/des/des_locl.h"; | |
191 | $des ="crypto/des/des.h"; | |
192 | $bn ="crypto/bn/bn.h"; | |
58964a49 | 193 | $md2 ="crypto/md2/md2.h"; |
d02b48c6 | 194 | $rc4 ="crypto/rc4/rc4.h"; |
58964a49 | 195 | $rc4_locl="crypto/rc4/rc4_locl.h"; |
d02b48c6 RE |
196 | $idea ="crypto/idea/idea.h"; |
197 | $rc2 ="crypto/rc2/rc2.h"; | |
198 | $bf ="crypto/bf/bf_locl.h"; | |
199 | $bn_mulw="bn_mulw.o"; | |
200 | $des_enc="des_enc.o fcrypt_b.o"; | |
201 | $bf_enc ="bf_enc.o"; | |
58964a49 RE |
202 | $cast_enc="c_enc.o"; |
203 | $rc4_enc="rc4_enc.o"; | |
204 | $rc5_enc="rc5_enc.o"; | |
205 | $md5_obj=""; | |
206 | $sha1_obj=""; | |
207 | $rmd160_obj=""; | |
d02b48c6 RE |
208 | |
209 | if ($#ARGV < 0) | |
210 | { | |
211 | &bad_target; | |
212 | exit(1); | |
213 | } | |
214 | ||
215 | $flags=""; | |
216 | foreach (@ARGV) | |
217 | { | |
218 | if ($_ =~ /^-/) | |
219 | { | |
220 | if ($_ =~ /^-[lL](.*)$/) | |
221 | { | |
222 | $libs.=$_." "; | |
223 | } | |
224 | elsif ($_ =~ /^-D(.*)$/) | |
225 | { | |
226 | $flags.=$_." "; | |
227 | } | |
228 | else | |
229 | { | |
230 | die "unknown options, only -Dxxx, -Lxxx -lxxx supported\n"; | |
231 | } | |
232 | } | |
233 | else | |
234 | { | |
235 | die "target already defined - $target\n" if ($target ne ""); | |
236 | $target=$_; | |
237 | if (!defined($table{$target})) | |
238 | { | |
239 | &bad_target; | |
240 | exit(1); | |
241 | } | |
242 | } | |
243 | } | |
244 | ||
245 | if (!defined($table{$target})) | |
246 | { | |
247 | &bad_target; | |
248 | exit(1); | |
249 | } | |
250 | ||
58964a49 RE |
251 | ($cc,$cflags,$lflags,$bn_ops,$bn_obj,$des_obj,$bf_obj,$md5_obj,$sha1_obj, |
252 | $cast_obj,$rc4_obj,$rmd160_obj,$rc5_obj)= | |
d02b48c6 RE |
253 | split(/\s*:\s*/,$table{$target}); |
254 | $cflags="$flags$cflags" if ($flags ne ""); | |
255 | $lflags="$libs$lflags"if ($libs ne ""); | |
256 | ||
58964a49 RE |
257 | $bn_obj=$bn_mulw unless ($bn_obj =~ /\.o$/); |
258 | $des_obj=$des_enc unless ($des_obj =~ /\.o$/); | |
259 | $bf_obj=$bf_enc unless ($bf_obj =~ /\.o$/); | |
260 | $cast_obj=$cast_enc unless ($cast_obj =~ /\.o$/); | |
261 | $rc4_obj=$rc4_enc unless ($rc4_obj =~ /\.o$/); | |
262 | $rc5_obj=$rc5_enc unless ($rc5_obj =~ /\.o$/); | |
263 | if ($sha1_obj =~ /\.o$/) | |
264 | { | |
265 | # $sha1_obj=$sha1_enc; | |
266 | $cflags.=" -DSHA1_ASM"; | |
267 | } | |
268 | if ($md5_obj =~ /\.o$/) | |
269 | { | |
270 | # $md5_obj=$md5_enc; | |
271 | $cflags.=" -DMD5_ASM"; | |
272 | } | |
273 | if ($rmd160_obj =~ /\.o$/) | |
274 | { | |
275 | # $rmd160_obj=$rmd160_enc; | |
276 | $cflags.=" -DRMD160_ASM"; | |
277 | } | |
d02b48c6 RE |
278 | |
279 | $n=&file_new($Makefile); | |
280 | open(IN,"<".$Makefile) || die "unable to read $Makefile:$!\n"; | |
281 | open(OUT,">".$n) || die "unable to read $n:$!\n"; | |
282 | while (<IN>) | |
283 | { | |
284 | chop; | |
285 | s/^CC=.*$/CC= $cc/; | |
286 | s/^CFLAG=.*$/CFLAG= $cflags/; | |
287 | s/^EX_LIBS=.*$/EX_LIBS= $lflags/; | |
288 | s/^BN_MULW=.*$/BN_MULW= $bn_obj/; | |
289 | s/^DES_ENC=.*$/DES_ENC= $des_obj/; | |
290 | s/^BF_ENC=.*$/BF_ENC= $bf_obj/; | |
58964a49 RE |
291 | s/^CAST_ENC=.*$/CAST_ENC= $cast_obj/; |
292 | s/^RC4_ENC=.*$/RC4_ENC= $rc4_obj/; | |
293 | s/^RC5_ENC=.*$/RC5_ENC= $rc5_obj/; | |
294 | s/^MD5_ASM_OBJ=.*$/MD5_ASM_OBJ= $md5_obj/; | |
295 | s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/; | |
296 | s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/; | |
d02b48c6 RE |
297 | print OUT $_."\n"; |
298 | } | |
299 | close(IN); | |
300 | close(OUT); | |
301 | &Rename($Makefile,&file_old($Makefile)); | |
302 | &Rename($n,$Makefile); | |
58964a49 RE |
303 | print "CC =$cc\n"; |
304 | print "CFLAG =$cflags\n"; | |
305 | print "EX_LIBS =$lflags\n"; | |
306 | print "BN_MULW =$bn_obj\n"; | |
307 | print "DES_ENC =$des_obj\n"; | |
308 | print "BF_ENC =$bf_obj\n"; | |
309 | print "CAST_ENC =$cast_obj\n"; | |
310 | print "RC4_ENC =$rc4_obj\n"; | |
311 | print "RC5_ENC =$rc5_obj\n"; | |
312 | print "MD5_OBJ_ASM =$md5_obj\n"; | |
313 | print "SHA1_OBJ_ASM =$sha1_obj\n"; | |
314 | print "RMD160_OBJ_ASM=$rmd160_obj\n"; | |
d02b48c6 RE |
315 | |
316 | $des_ptr=0; | |
317 | $des_risc1=0; | |
318 | $des_risc2=0; | |
319 | $des_unroll=0; | |
320 | $bn_ll=0; | |
321 | $def_int=2; | |
322 | $rc4_int=$def_int; | |
323 | $md2_int=$def_int; | |
324 | $idea_int=$def_int; | |
325 | $rc2_int=$def_int; | |
326 | $rc4_idx=0; | |
327 | $bf_ptr=0; | |
328 | @type=("char","short","int","long"); | |
329 | ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0); | |
330 | ||
331 | foreach (sort split(/\s+/,$bn_ops)) | |
332 | { | |
333 | $des_ptr=1 if /DES_PTR/; | |
334 | $des_risc1=1 if /DES_RISC1/; | |
335 | $des_risc2=1 if /DES_RISC2/; | |
336 | $des_unroll=1 if /DES_UNROLL/; | |
337 | $des_int=1 if /DES_INT/; | |
338 | $bn_ll=1 if /BN_LLONG/; | |
339 | $rc4_int=0 if /RC4_CHAR/; | |
340 | $rc4_int=3 if /RC4_LONG/; | |
341 | $rc4_idx=1 if /RC4_INDEX/; | |
342 | $md2_int=0 if /MD2_CHAR/; | |
343 | $md2_int=3 if /MD2_LONG/; | |
344 | $idea_int=1 if /IDEA_SHORT/; | |
345 | $idea_int=3 if /IDEA_LONG/; | |
346 | $rc2_int=1 if /RC2_SHORT/; | |
347 | $rc2_int=3 if /RC2_LONG/; | |
348 | $bf_ptr=1 if $_ eq "BF_PTR"; | |
349 | $bf_ptr=2 if $_ eq "BF_PTR2"; | |
d02b48c6 | 350 | ($b64l,$b64,$b32,$b16,$b8)=(0,1,0,0,0) if /SIXTY_FOUR_BIT/; |
58964a49 | 351 | ($b64l,$b64,$b32,$b16,$b8)=(1,0,0,0,0) if /SIXTY_FOUR_BIT_LONG/; |
d02b48c6 RE |
352 | ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/; |
353 | ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/; | |
354 | ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/; | |
355 | } | |
356 | ||
357 | (($in=$bn) =~ s/\.([^.]+)/.$postfix/); | |
358 | $n=&file_new($bn); | |
359 | open(IN,"<".$in) || die "unable to read $bn:$!\n"; | |
360 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
361 | while (<IN>) | |
362 | { | |
363 | if (/^#((define)|(undef))\s+SIXTY_FOUR_BIT_LONG/) | |
364 | { printf OUT "#%s SIXTY_FOUR_BIT_LONG\n",($b64l)?"define":"undef"; } | |
365 | elsif (/^#((define)|(undef))\s+SIXTY_FOUR_BIT/) | |
366 | { printf OUT "#%s SIXTY_FOUR_BIT\n",($b64)?"define":"undef"; } | |
367 | elsif (/^#((define)|(undef))\s+THIRTY_TWO_BIT/) | |
368 | { printf OUT "#%s THIRTY_TWO_BIT\n",($b32)?"define":"undef"; } | |
369 | elsif (/^#((define)|(undef))\s+SIXTEEN_BIT/) | |
370 | { printf OUT "#%s SIXTEEN_BIT\n",($b16)?"define":"undef"; } | |
371 | elsif (/^#((define)|(undef))\s+EIGHT_BIT/) | |
372 | { printf OUT "#%s EIGHT_BIT\n",($b8)?"define":"undef"; } | |
373 | elsif (/^#((define)|(undef))\s+BN_LLONG\s*$/) | |
374 | { printf OUT "#%s BN_LLONG\n",($bn_ll)?"define":"undef"; } | |
375 | else | |
376 | { print OUT $_; } | |
377 | } | |
378 | close(IN); | |
379 | close(OUT); | |
380 | &Rename($bn,&file_old($bn)); | |
381 | &Rename($n,$bn); | |
382 | ||
383 | (($in=$des) =~ s/\.([^.]+)/.$postfix/); | |
384 | $n=&file_new($des); | |
385 | open(IN,"<".$in) || die "unable to read $des:$!\n"; | |
386 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
387 | while (<IN>) | |
388 | { | |
389 | if (/^\#define\s+DES_LONG\s+.*/) | |
390 | { printf OUT "#define DES_LONG unsigned %s\n", | |
391 | ($des_int)?'int':'long'; } | |
392 | else | |
393 | { print OUT $_; } | |
394 | } | |
395 | close(IN); | |
396 | close(OUT); | |
397 | &Rename($des,&file_old($des)); | |
398 | &Rename($n,$des); | |
399 | ||
400 | (($in=$des_locl) =~ s/\.([^.]+)/.$postfix/); | |
401 | $n=&file_new($des_locl); | |
402 | open(IN,"<".$in) || die "unable to read $des_locl:$!\n"; | |
403 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
404 | while (<IN>) | |
405 | { | |
406 | if (/^\#(define|undef)\s+DES_PTR/) | |
407 | { printf OUT "#%s DES_PTR\n",($des_ptr)?'define':'undef'; } | |
408 | elsif (/^\#(define|undef)\s+DES_RISC1/) | |
409 | { printf OUT "#%s DES_RISC1\n",($des_risc1)?'define':'undef'; } | |
410 | elsif (/^\#(define|undef)\s+DES_RISC2/) | |
411 | { printf OUT "#%s DES_RISC2\n",($des_risc2)?'define':'undef'; } | |
412 | elsif (/^\#(define|undef)\s+DES_UNROLL/) | |
413 | { printf OUT "#%s DES_UNROLL\n",($des_unroll)?'define':'undef'; } | |
414 | else | |
415 | { print OUT $_; } | |
416 | } | |
417 | close(IN); | |
418 | close(OUT); | |
419 | &Rename($des_locl,&file_old($des_locl)); | |
420 | &Rename($n,$des_locl); | |
421 | ||
422 | (($in=$rc4) =~ s/\.([^.]+)/.$postfix/); | |
423 | $n=&file_new($rc4); | |
424 | open(IN,"<".$in) || die "unable to read $rc4:$!\n"; | |
425 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
426 | while (<IN>) | |
427 | { | |
428 | if (/^#define\s+RC4_INT\s/) | |
429 | { printf OUT "#define RC4_INT unsigned %s\n",$type[$rc4_int]; } | |
430 | else | |
431 | { print OUT $_; } | |
432 | } | |
433 | close(IN); | |
434 | close(OUT); | |
435 | &Rename($rc4,&file_old($rc4)); | |
436 | &Rename($n,$rc4); | |
437 | ||
58964a49 RE |
438 | (($in=$rc4_locl) =~ s/\.([^.]+)/.$postfix/); |
439 | $n=&file_new($rc4_locl); | |
440 | open(IN,"<".$in) || die "unable to read $rc4_locl:$!\n"; | |
d02b48c6 RE |
441 | open(OUT,">$n") || die "unable to read $n:$!\n"; |
442 | while (<IN>) | |
443 | { | |
444 | if (/^#((define)|(undef))\s+RC4_INDEX/) | |
445 | { printf OUT "#%s RC4_INDEX\n",($rc4_idx)?"define":"undef"; } | |
446 | else | |
447 | { print OUT $_; } | |
448 | } | |
449 | close(IN); | |
450 | close(OUT); | |
58964a49 RE |
451 | &Rename($rc4_locl,&file_old($rc4_locl)); |
452 | &Rename($n,$rc4_locl); | |
d02b48c6 RE |
453 | |
454 | (($in=$md2) =~ s/\.([^.]+)/.$postfix/); | |
455 | $n=&file_new($md2); | |
456 | open(IN,"<".$in) || die "unable to read $bn:$!\n"; | |
457 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
458 | while (<IN>) | |
459 | { | |
460 | if (/^#define\s+MD2_INT\s/) | |
461 | { printf OUT "#define MD2_INT unsigned %s\n",$type[$md2_int]; } | |
462 | else | |
463 | { print OUT $_; } | |
464 | } | |
465 | close(IN); | |
466 | close(OUT); | |
467 | &Rename($md2,&file_old($md2)); | |
468 | &Rename($n,$md2); | |
469 | ||
470 | (($in=$idea) =~ s/\.([^.]+)/.$postfix/); | |
471 | $n=&file_new($idea); | |
472 | open(IN,"<".$in) || die "unable to read $idea:$!\n"; | |
473 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
474 | while (<IN>) | |
475 | { | |
476 | if (/^#define\s+IDEA_INT\s/) | |
477 | {printf OUT "#define IDEA_INT unsigned %s\n",$type[$idea_int];} | |
478 | else | |
479 | { print OUT $_; } | |
480 | } | |
481 | close(IN); | |
482 | close(OUT); | |
483 | &Rename($idea,&file_old($idea)); | |
484 | &Rename($n,$idea); | |
485 | ||
486 | (($in=$rc2) =~ s/\.([^.]+)/.$postfix/); | |
487 | $n=&file_new($rc2); | |
488 | open(IN,"<".$in) || die "unable to read $rc2:$!\n"; | |
489 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
490 | while (<IN>) | |
491 | { | |
492 | if (/^#define\s+RC2_INT\s/) | |
493 | {printf OUT "#define RC2_INT unsigned %s\n",$type[$rc2_int];} | |
494 | else | |
495 | { print OUT $_; } | |
496 | } | |
497 | close(IN); | |
498 | close(OUT); | |
499 | &Rename($rc2,&file_old($rc2)); | |
500 | &Rename($n,$rc2); | |
501 | ||
502 | (($in=$bf) =~ s/\.([^.]+)/.$postfix/); | |
503 | $n=&file_new($bf); | |
504 | open(IN,"<".$in) || die "unable to read $bf:$!\n"; | |
505 | open(OUT,">$n") || die "unable to read $n:$!\n"; | |
506 | while (<IN>) | |
507 | { | |
508 | if (/^#(define|undef)\s+BF_PTR/) | |
509 | { | |
510 | printf OUT "#undef BF_PTR\n" if $bf_ptr == 0; | |
511 | printf OUT "#define BF_PTR\n" if $bf_ptr == 1; | |
512 | printf OUT "#define BF_PTR2\n" if $bf_ptr == 2; | |
513 | } | |
514 | else | |
515 | { print OUT $_; } | |
516 | } | |
517 | close(IN); | |
518 | close(OUT); | |
519 | &Rename($bf,&file_old($bf)); | |
520 | &Rename($n,$bf); | |
521 | ||
522 | print "SIXTY_FOUR_BIT_LONG mode\n" if $b64l; | |
523 | print "SIXTY_FOUR_BIT mode\n" if $b64; | |
524 | print "THIRTY_TWO_BIT mode\n" if $b32; | |
525 | print "SIXTEEN_BIT mode\n" if $b16; | |
526 | print "EIGHT_BIT mode\n" if $b8; | |
527 | print "DES_PTR used\n" if $des_ptr; | |
528 | print "DES_RISC1 used\n" if $des_risc1; | |
529 | print "DES_RISC2 used\n" if $des_risc2; | |
530 | print "DES_UNROLL used\n" if $des_unroll; | |
531 | print "DES_INT used\n" if $des_int; | |
532 | print "BN_LLONG mode\n" if $bn_ll; | |
533 | print "RC4 uses u$type[$rc4_int]\n" if $rc4_int != $def_int; | |
534 | print "RC4_INDEX mode\n" if $rc4_idx; | |
535 | print "MD2 uses u$type[$md2_int]\n" if $md2_int != $def_int; | |
536 | print "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int; | |
537 | print "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int; | |
538 | print "BF_PTR used\n" if $bf_ptr == 1; | |
539 | print "BF_PTR2 used\n" if $bf_ptr == 2; | |
540 | exit(0); | |
541 | ||
542 | sub bad_target | |
543 | { | |
544 | print STDERR "Usage: Configure [-Dxxx] [-Lxxx] [-lxxx] os/compiler\n"; | |
545 | print STDERR "pick os/compiler from:"; | |
546 | $j=0; | |
547 | foreach $i (sort keys %table) | |
548 | { | |
549 | next if /^b-/; | |
550 | print STDERR "\n" if ($j++ % 4) == 0; | |
551 | printf(STDERR "%-18s ",$i); | |
552 | } | |
553 | print STDERR "\n"; | |
554 | } | |
555 | ||
556 | sub Rename | |
557 | { | |
558 | local($from,$to)=@_; | |
559 | ||
560 | unlink($to); | |
561 | rename($from,$to) || die "unable to rename $from to $to:$!\n"; | |
562 | } | |
563 | ||
564 | sub file_new { local($a)=@_; $a =~ s/(\.[^.]+$|$)/.new/; $a; } | |
565 | sub file_old { local($a)=@_; $a =~ s/(\.[^.]+$|$)/.old/; $a; } |