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;
17 local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
19 local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
23 # Options to import from top level Makefile
26 VERSION => \$ssl_version,
28 INSTALLTOP => \$INSTALLTOP,
29 OPENSSLDIR => \$OPENSSLDIR,
30 PLATFORM => \$mf_platform,
32 DEPFLAG => \$mf_depflag,
33 CPUID_OBJ => \$mf_cpuid_asm,
34 BN_ASM => \$mf_bn_asm,
35 DES_ENC => \$mf_des_asm,
36 AES_ENC => \$mf_aes_asm,
37 BF_ENC => \$mf_bf_asm,
38 CAST_ENC => \$mf_cast_asm,
39 RC4_ENC => \$mf_rc4_asm,
40 RC5_ENC => \$mf_rc5_asm,
41 MD5_ASM_OBJ => \$mf_md5_asm,
42 SHA1_ASM_OBJ => \$mf_sha_asm,
43 RMD160_ASM_OBJ => \$mf_rmd_asm,
44 WP_ASM_OBJ => \$mf_wp_asm,
45 CMLL_ENC => \$mf_cm_asm,
46 BASEADDR => \$baseaddr,
51 open(IN,"<Makefile") || die "unable to open Makefile!\n";
53 my ($mf_opt, $mf_ref);
54 while (($mf_opt, $mf_ref) = each %mf_import) {
55 if (/^$mf_opt\s*=\s*(.*)$/) {
62 $fipsdir =~ tr/\\/\//;
63 $debug = 1 if $mf_platform =~ /^debug-/;
65 die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
70 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
71 "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
72 "VC-WIN64A", "Microsoft C/C++ - Win64/x64",
73 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
74 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
75 "Mingw32", "GNU C++ - Windows NT or 9x",
76 "Mingw32-files", "Create files with DOS copy ...",
77 "BC-NT", "Borland C++ 4.5 - Windows NT",
78 "linux-elf","Linux elf",
79 "ultrix-mips","DEC mips ultrix",
80 "FreeBSD","FreeBSD distribution",
81 "OS2-EMX", "EMX GCC OS/2",
82 "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
83 "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
84 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
85 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
86 "default","cc under unix",
87 "auto", "auto detect from top level Makefile"
94 if (!&read_options && !defined($ops{$_}))
96 print STDERR "unknown option - $_\n";
97 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
98 print STDERR "\nwhere [system] can be one of the following\n";
99 foreach $i (sort keys %ops)
100 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
101 print STDERR <<"EOF";
102 and [options] can be one of
103 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
105 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
106 no-bf no-cast no-aes no-camellia no-seed
107 no-rsa no-dsa no-dh - Skip this public key cipher
108 no-ssl2 no-ssl3 - Skip this version of SSL
109 just-ssl - remove all non-ssl keys/digest
116 no-engine - No engine
118 nasm - Use NASM for x86 asm
119 nw-nasm - Use NASM x86 asm for NetWare
120 nw-mwasm - Use Metrowerks x86 asm for NetWare
121 gaswin - Use GNU as with Mingw32
122 no-socks - No socket code
123 no-err - No error strings
124 dll/shlib - Build shared libraries (MS)
126 profile - Profiling build
129 Values that can be set
130 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
132 -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
133 -<ex_cc_flags> - extra 'cc' flags,
134 added (MS), or replace (unix)
140 foreach (grep(!/^$/, split(/ /, $OPTIONS)))
142 print STDERR "unknown option - $_\n" if !&read_options;
145 $no_static_engine = 0 if (!$shlib);
147 $no_mdc2=1 if ($no_des);
149 $no_ssl3=1 if ($no_md5 || $no_sha);
150 $no_ssl3=1 if ($no_rsa && $no_dh);
152 $no_ssl2=1 if ($no_md5);
153 $no_ssl2=1 if ($no_rsa);
159 $perl="perl" unless defined $perl;
160 $mkdir="-mkdir" unless defined $mkdir;
162 ($ssl,$crypto)=("ssl","crypto");
163 $ranlib="echo ranlib";
165 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
166 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
167 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
169 # $bin_dir.=$o causes a core dump on my sparc :-(
174 push(@INC,"util/pl","pl");
176 if ($platform eq "auto") {
177 $platform = $mf_platform;
178 print STDERR "Imported platform $mf_platform\n";
181 if (($platform =~ /VC-(.+)/))
184 $NT = 1 if $1 eq "NT";
187 elsif ($platform eq "Mingw32")
189 require 'Mingw32.pl';
191 elsif ($platform eq "Mingw32-files")
193 require 'Mingw32f.pl';
195 elsif ($platform eq "BC-NT")
200 elsif ($platform eq "FreeBSD")
203 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
205 elsif ($platform eq "linux-elf")
211 elsif ($platform eq "ultrix-mips")
217 elsif ($platform eq "OS2-EMX")
220 require 'OS2-EMX.pl';
222 elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
223 ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
225 $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
226 $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
227 require 'netware.pl';
234 $cflags.=' -DTERMIO';
237 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
238 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
239 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
241 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
243 $cflags= "$xcflags$cflags" if $xcflags ne "";
245 $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
246 $cflags.=" -DOPENSSL_NO_AES" if $no_aes;
247 $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia;
248 $cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
249 $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
250 $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
251 $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
252 $cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
253 $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
254 $cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
255 $cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
256 $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
257 $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
258 $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
259 $cflags.=" -DOPENSSL_NO_BF" if $no_bf;
260 $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
261 $cflags.=" -DOPENSSL_NO_DES" if $no_des;
262 $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
263 $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
264 $cflags.=" -DOPENSSL_NO_DH" if $no_dh;
265 $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
266 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
267 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
268 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
269 $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
270 $cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
271 $cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
272 $cflags.=" -DOPENSSL_NO_ERR" if $no_err;
273 $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
274 $cflags.=" -DOPENSSL_NO_EC" if $no_ec;
275 $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
276 $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
277 $cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
278 $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
279 $cflags.=" -DOPENSSL_NO_HW" if $no_hw;
280 $cflags.=" -DOPENSSL_FIPS" if $fips;
281 $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
282 $cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m;
283 $cflags.= " -DZLIB" if $zlib_opt;
284 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
286 if ($no_static_engine)
288 $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
292 $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
295 #$cflags.=" -DRSAref" if $rsaref ne "";
298 ## { $cflags="$c_flags" if ($c_flags ne ""); }
300 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
302 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
305 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
306 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
310 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
311 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
312 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
313 $banner.="\t\@echo documentation for details.\n";
316 # have to do this to allow $(CC) under unix
317 $link="$bin_dir$link" if ($link !~ /^\$/);
319 $INSTALLTOP =~ s|/|$o|g;
320 $OPENSSLDIR =~ s|/|$o|g;
322 #############################################
323 # We parse in input file and 'store' info for later printing.
324 open(IN,"<$infile") || die "unable to open $infile:$!\n";
330 ($key,$val)=/^([^=]+)=(.*)/;
331 if ($key eq "RELATIVE_DIRECTORY")
336 $uc =~ s/^lib(.*)\.a/$1/;
339 $lib_obj{$uc}.=$libobj." ";
341 last if ($val eq "FINISHED");
347 if ($key eq "KRB5_INCLUDES")
348 { $cflags .= " $val";}
350 if ($key eq "ZLIB_INCLUDE")
351 { $cflags .= " $val" if $val ne "";}
353 if ($key eq "LIBZLIB")
354 { $zlib_lib = "$val" if $val ne "";}
356 if ($key eq "LIBKRB5")
357 { $ex_libs .= " $val" if $val ne "";}
360 { $test.=&var_add($dir,$val, 0); }
362 if (($key eq "PROGS") || ($key eq "E_OBJ"))
363 { $e_exe.=&var_add($dir,$val, 0); }
368 $lib =~ s/^.*\/([^\/]+)$/$1/;
370 if ($key eq "LIBNAME" && $no_static_engine)
373 $lib =~ s/^.*\/([^\/]+)$/$1/;
374 $otherlibs .= " $lib";
377 if ($key eq "EXHEADER")
378 { $exheader.=&var_add($dir,$val, 1); }
380 if ($key eq "HEADER")
381 { $header.=&var_add($dir,$val, 1); }
383 if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine))
384 { $libobj=&var_add($dir,$val, 0); }
385 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
389 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
395 $extra_install= <<"EOF";
396 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
397 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
398 \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
399 \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
401 if ($no_static_engine)
403 $extra_install .= <<"EOF"
404 \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
405 \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
411 $extra_install= <<"EOF";
412 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
413 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
415 $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
418 $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
419 $ex_l_libs .= " \$(O_FIPSCANISTER)";
424 # This makefile has been automatically generated from the OpenSSL distribution.
425 # This single makefile will build the complete OpenSSL distribution and
426 # by default leave the 'intertesting' output files in .${o}out and the stuff
427 # that needs deleting in .${o}tmp.
428 # The file was generated by running 'make makefile.one', which
429 # does a 'make files', which writes all the environment variables from all
430 # the makefiles to the file call MINFO. This file is used by
431 # util${o}mk1mf.pl to generate makefile.one.
432 # The 'makefile per directory' system suites me when developing this
433 # library and also so I can 'distribute' indervidual library sections.
434 # The one monster makefile better suits building in non-unix
439 $defs .= $preamble if defined $preamble;
442 INSTALLTOP=$INSTALLTOP
443 OPENSSLDIR=$OPENSSLDIR
445 # Set your compiler options
451 SHLIB_CFLAG=$shl_cflag
452 APP_EX_OBJ=$app_ex_obj
453 SHLIB_EX_OBJ=$shlib_ex_obj
454 # add extra libraries to this define, for solaris -lsocket -lnsl would
458 # The OpenSSL directory
465 # The output directory for everything intersting
467 # The output directory for all the temporary muck
469 # The output directory for the header files
471 INCO_D=$inc_dir${o}openssl
482 # FIPS validated module and support file locations
486 FIPSLIB_D=\$(FIPSDIR)lib
487 FIPS_PREMAIN_SRC=\$(FIPSLIB_D)${o}fips_premain.c
488 O_FIPSCANISTER=\$(FIPSLIB_D)${o}fipscanister.lib
489 FIPS_SHA1_EXE=\$(FIPSDIR)bin${o}fips_standalone_sha1${exep}
490 E_PREMAIN_DSO=fips_premain_dso
491 PREMAIN_DSO_EXE=\$(BIN_D)${o}fips_premain_dso$exep
492 FIPSLINK=\$(PERL) \$(FIPSDIR)bin${o}fipslink.pl
494 ######################################################
495 # You should not need to touch anything below this point
496 ######################################################
502 # BIN_D - Binary output directory
503 # TEST_D - Binary test file output directory
504 # LIB_D - library output directory
505 # ENG_D - dynamic engine output directory
506 # Note: if you change these point to different directories then uncomment out
507 # the lines around the 'NB' comment below.
514 # INCL_D - local library directory
515 # OBJ_D - temp object file directory
519 O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
520 O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
521 SO_SSL= $plib\$(SSL)$so_shlibp
522 SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
523 L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
524 L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
526 L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
528 ######################################################
529 # Don't touch anything below this point
530 ######################################################
532 INC=-I\$(INC_D) -I\$(INCL_D)
533 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
534 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
535 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
536 LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
538 #############################################
542 all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe $build_targets
548 \$(MKDIR) \"\$(TMP_D)\"
549 # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
551 # \$(MKDIR) \$(BIN_D)
554 # \$(MKDIR) \$(TEST_D)
557 \$(MKDIR) \"\$(LIB_D)\"
559 \$(INCO_D): \$(INC_D)
560 \$(MKDIR) \"\$(INCO_D)\"
563 \$(MKDIR) \"\$(INC_D)\"
565 headers: \$(HEADER) \$(EXHEADER)
568 lib: \$(LIBS_DEP) \$(E_SHLIB)
570 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
573 \$(MKDIR) \"\$(INSTALLTOP)\"
574 \$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
575 \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
576 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
577 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
578 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
579 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
580 \$(MKDIR) \"\$(OPENSSLDIR)\"
581 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
590 \$(RM) \$(TMP_D)$o*.*
593 \$(RM) \$(TMP_D)$o*.*
594 \$(RM) \$(OUT_D)$o*.*
598 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
599 $platform_cpp_symbol =~ s/-/_/g;
600 if (open(IN,"crypto/buildinf.h"))
602 # Remove entry for this platform in existing file buildinf.h.
604 my $old_buildinf_h = "";
607 if (/^\#ifdef $platform_cpp_symbol$/)
609 while (<IN>) { last if (/^\#endif/); }
613 $old_buildinf_h .= $_;
618 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
619 print OUT $old_buildinf_h;
623 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
625 #ifdef $platform_cpp_symbol
626 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
627 #define CFLAGS "$cc $cflags"
628 #define PLATFORM "$platform"
630 printf OUT " #define DATE \"%s\"\n", scalar gmtime();
631 printf OUT "#endif\n";
634 # Strip of trailing ' '
635 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
636 $test=&clean_up_ws($test);
637 $e_exe=&clean_up_ws($e_exe);
638 $exheader=&clean_up_ws($exheader);
639 $header=&clean_up_ws($header);
641 # First we strip the exheaders from the headers list
642 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
643 foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
644 chop($h); $header=$h;
646 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
647 $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
649 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
650 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
652 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
653 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
655 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
656 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
658 # Special case rule for fips_premain_dso
662 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
663 "\$(FIPS_PREMAIN_SRC)",
664 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)", "");
665 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
668 foreach (values %lib_nam)
670 $lib_obj=$lib_obj{$_};
673 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
675 $rules.="\$(O_SSL):\n\n";
679 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
680 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
681 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
684 # hack to add version info on MSVC
685 if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
686 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
688 \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
689 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
691 \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
692 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
697 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
698 foreach (split(/\s+/,$test))
701 $tt="\$(OBJ_D)${o}$t${obj}";
702 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
705 $defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp);
707 foreach (split(/\s+/,$engines))
709 $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
710 $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
715 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
721 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
722 "\$(O_CRYPTO)", "$crypto",
723 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
727 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
728 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
729 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
730 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
735 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
739 foreach (split(" ",$otherlibs))
743 $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, "");
747 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
751 if ($platform eq "linux-elf") {
753 # Generate perlasm output files
755 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
758 print "###################################################################\n";
761 ###############################################
762 # strip off any trailing .[och] and append the relative directory
763 # also remembering to do nothing if we are in one of the dropped
767 local($dir,$val,$keepext)=@_;
770 return("") if $no_engine && $dir =~ /\/engine/;
771 return("") if $no_hw && $dir =~ /\/hw/;
772 return("") if $no_idea && $dir =~ /\/idea/;
773 return("") if $no_aes && $dir =~ /\/aes/;
774 return("") if $no_camellia && $dir =~ /\/camellia/;
775 return("") if $no_seed && $dir =~ /\/seed/;
776 return("") if $no_rc2 && $dir =~ /\/rc2/;
777 return("") if $no_rc4 && $dir =~ /\/rc4/;
778 return("") if $no_rc5 && $dir =~ /\/rc5/;
779 return("") if $no_rsa && $dir =~ /\/rsa/;
780 return("") if $no_rsa && $dir =~ /^rsaref/;
781 return("") if $no_dsa && $dir =~ /\/dsa/;
782 return("") if $no_dh && $dir =~ /\/dh/;
783 return("") if $no_ec && $dir =~ /\/ec/;
784 return("") if $no_gost && $dir =~ /\/ccgost/;
785 return("") if $no_cms && $dir =~ /\/cms/;
786 return("") if $no_jpake && $dir =~ /\/jpake/;
787 if ($no_des && $dir =~ /\/des/)
789 if ($val =~ /read_pwd/)
790 { return("$dir/read_pwd "); }
794 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
795 return("") if $no_sock && $dir =~ /\/proxy/;
796 return("") if $no_bf && $dir =~ /\/bf/;
797 return("") if $no_cast && $dir =~ /\/cast/;
798 return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
800 $val =~ s/^\s*(.*)\s*$/$1/;
801 @a=split(/\s+/,$val);
802 grep(s/\.[och]$//,@a) unless $keepext;
804 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
805 @a=grep(!/^e_.*_d$/,@a) if $no_des;
806 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
807 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
808 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
809 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
810 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
811 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
812 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
813 @a=grep(!/^e_camellia$/,@a) if $no_camellia;
814 @a=grep(!/^e_seed$/,@a) if $no_seed;
816 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
817 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
819 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
821 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
822 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
823 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
824 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
826 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
827 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
828 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
830 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
831 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
833 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
835 @a=grep(!/_dhp$/,@a) if $no_dh;
837 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
838 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
839 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
841 @a=grep(!/(srp)/,@a) if $no_srp;
843 @a=grep(!/^engine$/,@a) if $no_engine;
844 @a=grep(!/^hw$/,@a) if $no_hw;
845 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
846 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
847 @a=grep(!/^gendsa$/,@a) if $no_sha1;
848 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
850 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
852 grep($_="$dir/$_",@a);
853 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
854 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
855 $ret=join(' ',@a)." ";
859 # change things so that each 'token' is only separated by one space
864 $w =~ s/^\s*(.*)\s*$/$1/;
871 local($var,$files,$location,$postfix)=@_;
875 $files =~ s/\//$o/g if $o ne '/';
879 foreach (split(/ /,$files))
882 $_=&bname($_) unless /^\$/;
888 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
890 else { $pf=$postfix; }
891 if ($_ =~ /BN_ASM/) { $t="$_ "; }
892 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
893 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
894 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
895 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
896 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
897 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
898 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
899 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
900 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
901 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
902 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
903 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
904 else { $t="$location${o}$_$pf "; }
909 # hack to add version info on MSVC
910 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
912 if ($var eq "CRYPTOOBJ")
913 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
914 elsif ($var eq "SSLOBJ")
915 { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
922 # return the name with the leading path removed
926 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
930 # return the leading path
934 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
938 ##############################################################
939 # do a rule for each file that says 'compile' to new direcory
940 # compile the files in '$files' into $to
943 local($to,$files,$ex)=@_;
944 local($ret,$_,$n,$d,$s);
946 $files =~ s/\//$o/g if $o ne '/';
947 foreach (split(/\s+/,$files))
953 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
955 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
956 ($s=~s/sha256/sha512/ and -f $s) or
957 -f ($s="${d}${o}${n}.pl"))
959 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
961 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
962 -f ($s="${d}${o}${n}.S"))
964 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
966 else { die "no rule for $_"; }
971 ##############################################################
972 # do a rule for each file that says 'compile' to new direcory
973 sub perlasm_compile_target
975 my($target,$source,$bname)=@_;
978 $bname =~ s/(.*)\.[^\.]$/$1/;
979 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
980 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
981 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
982 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
986 sub Sasm_compile_target
988 my($target,$source,$bname)=@_;
991 $bname =~ s/(.*)\.[^\.]$/$1/;
992 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
993 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n";
994 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
995 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
999 sub cc_compile_target
1001 local($target,$source,$ex_flags, $srcd)=@_;
1004 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
1005 $target =~ s/\//$o/g if $o ne "/";
1006 $source =~ s/\//$o/g if $o ne "/";
1007 $srcd = "\$(SRC_D)$o" unless defined $srcd;
1008 $ret ="$target: $srcd$source\n\t";
1009 $ret.="\$(CC) ${ofile}$target $ex_flags -c $srcd$source\n\n";
1013 ##############################################################
1016 local($target,$src)=@_;
1017 local($ret,@s,@t,$i);
1019 $target =~ s/\//$o/g if $o ne "/";
1020 $src =~ s/\//$o/g if $o ne "/";
1022 @t=split(/\s+/,$target);
1023 @s=split(/\s+/,$src);
1026 for ($i=0; $i<=$#s; $i++)
1028 my $objfile = $t[$i];
1029 my $srcfile = $s[$i];
1033 my $plasm = $objfile;
1034 $plasm =~ s/${obj}/.pl/;
1035 $ret.="$srcfile: $plasm\n";
1036 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
1039 $ret.="$objfile: $srcfile\n";
1040 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
1051 ($nn=$n) =~ tr/a-z/A-Z/;
1052 $ret.="$n.dll: \$(${nn}OBJ)\n";
1055 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
1061 # do a rule for each file that says 'copy' to new direcory on change
1064 local($to,$files,$p)=@_;
1065 local($ret,$_,$n,$pp);
1067 $files =~ s/\//$o/g if $o ne '/';
1068 foreach (split(/\s+/,$files))
1071 if ($n =~ /bss_file/)
1074 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
1081 # Many options are handled in a similar way. In particular
1082 # no-xxx sets zero or more scalars to 1.
1083 # Process these using a hash containing the option name and
1084 # reference to the scalars to set.
1086 my %valid_options = (
1087 "no-rc2" => \$no_rc2,
1088 "no-rc4" => \$no_rc4,
1089 "no-rc5" => \$no_rc5,
1090 "no-idea" => \$no_idea,
1091 "no-aes" => \$no_aes,
1092 "no-camellia" => \$no_camellia,
1093 "no-seed" => \$no_seed,
1094 "no-des" => \$no_des,
1096 "no-cast" => \$no_cast,
1097 "no-md2" => \$no_md2,
1098 "no-md4" => \$no_md4,
1099 "no-md5" => \$no_md5,
1100 "no-sha" => \$no_sha,
1101 "no-sha1" => \$no_sha1,
1102 "no-ripemd" => \$no_ripemd,
1103 "no-mdc2" => \$no_mdc2,
1104 "no-whirlpool" => \$no_whirlpool,
1106 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1107 "no-rsa" => \$no_rsa,
1108 "no-dsa" => \$no_dsa,
1110 "no-hmac" => \$no_hmac,
1111 "no-asm" => \$no_asm,
1113 "nw-nasm" => \$nw_nasm,
1114 "nw-mwasm" => \$nw_mwasm,
1115 "gaswin" => \$gaswin,
1116 "no-ssl2" => \$no_ssl2,
1117 "no-ssl3" => \$no_ssl3,
1118 "no-tlsext" => \$no_tlsext,
1119 "no-srp" => \$no_srp,
1120 "no-cms" => \$no_cms,
1121 "no-ec2m" => \$no_ec2m,
1122 "no-jpake" => \$no_jpake,
1123 "no-ec-nistp224-64-gcc-128" => 0,
1124 "no-err" => \$no_err,
1125 "no-sock" => \$no_sock,
1126 "no-krb5" => \$no_krb5,
1128 "no-ecdsa" => \$no_ecdsa,
1129 "no-ecdh" => \$no_ecdh,
1130 "no-gost" => \$no_gost,
1131 "no-engine" => \$no_engine,
1134 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
1135 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
1136 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
1137 \$no_aes, \$no_camellia, \$no_seed, \$no_srp],
1141 "profile" => \$profile,
1151 "no-zlib-dynamic" => 0,
1155 if (exists $valid_options{$_})
1157 my $r = $valid_options{$_};
1158 if ( ref $r eq "SCALAR")
1160 elsif ( ref $r eq "ARRAY")
1169 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
1170 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1171 elsif (/^enable-zlib-dynamic$/)
1175 elsif (/^no-static-engine/)
1177 $no_static_engine = 1;
1179 elsif (/^enable-static-engine/)
1181 $no_static_engine = 0;
1183 # There are also enable-xxx options which correspond to
1184 # the no-xxx. Since the scalars are enabled by default
1185 # these can be ignored.
1189 $t =~ s/^enable/no/;
1190 if (exists $valid_options{$t})
1194 # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1195 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1196 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1197 elsif (/^experimental-/)
1200 ($algo = $_) =~ s/^experimental-//;
1201 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1203 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1206 elsif (/^--with-krb5-flavor=(.*)$/)
1208 my $krb5_flavor = $1;
1209 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1211 $xcflags="-DKRB5_HEIMDAL $xcflags";
1213 elsif ($krb5_flavor =~ /^MIT/i)
1215 $xcflags="-DKRB5_MIT $xcflags";
1216 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1218 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1222 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1223 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
1224 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1225 { $c_flags.="$_ "; }