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
8 $INSTALLTOP="/usr/local/ssl";
9 $OPENSSLDIR="/usr/local/ssl";
12 $banner="\t\@echo Building OpenSSL";
14 my $no_static_engine = 1;
18 local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
20 local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
22 local $fips_canister_path = "";
23 my $fips_premain_dso_exe_path = "";
24 my $fips_premain_c_path = "";
25 my $fips_sha1_exe_path = "";
27 local $fipscanisterbuild = 0;
29 my $fipscanisteronly = 0;
36 my $build_targets = "lib exe";
37 my $libs_dep = "\$(O_CRYPTO) \$(O_SSL)";
39 # Options to import from top level Makefile
42 VERSION => \$ssl_version,
44 INSTALLTOP => \$INSTALLTOP,
45 OPENSSLDIR => \$OPENSSLDIR,
46 PLATFORM => \$mf_platform,
49 DEPFLAG => \$mf_depflag,
50 CPUID_OBJ => \$mf_cpuid_asm,
51 BN_ASM => \$mf_bn_asm,
52 DES_ENC => \$mf_des_asm,
53 AES_ENC => \$mf_aes_asm,
54 BF_ENC => \$mf_bf_asm,
55 CAST_ENC => \$mf_cast_asm,
56 RC4_ENC => \$mf_rc4_asm,
57 RC5_ENC => \$mf_rc5_asm,
58 MD5_ASM_OBJ => \$mf_md5_asm,
59 SHA1_ASM_OBJ => \$mf_sha_asm,
60 RMD160_ASM_OBJ => \$mf_rmd_asm,
61 WP_ASM_OBJ => \$mf_wp_asm,
62 CMLL_ENC => \$mf_cm_asm,
63 MODES_ASM_OBJ => \$mf_modes_asm,
64 ENGINES_ASM_OBJ=> \$mf_engines_asm,
65 FIPSCANISTERONLY => \$mf_fipscanisteronly,
66 FIPSCANISTERINTERNAL => \$mf_fipscanisterinternal
69 open(IN,"<Makefile") || die "unable to open Makefile!\n";
71 my ($mf_opt, $mf_ref);
72 while (($mf_opt, $mf_ref) = each %mf_import) {
73 if (/^$mf_opt\s*=\s*(.*)$/ && !defined($$mfref)) {
80 $debug = 1 if $mf_platform =~ /^debug-/;
82 if ($mf_fipscanisterinternal eq "y") {
84 $fipscanisterbuild = 1;
85 $fipscanisteronly = 1;
89 die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
94 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
95 "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
96 "VC-WIN64A", "Microsoft C/C++ - Win64/x64",
97 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
98 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
99 "Mingw32", "GNU C++ - Windows NT or 9x",
100 "Mingw32-files", "Create files with DOS copy ...",
101 "BC-NT", "Borland C++ 4.5 - Windows NT",
102 "linux-elf","Linux elf",
103 "ultrix-mips","DEC mips ultrix",
104 "FreeBSD","FreeBSD distribution",
105 "OS2-EMX", "EMX GCC OS/2",
106 "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
107 "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
108 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
109 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
110 "default","cc under unix",
111 "auto", "auto detect from top level Makefile",
112 "copy", "copy from top level Makefile"
119 if (!&read_options && !defined($ops{$_}))
121 print STDERR "unknown option - $_\n";
122 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
123 print STDERR "\nwhere [system] can be one of the following\n";
124 foreach $i (sort keys %ops)
125 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
126 print STDERR <<"EOF";
127 and [options] can be one of
128 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
130 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
131 no-bf no-cast no-aes no-camellia no-seed
132 no-rsa no-dsa no-dh - Skip this public key cipher
133 no-ssl2 no-ssl3 - Skip this version of SSL
134 just-ssl - remove all non-ssl keys/digest
141 no-engine - No engine
143 nasm - Use NASM for x86 asm
144 nw-nasm - Use NASM x86 asm for NetWare
145 nw-mwasm - Use Metrowerks x86 asm for NetWare
146 gaswin - Use GNU as with Mingw32
147 no-socks - No socket code
148 no-err - No error strings
149 dll/shlib - Build shared libraries (MS)
151 profile - Profiling build
154 Values that can be set
155 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
157 -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
158 -<ex_cc_flags> - extra 'cc' flags,
159 added (MS), or replace (unix)
165 foreach (grep(!/^$/, split(/ /, $OPTIONS)))
167 print STDERR "unknown option - $_\n" if !&read_options;
170 $no_static_engine = 0 if (!$shlib);
172 $no_mdc2=1 if ($no_des);
174 $no_ssl3=1 if ($no_md5 || $no_sha);
175 $no_ssl3=1 if ($no_rsa && $no_dh);
177 $no_ssl2=1 if ($no_md5);
178 $no_ssl2=1 if ($no_rsa);
184 $perl="perl" unless defined $perl;
185 $mkdir="-mkdir" unless defined $mkdir;
187 ($ssl,$crypto)=("ssl","crypto");
188 $ranlib="echo ranlib";
190 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
191 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
192 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
194 # $bin_dir.=$o causes a core dump on my sparc :-(
199 push(@INC,"util/pl","pl");
201 if ($platform eq "auto" || $platform eq 'copy') {
202 $orig_platform = $platform;
203 $platform = $mf_platform;
204 print STDERR "Imported platform $mf_platform\n";
207 if (($platform =~ /VC-(.+)/))
210 $NT = 1 if $1 eq "NT";
213 elsif ($platform eq "Mingw32")
215 require 'Mingw32.pl';
217 elsif ($platform eq "Mingw32-files")
219 require 'Mingw32f.pl';
221 elsif ($platform eq "BC-NT")
226 elsif ($platform eq "FreeBSD")
229 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
231 elsif ($platform eq "linux-elf")
237 elsif ($platform eq "ultrix-mips")
243 elsif ($platform eq "OS2-EMX")
246 require 'OS2-EMX.pl';
248 elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
249 ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
251 $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
252 $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
253 require 'netware.pl';
260 $cflags.=' -DTERMIO';
263 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
264 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
265 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
267 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
269 $cflags= "$xcflags$cflags" if $xcflags ne "";
271 $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
272 $cflags.=" -DOPENSSL_NO_AES" if $no_aes;
273 $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia;
274 $cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
275 $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
276 $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
277 $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
278 $cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
279 $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
280 $cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
281 $cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
282 $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
283 $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
284 $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
285 $cflags.=" -DOPENSSL_NO_BF" if $no_bf;
286 $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
287 $cflags.=" -DOPENSSL_NO_DES" if $no_des;
288 $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
289 $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
290 $cflags.=" -DOPENSSL_NO_DH" if $no_dh;
291 $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
292 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
293 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
294 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
295 $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
296 $cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
297 $cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
298 $cflags.=" -DOPENSSL_NO_ERR" if $no_err;
299 $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
300 $cflags.=" -DOPENSSL_NO_EC" if $no_ec;
301 $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
302 $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
303 $cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
304 $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
305 $cflags.=" -DOPENSSL_NO_HW" if $no_hw;
306 $cflags.=" -DOPENSSL_FIPS" if $fips;
307 $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
308 $cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m;
309 $cflags.= " -DZLIB" if $zlib_opt;
310 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
312 if ($no_static_engine)
314 $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
318 $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
321 #$cflags.=" -DRSAref" if $rsaref ne "";
324 ## { $cflags="$c_flags" if ($c_flags ne ""); }
326 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
328 if ($orig_platform eq 'copy') {
333 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
336 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
337 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
341 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
342 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
343 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
344 $banner.="\t\@echo documentation for details.\n";
347 # have to do this to allow $(CC) under unix
348 $link="$bin_dir$link" if ($link !~ /^\$/);
350 $INSTALLTOP =~ s|/|$o|g;
351 $OPENSSLDIR =~ s|/|$o|g;
353 #############################################
354 # We parse in input file and 'store' info for later printing.
355 open(IN,"<$infile") || die "unable to open $infile:$!\n";
359 s/\s*$//; # was chop, didn't work in mixture of perls for Windows...
361 ($key,$val)=/^([^=]+)=(.*)/;
362 if ($key eq "RELATIVE_DIRECTORY")
366 if ($fips && $dir =~ /^fips/)
373 $uc =~ s/^lib(.*)\.a/$1/;
376 if (($uc ne "FIPS") || $fipscanisterbuild)
379 $lib_obj{$uc}.=$libobj." ";
382 last if ($val eq "FINISHED");
388 if ($key eq "KRB5_INCLUDES")
389 { $cflags .= " $val";}
391 if ($key eq "ZLIB_INCLUDE")
392 { $cflags .= " $val" if $val ne "";}
394 if ($key eq "LIBZLIB")
395 { $zlib_lib = "$val" if $val ne "";}
397 if ($key eq "LIBKRB5")
398 { $ex_libs .= " $val" if $val ne "";}
400 if ($key eq "TEST" && (!$fipscanisteronly || $dir =~ /^fips/ ))
401 { $test.=&var_add($dir,$val, 0); }
403 if (($key eq "PROGS") || ($key eq "E_OBJ"))
404 { $e_exe.=&var_add($dir,$val, 0); }
409 $lib =~ s/^.*\/([^\/]+)$/$1/;
411 if ($key eq "LIBNAME" && $no_static_engine)
414 $lib =~ s/^.*\/([^\/]+)$/$1/;
415 $otherlibs .= " $lib";
418 if ($key eq "EXHEADER")
419 { $exheader.=&var_add($dir,$val, 1); }
421 if ($key eq "HEADER")
422 { $header.=&var_add($dir,$val, 1); }
424 if ($key eq "LIBOBJ")
426 if ($dir ne "engines" || !$no_static_engine)
427 { $libobj=&var_add($dir,$val, 0); }
429 { push(@engines_obj,split(/\s+/,&var_add($dir,$val,0))); }
431 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
434 if ($key eq "FIPS_EX_OBJ")
436 $fips_ex_obj=&var_add("crypto",$val,0);
439 if ($key eq "FIPSLIBDIR")
442 $fipslibdir =~ s/\/$//;
443 $fipslibdir =~ s/\//$o/g;
446 if ($key eq "BASEADDR")
450 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
457 foreach (split " ", $fips_ex_obj)
459 $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/);
462 "$mf_cpuid_asm $mf_aes_asm $mf_sha_asm $mf_bn_asm " .
463 "$mf_des_asm $mf_modes_asm")
466 $fips_exclude_obj{$_} = 1;
468 my @ltmp = split " ", $lib_obj{"CRYPTO"};
471 $lib_obj{"CRYPTO"} = "";
475 if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1})
477 if ($fipscanisterbuild)
479 $lib_obj{"FIPS"} .= "$_ ";
482 elsif (!$fipscanisteronly)
484 $lib_obj{"CRYPTO"} .= "$_ ";
490 if ($fipscanisterbuild)
492 $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq "";
493 $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c";
497 if ($fips_canister_path eq "")
499 $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib";
502 if ($fips_premain_c_path eq "")
504 $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
510 if ($fips_sha1_exe_path eq "")
512 $fips_sha1_exe_path =
513 "\$(BIN_D)${o}fips_standalone_sha1$exep";
518 $fips_sha1_exe_path = "";
521 if ($fips_premain_dso_exe_path eq "")
523 $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
526 # $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
532 $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
533 $ex_l_libs .= " \$(O_FIPSCANISTER)";
534 $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
536 if ($fipscanisterbuild)
538 $fipslibdir = "\$(LIB_D)";
542 if ($fipslibdir eq "")
544 open (IN, "util/fipslib_path.txt") || fipslib_error();
549 fips_check_files($fipslibdir,
550 "fipscanister.lib", "fipscanister.lib.sha1",
551 "fips_premain.c", "fips_premain.c.sha1");
555 if ($fipscanisteronly)
557 $build_targets = "\$(O_FIPSCANISTER) \$(T_EXE)";
561 $cp2 = $cp unless defined $cp2;
563 $extra_install= <<"EOF";
564 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
565 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
566 \$(MKDIR) \"\$(OPENSSLDIR)\"
567 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
570 if ($fipscanisteronly)
572 $extra_install = <<"EOF";
573 \$(CP) \"\$(O_FIPSCANISTER)\" \"\$(INSTALLTOP)${o}lib\"
574 \$(CP) \"\$(O_FIPSCANISTER).sha1\" \"\$(INSTALLTOP)${o}lib\"
575 \$(CP2) \"fips${o}fips_premain.c\" \"\$(INSTALLTOP)${o}lib\"
576 \$(CP) \"fips${o}fips_premain.c.sha1\" \"\$(INSTALLTOP)${o}lib\"
577 \$(CP) \"\$(INCO_D)${o}fips.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
578 \$(CP) \"\$(INCO_D)${o}fips_rand.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
579 \$(CP) "\$(BIN_D)${o}fips_standalone_sha1$exep" \"\$(INSTALLTOP)${o}bin\"
580 \$(CP) \"util${o}fipslink.pl\" \"\$(INSTALLTOP)${o}bin\"
585 $extra_install .= <<"EOF";
586 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
587 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
588 \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
589 \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
591 if ($no_static_engine)
593 $extra_install .= <<"EOF"
594 \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
595 \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
601 $extra_install .= <<"EOF";
602 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
603 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
605 $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
609 # This makefile has been automatically generated from the OpenSSL distribution.
610 # This single makefile will build the complete OpenSSL distribution and
611 # by default leave the 'intertesting' output files in .${o}out and the stuff
612 # that needs deleting in .${o}tmp.
613 # The file was generated by running 'make makefile.one', which
614 # does a 'make files', which writes all the environment variables from all
615 # the makefiles to the file call MINFO. This file is used by
616 # util${o}mk1mf.pl to generate makefile.one.
617 # The 'makefile per directory' system suites me when developing this
618 # library and also so I can 'distribute' indervidual library sections.
619 # The one monster makefile better suits building in non-unix
624 $defs .= $preamble if defined $preamble;
627 INSTALLTOP=$INSTALLTOP
628 OPENSSLDIR=$OPENSSLDIR
630 # Set your compiler options
636 SHLIB_CFLAG=$shl_cflag
637 APP_EX_OBJ=$app_ex_obj
638 SHLIB_EX_OBJ=$shlib_ex_obj
639 # add extra libraries to this define, for solaris -lsocket -lnsl would
643 # The OpenSSL directory
649 FIPSLINK=\$(PERL) util${o}fipslink.pl
651 # The output directory for everything interesting
653 # The output directory for all the temporary muck
655 # The output directory for the header files
657 INCO_D=$inc_dir${o}openssl
669 # FIPS validated module and support file locations
671 E_PREMAIN_DSO=fips_premain_dso
673 FIPSLIB_D=$fipslibdir
675 FIPS_PREMAIN_SRC=$fips_premain_c_path
676 O_FIPSCANISTER=$fips_canister_path
677 FIPS_SHA1_EXE=$fips_sha1_exe_path
678 PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
680 ######################################################
681 # You should not need to touch anything below this point
682 ######################################################
688 # BIN_D - Binary output directory
689 # TEST_D - Binary test file output directory
690 # LIB_D - library output directory
691 # ENG_D - dynamic engine output directory
692 # Note: if you change these point to different directories then uncomment out
693 # the lines around the 'NB' comment below.
700 # INCL_D - local library directory
701 # OBJ_D - temp object file directory
705 O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
706 O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
707 SO_SSL= $plib\$(SSL)$so_shlibp
708 SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
709 L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
710 L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
712 L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
714 ######################################################
715 # Don't touch anything below this point
716 ######################################################
718 INC=-I\$(INC_D) -I\$(INCL_D)
719 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
720 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
721 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
724 #############################################
728 all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) $build_targets
734 \$(MKDIR) \"\$(TMP_D)\"
735 # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
737 # \$(MKDIR) \$(BIN_D)
740 # \$(MKDIR) \$(TEST_D)
743 \$(MKDIR) \"\$(LIB_D)\"
745 \$(INCO_D): \$(INC_D)
746 \$(MKDIR) \"\$(INCO_D)\"
749 \$(MKDIR) \"\$(INC_D)\"
751 headers: \$(HEADER) \$(EXHEADER)
753 lib: \$(LIBS_DEP) \$(E_SHLIB)
755 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
758 \$(MKDIR) \"\$(INSTALLTOP)\"
759 \$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
760 \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
761 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
762 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
771 \$(RM) \$(TMP_D)$o*.*
774 \$(RM) \$(TMP_D)$o*.*
775 \$(RM) \$(OUT_D)$o*.*
780 \$(RM) -rf \$(TEST_D)
786 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
787 $platform_cpp_symbol =~ s/-/_/g;
788 if (open(IN,"crypto/buildinf.h"))
790 # Remove entry for this platform in existing file buildinf.h.
792 my $old_buildinf_h = "";
795 if (/^\#ifdef $platform_cpp_symbol$/)
797 while (<IN>) { last if (/^\#endif/); }
801 $old_buildinf_h .= $_;
806 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
807 print OUT $old_buildinf_h;
811 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
813 #ifdef $platform_cpp_symbol
814 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
815 #define CFLAGS "$cc $cflags"
816 #define PLATFORM "$platform"
818 printf OUT " #define DATE \"%s\"\n", scalar gmtime();
819 printf OUT "#endif\n";
822 # Strip off trailing ' '
823 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
824 $test=&clean_up_ws($test);
825 $e_exe=&clean_up_ws($e_exe);
826 $exheader=&clean_up_ws($exheader);
827 $header=&clean_up_ws($header);
829 # First we strip the exheaders from the headers list
830 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
831 foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
832 chop($h); $header=$h;
834 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
835 $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
837 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
838 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
840 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
841 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
843 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
844 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
846 # Special case rules for fips_start and fips_end fips_premain_dso
850 if ($fipscanisterbuild)
852 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
853 "fips${o}fips_canister.c",
854 "-DFIPS_START \$(SHLIB_CFLAGS)");
855 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
856 "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
858 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
859 "fips${o}sha${o}fips_standalone_sha1.c",
861 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
862 "fips${o}fips_premain.c",
863 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)");
871 $asm =~ s/\s+/ $dir\//g;
878 $lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5');
879 $lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn');
880 # cpuid is included by the crypto dir
881 #$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto');
882 # AES asm files end up included by the aes dir itself
883 #$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes');
884 $lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha');
885 $lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines');
886 $lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4');
887 $lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes');
889 foreach (values %lib_nam)
891 $lib_obj=$lib_obj{$_};
894 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
896 $rules.="\$(O_SSL):\n\n";
900 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
901 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
902 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
905 # hack to add version info on MSVC
906 if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
907 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
909 \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
910 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
912 \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
913 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
918 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
919 foreach (split(/\s+/,$test))
924 # Check to see if test program is FIPS
927 # If fips perform static link to
929 $t_libs = "\$(O_FIPSCANISTER)";
934 $t_libs = "\$(L_LIBS)";
938 $tt="\$(OBJ_D)${o}$t${obj}";
939 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype);
942 $defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp);
944 foreach (split(/\s+/,$engines))
947 my @objs = grep {/e_$engine/} @engines_obj;
948 $rules.=&do_compile_rule("\$(OBJ_D)",join(" ",@objs),$lib);
949 map {$_=~s/.*\/([^\/]+)$/\$(OBJ_D)${o}$1$obj/} @objs;
950 $rules.= &do_lib_rule(join(" ",@objs),"\$(ENG_D)$o$engine$shlibp","",$shlib,"");
955 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
956 #$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
958 foreach (split(" ",$otherlibs))
962 $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, "");
970 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
971 "\$(O_CRYPTO)", "$crypto",
972 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
976 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
977 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
978 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
979 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
984 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
990 if ($fipscanisterbuild)
992 $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)",
993 "\$(OBJ_D)${o}fips_start$obj",
995 "\$(OBJ_D)${o}fips_end$obj",
996 "\$(FIPS_SHA1_EXE)", "");
998 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
999 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj $sha1_asm_obj",
1000 "","\$(EX_LIBS)", 1);
1004 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
1005 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)",
1009 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
1013 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
1017 if ($platform eq "linux-elf") {
1019 # Generate perlasm output files
1021 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
1024 print "###################################################################\n";
1027 ###############################################
1028 # strip off any trailing .[och] and append the relative directory
1029 # also remembering to do nothing if we are in one of the dropped
1033 local($dir,$val,$keepext)=@_;
1036 return("") if $no_engine && $dir =~ /\/engine/;
1037 return("") if $no_hw && $dir =~ /\/hw/;
1038 return("") if $no_idea && $dir =~ /\/idea/;
1039 return("") if $no_aes && $dir =~ /\/aes/;
1040 return("") if $no_camellia && $dir =~ /\/camellia/;
1041 return("") if $no_seed && $dir =~ /\/seed/;
1042 return("") if $no_rc2 && $dir =~ /\/rc2/;
1043 return("") if $no_rc4 && $dir =~ /\/rc4/;
1044 return("") if $no_rc5 && $dir =~ /\/rc5/;
1045 return("") if $no_rsa && $dir =~ /\/rsa/;
1046 return("") if $no_rsa && $dir =~ /^rsaref/;
1047 return("") if $no_dsa && $dir =~ /\/dsa/;
1048 return("") if $no_dh && $dir =~ /\/dh/;
1049 return("") if $no_ec && $dir =~ /\/ec/;
1050 return("") if $no_gost && $dir =~ /\/ccgost/;
1051 return("") if $no_cms && $dir =~ /\/cms/;
1052 return("") if $no_jpake && $dir =~ /\/jpake/;
1053 return("") if !$fips && $dir =~ /^fips/;
1054 if ($no_des && $dir =~ /\/des/)
1056 if ($val =~ /read_pwd/)
1057 { return("$dir/read_pwd "); }
1061 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
1062 return("") if $no_sock && $dir =~ /\/proxy/;
1063 return("") if $no_bf && $dir =~ /\/bf/;
1064 return("") if $no_cast && $dir =~ /\/cast/;
1065 return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
1067 $val =~ s/^\s*(.*)\s*$/$1/;
1068 @a=split(/\s+/,$val);
1069 grep(s/\.[och]$//,@a) unless $keepext;
1071 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
1072 @a=grep(!/^e_.*_d$/,@a) if $no_des;
1073 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
1074 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
1075 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
1076 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
1077 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
1078 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
1079 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
1080 @a=grep(!/^e_camellia$/,@a) if $no_camellia;
1081 @a=grep(!/^e_seed$/,@a) if $no_seed;
1083 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
1084 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
1086 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
1088 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
1089 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
1090 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
1091 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
1093 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
1094 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
1095 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
1097 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
1098 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
1100 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
1102 @a=grep(!/_dhp$/,@a) if $no_dh;
1104 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
1105 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
1106 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
1108 @a=grep(!/(srp)/,@a) if $no_srp;
1110 @a=grep(!/^engine$/,@a) if $no_engine;
1111 @a=grep(!/^hw$/,@a) if $no_hw;
1112 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
1113 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
1114 @a=grep(!/^gendsa$/,@a) if $no_sha1;
1115 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
1117 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
1119 grep($_="$dir/$_",@a);
1120 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
1121 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
1122 $ret=join(' ',@a)." ";
1126 # change things so that each 'token' is only separated by one space
1131 $w =~ s/^\s*(.*)\s*$/$1/;
1138 local($var,$files,$location,$postfix)=@_;
1140 local(*OUT,$tmp,$t);
1142 $files =~ s/\//$o/g if $o ne '/';
1146 foreach (split(/ /,$files))
1149 $_=&bname($_) unless /^\$/;
1155 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
1157 else { $pf=$postfix; }
1158 if ($_ =~ /BN_ASM/) { $t="$_ "; }
1159 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
1160 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
1161 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
1162 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
1163 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
1164 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
1165 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
1166 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
1167 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
1168 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
1169 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
1170 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
1171 else { $t="$location${o}$_$pf "; }
1176 # hack to add version info on MSVC
1177 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
1179 if ($var eq "CRYPTOOBJ")
1180 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
1181 elsif ($var eq "SSLOBJ")
1182 { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
1189 # return the name with the leading path removed
1193 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
1197 # return the leading path
1201 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
1205 ##############################################################
1206 # do a rule for each file that says 'compile' to new direcory
1207 # compile the files in '$files' into $to
1210 local($to,$files,$ex)=@_;
1211 local($ret,$_,$n,$d,$s);
1213 $files =~ s/\//$o/g if $o ne '/';
1214 foreach (split(/\s+/,$files))
1220 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
1222 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
1223 ($s=~s/sha256/sha512/ and -f $s) or
1224 -f ($s="${d}${o}${n}.pl"))
1226 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
1228 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
1229 -f ($s="${d}${o}${n}.S"))
1231 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
1233 elsif (defined &special_compile_target and
1234 ($s=special_compile_target($_)))
1238 else { die "no rule for $_"; }
1243 ##############################################################
1244 # do a rule for each file that says 'compile' to new direcory
1245 sub perlasm_compile_target
1247 my($target,$source,$bname)=@_;
1249 return platform_perlasm_compile_target($target, $source, $bname)
1250 if defined &platform_perlasm_compile_target;
1253 $bname =~ s/(.*)\.[^\.]$/$1/;
1254 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
1255 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
1256 if ($fipscanisteronly)
1258 $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n";
1261 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
1262 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
1266 sub Sasm_compile_target
1268 my($target,$source,$bname)=@_;
1271 $bname =~ s/(.*)\.[^\.]$/$1/;
1272 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
1273 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n";
1274 $ret.="\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n" if $fipscanisteronly;
1276 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
1277 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
1281 sub cc_compile_target
1283 local($target,$source,$ex_flags)=@_;
1286 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
1287 $target =~ s/\//$o/g if $o ne "/";
1288 $source =~ s/\//$o/g if $o ne "/";
1289 # FIXME: do dependencies instead of all headers.
1290 $ret ="$target: \$(SRC_D)$o$source \$(HEADER) \$(EXHEADER)\n\t";
1291 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
1295 ##############################################################
1298 local($target,$src)=@_;
1299 local($ret,@s,@t,$i);
1301 $target =~ s/\//$o/g if $o ne "/";
1302 $src =~ s/\//$o/g if $o ne "/";
1304 @t=split(/\s+/,$target);
1305 @s=split(/\s+/,$src);
1308 for ($i=0; $i<=$#s; $i++)
1310 my $objfile = $t[$i];
1311 my $srcfile = $s[$i];
1315 my $plasm = $objfile;
1316 $plasm =~ s/${obj}/.pl/;
1317 $ret.="$srcfile: $plasm\n";
1318 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
1321 $ret.="$objfile: $srcfile\n";
1322 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
1333 ($nn=$n) =~ tr/a-z/A-Z/;
1334 $ret.="$n.dll: \$(${nn}OBJ)\n";
1337 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
1343 # do a rule for each file that says 'copy' to new direcory on change
1346 local($to,$files,$p)=@_;
1347 local($ret,$_,$n,$pp);
1349 $files =~ s/\//$o/g if $o ne '/';
1350 foreach (split(/\s+/,$files))
1353 if ($n =~ /bss_file/)
1356 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp $to\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
1363 # Many options are handled in a similar way. In particular
1364 # no-xxx sets zero or more scalars to 1.
1365 # Process these using a hash containing the option name and
1366 # reference to the scalars to set.
1368 my %valid_options = (
1369 "no-rc2" => \$no_rc2,
1370 "no-rc4" => \$no_rc4,
1371 "no-rc5" => \$no_rc5,
1372 "no-idea" => \$no_idea,
1373 "no-aes" => \$no_aes,
1374 "no-camellia" => \$no_camellia,
1375 "no-seed" => \$no_seed,
1376 "no-des" => \$no_des,
1378 "no-cast" => \$no_cast,
1379 "no-md2" => \$no_md2,
1380 "no-md4" => \$no_md4,
1381 "no-md5" => \$no_md5,
1382 "no-sha" => \$no_sha,
1383 "no-sha1" => \$no_sha1,
1384 "no-ripemd" => \$no_ripemd,
1385 "no-mdc2" => \$no_mdc2,
1386 "no-whirlpool" => \$no_whirlpool,
1388 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1389 "no-rsa" => \$no_rsa,
1390 "no-dsa" => \$no_dsa,
1392 "no-hmac" => \$no_hmac,
1393 "no-asm" => \$no_asm,
1395 "nw-nasm" => \$nw_nasm,
1396 "nw-mwasm" => \$nw_mwasm,
1397 "gaswin" => \$gaswin,
1398 "no-ssl2" => \$no_ssl2,
1399 "no-ssl3" => \$no_ssl3,
1400 "no-tlsext" => \$no_tlsext,
1401 "no-srp" => \$no_srp,
1402 "no-cms" => \$no_cms,
1403 "no-jpake" => \$no_jpake,
1404 "no-ec2m" => \$no_ec2m,
1405 "no-ec_nistp_64_gcc_128" => 0,
1406 "no-err" => \$no_err,
1407 "no-sock" => \$no_sock,
1408 "no-krb5" => \$no_krb5,
1410 "no-ecdsa" => \$no_ecdsa,
1411 "no-ecdh" => \$no_ecdh,
1412 "no-gost" => \$no_gost,
1413 "no-engine" => \$no_engine,
1416 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
1417 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
1418 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
1419 \$no_aes, \$no_camellia, \$no_seed, \$no_srp],
1423 "profile" => \$profile,
1434 "no-zlib-dynamic" => 0,
1435 "no-ssl-trace" => 0,
1437 "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
1438 "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
1439 "fipscheck" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
1442 if (exists $valid_options{$_})
1444 my $r = $valid_options{$_};
1445 if ( ref $r eq "SCALAR")
1447 elsif ( ref $r eq "ARRAY")
1456 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
1457 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1458 elsif (/^enable-zlib-dynamic$/)
1462 elsif (/^no-static-engine/)
1464 $no_static_engine = 1;
1466 elsif (/^enable-static-engine/)
1468 $no_static_engine = 0;
1470 # There are also enable-xxx options which correspond to
1471 # the no-xxx. Since the scalars are enabled by default
1472 # these can be ignored.
1476 $t =~ s/^enable/no/;
1477 if (exists $valid_options{$t})
1481 # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1482 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1483 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1484 elsif (/^experimental-/)
1487 ($algo = $_) =~ s/^experimental-//;
1488 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1490 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1493 elsif (/^--with-krb5-flavor=(.*)$/)
1495 my $krb5_flavor = $1;
1496 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1498 $xcflags="-DKRB5_HEIMDAL $xcflags";
1500 elsif ($krb5_flavor =~ /^MIT/i)
1502 $xcflags="-DKRB5_MIT $xcflags";
1503 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1505 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1509 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1510 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
1511 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1512 { $c_flags.="$_ "; }
1519 print STDERR "***FIPS module directory sanity check failed***\n";
1520 print STDERR "FIPS module build failed, or was deleted\n";
1521 print STDERR "Please rebuild FIPS module.\n";
1525 sub fips_check_files
1531 print STDERR "FIPS module directory $dir does not exist\n";
1536 if (!-f "$dir${o}$_")
1538 print STDERR "FIPS module file $_ does not exist!\n";
1542 fipslib_error() if ($ret == 0);