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 (if the target is not "copy").
6 # If the target is "copy", then it tries to create a makefile that can be
7 # safely used with the -j flag and that is compatible with the top-level
8 # Makefile, in the sense that it uses the same options and assembler files etc.
12 $INSTALLTOP="/usr/local/ssl";
13 $OPENSSLDIR="/usr/local/ssl";
16 $banner="\t\@echo Building OpenSSL";
18 my $no_static_engine = 1;
22 local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
24 local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
26 local $fips_canister_path = "";
27 my $fips_premain_dso_exe_path = "";
28 my $fips_premain_c_path = "";
29 my $fips_sha1_exe_path = "";
31 local $fipscanisterbuild = 0;
33 my $fipscanisteronly = 0;
40 my $build_targets = "lib exe";
41 my $libs_dep = "\$(O_CRYPTO) \$(O_SSL)";
43 # Options to import from top level Makefile
46 VERSION => \$ssl_version,
48 INSTALLTOP => \$INSTALLTOP,
49 OPENSSLDIR => \$OPENSSLDIR,
50 PLATFORM => \$mf_platform,
53 DEPFLAG => \$mf_depflag,
54 CPUID_OBJ => \$mf_cpuid_asm,
55 BN_ASM => \$mf_bn_asm,
56 DES_ENC => \$mf_des_asm,
57 AES_ENC => \$mf_aes_asm,
58 BF_ENC => \$mf_bf_asm,
59 CAST_ENC => \$mf_cast_asm,
60 RC4_ENC => \$mf_rc4_asm,
61 RC5_ENC => \$mf_rc5_asm,
62 MD5_ASM_OBJ => \$mf_md5_asm,
63 SHA1_ASM_OBJ => \$mf_sha_asm,
64 RMD160_ASM_OBJ => \$mf_rmd_asm,
65 WP_ASM_OBJ => \$mf_wp_asm,
66 CMLL_ENC => \$mf_cm_asm,
67 MODES_ASM_OBJ => \$mf_modes_asm,
68 ENGINES_ASM_OBJ=> \$mf_engines_asm,
69 FIPSCANISTERONLY => \$mf_fipscanisteronly,
70 FIPSCANISTERINTERNAL => \$mf_fipscanisterinternal
73 open(IN,"<Makefile") || die "unable to open Makefile!\n";
75 my ($mf_opt, $mf_ref);
76 while (($mf_opt, $mf_ref) = each %mf_import) {
77 if (/^$mf_opt\s*=\s*(.*)$/ && !defined($$mfref)) {
84 $debug = 1 if $mf_platform =~ /^debug-/;
86 if ($mf_fipscanisterinternal eq "y") {
88 $fipscanisterbuild = 1;
89 $fipscanisteronly = 1;
93 die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
98 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
99 "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
100 "VC-WIN64A", "Microsoft C/C++ - Win64/x64",
101 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
102 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
103 "Mingw32", "GNU C++ - Windows NT or 9x",
104 "Mingw32-files", "Create files with DOS copy ...",
105 "BC-NT", "Borland C++ 4.5 - Windows NT",
106 "linux-elf","Linux elf",
107 "ultrix-mips","DEC mips ultrix",
108 "FreeBSD","FreeBSD distribution",
109 "OS2-EMX", "EMX GCC OS/2",
110 "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
111 "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
112 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
113 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
114 "default","cc under unix",
115 "auto", "auto detect from top level Makefile",
116 "copy", "copy from top level Makefile"
123 if (!&read_options && !defined($ops{$_}))
125 print STDERR "unknown option - $_\n";
126 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
127 print STDERR "\nwhere [system] can be one of the following\n";
128 foreach $i (sort keys %ops)
129 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
130 print STDERR <<"EOF";
131 and [options] can be one of
132 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
134 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
135 no-bf no-cast no-aes no-camellia no-seed
136 no-rsa no-dsa no-dh - Skip this public key cipher
137 no-ssl2 no-ssl3 - Skip this version of SSL
138 just-ssl - remove all non-ssl keys/digest
145 no-engine - No engine
147 nasm - Use NASM for x86 asm
148 nw-nasm - Use NASM x86 asm for NetWare
149 nw-mwasm - Use Metrowerks x86 asm for NetWare
150 gaswin - Use GNU as with Mingw32
151 no-socks - No socket code
152 no-err - No error strings
153 dll/shlib - Build shared libraries (MS)
155 profile - Profiling build
158 Values that can be set
159 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
161 -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
162 -<ex_cc_flags> - extra 'cc' flags,
163 added (MS), or replace (unix)
169 foreach (grep(!/^$/, split(/ /, $OPTIONS)))
171 print STDERR "unknown option - $_\n" if !&read_options;
174 $no_static_engine = 0 if (!$shlib);
176 $no_mdc2=1 if ($no_des);
178 $no_ssl3=1 if ($no_md5 || $no_sha);
179 $no_ssl3=1 if ($no_rsa && $no_dh);
181 $no_ssl2=1 if ($no_md5);
182 $no_ssl2=1 if ($no_rsa);
188 $perl="perl" unless defined $perl;
189 $mkdir="-mkdir" unless defined $mkdir;
191 ($ssl,$crypto)=("ssl","crypto");
192 $ranlib="echo ranlib";
194 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
195 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}: $platform eq 'copy' ? getcwd() : '.';
196 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
198 # $bin_dir.=$o causes a core dump on my sparc :-(
203 push(@INC,"util/pl","pl");
205 if ($platform eq "auto" || $platform eq 'copy') {
206 $orig_platform = $platform;
207 $platform = $mf_platform;
208 print STDERR "Imported platform $mf_platform\n";
211 if (($platform =~ /VC-(.+)/))
214 $NT = 1 if $1 eq "NT";
217 elsif ($platform eq "Mingw32")
219 require 'Mingw32.pl';
221 elsif ($platform eq "Mingw32-files")
223 require 'Mingw32f.pl';
225 elsif ($platform eq "BC-NT")
230 elsif ($platform eq "FreeBSD")
233 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
235 elsif ($platform eq "linux-elf")
241 elsif ($platform eq "ultrix-mips")
247 elsif ($platform eq "OS2-EMX")
250 require 'OS2-EMX.pl';
252 elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
253 ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
255 $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
256 $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
257 require 'netware.pl';
264 $cflags.=' -DTERMIO';
267 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
268 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
269 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
271 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
273 $cflags= "$xcflags$cflags" if $xcflags ne "";
275 $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
276 $cflags.=" -DOPENSSL_NO_AES" if $no_aes;
277 $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia;
278 $cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
279 $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
280 $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
281 $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
282 $cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
283 $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
284 $cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
285 $cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
286 $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
287 $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
288 $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
289 $cflags.=" -DOPENSSL_NO_BF" if $no_bf;
290 $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
291 $cflags.=" -DOPENSSL_NO_DES" if $no_des;
292 $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
293 $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
294 $cflags.=" -DOPENSSL_NO_DH" if $no_dh;
295 $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
296 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
297 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
298 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
299 $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
300 $cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
301 $cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
302 $cflags.=" -DOPENSSL_NO_ERR" if $no_err;
303 $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
304 $cflags.=" -DOPENSSL_NO_EC" if $no_ec;
305 $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
306 $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
307 $cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
308 $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
309 $cflags.=" -DOPENSSL_NO_HW" if $no_hw;
310 $cflags.=" -DOPENSSL_FIPS" if $fips;
311 $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
312 $cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m;
313 $cflags.= " -DZLIB" if $zlib_opt;
314 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
316 if ($no_static_engine)
318 $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
322 $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
325 #$cflags.=" -DRSAref" if $rsaref ne "";
328 ## { $cflags="$c_flags" if ($c_flags ne ""); }
330 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
332 if ($orig_platform eq 'copy') {
337 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
340 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
341 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
345 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
346 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
347 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
348 $banner.="\t\@echo documentation for details.\n";
351 # have to do this to allow $(CC) under unix
352 $link="$bin_dir$link" if ($link !~ /^\$/);
354 $INSTALLTOP =~ s|/|$o|g;
355 $OPENSSLDIR =~ s|/|$o|g;
357 #############################################
358 # We parse in input file and 'store' info for later printing.
359 open(IN,"<$infile") || die "unable to open $infile:$!\n";
363 s/\s*$//; # was chop, didn't work in mixture of perls for Windows...
365 ($key,$val)=/^([^=]+)=(.*)/;
366 if ($key eq "RELATIVE_DIRECTORY")
370 if ($fips && $dir =~ /^fips/)
377 $uc =~ s/^lib(.*)\.a/$1/;
380 if (($uc ne "FIPS") || $fipscanisterbuild)
383 $lib_obj{$uc}.=$libobj." ";
386 last if ($val eq "FINISHED");
392 if ($key eq "KRB5_INCLUDES")
393 { $cflags .= " $val";}
395 if ($key eq "ZLIB_INCLUDE")
396 { $cflags .= " $val" if $val ne "";}
398 if ($key eq "LIBZLIB")
399 { $zlib_lib = "$val" if $val ne "";}
401 if ($key eq "LIBKRB5")
402 { $ex_libs .= " $val" if $val ne "";}
404 if ($key eq "TEST" && (!$fipscanisteronly || $dir =~ /^fips/ ))
405 { $test.=&var_add($dir,$val, 0); }
407 if (($key eq "PROGS") || ($key eq "E_OBJ"))
408 { $e_exe.=&var_add($dir,$val, 0); }
413 $lib =~ s/^.*\/([^\/]+)$/$1/;
415 if ($key eq "LIBNAME" && $no_static_engine)
418 $lib =~ s/^.*\/([^\/]+)$/$1/;
419 $otherlibs .= " $lib";
422 if ($key eq "EXHEADER")
423 { $exheader.=&var_add($dir,$val, 1); }
425 if ($key eq "HEADER")
426 { $header.=&var_add($dir,$val, 1); }
428 if ($key eq "LIBOBJ")
430 if ($dir ne "engines" || !$no_static_engine)
431 { $libobj=&var_add($dir,$val, 0); }
433 { push(@engines_obj,split(/\s+/,&var_add($dir,$val,0))); }
435 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
438 if ($key eq "FIPS_EX_OBJ")
440 $fips_ex_obj=&var_add("crypto",$val,0);
443 if ($key eq "FIPSLIBDIR")
446 $fipslibdir =~ s/\/$//;
447 $fipslibdir =~ s/\//$o/g;
450 if ($key eq "BASEADDR")
454 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
458 if ($orig_platform eq 'copy')
460 # Remove opensslconf.h so it doesn't get updated if we configure a
462 $exheader =~ s/[^ ]+\/opensslconf.h//;
463 $header =~ s/[^ ]+\/opensslconf.h//;
469 foreach (split " ", $fips_ex_obj)
471 $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/);
474 "$mf_cpuid_asm $mf_aes_asm $mf_sha_asm $mf_bn_asm " .
475 "$mf_des_asm $mf_modes_asm")
478 $fips_exclude_obj{$_} = 1;
480 my @ltmp = split " ", $lib_obj{"CRYPTO"};
483 $lib_obj{"CRYPTO"} = "";
487 if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1})
489 if ($fipscanisterbuild)
491 $lib_obj{"FIPS"} .= "$_ ";
494 elsif (!$fipscanisteronly)
496 $lib_obj{"CRYPTO"} .= "$_ ";
502 if ($fipscanisterbuild)
504 $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq "";
505 $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c";
509 if ($fips_canister_path eq "")
511 $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib";
514 if ($fips_premain_c_path eq "")
516 $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
522 if ($fips_sha1_exe_path eq "")
524 $fips_sha1_exe_path =
525 "\$(BIN_D)${o}fips_standalone_sha1$exep";
530 $fips_sha1_exe_path = "";
533 if ($fips_premain_dso_exe_path eq "")
535 $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
538 # $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
544 $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
545 $ex_l_libs .= " \$(O_FIPSCANISTER)";
546 $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
548 if ($fipscanisterbuild)
550 $fipslibdir = "\$(LIB_D)";
554 if ($fipslibdir eq "")
556 open (IN, "util/fipslib_path.txt") || fipslib_error();
561 fips_check_files($fipslibdir,
562 "fipscanister.lib", "fipscanister.lib.sha1",
563 "fips_premain.c", "fips_premain.c.sha1");
567 if ($fipscanisteronly)
569 $build_targets = "\$(O_FIPSCANISTER) \$(T_EXE)";
573 $cp2 = $cp unless defined $cp2;
575 $extra_install= <<"EOF";
576 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
577 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
578 \$(MKDIR) \"\$(OPENSSLDIR)\"
579 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
582 if ($fipscanisteronly)
584 $extra_install = <<"EOF";
585 \$(CP) \"\$(O_FIPSCANISTER)\" \"\$(INSTALLTOP)${o}lib\"
586 \$(CP) \"\$(O_FIPSCANISTER).sha1\" \"\$(INSTALLTOP)${o}lib\"
587 \$(CP2) \"fips${o}fips_premain.c\" \"\$(INSTALLTOP)${o}lib\"
588 \$(CP) \"fips${o}fips_premain.c.sha1\" \"\$(INSTALLTOP)${o}lib\"
589 \$(CP) \"\$(INCO_D)${o}fips.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
590 \$(CP) \"\$(INCO_D)${o}fips_rand.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
591 \$(CP) "\$(BIN_D)${o}fips_standalone_sha1$exep" \"\$(INSTALLTOP)${o}bin\"
592 \$(CP) \"util${o}fipslink.pl\" \"\$(INSTALLTOP)${o}bin\"
597 $extra_install .= <<"EOF";
598 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
599 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
600 \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
601 \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
603 if ($no_static_engine)
605 $extra_install .= <<"EOF"
606 \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
607 \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
613 $extra_install .= <<"EOF";
614 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
615 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
617 $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
620 my $asm_def = $orig_platform eq 'copy' ? "" : "ASM=$bin_dir$asm";
623 # N.B. You MUST use -j on FreeBSD.
624 # This makefile has been automatically generated from the OpenSSL distribution.
625 # This single makefile will build the complete OpenSSL distribution and
626 # by default leave the 'intertesting' output files in .${o}out and the stuff
627 # that needs deleting in .${o}tmp.
628 # The file was generated by running 'make makefile.one', which
629 # does a 'make files', which writes all the environment variables from all
630 # the makefiles to the file call MINFO. This file is used by
631 # util${o}mk1mf.pl to generate makefile.one.
632 # The 'makefile per directory' system suites me when developing this
633 # library and also so I can 'distribute' indervidual library sections.
634 # The one monster makefile better suits building in non-unix
639 $defs .= $preamble if defined $preamble;
642 INSTALLTOP=$INSTALLTOP
643 OPENSSLDIR=$OPENSSLDIR
645 # Set your compiler options
651 SHLIB_CFLAG=$shl_cflag
652 APP_EX_OBJ=$app_ex_obj
653 SHLIB_EX_OBJ=$shlib_ex_obj
654 # add extra libraries to this define, for solaris -lsocket -lnsl would
658 # The OpenSSL directory
664 FIPSLINK=\$(PERL) util${o}fipslink.pl
666 # The output directory for everything interesting
668 # The output directory for all the temporary muck
670 # The output directory for the header files
672 INCO_D=$inc_dir${o}openssl
684 # FIPS validated module and support file locations
686 E_PREMAIN_DSO=fips_premain_dso
688 FIPSLIB_D=$fipslibdir
690 FIPS_PREMAIN_SRC=$fips_premain_c_path
691 O_FIPSCANISTER=$fips_canister_path
692 FIPS_SHA1_EXE=$fips_sha1_exe_path
693 PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
695 ######################################################
696 # You should not need to touch anything below this point
697 ######################################################
703 # BIN_D - Binary output directory
704 # TEST_D - Binary test file output directory
705 # LIB_D - library output directory
706 # ENG_D - dynamic engine output directory
707 # Note: if you change these point to different directories then uncomment out
708 # the lines around the 'NB' comment below.
715 # INCL_D - local library directory
716 # OBJ_D - temp object file directory
720 O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
721 O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
722 SO_SSL= $plib\$(SSL)$so_shlibp
723 SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
724 L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
725 L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
727 L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
729 ######################################################
730 # Don't touch anything below this point
731 ######################################################
733 INC=-I\$(INC_D) -I\$(INCL_D)
734 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
735 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
736 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
739 #############################################
743 all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) $build_targets
749 \$(MKDIR) \"\$(TMP_D)\"
750 # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
752 # \$(MKDIR) \$(BIN_D)
755 # \$(MKDIR) \$(TEST_D)
758 \$(MKDIR) \"\$(LIB_D)\"
760 \$(INCO_D): \$(INC_D)
761 \$(MKDIR) \"\$(INCO_D)\"
764 \$(MKDIR) \"\$(INC_D)\"
766 # This needs to be invoked once, when the makefile is first constructed, or
768 init: \$(TMP_D) \$(LIB_D) \$(INC_D) \$(INCO_D) \$(BIN_D) \$(TEST_D) headers
769 \$(PERL) \$(SRC_D)/util/copy-if-different.pl "\$(SRC_D)/crypto/opensslconf.h" "\$(INCO_D)/opensslconf.h"
771 headers: \$(HEADER) \$(EXHEADER)
773 lib: \$(LIBS_DEP) \$(E_SHLIB)
775 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
778 \$(MKDIR) \"\$(INSTALLTOP)\"
779 \$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
780 \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
781 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
782 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
786 \$(RM) \$(TMP_D)$o*.*
789 \$(RM) \$(TMP_D)$o*.*
790 \$(RM) \$(OUT_D)$o*.*
795 \$(RM) -rf \$(TEST_D)
801 if ($orig_platform ne 'copy')
811 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
812 $platform_cpp_symbol =~ s/-/_/g;
813 if (open(IN,"crypto/buildinf.h"))
815 # Remove entry for this platform in existing file buildinf.h.
817 my $old_buildinf_h = "";
820 if (/^\#ifdef $platform_cpp_symbol$/)
822 while (<IN>) { last if (/^\#endif/); }
826 $old_buildinf_h .= $_;
831 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
832 print OUT $old_buildinf_h;
836 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
838 #ifdef $platform_cpp_symbol
839 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
840 #define CFLAGS "$cc $cflags"
841 #define PLATFORM "$platform"
843 printf OUT " #define DATE \"%s\"\n", scalar gmtime();
844 printf OUT "#endif\n";
847 # Strip off trailing ' '
848 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
849 $test=&clean_up_ws($test);
850 $e_exe=&clean_up_ws($e_exe);
851 $exheader=&clean_up_ws($exheader);
852 $header=&clean_up_ws($header);
854 # First we strip the exheaders from the headers list
855 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
856 foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
857 chop($h); $header=$h;
859 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
860 $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
862 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
863 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
865 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
866 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
868 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
869 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
871 # Special case rules for fips_start and fips_end fips_premain_dso
875 if ($fipscanisterbuild)
877 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
878 "fips${o}fips_canister.c",
879 "-DFIPS_START \$(SHLIB_CFLAGS)");
880 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
881 "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
883 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
884 "fips${o}sha${o}fips_standalone_sha1.c",
886 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
887 "fips${o}fips_premain.c",
888 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)");
896 $asm =~ s/\s+/ $dir\//g;
903 if ($orig_platform eq 'copy') {
904 $lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5');
905 $lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn');
906 # cpuid is included by the crypto dir
907 #$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto');
908 # AES asm files end up included by the aes dir itself
909 #$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes');
910 $lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha');
911 $lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines');
912 $lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4');
913 $lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes');
916 foreach (values %lib_nam)
918 $lib_obj=$lib_obj{$_};
921 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
923 $rules.="\$(O_SSL):\n\n";
927 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
928 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
929 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
932 # hack to add version info on MSVC
933 if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
934 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
936 \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
937 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
939 \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
940 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
945 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
946 foreach (split(/\s+/,$test))
951 # Check to see if test program is FIPS
954 # If fips perform static link to
956 $t_libs = "\$(O_FIPSCANISTER)";
961 $t_libs = "\$(L_LIBS)";
965 $tt="\$(OBJ_D)${o}$t${obj}";
966 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype);
969 $defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp);
971 foreach (split(/\s+/,$engines))
974 my @objs = grep {/e_$engine/} @engines_obj;
975 $rules.=&do_compile_rule("\$(OBJ_D)",join(" ",@objs),$lib);
976 map {$_=~s/.*\/([^\/]+)$/\$(OBJ_D)${o}$1$obj/} @objs;
977 $rules.= &do_lib_rule(join(" ",@objs),"\$(ENG_D)$o$engine$shlibp","",$shlib,"");
982 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
983 #$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
985 foreach (split(" ",$otherlibs))
989 $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, "");
997 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
998 "\$(O_CRYPTO)", "$crypto",
999 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
1003 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
1004 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
1005 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
1006 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
1011 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
1017 if ($fipscanisterbuild)
1019 $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)",
1020 "\$(OBJ_D)${o}fips_start$obj",
1022 "\$(OBJ_D)${o}fips_end$obj",
1023 "\$(FIPS_SHA1_EXE)", "");
1025 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
1026 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj $sha1_asm_obj",
1027 "","\$(EX_LIBS)", 1);
1031 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
1032 "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)",
1036 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
1040 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
1042 $rules .= get_tests('test/Makefile') if $orig_platform eq 'copy';
1046 if ($platform eq "linux-elf") {
1048 # Generate perlasm output files
1050 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
1053 print "###################################################################\n";
1056 ###############################################
1057 # strip off any trailing .[och] and append the relative directory
1058 # also remembering to do nothing if we are in one of the dropped
1062 local($dir,$val,$keepext)=@_;
1065 return("") if $no_engine && $dir =~ /\/engine/;
1066 return("") if $no_hw && $dir =~ /\/hw/;
1067 return("") if $no_idea && $dir =~ /\/idea/;
1068 return("") if $no_aes && $dir =~ /\/aes/;
1069 return("") if $no_camellia && $dir =~ /\/camellia/;
1070 return("") if $no_seed && $dir =~ /\/seed/;
1071 return("") if $no_rc2 && $dir =~ /\/rc2/;
1072 return("") if $no_rc4 && $dir =~ /\/rc4/;
1073 return("") if $no_rc5 && $dir =~ /\/rc5/;
1074 return("") if $no_rsa && $dir =~ /\/rsa/;
1075 return("") if $no_rsa && $dir =~ /^rsaref/;
1076 return("") if $no_dsa && $dir =~ /\/dsa/;
1077 return("") if $no_dh && $dir =~ /\/dh/;
1078 return("") if $no_ec && $dir =~ /\/ec/;
1079 return("") if $no_gost && $dir =~ /\/ccgost/;
1080 return("") if $no_cms && $dir =~ /\/cms/;
1081 return("") if $no_jpake && $dir =~ /\/jpake/;
1082 return("") if !$fips && $dir =~ /^fips/;
1083 if ($no_des && $dir =~ /\/des/)
1085 if ($val =~ /read_pwd/)
1086 { return("$dir/read_pwd "); }
1090 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
1091 return("") if $no_sock && $dir =~ /\/proxy/;
1092 return("") if $no_bf && $dir =~ /\/bf/;
1093 return("") if $no_cast && $dir =~ /\/cast/;
1094 return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
1096 $val =~ s/^\s*(.*)\s*$/$1/;
1097 @a=split(/\s+/,$val);
1098 grep(s/\.[och]$//,@a) unless $keepext;
1100 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
1101 @a=grep(!/^e_.*_d$/,@a) if $no_des;
1102 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
1103 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
1104 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
1105 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
1106 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
1107 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
1108 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
1109 @a=grep(!/^e_camellia$/,@a) if $no_camellia;
1110 @a=grep(!/^e_seed$/,@a) if $no_seed;
1112 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
1113 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
1115 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
1117 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
1118 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
1119 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
1120 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
1122 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
1123 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
1124 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
1126 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
1127 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
1129 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
1131 @a=grep(!/_dhp$/,@a) if $no_dh;
1133 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
1134 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
1135 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
1137 @a=grep(!/(srp)/,@a) if $no_srp;
1139 @a=grep(!/^engine$/,@a) if $no_engine;
1140 @a=grep(!/^hw$/,@a) if $no_hw;
1141 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
1142 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
1143 @a=grep(!/^gendsa$/,@a) if $no_sha1;
1144 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
1146 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
1148 grep($_="$dir/$_",@a);
1149 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
1150 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
1151 $ret=join(' ',@a)." ";
1155 # change things so that each 'token' is only separated by one space
1160 $w =~ s/^\s*(.*)\s*$/$1/;
1167 local($var,$files,$location,$postfix)=@_;
1169 local(*OUT,$tmp,$t);
1171 $files =~ s/\//$o/g if $o ne '/';
1175 foreach (split(/ /,$files))
1178 $_=&bname($_) unless /^\$/;
1184 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
1186 else { $pf=$postfix; }
1187 if ($_ =~ /BN_ASM/) { $t="$_ "; }
1188 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
1189 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
1190 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
1191 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
1192 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
1193 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
1194 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
1195 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
1196 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
1197 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
1198 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
1199 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
1200 else { $t="$location${o}$_$pf "; }
1205 # hack to add version info on MSVC
1206 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
1208 if ($var eq "CRYPTOOBJ")
1209 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
1210 elsif ($var eq "SSLOBJ")
1211 { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
1218 # return the name with the leading path removed
1222 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
1226 # return the leading path
1230 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
1234 ##############################################################
1235 # do a rule for each file that says 'compile' to new direcory
1236 # compile the files in '$files' into $to
1239 local($to,$files,$ex)=@_;
1240 local($ret,$_,$n,$d,$s);
1242 $files =~ s/\//$o/g if $o ne '/';
1243 foreach (split(/\s+/,$files))
1249 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
1251 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
1252 ($s=~s/sha256/sha512/ and -f $s) or
1253 -f ($s="${d}${o}${n}.pl"))
1255 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
1257 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
1258 -f ($s="${d}${o}${n}.S"))
1260 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
1262 elsif (defined &special_compile_target and
1263 ($s=special_compile_target($_)))
1267 else { die "no rule for $_"; }
1272 ##############################################################
1273 # do a rule for each file that says 'compile' to new direcory
1274 sub perlasm_compile_target
1276 my($target,$source,$bname)=@_;
1278 return platform_perlasm_compile_target($target, $source, $bname)
1279 if defined &platform_perlasm_compile_target;
1282 $bname =~ s/(.*)\.[^\.]$/$1/;
1283 $ret ="\$(TMP_D)$o$bname$asm_suffix: $source\n";
1284 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
1285 if ($fipscanisteronly)
1287 $ret .= "\t\$(PERL) util$o.pl . \$@ norunasm \$(CFLAG)\n";
1290 $ret.="$target: \$(TMP_D)$o$bname$asm_suffix\n";
1291 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname$asm_suffix\n\n";
1295 sub Sasm_compile_target
1297 my($target,$source,$bname)=@_;
1300 $bname =~ s/(.*)\.[^\.]$/$1/;
1301 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
1302 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n";
1303 $ret.="\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n" if $fipscanisteronly;
1305 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
1306 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
1310 sub cc_compile_target
1312 local($target,$source,$ex_flags)=@_;
1315 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
1316 $target =~ s/\//$o/g if $o ne "/";
1317 $source =~ s/\//$o/g if $o ne "/";
1318 $ret ="$target: \$(SRC_D)$o$source\n\t";
1320 $ret.= " -MMD" if $orig_platform eq "copy";
1321 $ret.= " ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
1322 $target =~ s/\.o$/.d/;
1323 $ret.=".sinclude \"$target\"\n\n" if $orig_platform eq "copy";
1327 ##############################################################
1330 local($target,$src)=@_;
1331 local($ret,@s,@t,$i);
1333 $target =~ s/\//$o/g if $o ne "/";
1334 $src =~ s/\//$o/g if $o ne "/";
1336 @t=split(/\s+/,$target);
1337 @s=split(/\s+/,$src);
1340 for ($i=0; $i<=$#s; $i++)
1342 my $objfile = $t[$i];
1343 my $srcfile = $s[$i];
1347 my $plasm = $objfile;
1348 $plasm =~ s/${obj}/.pl/;
1349 $ret.="$srcfile: $plasm\n";
1350 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
1353 $ret.="$objfile: $srcfile\n";
1354 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
1365 ($nn=$n) =~ tr/a-z/A-Z/;
1366 $ret.="$n.dll: \$(${nn}OBJ)\n";
1369 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
1375 # do a rule for each file that says 'copy' to new direcory on change
1378 local($to,$files,$p)=@_;
1379 local($ret,$_,$n,$pp);
1381 $files =~ s/\//$o/g if $o ne '/';
1382 foreach (split(/\s+/,$files))
1385 if ($n =~ /bss_file/)
1388 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(PERL) \$(SRC_D)${o}util${o}copy-if-different.pl \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
1395 # Many options are handled in a similar way. In particular
1396 # no-xxx sets zero or more scalars to 1.
1397 # Process these using a hash containing the option name and
1398 # reference to the scalars to set.
1400 my %valid_options = (
1401 "no-rc2" => \$no_rc2,
1402 "no-rc4" => \$no_rc4,
1403 "no-rc5" => \$no_rc5,
1404 "no-idea" => \$no_idea,
1405 "no-aes" => \$no_aes,
1406 "no-camellia" => \$no_camellia,
1407 "no-seed" => \$no_seed,
1408 "no-des" => \$no_des,
1410 "no-cast" => \$no_cast,
1411 "no-md2" => \$no_md2,
1412 "no-md4" => \$no_md4,
1413 "no-md5" => \$no_md5,
1414 "no-sha" => \$no_sha,
1415 "no-sha1" => \$no_sha1,
1416 "no-ripemd" => \$no_ripemd,
1417 "no-mdc2" => \$no_mdc2,
1418 "no-whirlpool" => \$no_whirlpool,
1420 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1421 "no-rsa" => \$no_rsa,
1422 "no-dsa" => \$no_dsa,
1424 "no-hmac" => \$no_hmac,
1425 "no-asm" => \$no_asm,
1427 "nw-nasm" => \$nw_nasm,
1428 "nw-mwasm" => \$nw_mwasm,
1429 "gaswin" => \$gaswin,
1430 "no-ssl2" => \$no_ssl2,
1431 "no-ssl3" => \$no_ssl3,
1432 "no-tlsext" => \$no_tlsext,
1433 "no-srp" => \$no_srp,
1434 "no-cms" => \$no_cms,
1435 "no-jpake" => \$no_jpake,
1436 "no-ec2m" => \$no_ec2m,
1437 "no-ec_nistp_64_gcc_128" => 0,
1438 "no-err" => \$no_err,
1439 "no-sock" => \$no_sock,
1440 "no-krb5" => \$no_krb5,
1442 "no-ecdsa" => \$no_ecdsa,
1443 "no-ecdh" => \$no_ecdh,
1444 "no-gost" => \$no_gost,
1445 "no-engine" => \$no_engine,
1448 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
1449 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
1450 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
1451 \$no_aes, \$no_camellia, \$no_seed, \$no_srp],
1455 "profile" => \$profile,
1466 "no-zlib-dynamic" => 0,
1467 "no-ssl-trace" => 0,
1469 "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
1470 "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
1471 "fipscheck" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
1474 if (exists $valid_options{$_})
1476 my $r = $valid_options{$_};
1477 if ( ref $r eq "SCALAR")
1479 elsif ( ref $r eq "ARRAY")
1488 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
1489 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1490 elsif (/^enable-zlib-dynamic$/)
1494 elsif (/^no-static-engine/)
1496 $no_static_engine = 1;
1498 elsif (/^enable-static-engine/)
1500 $no_static_engine = 0;
1502 # There are also enable-xxx options which correspond to
1503 # the no-xxx. Since the scalars are enabled by default
1504 # these can be ignored.
1508 $t =~ s/^enable/no/;
1509 if (exists $valid_options{$t})
1513 # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1514 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1515 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1516 elsif (/^experimental-/)
1519 ($algo = $_) =~ s/^experimental-//;
1520 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1522 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1525 elsif (/^--with-krb5-flavor=(.*)$/)
1527 my $krb5_flavor = $1;
1528 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1530 $xcflags="-DKRB5_HEIMDAL $xcflags";
1532 elsif ($krb5_flavor =~ /^MIT/i)
1534 $xcflags="-DKRB5_MIT $xcflags";
1535 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1537 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1541 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1542 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
1543 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1544 { $c_flags.="$_ "; }
1551 print STDERR "***FIPS module directory sanity check failed***\n";
1552 print STDERR "FIPS module build failed, or was deleted\n";
1553 print STDERR "Please rebuild FIPS module.\n";
1557 sub fips_check_files
1563 print STDERR "FIPS module directory $dir does not exist\n";
1568 if (!-f "$dir${o}$_")
1570 print STDERR "FIPS module file $_ does not exist!\n";
1574 fipslib_error() if ($ret == 0);