diff options
Diffstat (limited to 'src/lib/libcrypto/util/mk1mf.pl')
-rw-r--r-- | src/lib/libcrypto/util/mk1mf.pl | 1146 |
1 files changed, 1146 insertions, 0 deletions
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl new file mode 100644 index 0000000000..780029a03f --- /dev/null +++ b/src/lib/libcrypto/util/mk1mf.pl | |||
@@ -0,0 +1,1146 @@ | |||
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 | $OPENSSLDIR="/usr/local/ssl"; | ||
10 | $OPTIONS=""; | ||
11 | $ssl_version=""; | ||
12 | $banner="\t\@echo Building OpenSSL"; | ||
13 | |||
14 | my $no_static_engine = 1; | ||
15 | my $engines = ""; | ||
16 | local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic | ||
17 | local $zlib_lib = ""; | ||
18 | local $perl_asm = 0; # 1 to autobuild asm files from perl scripts | ||
19 | |||
20 | # Options to import from top level Makefile | ||
21 | |||
22 | my %mf_import = ( | ||
23 | VERSION => \$ssl_version, | ||
24 | OPTIONS => \$OPTIONS, | ||
25 | INSTALLTOP => \$INSTALLTOP, | ||
26 | OPENSSLDIR => \$OPENSSLDIR, | ||
27 | PLATFORM => \$mf_platform, | ||
28 | CFLAG => \$mf_cflag, | ||
29 | DEPFLAG => \$mf_depflag, | ||
30 | CPUID_OBJ => \$mf_cpuid_asm, | ||
31 | BN_ASM => \$mf_bn_asm, | ||
32 | DES_ENC => \$mf_des_asm, | ||
33 | AES_ENC => \$mf_aes_asm, | ||
34 | BF_ENC => \$mf_bf_asm, | ||
35 | CAST_ENC => \$mf_cast_asm, | ||
36 | RC4_ENC => \$mf_rc4_asm, | ||
37 | RC5_ENC => \$mf_rc5_asm, | ||
38 | MD5_ASM_OBJ => \$mf_md5_asm, | ||
39 | SHA1_ASM_OBJ => \$mf_sha_asm, | ||
40 | RMD160_ASM_OBJ => \$mf_rmd_asm, | ||
41 | WP_ASM_OBJ => \$mf_wp_asm, | ||
42 | CMLL_ENC => \$mf_cm_asm | ||
43 | ); | ||
44 | |||
45 | |||
46 | open(IN,"<Makefile") || die "unable to open Makefile!\n"; | ||
47 | while(<IN>) { | ||
48 | my ($mf_opt, $mf_ref); | ||
49 | while (($mf_opt, $mf_ref) = each %mf_import) { | ||
50 | if (/^$mf_opt\s*=\s*(.*)$/) { | ||
51 | $$mf_ref = $1; | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | close(IN); | ||
56 | |||
57 | $debug = 1 if $mf_platform =~ /^debug-/; | ||
58 | |||
59 | die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; | ||
60 | |||
61 | $infile="MINFO"; | ||
62 | |||
63 | %ops=( | ||
64 | "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", | ||
65 | "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", | ||
66 | "VC-WIN64A", "Microsoft C/C++ - Win64/x64", | ||
67 | "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", | ||
68 | "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", | ||
69 | "Mingw32", "GNU C++ - Windows NT or 9x", | ||
70 | "Mingw32-files", "Create files with DOS copy ...", | ||
71 | "BC-NT", "Borland C++ 4.5 - Windows NT", | ||
72 | "linux-elf","Linux elf", | ||
73 | "ultrix-mips","DEC mips ultrix", | ||
74 | "FreeBSD","FreeBSD distribution", | ||
75 | "OS2-EMX", "EMX GCC OS/2", | ||
76 | "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", | ||
77 | "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets", | ||
78 | "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", | ||
79 | "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", | ||
80 | "default","cc under unix", | ||
81 | "auto", "auto detect from top level Makefile" | ||
82 | ); | ||
83 | |||
84 | $platform=""; | ||
85 | my $xcflags=""; | ||
86 | foreach (@ARGV) | ||
87 | { | ||
88 | if (!&read_options && !defined($ops{$_})) | ||
89 | { | ||
90 | print STDERR "unknown option - $_\n"; | ||
91 | print STDERR "usage: perl mk1mf.pl [options] [system]\n"; | ||
92 | print STDERR "\nwhere [system] can be one of the following\n"; | ||
93 | foreach $i (sort keys %ops) | ||
94 | { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } | ||
95 | print STDERR <<"EOF"; | ||
96 | and [options] can be one of | ||
97 | no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest | ||
98 | no-ripemd | ||
99 | no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher | ||
100 | no-bf no-cast no-aes no-camellia no-seed | ||
101 | no-rsa no-dsa no-dh - Skip this public key cipher | ||
102 | no-ssl2 no-ssl3 - Skip this version of SSL | ||
103 | just-ssl - remove all non-ssl keys/digest | ||
104 | no-asm - No x86 asm | ||
105 | no-krb5 - No KRB5 | ||
106 | no-ec - No EC | ||
107 | no-ecdsa - No ECDSA | ||
108 | no-ecdh - No ECDH | ||
109 | no-engine - No engine | ||
110 | no-hw - No hw | ||
111 | nasm - Use NASM for x86 asm | ||
112 | nw-nasm - Use NASM x86 asm for NetWare | ||
113 | nw-mwasm - Use Metrowerks x86 asm for NetWare | ||
114 | gaswin - Use GNU as with Mingw32 | ||
115 | no-socks - No socket code | ||
116 | no-err - No error strings | ||
117 | dll/shlib - Build shared libraries (MS) | ||
118 | debug - Debug build | ||
119 | profile - Profiling build | ||
120 | gcc - Use Gcc (unix) | ||
121 | |||
122 | Values that can be set | ||
123 | TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler | ||
124 | |||
125 | -L<ex_lib_path> -l<ex_lib> - extra library flags (unix) | ||
126 | -<ex_cc_flags> - extra 'cc' flags, | ||
127 | added (MS), or replace (unix) | ||
128 | EOF | ||
129 | exit(1); | ||
130 | } | ||
131 | $platform=$_; | ||
132 | } | ||
133 | foreach (grep(!/^$/, split(/ /, $OPTIONS))) | ||
134 | { | ||
135 | print STDERR "unknown option - $_\n" if !&read_options; | ||
136 | } | ||
137 | |||
138 | $no_static_engine = 0 if (!$shlib); | ||
139 | |||
140 | $no_mdc2=1 if ($no_des); | ||
141 | |||
142 | $no_ssl3=1 if ($no_md5 || $no_sha); | ||
143 | $no_ssl3=1 if ($no_rsa && $no_dh); | ||
144 | |||
145 | $no_ssl2=1 if ($no_md5); | ||
146 | $no_ssl2=1 if ($no_rsa); | ||
147 | |||
148 | $out_def="out"; | ||
149 | $inc_def="outinc"; | ||
150 | $tmp_def="tmp"; | ||
151 | |||
152 | $perl="perl" unless defined $perl; | ||
153 | $mkdir="-mkdir" unless defined $mkdir; | ||
154 | |||
155 | ($ssl,$crypto)=("ssl","crypto"); | ||
156 | $ranlib="echo ranlib"; | ||
157 | |||
158 | $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; | ||
159 | $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; | ||
160 | $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; | ||
161 | |||
162 | # $bin_dir.=$o causes a core dump on my sparc :-( | ||
163 | |||
164 | |||
165 | $NT=0; | ||
166 | |||
167 | push(@INC,"util/pl","pl"); | ||
168 | |||
169 | if ($platform eq "auto") { | ||
170 | $platform = $mf_platform; | ||
171 | print STDERR "Imported platform $mf_platform\n"; | ||
172 | } | ||
173 | |||
174 | if (($platform =~ /VC-(.+)/)) | ||
175 | { | ||
176 | $FLAVOR=$1; | ||
177 | $NT = 1 if $1 eq "NT"; | ||
178 | require 'VC-32.pl'; | ||
179 | } | ||
180 | elsif ($platform eq "Mingw32") | ||
181 | { | ||
182 | require 'Mingw32.pl'; | ||
183 | } | ||
184 | elsif ($platform eq "Mingw32-files") | ||
185 | { | ||
186 | require 'Mingw32f.pl'; | ||
187 | } | ||
188 | elsif ($platform eq "BC-NT") | ||
189 | { | ||
190 | $bc=1; | ||
191 | require 'BC-32.pl'; | ||
192 | } | ||
193 | elsif ($platform eq "FreeBSD") | ||
194 | { | ||
195 | require 'unix.pl'; | ||
196 | $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; | ||
197 | } | ||
198 | elsif ($platform eq "linux-elf") | ||
199 | { | ||
200 | require "unix.pl"; | ||
201 | require "linux.pl"; | ||
202 | $unix=1; | ||
203 | } | ||
204 | elsif ($platform eq "ultrix-mips") | ||
205 | { | ||
206 | require "unix.pl"; | ||
207 | require "ultrix.pl"; | ||
208 | $unix=1; | ||
209 | } | ||
210 | elsif ($platform eq "OS2-EMX") | ||
211 | { | ||
212 | $wc=1; | ||
213 | require 'OS2-EMX.pl'; | ||
214 | } | ||
215 | elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || | ||
216 | ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock")) | ||
217 | { | ||
218 | $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; | ||
219 | $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock"); | ||
220 | require 'netware.pl'; | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | require "unix.pl"; | ||
225 | |||
226 | $unix=1; | ||
227 | $cflags.=' -DTERMIO'; | ||
228 | } | ||
229 | |||
230 | $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); | ||
231 | $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); | ||
232 | $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; | ||
233 | |||
234 | $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); | ||
235 | |||
236 | $cflags= "$xcflags$cflags" if $xcflags ne ""; | ||
237 | |||
238 | $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; | ||
239 | $cflags.=" -DOPENSSL_NO_AES" if $no_aes; | ||
240 | $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; | ||
241 | $cflags.=" -DOPENSSL_NO_SEED" if $no_seed; | ||
242 | $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; | ||
243 | $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; | ||
244 | $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; | ||
245 | $cflags.=" -DOPENSSL_NO_MD2" if $no_md2; | ||
246 | $cflags.=" -DOPENSSL_NO_MD4" if $no_md4; | ||
247 | $cflags.=" -DOPENSSL_NO_MD5" if $no_md5; | ||
248 | $cflags.=" -DOPENSSL_NO_SHA" if $no_sha; | ||
249 | $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; | ||
250 | $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; | ||
251 | $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; | ||
252 | $cflags.=" -DOPENSSL_NO_BF" if $no_bf; | ||
253 | $cflags.=" -DOPENSSL_NO_CAST" if $no_cast; | ||
254 | $cflags.=" -DOPENSSL_NO_DES" if $no_des; | ||
255 | $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; | ||
256 | $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; | ||
257 | $cflags.=" -DOPENSSL_NO_DH" if $no_dh; | ||
258 | $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool; | ||
259 | $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; | ||
260 | $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; | ||
261 | $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; | ||
262 | $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; | ||
263 | $cflags.=" -DOPENSSL_NO_CMS" if $no_cms; | ||
264 | $cflags.=" -DOPENSSL_NO_ERR" if $no_err; | ||
265 | $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; | ||
266 | $cflags.=" -DOPENSSL_NO_EC" if $no_ec; | ||
267 | $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; | ||
268 | $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; | ||
269 | $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; | ||
270 | $cflags.=" -DOPENSSL_NO_HW" if $no_hw; | ||
271 | $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake; | ||
272 | $cflags.= " -DZLIB" if $zlib_opt; | ||
273 | $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; | ||
274 | |||
275 | if ($no_static_engine) | ||
276 | { | ||
277 | $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; | ||
282 | } | ||
283 | |||
284 | #$cflags.=" -DRSAref" if $rsaref ne ""; | ||
285 | |||
286 | ## if ($unix) | ||
287 | ## { $cflags="$c_flags" if ($c_flags ne ""); } | ||
288 | ##else | ||
289 | { $cflags="$c_flags$cflags" if ($c_flags ne ""); } | ||
290 | |||
291 | $ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); | ||
292 | |||
293 | |||
294 | %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", | ||
295 | "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); | ||
296 | |||
297 | if ($msdos) | ||
298 | { | ||
299 | $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; | ||
300 | $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; | ||
301 | $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; | ||
302 | $banner.="\t\@echo documentation for details.\n"; | ||
303 | } | ||
304 | |||
305 | # have to do this to allow $(CC) under unix | ||
306 | $link="$bin_dir$link" if ($link !~ /^\$/); | ||
307 | |||
308 | $INSTALLTOP =~ s|/|$o|g; | ||
309 | $OPENSSLDIR =~ s|/|$o|g; | ||
310 | |||
311 | ############################################# | ||
312 | # We parse in input file and 'store' info for later printing. | ||
313 | open(IN,"<$infile") || die "unable to open $infile:$!\n"; | ||
314 | $_=<IN>; | ||
315 | for (;;) | ||
316 | { | ||
317 | chop; | ||
318 | |||
319 | ($key,$val)=/^([^=]+)=(.*)/; | ||
320 | if ($key eq "RELATIVE_DIRECTORY") | ||
321 | { | ||
322 | if ($lib ne "") | ||
323 | { | ||
324 | $uc=$lib; | ||
325 | $uc =~ s/^lib(.*)\.a/$1/; | ||
326 | $uc =~ tr/a-z/A-Z/; | ||
327 | $lib_nam{$uc}=$uc; | ||
328 | $lib_obj{$uc}.=$libobj." "; | ||
329 | } | ||
330 | last if ($val eq "FINISHED"); | ||
331 | $lib=""; | ||
332 | $libobj=""; | ||
333 | $dir=$val; | ||
334 | } | ||
335 | |||
336 | if ($key eq "KRB5_INCLUDES") | ||
337 | { $cflags .= " $val";} | ||
338 | |||
339 | if ($key eq "ZLIB_INCLUDE") | ||
340 | { $cflags .= " $val" if $val ne "";} | ||
341 | |||
342 | if ($key eq "LIBZLIB") | ||
343 | { $zlib_lib = "$val" if $val ne "";} | ||
344 | |||
345 | if ($key eq "LIBKRB5") | ||
346 | { $ex_libs .= " $val" if $val ne "";} | ||
347 | |||
348 | if ($key eq "TEST") | ||
349 | { $test.=&var_add($dir,$val, 0); } | ||
350 | |||
351 | if (($key eq "PROGS") || ($key eq "E_OBJ")) | ||
352 | { $e_exe.=&var_add($dir,$val, 0); } | ||
353 | |||
354 | if ($key eq "LIB") | ||
355 | { | ||
356 | $lib=$val; | ||
357 | $lib =~ s/^.*\/([^\/]+)$/$1/; | ||
358 | } | ||
359 | |||
360 | if ($key eq "EXHEADER") | ||
361 | { $exheader.=&var_add($dir,$val, 1); } | ||
362 | |||
363 | if ($key eq "HEADER") | ||
364 | { $header.=&var_add($dir,$val, 1); } | ||
365 | |||
366 | if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) | ||
367 | { $libobj=&var_add($dir,$val, 0); } | ||
368 | if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) | ||
369 | { $engines.=$val } | ||
370 | |||
371 | if (!($_=<IN>)) | ||
372 | { $_="RELATIVE_DIRECTORY=FINISHED\n"; } | ||
373 | } | ||
374 | close(IN); | ||
375 | |||
376 | if ($shlib) | ||
377 | { | ||
378 | $extra_install= <<"EOF"; | ||
379 | \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\" | ||
380 | \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\" | ||
381 | \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\" | ||
382 | \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" | ||
383 | EOF | ||
384 | if ($no_static_engine) | ||
385 | { | ||
386 | $extra_install .= <<"EOF" | ||
387 | \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" | ||
388 | \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" | ||
389 | EOF | ||
390 | } | ||
391 | } | ||
392 | else | ||
393 | { | ||
394 | $extra_install= <<"EOF"; | ||
395 | \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\" | ||
396 | \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" | ||
397 | EOF | ||
398 | $ex_libs .= " $zlib_lib" if $zlib_opt == 1; | ||
399 | } | ||
400 | |||
401 | $defs= <<"EOF"; | ||
402 | # This makefile has been automatically generated from the OpenSSL distribution. | ||
403 | # This single makefile will build the complete OpenSSL distribution and | ||
404 | # by default leave the 'intertesting' output files in .${o}out and the stuff | ||
405 | # that needs deleting in .${o}tmp. | ||
406 | # The file was generated by running 'make makefile.one', which | ||
407 | # does a 'make files', which writes all the environment variables from all | ||
408 | # the makefiles to the file call MINFO. This file is used by | ||
409 | # util${o}mk1mf.pl to generate makefile.one. | ||
410 | # The 'makefile per directory' system suites me when developing this | ||
411 | # library and also so I can 'distribute' indervidual library sections. | ||
412 | # The one monster makefile better suits building in non-unix | ||
413 | # environments. | ||
414 | |||
415 | EOF | ||
416 | |||
417 | $defs .= $preamble if defined $preamble; | ||
418 | |||
419 | $defs.= <<"EOF"; | ||
420 | INSTALLTOP=$INSTALLTOP | ||
421 | OPENSSLDIR=$OPENSSLDIR | ||
422 | |||
423 | # Set your compiler options | ||
424 | PLATFORM=$platform | ||
425 | CC=$bin_dir${cc} | ||
426 | CFLAG=$cflags | ||
427 | APP_CFLAG=$app_cflag | ||
428 | LIB_CFLAG=$lib_cflag | ||
429 | SHLIB_CFLAG=$shl_cflag | ||
430 | APP_EX_OBJ=$app_ex_obj | ||
431 | SHLIB_EX_OBJ=$shlib_ex_obj | ||
432 | # add extra libraries to this define, for solaris -lsocket -lnsl would | ||
433 | # be added | ||
434 | EX_LIBS=$ex_libs | ||
435 | |||
436 | # The OpenSSL directory | ||
437 | SRC_D=$src_dir | ||
438 | |||
439 | LINK=$link | ||
440 | LFLAGS=$lflags | ||
441 | RSC=$rsc | ||
442 | |||
443 | # The output directory for everything intersting | ||
444 | OUT_D=$out_dir | ||
445 | # The output directory for all the temporary muck | ||
446 | TMP_D=$tmp_dir | ||
447 | # The output directory for the header files | ||
448 | INC_D=$inc_dir | ||
449 | INCO_D=$inc_dir${o}openssl | ||
450 | |||
451 | PERL=$perl | ||
452 | CP=$cp | ||
453 | RM=$rm | ||
454 | RANLIB=$ranlib | ||
455 | MKDIR=$mkdir | ||
456 | MKLIB=$bin_dir$mklib | ||
457 | MLFLAGS=$mlflags | ||
458 | ASM=$bin_dir$asm | ||
459 | |||
460 | ###################################################### | ||
461 | # You should not need to touch anything below this point | ||
462 | ###################################################### | ||
463 | |||
464 | E_EXE=openssl | ||
465 | SSL=$ssl | ||
466 | CRYPTO=$crypto | ||
467 | |||
468 | # BIN_D - Binary output directory | ||
469 | # TEST_D - Binary test file output directory | ||
470 | # LIB_D - library output directory | ||
471 | # ENG_D - dynamic engine output directory | ||
472 | # Note: if you change these point to different directories then uncomment out | ||
473 | # the lines around the 'NB' comment below. | ||
474 | # | ||
475 | BIN_D=\$(OUT_D) | ||
476 | TEST_D=\$(OUT_D) | ||
477 | LIB_D=\$(OUT_D) | ||
478 | ENG_D=\$(OUT_D) | ||
479 | |||
480 | # INCL_D - local library directory | ||
481 | # OBJ_D - temp object file directory | ||
482 | OBJ_D=\$(TMP_D) | ||
483 | INCL_D=\$(TMP_D) | ||
484 | |||
485 | O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp | ||
486 | O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp | ||
487 | SO_SSL= $plib\$(SSL)$so_shlibp | ||
488 | SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp | ||
489 | L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp | ||
490 | L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp | ||
491 | |||
492 | L_LIBS= \$(L_SSL) \$(L_CRYPTO) | ||
493 | |||
494 | ###################################################### | ||
495 | # Don't touch anything below this point | ||
496 | ###################################################### | ||
497 | |||
498 | INC=-I\$(INC_D) -I\$(INCL_D) | ||
499 | APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) | ||
500 | LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) | ||
501 | SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) | ||
502 | LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) | ||
503 | |||
504 | ############################################# | ||
505 | EOF | ||
506 | |||
507 | $rules=<<"EOF"; | ||
508 | all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe | ||
509 | |||
510 | banner: | ||
511 | $banner | ||
512 | |||
513 | \$(TMP_D): | ||
514 | \$(MKDIR) \"\$(TMP_D)\" | ||
515 | # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different | ||
516 | #\$(BIN_D): | ||
517 | # \$(MKDIR) \$(BIN_D) | ||
518 | # | ||
519 | #\$(TEST_D): | ||
520 | # \$(MKDIR) \$(TEST_D) | ||
521 | |||
522 | \$(LIB_D): | ||
523 | \$(MKDIR) \"\$(LIB_D)\" | ||
524 | |||
525 | \$(INCO_D): \$(INC_D) | ||
526 | \$(MKDIR) \"\$(INCO_D)\" | ||
527 | |||
528 | \$(INC_D): | ||
529 | \$(MKDIR) \"\$(INC_D)\" | ||
530 | |||
531 | headers: \$(HEADER) \$(EXHEADER) | ||
532 | @ | ||
533 | |||
534 | lib: \$(LIBS_DEP) \$(E_SHLIB) | ||
535 | |||
536 | exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep | ||
537 | |||
538 | install: all | ||
539 | \$(MKDIR) \"\$(INSTALLTOP)\" | ||
540 | \$(MKDIR) \"\$(INSTALLTOP)${o}bin\" | ||
541 | \$(MKDIR) \"\$(INSTALLTOP)${o}include\" | ||
542 | \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" | ||
543 | \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" | ||
544 | \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" | ||
545 | \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\" | ||
546 | \$(MKDIR) \"\$(OPENSSLDIR)\" | ||
547 | \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\" | ||
548 | $extra_install | ||
549 | |||
550 | |||
551 | test: \$(T_EXE) | ||
552 | cd \$(BIN_D) | ||
553 | ..${o}ms${o}test | ||
554 | |||
555 | clean: | ||
556 | \$(RM) \$(TMP_D)$o*.* | ||
557 | |||
558 | vclean: | ||
559 | \$(RM) \$(TMP_D)$o*.* | ||
560 | \$(RM) \$(OUT_D)$o*.* | ||
561 | |||
562 | EOF | ||
563 | |||
564 | my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; | ||
565 | $platform_cpp_symbol =~ s/-/_/g; | ||
566 | if (open(IN,"crypto/buildinf.h")) | ||
567 | { | ||
568 | # Remove entry for this platform in existing file buildinf.h. | ||
569 | |||
570 | my $old_buildinf_h = ""; | ||
571 | while (<IN>) | ||
572 | { | ||
573 | if (/^\#ifdef $platform_cpp_symbol$/) | ||
574 | { | ||
575 | while (<IN>) { last if (/^\#endif/); } | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | $old_buildinf_h .= $_; | ||
580 | } | ||
581 | } | ||
582 | close(IN); | ||
583 | |||
584 | open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; | ||
585 | print OUT $old_buildinf_h; | ||
586 | close(OUT); | ||
587 | } | ||
588 | |||
589 | open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; | ||
590 | printf OUT <<EOF; | ||
591 | #ifdef $platform_cpp_symbol | ||
592 | /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ | ||
593 | #define CFLAGS "$cc $cflags" | ||
594 | #define PLATFORM "$platform" | ||
595 | EOF | ||
596 | printf OUT " #define DATE \"%s\"\n", scalar gmtime(); | ||
597 | printf OUT "#endif\n"; | ||
598 | close(OUT); | ||
599 | |||
600 | # Strip of trailing ' ' | ||
601 | foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } | ||
602 | $test=&clean_up_ws($test); | ||
603 | $e_exe=&clean_up_ws($e_exe); | ||
604 | $exheader=&clean_up_ws($exheader); | ||
605 | $header=&clean_up_ws($header); | ||
606 | |||
607 | # First we strip the exheaders from the headers list | ||
608 | foreach (split(/\s+/,$exheader)){ $h{$_}=1; } | ||
609 | foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } | ||
610 | chop($h); $header=$h; | ||
611 | |||
612 | $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); | ||
613 | $rules.=&do_copy_rule("\$(INCL_D)",$header,""); | ||
614 | |||
615 | $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); | ||
616 | $rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); | ||
617 | |||
618 | $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); | ||
619 | $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); | ||
620 | |||
621 | $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); | ||
622 | $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); | ||
623 | |||
624 | foreach (values %lib_nam) | ||
625 | { | ||
626 | $lib_obj=$lib_obj{$_}; | ||
627 | local($slib)=$shlib; | ||
628 | |||
629 | if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) | ||
630 | { | ||
631 | $rules.="\$(O_SSL):\n\n"; | ||
632 | next; | ||
633 | } | ||
634 | |||
635 | $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); | ||
636 | $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; | ||
637 | $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); | ||
638 | } | ||
639 | |||
640 | # hack to add version info on MSVC | ||
641 | if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A") | ||
642 | || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) { | ||
643 | $rules.= <<"EOF"; | ||
644 | \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc | ||
645 | \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc | ||
646 | |||
647 | \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc | ||
648 | \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc | ||
649 | |||
650 | EOF | ||
651 | } | ||
652 | |||
653 | $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); | ||
654 | foreach (split(/\s+/,$test)) | ||
655 | { | ||
656 | $t=&bname($_); | ||
657 | $tt="\$(OBJ_D)${o}$t${obj}"; | ||
658 | $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | ||
659 | } | ||
660 | |||
661 | $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); | ||
662 | |||
663 | foreach (split(/\s+/,$engines)) | ||
664 | { | ||
665 | $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); | ||
666 | $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); | ||
667 | } | ||
668 | |||
669 | |||
670 | |||
671 | $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); | ||
672 | $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); | ||
673 | |||
674 | $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | ||
675 | |||
676 | print $defs; | ||
677 | |||
678 | if ($platform eq "linux-elf") { | ||
679 | print <<"EOF"; | ||
680 | # Generate perlasm output files | ||
681 | %.cpp: | ||
682 | (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) | ||
683 | EOF | ||
684 | } | ||
685 | print "###################################################################\n"; | ||
686 | print $rules; | ||
687 | |||
688 | ############################################### | ||
689 | # strip off any trailing .[och] and append the relative directory | ||
690 | # also remembering to do nothing if we are in one of the dropped | ||
691 | # directories | ||
692 | sub var_add | ||
693 | { | ||
694 | local($dir,$val,$keepext)=@_; | ||
695 | local(@a,$_,$ret); | ||
696 | |||
697 | return("") if $no_engine && $dir =~ /\/engine/; | ||
698 | return("") if $no_hw && $dir =~ /\/hw/; | ||
699 | return("") if $no_idea && $dir =~ /\/idea/; | ||
700 | return("") if $no_aes && $dir =~ /\/aes/; | ||
701 | return("") if $no_camellia && $dir =~ /\/camellia/; | ||
702 | return("") if $no_seed && $dir =~ /\/seed/; | ||
703 | return("") if $no_rc2 && $dir =~ /\/rc2/; | ||
704 | return("") if $no_rc4 && $dir =~ /\/rc4/; | ||
705 | return("") if $no_rc5 && $dir =~ /\/rc5/; | ||
706 | return("") if $no_rsa && $dir =~ /\/rsa/; | ||
707 | return("") if $no_rsa && $dir =~ /^rsaref/; | ||
708 | return("") if $no_dsa && $dir =~ /\/dsa/; | ||
709 | return("") if $no_dh && $dir =~ /\/dh/; | ||
710 | return("") if $no_ec && $dir =~ /\/ec/; | ||
711 | return("") if $no_cms && $dir =~ /\/cms/; | ||
712 | return("") if $no_jpake && $dir =~ /\/jpake/; | ||
713 | if ($no_des && $dir =~ /\/des/) | ||
714 | { | ||
715 | if ($val =~ /read_pwd/) | ||
716 | { return("$dir/read_pwd "); } | ||
717 | else | ||
718 | { return(""); } | ||
719 | } | ||
720 | return("") if $no_mdc2 && $dir =~ /\/mdc2/; | ||
721 | return("") if $no_sock && $dir =~ /\/proxy/; | ||
722 | return("") if $no_bf && $dir =~ /\/bf/; | ||
723 | return("") if $no_cast && $dir =~ /\/cast/; | ||
724 | return("") if $no_whirlpool && $dir =~ /\/whrlpool/; | ||
725 | |||
726 | $val =~ s/^\s*(.*)\s*$/$1/; | ||
727 | @a=split(/\s+/,$val); | ||
728 | grep(s/\.[och]$//,@a) unless $keepext; | ||
729 | |||
730 | @a=grep(!/^e_.*_3d$/,@a) if $no_des; | ||
731 | @a=grep(!/^e_.*_d$/,@a) if $no_des; | ||
732 | @a=grep(!/^e_.*_ae$/,@a) if $no_idea; | ||
733 | @a=grep(!/^e_.*_i$/,@a) if $no_aes; | ||
734 | @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; | ||
735 | @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; | ||
736 | @a=grep(!/^e_.*_bf$/,@a) if $no_bf; | ||
737 | @a=grep(!/^e_.*_c$/,@a) if $no_cast; | ||
738 | @a=grep(!/^e_rc4$/,@a) if $no_rc4; | ||
739 | @a=grep(!/^e_camellia$/,@a) if $no_camellia; | ||
740 | @a=grep(!/^e_seed$/,@a) if $no_seed; | ||
741 | |||
742 | #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; | ||
743 | #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; | ||
744 | |||
745 | @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; | ||
746 | |||
747 | @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; | ||
748 | @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; | ||
749 | @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; | ||
750 | @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; | ||
751 | |||
752 | @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; | ||
753 | @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; | ||
754 | @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; | ||
755 | |||
756 | @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; | ||
757 | @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; | ||
758 | |||
759 | @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; | ||
760 | |||
761 | @a=grep(!/_dhp$/,@a) if $no_dh; | ||
762 | |||
763 | @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; | ||
764 | @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | ||
765 | @a=grep(!/_mdc2$/,@a) if $no_mdc2; | ||
766 | |||
767 | @a=grep(!/^engine$/,@a) if $no_engine; | ||
768 | @a=grep(!/^hw$/,@a) if $no_hw; | ||
769 | @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; | ||
770 | @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; | ||
771 | @a=grep(!/^gendsa$/,@a) if $no_sha1; | ||
772 | @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; | ||
773 | |||
774 | @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | ||
775 | |||
776 | grep($_="$dir/$_",@a); | ||
777 | @a=grep(!/(^|\/)s_/,@a) if $no_sock; | ||
778 | @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; | ||
779 | $ret=join(' ',@a)." "; | ||
780 | return($ret); | ||
781 | } | ||
782 | |||
783 | # change things so that each 'token' is only separated by one space | ||
784 | sub clean_up_ws | ||
785 | { | ||
786 | local($w)=@_; | ||
787 | |||
788 | $w =~ s/^\s*(.*)\s*$/$1/; | ||
789 | $w =~ s/\s+/ /g; | ||
790 | return($w); | ||
791 | } | ||
792 | |||
793 | sub do_defs | ||
794 | { | ||
795 | local($var,$files,$location,$postfix)=@_; | ||
796 | local($_,$ret,$pf); | ||
797 | local(*OUT,$tmp,$t); | ||
798 | |||
799 | $files =~ s/\//$o/g if $o ne '/'; | ||
800 | $ret="$var="; | ||
801 | $n=1; | ||
802 | $Vars{$var}.=""; | ||
803 | foreach (split(/ /,$files)) | ||
804 | { | ||
805 | $orig=$_; | ||
806 | $_=&bname($_) unless /^\$/; | ||
807 | if ($n++ == 2) | ||
808 | { | ||
809 | $n=0; | ||
810 | $ret.="\\\n\t"; | ||
811 | } | ||
812 | if (($_ =~ /bss_file/) && ($postfix eq ".h")) | ||
813 | { $pf=".c"; } | ||
814 | else { $pf=$postfix; } | ||
815 | if ($_ =~ /BN_ASM/) { $t="$_ "; } | ||
816 | elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } | ||
817 | elsif ($_ =~ /AES_ASM/){ $t="$_ "; } | ||
818 | elsif ($_ =~ /DES_ENC/) { $t="$_ "; } | ||
819 | elsif ($_ =~ /BF_ENC/) { $t="$_ "; } | ||
820 | elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } | ||
821 | elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } | ||
822 | elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } | ||
823 | elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } | ||
824 | elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } | ||
825 | elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } | ||
826 | elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; } | ||
827 | elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } | ||
828 | else { $t="$location${o}$_$pf "; } | ||
829 | |||
830 | $Vars{$var}.="$t "; | ||
831 | $ret.=$t; | ||
832 | } | ||
833 | # hack to add version info on MSVC | ||
834 | if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT"))) | ||
835 | { | ||
836 | if ($var eq "CRYPTOOBJ") | ||
837 | { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } | ||
838 | elsif ($var eq "SSLOBJ") | ||
839 | { $ret.="\$(OBJ_D)\\\$(SSL).res "; } | ||
840 | } | ||
841 | chomp($ret); | ||
842 | $ret.="\n\n"; | ||
843 | return($ret); | ||
844 | } | ||
845 | |||
846 | # return the name with the leading path removed | ||
847 | sub bname | ||
848 | { | ||
849 | local($ret)=@_; | ||
850 | $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; | ||
851 | return($ret); | ||
852 | } | ||
853 | |||
854 | # return the leading path | ||
855 | sub dname | ||
856 | { | ||
857 | my $ret=shift; | ||
858 | $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/; | ||
859 | return($ret); | ||
860 | } | ||
861 | |||
862 | ############################################################## | ||
863 | # do a rule for each file that says 'compile' to new direcory | ||
864 | # compile the files in '$files' into $to | ||
865 | sub do_compile_rule | ||
866 | { | ||
867 | local($to,$files,$ex)=@_; | ||
868 | local($ret,$_,$n,$d,$s); | ||
869 | |||
870 | $files =~ s/\//$o/g if $o ne '/'; | ||
871 | foreach (split(/\s+/,$files)) | ||
872 | { | ||
873 | $n=&bname($_); | ||
874 | $d=&dname($_); | ||
875 | if (-f "${_}.c") | ||
876 | { | ||
877 | $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) | ||
878 | } | ||
879 | elsif (-f ($s="${d}${o}asm${o}${n}.pl") or | ||
880 | ($s=~s/sha256/sha512/ and -f $s) or | ||
881 | -f ($s="${d}${o}${n}.pl")) | ||
882 | { | ||
883 | $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n); | ||
884 | } | ||
885 | elsif (-f ($s="${d}${o}asm${o}${n}.S") or | ||
886 | -f ($s="${d}${o}${n}.S")) | ||
887 | { | ||
888 | $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n); | ||
889 | } | ||
890 | else { die "no rule for $_"; } | ||
891 | } | ||
892 | return($ret); | ||
893 | } | ||
894 | |||
895 | ############################################################## | ||
896 | # do a rule for each file that says 'compile' to new direcory | ||
897 | sub perlasm_compile_target | ||
898 | { | ||
899 | my($target,$source,$bname)=@_; | ||
900 | my($ret); | ||
901 | |||
902 | $bname =~ s/(.*)\.[^\.]$/$1/; | ||
903 | $ret ="\$(TMP_D)$o$bname.asm: $source\n"; | ||
904 | $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n"; | ||
905 | $ret.="$target: \$(TMP_D)$o$bname.asm\n"; | ||
906 | $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; | ||
907 | return($ret); | ||
908 | } | ||
909 | |||
910 | sub Sasm_compile_target | ||
911 | { | ||
912 | my($target,$source,$bname)=@_; | ||
913 | my($ret); | ||
914 | |||
915 | $bname =~ s/(.*)\.[^\.]$/$1/; | ||
916 | $ret ="\$(TMP_D)$o$bname.asm: $source\n"; | ||
917 | $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n"; | ||
918 | $ret.="$target: \$(TMP_D)$o$bname.asm\n"; | ||
919 | $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; | ||
920 | return($ret); | ||
921 | } | ||
922 | |||
923 | sub cc_compile_target | ||
924 | { | ||
925 | local($target,$source,$ex_flags)=@_; | ||
926 | local($ret); | ||
927 | |||
928 | $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); | ||
929 | $target =~ s/\//$o/g if $o ne "/"; | ||
930 | $source =~ s/\//$o/g if $o ne "/"; | ||
931 | $ret ="$target: \$(SRC_D)$o$source\n\t"; | ||
932 | $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; | ||
933 | return($ret); | ||
934 | } | ||
935 | |||
936 | ############################################################## | ||
937 | sub do_asm_rule | ||
938 | { | ||
939 | local($target,$src)=@_; | ||
940 | local($ret,@s,@t,$i); | ||
941 | |||
942 | $target =~ s/\//$o/g if $o ne "/"; | ||
943 | $src =~ s/\//$o/g if $o ne "/"; | ||
944 | |||
945 | @t=split(/\s+/,$target); | ||
946 | @s=split(/\s+/,$src); | ||
947 | |||
948 | |||
949 | for ($i=0; $i<=$#s; $i++) | ||
950 | { | ||
951 | my $objfile = $t[$i]; | ||
952 | my $srcfile = $s[$i]; | ||
953 | |||
954 | if ($perl_asm == 1) | ||
955 | { | ||
956 | my $plasm = $objfile; | ||
957 | $plasm =~ s/${obj}/.pl/; | ||
958 | $ret.="$srcfile: $plasm\n"; | ||
959 | $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n"; | ||
960 | } | ||
961 | |||
962 | $ret.="$objfile: $srcfile\n"; | ||
963 | $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n"; | ||
964 | } | ||
965 | return($ret); | ||
966 | } | ||
967 | |||
968 | sub do_shlib_rule | ||
969 | { | ||
970 | local($n,$def)=@_; | ||
971 | local($ret,$nn); | ||
972 | local($t); | ||
973 | |||
974 | ($nn=$n) =~ tr/a-z/A-Z/; | ||
975 | $ret.="$n.dll: \$(${nn}OBJ)\n"; | ||
976 | if ($vc && $w32) | ||
977 | { | ||
978 | $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; | ||
979 | } | ||
980 | $ret.="\n"; | ||
981 | return($ret); | ||
982 | } | ||
983 | |||
984 | # do a rule for each file that says 'copy' to new direcory on change | ||
985 | sub do_copy_rule | ||
986 | { | ||
987 | local($to,$files,$p)=@_; | ||
988 | local($ret,$_,$n,$pp); | ||
989 | |||
990 | $files =~ s/\//$o/g if $o ne '/'; | ||
991 | foreach (split(/\s+/,$files)) | ||
992 | { | ||
993 | $n=&bname($_); | ||
994 | if ($n =~ /bss_file/) | ||
995 | { $pp=".c"; } | ||
996 | else { $pp=$p; } | ||
997 | $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; | ||
998 | } | ||
999 | return($ret); | ||
1000 | } | ||
1001 | |||
1002 | sub read_options | ||
1003 | { | ||
1004 | # Many options are handled in a similar way. In particular | ||
1005 | # no-xxx sets zero or more scalars to 1. | ||
1006 | # Process these using a hash containing the option name and | ||
1007 | # reference to the scalars to set. | ||
1008 | |||
1009 | my %valid_options = ( | ||
1010 | "no-rc2" => \$no_rc2, | ||
1011 | "no-rc4" => \$no_rc4, | ||
1012 | "no-rc5" => \$no_rc5, | ||
1013 | "no-idea" => \$no_idea, | ||
1014 | "no-aes" => \$no_aes, | ||
1015 | "no-camellia" => \$no_camellia, | ||
1016 | "no-seed" => \$no_seed, | ||
1017 | "no-des" => \$no_des, | ||
1018 | "no-bf" => \$no_bf, | ||
1019 | "no-cast" => \$no_cast, | ||
1020 | "no-md2" => \$no_md2, | ||
1021 | "no-md4" => \$no_md4, | ||
1022 | "no-md5" => \$no_md5, | ||
1023 | "no-sha" => \$no_sha, | ||
1024 | "no-sha1" => \$no_sha1, | ||
1025 | "no-ripemd" => \$no_ripemd, | ||
1026 | "no-mdc2" => \$no_mdc2, | ||
1027 | "no-whirlpool" => \$no_whirlpool, | ||
1028 | "no-patents" => | ||
1029 | [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], | ||
1030 | "no-rsa" => \$no_rsa, | ||
1031 | "no-dsa" => \$no_dsa, | ||
1032 | "no-dh" => \$no_dh, | ||
1033 | "no-hmac" => \$no_hmac, | ||
1034 | "no-asm" => \$no_asm, | ||
1035 | "nasm" => \$nasm, | ||
1036 | "nw-nasm" => \$nw_nasm, | ||
1037 | "nw-mwasm" => \$nw_mwasm, | ||
1038 | "gaswin" => \$gaswin, | ||
1039 | "no-ssl2" => \$no_ssl2, | ||
1040 | "no-ssl3" => \$no_ssl3, | ||
1041 | "no-tlsext" => \$no_tlsext, | ||
1042 | "no-cms" => \$no_cms, | ||
1043 | "no-jpake" => \$no_jpake, | ||
1044 | "no-err" => \$no_err, | ||
1045 | "no-sock" => \$no_sock, | ||
1046 | "no-krb5" => \$no_krb5, | ||
1047 | "no-ec" => \$no_ec, | ||
1048 | "no-ecdsa" => \$no_ecdsa, | ||
1049 | "no-ecdh" => \$no_ecdh, | ||
1050 | "no-engine" => \$no_engine, | ||
1051 | "no-hw" => \$no_hw, | ||
1052 | "just-ssl" => | ||
1053 | [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, | ||
1054 | \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, | ||
1055 | \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, | ||
1056 | \$no_aes, \$no_camellia, \$no_seed], | ||
1057 | "rsaref" => 0, | ||
1058 | "gcc" => \$gcc, | ||
1059 | "debug" => \$debug, | ||
1060 | "profile" => \$profile, | ||
1061 | "shlib" => \$shlib, | ||
1062 | "dll" => \$shlib, | ||
1063 | "shared" => 0, | ||
1064 | "no-gmp" => 0, | ||
1065 | "no-rfc3779" => 0, | ||
1066 | "no-montasm" => 0, | ||
1067 | "no-shared" => 0, | ||
1068 | "no-store" => 0, | ||
1069 | "no-zlib" => 0, | ||
1070 | "no-zlib-dynamic" => 0, | ||
1071 | ); | ||
1072 | |||
1073 | if (exists $valid_options{$_}) | ||
1074 | { | ||
1075 | my $r = $valid_options{$_}; | ||
1076 | if ( ref $r eq "SCALAR") | ||
1077 | { $$r = 1;} | ||
1078 | elsif ( ref $r eq "ARRAY") | ||
1079 | { | ||
1080 | my $r2; | ||
1081 | foreach $r2 (@$r) | ||
1082 | { | ||
1083 | $$r2 = 1; | ||
1084 | } | ||
1085 | } | ||
1086 | } | ||
1087 | elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } | ||
1088 | elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } | ||
1089 | elsif (/^enable-zlib-dynamic$/) | ||
1090 | { | ||
1091 | $zlib_opt = 2; | ||
1092 | } | ||
1093 | elsif (/^no-static-engine/) | ||
1094 | { | ||
1095 | $no_static_engine = 1; | ||
1096 | } | ||
1097 | elsif (/^enable-static-engine/) | ||
1098 | { | ||
1099 | $no_static_engine = 0; | ||
1100 | } | ||
1101 | # There are also enable-xxx options which correspond to | ||
1102 | # the no-xxx. Since the scalars are enabled by default | ||
1103 | # these can be ignored. | ||
1104 | elsif (/^enable-/) | ||
1105 | { | ||
1106 | my $t = $_; | ||
1107 | $t =~ s/^enable/no/; | ||
1108 | if (exists $valid_options{$t}) | ||
1109 | {return 1;} | ||
1110 | return 0; | ||
1111 | } | ||
1112 | # experimental-xxx is mostly like enable-xxx, but opensslconf.v | ||
1113 | # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx. | ||
1114 | # (No need to fail if we don't know the algorithm -- this is for adventurous users only.) | ||
1115 | elsif (/^experimental-/) | ||
1116 | { | ||
1117 | my $algo, $ALGO; | ||
1118 | ($algo = $_) =~ s/^experimental-//; | ||
1119 | ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/; | ||
1120 | |||
1121 | $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags"; | ||
1122 | |||
1123 | } | ||
1124 | elsif (/^--with-krb5-flavor=(.*)$/) | ||
1125 | { | ||
1126 | my $krb5_flavor = $1; | ||
1127 | if ($krb5_flavor =~ /^force-[Hh]eimdal$/) | ||
1128 | { | ||
1129 | $xcflags="-DKRB5_HEIMDAL $xcflags"; | ||
1130 | } | ||
1131 | elsif ($krb5_flavor =~ /^MIT/i) | ||
1132 | { | ||
1133 | $xcflags="-DKRB5_MIT $xcflags"; | ||
1134 | if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) | ||
1135 | { | ||
1136 | $xcflags="-DKRB5_MIT_OLD11 $xcflags" | ||
1137 | } | ||
1138 | } | ||
1139 | } | ||
1140 | elsif (/^([^=]*)=(.*)$/ && !/^-D/){ $VARS{$1}=$2; } | ||
1141 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } | ||
1142 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) | ||
1143 | { $c_flags.="$_ "; } | ||
1144 | else { return(0); } | ||
1145 | return(1); | ||
1146 | } | ||