]>
Commit | Line | Data |
---|---|---|
d02b48c6 RE |
1 | #!/usr/local/bin/perl |
2 | # A bit of an evil hack but it post processes the file ../MINFO which | |
3 | # is generated by `make files` in the top directory. | |
4 | # This script outputs one mega makefile that has no shell stuff or any | |
5 | # funny stuff | |
6 | # | |
7 | ||
8 | $INSTALLTOP="/usr/local/ssl"; | |
9 | ||
58964a49 RE |
10 | $ssl_version="0.8.2"; |
11 | ||
d02b48c6 RE |
12 | $infile="MINFO"; |
13 | ||
14 | %ops=( | |
15 | "VC-WIN32", "Microsoft Visual C++ 4.[01] - Windows NT [34].x", | |
16 | "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286", | |
17 | "VC-WIN16", "Alias for VC-W31-32", | |
18 | "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+", | |
19 | "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS", | |
20 | "BC-NT", "Borland C++ 4.5 - Windows NT - PROBABLY NOT WORKING", | |
21 | "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING", | |
22 | "BC-MSDOS","Borland C++ 4.5 - MSDOS", | |
58964a49 | 23 | "linux-elf","Linux elf", |
dfeab068 | 24 | "ultrix-mips","DEC mips ultrix", |
d02b48c6 RE |
25 | "FreeBSD","FreeBSD distribution", |
26 | "default","cc under unix", | |
27 | ); | |
28 | ||
dfeab068 | 29 | $platform=""; |
d02b48c6 RE |
30 | foreach (@ARGV) |
31 | { | |
32 | if (/^no-rc2$/) { $no_rc2=1; } | |
33 | elsif (/^no-rc4$/) { $no_rc4=1; } | |
58964a49 | 34 | elsif (/^no-rc5$/) { $no_rc5=1; } |
d02b48c6 RE |
35 | elsif (/^no-idea$/) { $no_idea=1; } |
36 | elsif (/^no-des$/) { $no_des=1; } | |
37 | elsif (/^no-bf$/) { $no_bf=1; } | |
58964a49 | 38 | elsif (/^no-cast$/) { $no_cast=1; } |
d02b48c6 RE |
39 | elsif (/^no-md2$/) { $no_md2=1; } |
40 | elsif (/^no-md5$/) { $no_md5=1; } | |
41 | elsif (/^no-sha$/) { $no_sha=1; } | |
42 | elsif (/^no-sha1$/) { $no_sha1=1; } | |
58964a49 | 43 | elsif (/^no-rmd160$/) { $no_rmd160=1; } |
d02b48c6 | 44 | elsif (/^no-mdc2$/) { $no_mdc2=1; } |
58964a49 | 45 | elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; } |
d02b48c6 RE |
46 | elsif (/^no-rsa$/) { $no_rsa=1; } |
47 | elsif (/^no-dsa$/) { $no_dsa=1; } | |
48 | elsif (/^no-dh$/) { $no_dh=1; } | |
49 | elsif (/^no-asm$/) { $no_asm=1; } | |
50 | elsif (/^no-ssl2$/) { $no_ssl2=1; } | |
51 | elsif (/^no-ssl3$/) { $no_ssl3=1; } | |
52 | elsif (/^no-err$/) { $no_err=1; } | |
53 | elsif (/^no-sock$/) { $no_sock=1; } | |
54 | ||
58964a49 RE |
55 | elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1; |
56 | $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1; | |
dfeab068 | 57 | $no_ssl2=$no_err=$no_rmd160=$no_rc5=1; } |
58964a49 | 58 | |
d02b48c6 RE |
59 | elsif (/^rsaref$/) { $rsaref=1; } |
60 | elsif (/^gcc$/) { $gcc=1; } | |
61 | elsif (/^debug$/) { $debug=1; } | |
62 | elsif (/^shlib$/) { $shlib=1; } | |
63 | elsif (/^dll$/) { $shlib=1; } | |
64 | elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } | |
65 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } | |
66 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) | |
67 | { $c_flags.="$_ "; } | |
68 | else | |
69 | { | |
70 | if (!defined($ops{$_})) | |
71 | { | |
72 | print STDERR "unknown option - $_\n"; | |
73 | print STDERR "usage: perl mk1mf.pl [system] [options]\n"; | |
74 | print STDERR "\nwhere [system] can be one of the following\n"; | |
75 | foreach $i (sort keys %ops) | |
76 | { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } | |
77 | print STDERR <<"EOF"; | |
78 | and [options] can be one of | |
58964a49 RE |
79 | no-md2 no-md5 no-sha no-sha1 no-mdc2 no-rmd160 - Skip this digest |
80 | no-rc2 no-rc4 no-idea no-des no-bf no-cast - Skip this symetric cipher | |
81 | no-rc5 | |
d02b48c6 RE |
82 | no-rsa no-dsa no-dh - Skip this public key cipher |
83 | no-ssl2 no-ssl3 - Skip this version of SSL | |
84 | just-ssl - remove all non-ssl keys/digest | |
85 | no-asm - No x86 asm | |
86 | no-socks - No socket code | |
87 | no-err - No error strings | |
88 | dll/shlib - Build shared libraries (MS) | |
89 | debug - Debug build | |
90 | gcc - Use Gcc (unix) | |
91 | rsaref - Build to require RSAref | |
92 | ||
93 | Values that can be set | |
58964a49 | 94 | TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler |
d02b48c6 RE |
95 | |
96 | -L<ex_lib_path> -l<ex_lib> - extra library flags (unix) | |
97 | -<ex_cc_flags> - extra 'cc' flags, | |
98 | added (MS), or replace (unix) | |
99 | EOF | |
100 | exit(1); | |
101 | } | |
dfeab068 | 102 | $platform=$_; |
d02b48c6 RE |
103 | } |
104 | } | |
105 | ||
106 | $no_mdc2=1 if ($no_des); | |
107 | ||
108 | $no_ssl3=1 if ($no_md5 || $no_sha1); | |
109 | $no_ssl3=1 if ($no_rsa && $no_dh); | |
110 | ||
111 | $no_ssl2=1 if ($no_md5 || $no_rsa); | |
112 | $no_ssl2=1 if ($no_rsa); | |
113 | ||
58964a49 RE |
114 | $out_def="out"; |
115 | $inc_def="outinc"; | |
116 | $tmp_def="tmp"; | |
117 | ||
d02b48c6 RE |
118 | |
119 | ($ssl,$crypto)=("ssl","crypto"); | |
120 | $RSAglue="RSAglue"; | |
121 | $ranlib="echo ranlib"; | |
122 | ||
58964a49 RE |
123 | $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; |
124 | $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; | |
125 | $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; | |
126 | ||
127 | # $bin_dir.=$o causes a core dump on my sparc :-( | |
128 | ||
d02b48c6 | 129 | push(@INC,"util/pl","pl"); |
dfeab068 | 130 | if ($platform eq "VC-MSDOS") |
d02b48c6 RE |
131 | { |
132 | $asmbits=16; | |
133 | $msdos=1; | |
134 | require 'VC-16.pl'; | |
135 | } | |
dfeab068 | 136 | elsif ($platform eq "VC-W31-16") |
d02b48c6 RE |
137 | { |
138 | $asmbits=16; | |
139 | $msdos=1; $win16=1; | |
140 | require 'VC-16.pl'; | |
141 | } | |
dfeab068 | 142 | elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16")) |
d02b48c6 RE |
143 | { |
144 | $asmbits=32; | |
145 | $msdos=1; $win16=1; | |
146 | require 'VC-16.pl'; | |
147 | } | |
dfeab068 | 148 | elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) |
d02b48c6 RE |
149 | { |
150 | require 'VC-32.pl'; | |
151 | } | |
dfeab068 | 152 | elsif ($platform eq "BC-NT") |
d02b48c6 RE |
153 | { |
154 | $bc=1; | |
155 | require 'BC-32.pl'; | |
156 | } | |
dfeab068 | 157 | elsif ($platform eq "BC-W31") |
d02b48c6 RE |
158 | { |
159 | $bc=1; | |
160 | $msdos=1; $w16=1; | |
161 | require 'BC-16.pl'; | |
162 | } | |
dfeab068 | 163 | elsif ($platform eq "BC-Q16") |
d02b48c6 RE |
164 | { |
165 | $msdos=1; $w16=1; $shlib=0; $qw=1; | |
166 | require 'BC-16.pl'; | |
167 | } | |
dfeab068 | 168 | elsif ($platform eq "BC-MSDOS") |
d02b48c6 RE |
169 | { |
170 | $asmbits=16; | |
171 | $msdos=1; | |
172 | require 'BC-16.pl'; | |
173 | } | |
dfeab068 | 174 | elsif ($platform eq "FreeBSD") |
d02b48c6 RE |
175 | { |
176 | require 'unix.pl'; | |
177 | $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; | |
178 | } | |
dfeab068 | 179 | elsif ($platform eq "linux-elf") |
58964a49 RE |
180 | { |
181 | require "unix.pl"; | |
182 | require "linux.pl"; | |
183 | $unix=1; | |
184 | } | |
dfeab068 RE |
185 | elsif ($platform eq "ultrix-mips") |
186 | { | |
187 | require "unix.pl"; | |
188 | require "ultrix.pl"; | |
189 | $unix=1; | |
190 | } | |
d02b48c6 RE |
191 | else |
192 | { | |
193 | require "unix.pl"; | |
194 | ||
195 | $unix=1; | |
196 | $cflags.=' -DTERMIO'; | |
197 | } | |
198 | ||
58964a49 RE |
199 | $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); |
200 | $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); | |
201 | $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; | |
202 | ||
d02b48c6 RE |
203 | $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); |
204 | ||
205 | $cflags.=" -DNO_IDEA" if $no_idea; | |
206 | $cflags.=" -DNO_RC2" if $no_rc2; | |
207 | $cflags.=" -DNO_RC4" if $no_rc4; | |
58964a49 | 208 | $cflags.=" -DNO_RC5" if $no_rc5; |
d02b48c6 RE |
209 | $cflags.=" -DNO_MD2" if $no_md2; |
210 | $cflags.=" -DNO_MD5" if $no_md5; | |
211 | $cflags.=" -DNO_SHA" if $no_sha; | |
212 | $cflags.=" -DNO_SHA1" if $no_sha1; | |
58964a49 | 213 | $cflags.=" -DNO_RMD160" if $no_rmd160; |
d02b48c6 RE |
214 | $cflags.=" -DNO_MDC2" if $no_mdc2; |
215 | $cflags.=" -DNO_BLOWFISH" if $no_bf; | |
58964a49 | 216 | $cflags.=" -DNO_CAST" if $no_cast; |
d02b48c6 RE |
217 | $cflags.=" -DNO_DES" if $no_des; |
218 | $cflags.=" -DNO_RSA" if $no_rsa; | |
219 | $cflags.=" -DNO_DSA" if $no_dsa; | |
220 | $cflags.=" -DNO_DH" if $no_dh; | |
221 | $cflags.=" -DNO_SOCK" if $no_sock; | |
222 | $cflags.=" -DNO_SSL2" if $no_ssl2; | |
223 | $cflags.=" -DNO_SSL3" if $no_ssl3; | |
224 | $cflags.=" -DNO_ERR" if $no_err; | |
225 | $cflags.=" -DRSAref" if $rsaref ne ""; | |
226 | ||
227 | if ($unix) | |
228 | { $cflags="$c_flags" if ($c_flags ne ""); } | |
229 | else { $cflags="$c_flags$cflags" if ($c_flags ne ""); } | |
230 | ||
231 | $ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); | |
232 | ||
233 | if ($ranlib ne "") | |
234 | { | |
235 | $ranlib="\$(SRC_D)$o$ranlib"; | |
236 | } | |
237 | ||
238 | if ($msdos) | |
239 | { | |
dfeab068 | 240 | $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; |
d02b48c6 RE |
241 | $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; |
242 | $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; | |
243 | $banner.="\t\@echo documentation for details.\n"; | |
244 | } | |
245 | ||
246 | # have to do this to allow $(CC) under unix | |
247 | $link="$bin_dir$link" if ($link !~ /^\$/); | |
248 | ||
249 | $INSTALLTOP =~ s|/|$o|g; | |
250 | ||
251 | $defs= <<"EOF"; | |
252 | # This makefile has been automatically generated from the SSLeay distribution. | |
253 | # This single makefile will build the complete SSLeay distribution and | |
254 | # by default leave the 'intertesting' output files in .${o}out and the stuff | |
255 | # that needs deleting in .${o}tmp. | |
256 | # The file was generated by running 'make makefile.one', which | |
257 | # does a 'make files', which writes all the environment variables from all | |
258 | # the makefiles to the file call MINFO. This file is used by | |
259 | # util${o}mk1mf.pl to generate makefile.one. | |
260 | # The 'makefile per directory' system suites me when developing this | |
261 | # library and also so I can 'distribute' indervidual library sections. | |
262 | # The one monster makefile better suits building in non-unix | |
263 | # environments. | |
264 | ||
265 | INSTALLTOP=$INSTALLTOP | |
266 | ||
267 | # Set your compiler options | |
dfeab068 | 268 | PLATFORM=$platform |
d02b48c6 RE |
269 | CC=$bin_dir${cc} |
270 | CFLAG=$cflags | |
271 | APP_CFLAG=$app_cflag | |
272 | LIB_CFLAG=$lib_cflag | |
58964a49 | 273 | SHLIB_CFLAG=$shl_cflag |
d02b48c6 RE |
274 | APP_EX_OBJ=$app_ex_obj |
275 | SHLIB_EX_OBJ=$shlib_ex_obj | |
276 | # add extra libraries to this define, for solaris -lsocket -lnsl would | |
277 | # be added | |
278 | EX_LIBS=$ex_libs | |
279 | ||
280 | # The SSLeay directory | |
281 | SRC_D=$src_dir | |
282 | ||
283 | LINK=$link | |
284 | LFLAGS=$lflags | |
285 | ||
dfeab068 RE |
286 | BN_ASM_OBJ=$bn_asm_obj |
287 | BN_ASM_SRC=$bn_asm_src | |
d02b48c6 RE |
288 | DES_ENC_OBJ=$des_enc_obj |
289 | DES_ENC_SRC=$des_enc_src | |
d02b48c6 RE |
290 | BF_ENC_OBJ=$bf_enc_obj |
291 | BF_ENC_SRC=$bf_enc_src | |
58964a49 RE |
292 | CAST_ENC_OBJ=$cast_enc_obj |
293 | CAST_ENC_SRC=$cast_enc_src | |
294 | RC4_ENC_OBJ=$rc4_enc_obj | |
295 | RC4_ENC_SRC=$rc4_enc_src | |
296 | RC5_ENC_OBJ=$rc5_enc_obj | |
297 | RC5_ENC_SRC=$rc5_enc_src | |
298 | MD5_ASM_OBJ=$md5_asm_obj | |
299 | MD5_ASM_SRC=$md5_asm_src | |
300 | SHA1_ASM_OBJ=$sha1_asm_obj | |
301 | SHA1_ASM_SRC=$sha1_asm_src | |
302 | RMD160_ASM_OBJ=$rmd160_asm_obj | |
303 | RMD160_ASM_SRC=$rmd160_asm_src | |
d02b48c6 RE |
304 | |
305 | # The output directory for everything intersting | |
306 | OUT_D=$out_dir | |
307 | # The output directory for all the temporary muck | |
308 | TMP_D=$tmp_dir | |
58964a49 RE |
309 | # The output directory for the header files |
310 | INC_D=$inc_dir | |
d02b48c6 RE |
311 | |
312 | CP=$cp | |
313 | RM=$rm | |
314 | RANLIB=$ranlib | |
315 | MKDIR=mkdir | |
316 | MKLIB=$bin_dir$mklib | |
317 | MLFLAGS=$mlflags | |
318 | ASM=$bin_dir$asm | |
319 | ||
320 | ###################################################### | |
321 | # You should not need to touch anything below this point | |
322 | ###################################################### | |
323 | ||
324 | E_EXE=ssleay | |
325 | SSL=$ssl | |
326 | CRYPTO=$crypto | |
327 | RSAGLUE=$RSAglue | |
328 | ||
329 | # BIN_D - Binary output directory | |
330 | # TEST_D - Binary test file output directory | |
331 | # LIB_D - library output directory | |
d02b48c6 RE |
332 | BIN_D=\$(OUT_D) |
333 | TEST_D=\$(OUT_D) | |
334 | LIB_D=\$(OUT_D) | |
d02b48c6 RE |
335 | |
336 | # INCL_D - local library directory | |
337 | # OBJ_D - temp object file directory | |
338 | OBJ_D=\$(TMP_D) | |
339 | INCL_D=\$(TMP_D) | |
340 | ||
341 | O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp | |
342 | O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp | |
343 | O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp | |
58964a49 RE |
344 | SO_SSL= $plib\$(SSL)$so_shlibp |
345 | SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp | |
346 | L_SSL= \$(LIB_D)$o\$(SSL)$libp | |
347 | L_CRYPTO= \$(LIB_D)$o\$(CRYPTO)$libp | |
d02b48c6 RE |
348 | |
349 | L_LIBS= \$(L_SSL) \$(L_CRYPTO) | |
350 | #L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO) | |
351 | ||
352 | ###################################################### | |
353 | # Don't touch anything below this point | |
354 | ###################################################### | |
355 | ||
58964a49 | 356 | INC=-I\$(INC_D) -I\$(INCL_D) |
d02b48c6 RE |
357 | APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) |
358 | LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) | |
58964a49 | 359 | SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) |
d02b48c6 RE |
360 | LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) |
361 | ||
362 | ############################################# | |
363 | EOF | |
364 | ||
365 | $rules=<<"EOF"; | |
58964a49 | 366 | all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INC_D) headers lib exe |
d02b48c6 RE |
367 | |
368 | banner: | |
369 | $banner | |
370 | ||
d02b48c6 RE |
371 | \$(TMP_D): |
372 | \$(MKDIR) \$(TMP_D) | |
373 | ||
58964a49 RE |
374 | \$(BIN_D): |
375 | \$(MKDIR) \$(BIN_D) | |
376 | ||
377 | \$(TEST_D): | |
378 | \$(MKDIR) \$(TEST_D) | |
379 | ||
380 | \$(LIB_D): | |
381 | \$(MKDIR) \$(LIB_D) | |
382 | ||
383 | \$(INC_D): | |
384 | \$(MKDIR) \$(INC_D) | |
385 | ||
d02b48c6 RE |
386 | headers: \$(HEADER) \$(EXHEADER) |
387 | ||
388 | lib: \$(LIBS_DEP) | |
389 | ||
390 | exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep | |
391 | ||
392 | install: | |
393 | \$(MKDIR) \$(INSTALLTOP) | |
394 | \$(MKDIR) \$(INSTALLTOP)${o}bin | |
395 | \$(MKDIR) \$(INSTALLTOP)${o}include | |
396 | \$(MKDIR) \$(INSTALLTOP)${o}lib | |
58964a49 | 397 | \$(CP) \$(INC_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include |
d02b48c6 | 398 | \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin |
58964a49 RE |
399 | \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib |
400 | \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib | |
d02b48c6 RE |
401 | |
402 | clean: | |
403 | \$(RM) \$(TMP_D)$o*.* | |
404 | ||
405 | vclean: | |
406 | \$(RM) \$(TMP_D)$o*.* | |
407 | \$(RM) \$(OUT_D)$o*.* | |
408 | ||
409 | EOF | |
410 | ||
411 | ############################################# | |
412 | # We parse in input file and 'store' info for later printing. | |
413 | open(IN,"<$infile") || die "unable to open $infile:$!\n"; | |
414 | $_=<IN>; | |
415 | for (;;) | |
416 | { | |
417 | chop; | |
418 | ||
419 | ($key,$val)=/^([^=]+)=(.*)/; | |
420 | if ($key eq "RELATIVE_DIRECTORY") | |
421 | { | |
422 | if ($lib ne "") | |
423 | { | |
424 | $uc=$lib; | |
425 | $uc =~ s/^lib(.*)\.a/$1/; | |
426 | $uc =~ tr/a-z/A-Z/; | |
427 | $lib_nam{$uc}=$uc; | |
428 | $lib_obj{$uc}.=$libobj." "; | |
429 | } | |
430 | last if ($val eq "FINISHED"); | |
431 | $lib=""; | |
432 | $libobj=""; | |
433 | $dir=$val; | |
434 | } | |
435 | ||
436 | if ($key eq "TEST") | |
437 | { $test.=&var_add($dir,$val); } | |
438 | ||
439 | if (($key eq "PROGS") || ($key eq "E_OBJ")) | |
440 | { $e_exe.=&var_add($dir,$val); } | |
441 | ||
442 | if ($key eq "LIB") | |
443 | { | |
444 | $lib=$val; | |
445 | $lib =~ s/^.*\/([^\/]+)$/$1/; | |
446 | } | |
447 | ||
448 | if ($key eq "EXHEADER") | |
449 | { $exheader.=&var_add($dir,$val); } | |
450 | ||
451 | if ($key eq "HEADER") | |
452 | { $header.=&var_add($dir,$val); } | |
453 | ||
454 | if ($key eq "LIBOBJ") | |
455 | { $libobj=&var_add($dir,$val); } | |
456 | ||
457 | if (!($_=<IN>)) | |
458 | { $_="RELATIVE_DIRECTORY=FINISHED\n"; } | |
459 | } | |
460 | close(IN); | |
461 | ||
462 | # Strip of trailing ' ' | |
463 | foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } | |
464 | $test=&clean_up_ws($test); | |
465 | $e_exe=&clean_up_ws($e_exe); | |
466 | $exheader=&clean_up_ws($exheader); | |
467 | $header=&clean_up_ws($header); | |
468 | ||
469 | # First we strip the exheaders from the headers list | |
470 | foreach (split(/\s+/,$exheader)){ $h{$_}=1; } | |
471 | foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } | |
472 | chop($h); $header=$h; | |
473 | ||
474 | $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h"); | |
475 | $rules.=&do_copy_rule("\$(INCL_D)",$header,".h"); | |
476 | ||
477 | $defs.=&do_defs("EXHEADER",$exheader,"\$(INC_D)",".h"); | |
478 | $rules.=&do_copy_rule("\$(INC_D)",$exheader,".h"); | |
479 | ||
480 | $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); | |
481 | $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); | |
482 | ||
483 | $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); | |
484 | $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); | |
485 | ||
486 | foreach (values %lib_nam) | |
487 | { | |
488 | $lib_obj=$lib_obj{$_}; | |
58964a49 RE |
489 | local($slib)=$shlib; |
490 | ||
491 | $slib=0 if ($_ eq "RSAGLUE"); | |
d02b48c6 RE |
492 | |
493 | if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) | |
494 | { | |
495 | $rules.="\$(O_SSL):\n\n"; | |
496 | next; | |
497 | } | |
498 | ||
499 | if (($_ eq "RSAGLUE") && $no_rsa) | |
500 | { | |
501 | $rules.="\$(O_RSAGLUE):\n\n"; | |
502 | next; | |
503 | } | |
504 | ||
dfeab068 | 505 | if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) |
d02b48c6 | 506 | { |
dfeab068 RE |
507 | $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; |
508 | $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src); | |
d02b48c6 RE |
509 | } |
510 | if (($des_enc_obj ne "") && ($_ eq "CRYPTO")) | |
511 | { | |
58964a49 RE |
512 | $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; |
513 | $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; | |
d02b48c6 RE |
514 | $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); |
515 | } | |
516 | if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) | |
517 | { | |
58964a49 | 518 | $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/; |
d02b48c6 RE |
519 | $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src); |
520 | } | |
58964a49 RE |
521 | if (($cast_enc_obj ne "") && ($_ eq "CRYPTO")) |
522 | { | |
523 | $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/; | |
524 | $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src); | |
525 | } | |
526 | if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO")) | |
527 | { | |
528 | $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/; | |
529 | $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src); | |
530 | } | |
531 | if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO")) | |
532 | { | |
533 | $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/; | |
534 | $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src); | |
535 | } | |
536 | if (($md5_asm_obj ne "") && ($_ eq "CRYPTO")) | |
537 | { | |
538 | $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; | |
539 | $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); | |
540 | } | |
541 | if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO")) | |
542 | { | |
543 | $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/; | |
544 | $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src); | |
545 | } | |
546 | if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) | |
547 | { | |
548 | $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; | |
549 | $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); | |
550 | } | |
d02b48c6 | 551 | $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); |
58964a49 RE |
552 | $lib=($slib)?" \$(SHLIB_CFLAGS)":" \$(LIB_CFLAGS)"; |
553 | $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); | |
d02b48c6 RE |
554 | } |
555 | ||
556 | $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); | |
557 | foreach (split(/\s+/,$test)) | |
558 | { | |
559 | $t=&bname($_); | |
560 | $tt="\$(OBJ_D)${o}$t${obj}"; | |
561 | $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | |
562 | } | |
563 | ||
58964a49 RE |
564 | $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); |
565 | $rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0,"") | |
d02b48c6 | 566 | unless $no_rsa; |
58964a49 | 567 | $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); |
d02b48c6 RE |
568 | |
569 | $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | |
570 | ||
571 | print $defs; | |
572 | print "###################################################################\n"; | |
573 | print $rules; | |
574 | ||
575 | ############################################### | |
576 | # strip off any trailing .[och] and append the relative directory | |
577 | # also remembering to do nothing if we are in one of the dropped | |
578 | # directories | |
579 | sub var_add | |
580 | { | |
581 | local($dir,$val)=@_; | |
582 | local(@a,$_,$ret); | |
583 | ||
584 | return("") if $no_idea && $dir =~ /\/idea/; | |
585 | return("") if $no_rc2 && $dir =~ /\/rc2/; | |
586 | return("") if $no_rc4 && $dir =~ /\/rc4/; | |
58964a49 | 587 | return("") if $no_rc5 && $dir =~ /\/rc5/; |
d02b48c6 RE |
588 | return("") if $no_rsa && $dir =~ /\/rsa/; |
589 | return("") if $no_rsa && $dir =~ /^rsaref/; | |
590 | return("") if $no_dsa && $dir =~ /\/dsa/; | |
591 | return("") if $no_dh && $dir =~ /\/dh/; | |
592 | if ($no_des && $dir =~ /\/des/) | |
593 | { | |
594 | if ($val =~ /read_pwd/) | |
595 | { return("$dir/read_pwd "); } | |
596 | else | |
597 | { return(""); } | |
598 | } | |
599 | return("") if $no_mdc2 && $dir =~ /\/mdc2/; | |
600 | return("") if $no_sock && $dir =~ /\/proxy/; | |
601 | return("") if $no_bf && $dir =~ /\/bf/; | |
58964a49 | 602 | return("") if $no_cast && $dir =~ /\/cast/; |
d02b48c6 RE |
603 | |
604 | $val =~ s/^\s*(.*)\s*$/$1/; | |
605 | @a=split(/\s+/,$val); | |
606 | grep(s/\.[och]$//,@a); | |
607 | ||
608 | @a=grep(!/^e_.*_3d$/,@a) if $no_des; | |
609 | @a=grep(!/^e_.*_d$/,@a) if $no_des; | |
610 | @a=grep(!/^e_.*_i$/,@a) if $no_idea; | |
611 | @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; | |
58964a49 | 612 | @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; |
d02b48c6 | 613 | @a=grep(!/^e_.*_bf$/,@a) if $no_bf; |
58964a49 | 614 | @a=grep(!/^e_.*_c$/,@a) if $no_cast; |
d02b48c6 RE |
615 | @a=grep(!/^e_rc4$/,@a) if $no_rc4; |
616 | ||
617 | @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; | |
618 | @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; | |
619 | ||
620 | @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; | |
621 | ||
622 | @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; | |
623 | @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; | |
dfeab068 | 624 | @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160; |
d02b48c6 RE |
625 | |
626 | @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; | |
627 | @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; | |
628 | @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; | |
629 | ||
630 | @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; | |
631 | @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; | |
632 | ||
633 | @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; | |
634 | ||
635 | @a=grep(!/_dhp$/,@a) if $no_dh; | |
636 | ||
637 | @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; | |
638 | @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
639 | @a=grep(!/_mdc2$/,@a) if $no_mdc2; | |
640 | ||
13e91dd3 | 641 | @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; |
d02b48c6 RE |
642 | @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; |
643 | @a=grep(!/^gendsa$/,@a) if $no_sha1; | |
644 | @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; | |
645 | ||
646 | @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
647 | ||
648 | grep($_="$dir/$_",@a); | |
649 | @a=grep(!/(^|\/)s_/,@a) if $no_sock; | |
650 | @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; | |
651 | $ret=join(' ',@a)." "; | |
652 | return($ret); | |
653 | } | |
654 | ||
655 | # change things so that each 'token' is only separated by one space | |
656 | sub clean_up_ws | |
657 | { | |
658 | local($w)=@_; | |
659 | ||
660 | $w =~ s/^\s*(.*)\s*$/$1/; | |
661 | $w =~ s/\s+/ /g; | |
662 | return($w); | |
663 | } | |
664 | ||
665 | sub do_defs | |
666 | { | |
667 | local($var,$files,$location,$postfix)=@_; | |
58964a49 | 668 | local($_,$ret,$pf); |
d02b48c6 RE |
669 | local(*OUT,$tmp,$t); |
670 | ||
671 | $files =~ s/\//$o/g if $o ne '/'; | |
672 | $ret="$var="; | |
673 | $n=1; | |
674 | $Vars{$var}.=""; | |
675 | foreach (split(/ /,$files)) | |
676 | { | |
58964a49 | 677 | $orig=$_; |
d02b48c6 RE |
678 | $_=&bname($_) unless /^\$/; |
679 | if ($n++ == 2) | |
680 | { | |
681 | $n=0; | |
682 | $ret.="\\\n\t"; | |
683 | } | |
58964a49 RE |
684 | if (($_ =~ /bss_file/) && ($postfix eq ".h")) |
685 | { $pf=".c"; } | |
686 | else { $pf=$postfix; } | |
dfeab068 | 687 | if ($_ =~ /BN_ASM/) { $t="$_ "; } |
58964a49 RE |
688 | elsif ($_ =~ /DES_ENC/) { $t="$_ "; } |
689 | elsif ($_ =~ /BF_ENC/) { $t="$_ "; } | |
690 | elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } | |
691 | elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } | |
692 | elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } | |
693 | elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } | |
694 | elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } | |
695 | elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } | |
696 | else { $t="$location${o}$_$pf "; } | |
d02b48c6 RE |
697 | |
698 | $Vars{$var}.="$t "; | |
699 | $ret.=$t; | |
700 | } | |
701 | chop($ret); | |
702 | $ret.="\n\n"; | |
703 | return($ret); | |
704 | } | |
705 | ||
706 | # return the name with the leading path removed | |
707 | sub bname | |
708 | { | |
709 | local($ret)=@_; | |
710 | $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; | |
711 | return($ret); | |
712 | } | |
713 | ||
d02b48c6 RE |
714 | |
715 | ############################################################## | |
716 | # do a rule for each file that says 'compile' to new direcory | |
717 | # compile the files in '$files' into $to | |
718 | sub do_compile_rule | |
719 | { | |
720 | local($to,$files,$ex)=@_; | |
721 | local($ret,$_,$n); | |
722 | ||
723 | $files =~ s/\//$o/g if $o ne '/'; | |
724 | foreach (split(/\s+/,$files)) | |
725 | { | |
726 | $n=&bname($_); | |
727 | $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) | |
728 | } | |
729 | return($ret); | |
730 | } | |
731 | ||
732 | ############################################################## | |
733 | # do a rule for each file that says 'compile' to new direcory | |
734 | sub cc_compile_target | |
735 | { | |
736 | local($target,$source,$ex_flags)=@_; | |
737 | local($ret); | |
738 | ||
739 | # EAY EAY | |
dfeab068 | 740 | $ex_flags.=' -DCFLAGS="\"$(CC) $(CFLAG)\"" -DPLATFORM="\"$(PLATFORM)\""' if ($source =~ /cversion/); |
d02b48c6 RE |
741 | $target =~ s/\//$o/g if $o ne "/"; |
742 | $source =~ s/\//$o/g if $o ne "/"; | |
743 | $ret ="$target: \$(SRC_D)$o$source\n\t"; | |
744 | $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; | |
745 | return($ret); | |
746 | } | |
747 | ||
748 | ############################################################## | |
749 | sub do_asm_rule | |
750 | { | |
751 | local($target,$src)=@_; | |
752 | local($ret,@s,@t,$i); | |
753 | ||
754 | $target =~ s/\//$o/g if $o ne "/"; | |
755 | $src =~ s/\//$o/g if $o ne "/"; | |
756 | ||
757 | @s=split(/\s+/,$src); | |
758 | @t=split(/\s+/,$target); | |
759 | ||
760 | for ($i=0; $i<=$#s; $i++) | |
761 | { | |
762 | $ret.="$t[$i]: $s[$i]\n"; | |
763 | $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; | |
764 | } | |
765 | return($ret); | |
766 | } | |
767 | ||
768 | sub do_shlib_rule | |
769 | { | |
770 | local($n,$def)=@_; | |
771 | local($ret,$nn); | |
772 | local($t); | |
773 | ||
774 | ($nn=$n) =~ tr/a-z/A-Z/; | |
775 | $ret.="$n.dll: \$(${nn}OBJ)\n"; | |
776 | if ($vc && $w32) | |
777 | { | |
778 | $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; | |
779 | } | |
780 | $ret.="\n"; | |
781 | return($ret); | |
782 | } | |
783 | ||
dfeab068 RE |
784 | # do a rule for each file that says 'copy' to new direcory on change |
785 | sub do_copy_rule | |
786 | { | |
787 | local($to,$files,$p)=@_; | |
788 | local($ret,$_,$n,$pp); | |
789 | ||
790 | $files =~ s/\//$o/g if $o ne '/'; | |
791 | foreach (split(/\s+/,$files)) | |
792 | { | |
793 | $n=&bname($_); | |
794 | if ($n =~ /bss_file/) | |
795 | { $pp=".c"; } | |
796 | else { $pp=$p; } | |
797 | $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n"; | |
798 | } | |
799 | return($ret); | |
800 | } |