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";
11 $banner="\t\@echo Building OpenSSL";
13 open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
15 $ssl_version=$1 if (/^VERSION=(.*)$/);
16 $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
17 $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
21 die "Makefile.ssl is not the toplevel Makefile!\n" if $ssl_version eq "";
26 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
27 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
28 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
29 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
30 "VC-WIN16", "Alias for VC-W31-32",
31 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+",
32 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS",
33 "Mingw32", "GNU C++ - Windows NT or 9x",
34 "Mingw32-files", "Create files with DOS copy ...",
35 "BC-NT", "Borland C++ 4.5 - Windows NT",
36 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING",
37 "BC-MSDOS","Borland C++ 4.5 - MSDOS",
38 "linux-elf","Linux elf",
39 "ultrix-mips","DEC mips ultrix",
40 "FreeBSD","FreeBSD distribution",
41 "OS2-EMX", "EMX GCC OS/2",
42 "default","cc under unix",
48 if (!&read_options && !defined($ops{$_}))
50 print STDERR "unknown option - $_\n";
51 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
52 print STDERR "\nwhere [system] can be one of the following\n";
53 foreach $i (sort keys %ops)
54 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
56 and [options] can be one of
57 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
59 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
61 no-rsa no-dsa no-dh - Skip this public key cipher
62 no-ssl2 no-ssl3 - Skip this version of SSL
63 just-ssl - remove all non-ssl keys/digest
67 nasm - Use NASM for x86 asm
68 gaswin - Use GNU as with Mingw32
69 no-socks - No socket code
70 no-err - No error strings
71 dll/shlib - Build shared libraries (MS)
73 profile - Profiling build
76 Values that can be set
77 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
79 -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
80 -<ex_cc_flags> - extra 'cc' flags,
81 added (MS), or replace (unix)
87 foreach (grep(!/^$/, split(/ /, $OPTIONS)))
89 print STDERR "unknown option - $_\n" if !&read_options;
92 $no_mdc2=1 if ($no_des);
94 $no_ssl3=1 if ($no_md5 || $no_sha);
95 $no_ssl3=1 if ($no_rsa && $no_dh);
97 $no_ssl2=1 if ($no_md5);
98 $no_ssl2=1 if ($no_rsa);
106 ($ssl,$crypto)=("ssl","crypto");
107 $ranlib="echo ranlib";
109 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
110 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
111 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
113 # $bin_dir.=$o causes a core dump on my sparc :-(
117 push(@INC,"util/pl","pl");
118 if ($platform eq "VC-MSDOS")
124 elsif ($platform eq "VC-W31-16")
130 elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16"))
136 elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
138 $NT = 1 if $platform eq "VC-NT";
141 elsif ($platform eq "VC-CE")
145 elsif ($platform eq "Mingw32")
147 require 'Mingw32.pl';
149 elsif ($platform eq "Mingw32-files")
151 require 'Mingw32f.pl';
153 elsif ($platform eq "BC-NT")
158 elsif ($platform eq "BC-W31")
164 elsif ($platform eq "BC-Q16")
166 $msdos=1; $w16=1; $shlib=0; $qw=1;
169 elsif ($platform eq "BC-MSDOS")
175 elsif ($platform eq "FreeBSD")
178 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
180 elsif ($platform eq "linux-elf")
186 elsif ($platform eq "ultrix-mips")
192 elsif ($platform eq "OS2-EMX")
195 require 'OS2-EMX.pl';
202 $cflags.=' -DTERMIO';
205 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
206 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
207 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
209 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
211 $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
212 $cflags.=" -DOPENSSL_NO_AES" if $no_aes;
213 $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
214 $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
215 $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
216 $cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
217 $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
218 $cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
219 $cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
220 $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
221 $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_rmd160;
222 $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
223 $cflags.=" -DOPENSSL_NO_BF" if $no_bf;
224 $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
225 $cflags.=" -DOPENSSL_NO_DES" if $no_des;
226 $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
227 $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
228 $cflags.=" -DOPENSSL_NO_DH" if $no_dh;
229 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
230 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
231 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
232 $cflags.=" -DOPENSSL_NO_ERR" if $no_err;
233 $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
234 $cflags.=" -DOPENSSL_NO_EC" if $no_ec;
235 #$cflags.=" -DRSAref" if $rsaref ne "";
238 ## { $cflags="$c_flags" if ($c_flags ne ""); }
240 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
242 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
244 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
245 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
249 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
250 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
251 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
252 $banner.="\t\@echo documentation for details.\n";
255 # have to do this to allow $(CC) under unix
256 $link="$bin_dir$link" if ($link !~ /^\$/);
258 $INSTALLTOP =~ s|/|$o|g;
261 # This makefile has been automatically generated from the OpenSSL distribution.
262 # This single makefile will build the complete OpenSSL distribution and
263 # by default leave the 'intertesting' output files in .${o}out and the stuff
264 # that needs deleting in .${o}tmp.
265 # The file was generated by running 'make makefile.one', which
266 # does a 'make files', which writes all the environment variables from all
267 # the makefiles to the file call MINFO. This file is used by
268 # util${o}mk1mf.pl to generate makefile.one.
269 # The 'makefile per directory' system suites me when developing this
270 # library and also so I can 'distribute' indervidual library sections.
271 # The one monster makefile better suits building in non-unix
276 if ($platform eq "VC-CE")
279 !INCLUDE <\$(WCECOMPAT)/wcedefs.mak>
285 INSTALLTOP=$INSTALLTOP
287 # Set your compiler options
293 SHLIB_CFLAG=$shl_cflag
294 APP_EX_OBJ=$app_ex_obj
295 SHLIB_EX_OBJ=$shlib_ex_obj
296 # add extra libraries to this define, for solaris -lsocket -lnsl would
300 # The OpenSSL directory
306 BN_ASM_OBJ=$bn_asm_obj
307 BN_ASM_SRC=$bn_asm_src
308 BNCO_ASM_OBJ=$bnco_asm_obj
309 BNCO_ASM_SRC=$bnco_asm_src
310 DES_ENC_OBJ=$des_enc_obj
311 DES_ENC_SRC=$des_enc_src
312 BF_ENC_OBJ=$bf_enc_obj
313 BF_ENC_SRC=$bf_enc_src
314 CAST_ENC_OBJ=$cast_enc_obj
315 CAST_ENC_SRC=$cast_enc_src
316 RC4_ENC_OBJ=$rc4_enc_obj
317 RC4_ENC_SRC=$rc4_enc_src
318 RC5_ENC_OBJ=$rc5_enc_obj
319 RC5_ENC_SRC=$rc5_enc_src
320 MD5_ASM_OBJ=$md5_asm_obj
321 MD5_ASM_SRC=$md5_asm_src
322 SHA1_ASM_OBJ=$sha1_asm_obj
323 SHA1_ASM_SRC=$sha1_asm_src
324 RMD160_ASM_OBJ=$rmd160_asm_obj
325 RMD160_ASM_SRC=$rmd160_asm_src
327 # The output directory for everything intersting
329 # The output directory for all the temporary muck
331 # The output directory for the header files
333 INCO_D=$inc_dir${o}openssl
343 ######################################################
344 # You should not need to touch anything below this point
345 ######################################################
351 # BIN_D - Binary output directory
352 # TEST_D - Binary test file output directory
353 # LIB_D - library output directory
354 # Note: if you change these point to different directories then uncomment out
355 # the lines around the 'NB' comment below.
361 # INCL_D - local library directory
362 # OBJ_D - temp object file directory
366 O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
367 O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
368 SO_SSL= $plib\$(SSL)$so_shlibp
369 SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
370 L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
371 L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
373 L_LIBS= \$(L_SSL) \$(L_CRYPTO)
375 ######################################################
376 # Don't touch anything below this point
377 ######################################################
379 INC=-I\$(INC_D) -I\$(INCL_D)
380 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
381 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
382 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
383 LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
385 #############################################
389 all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
396 # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
398 # \$(MKDIR) \$(BIN_D)
401 # \$(MKDIR) \$(TEST_D)
406 \$(INCO_D): \$(INC_D)
412 headers: \$(HEADER) \$(EXHEADER)
417 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
420 \$(MKDIR) \$(INSTALLTOP)
421 \$(MKDIR) \$(INSTALLTOP)${o}bin
422 \$(MKDIR) \$(INSTALLTOP)${o}include
423 \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
424 \$(MKDIR) \$(INSTALLTOP)${o}lib
425 \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
426 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
427 \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
428 \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
431 \$(RM) \$(TMP_D)$o*.*
434 \$(RM) \$(TMP_D)$o*.*
435 \$(RM) \$(OUT_D)$o*.*
439 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
440 $platform_cpp_symbol =~ s/-/_/g;
441 if (open(IN,"crypto/buildinf.h"))
443 # Remove entry for this platform in existing file buildinf.h.
445 my $old_buildinf_h = "";
448 if (/^\#ifdef $platform_cpp_symbol$/)
450 while (<IN>) { last if (/^\#endif/); }
454 $old_buildinf_h .= $_;
459 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
460 print OUT $old_buildinf_h;
464 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
466 #ifdef $platform_cpp_symbol
467 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
468 #define CFLAGS "$cc $cflags"
469 #define PLATFORM "$platform"
471 printf OUT " #define DATE \"%s\"\n", scalar gmtime();
472 printf OUT "#endif\n";
475 #############################################
476 # We parse in input file and 'store' info for later printing.
477 open(IN,"<$infile") || die "unable to open $infile:$!\n";
483 ($key,$val)=/^([^=]+)=(.*)/;
484 if ($key eq "RELATIVE_DIRECTORY")
489 $uc =~ s/^lib(.*)\.a/$1/;
492 $lib_obj{$uc}.=$libobj." ";
494 last if ($val eq "FINISHED");
501 { $test.=&var_add($dir,$val); }
503 if (($key eq "PROGS") || ($key eq "E_OBJ"))
504 { $e_exe.=&var_add($dir,$val); }
509 $lib =~ s/^.*\/([^\/]+)$/$1/;
512 if ($key eq "EXHEADER")
513 { $exheader.=&var_add($dir,$val); }
515 if ($key eq "HEADER")
516 { $header.=&var_add($dir,$val); }
518 if ($key eq "LIBOBJ")
519 { $libobj=&var_add($dir,$val); }
522 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
526 # Strip of trailing ' '
527 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
528 $test=&clean_up_ws($test);
529 $e_exe=&clean_up_ws($e_exe);
530 $exheader=&clean_up_ws($exheader);
531 $header=&clean_up_ws($header);
533 # First we strip the exheaders from the headers list
534 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
535 foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
536 chop($h); $header=$h;
538 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h");
539 $rules.=&do_copy_rule("\$(INCL_D)",$header,".h");
541 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",".h");
542 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,".h");
544 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
545 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
547 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
548 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
550 foreach (values %lib_nam)
552 $lib_obj=$lib_obj{$_};
555 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
557 $rules.="\$(O_SSL):\n\n";
561 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
563 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
564 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
566 if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
568 $lib_obj .= "\$(BNCO_ASM_OBJ)";
569 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
571 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
573 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
574 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
575 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
577 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
579 $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
580 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
582 if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
584 $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
585 $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
587 if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
589 $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
590 $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
592 if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
594 $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
595 $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
597 if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
599 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
600 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
602 if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
604 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
605 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
607 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
609 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
610 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
612 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
613 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
614 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
617 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
618 foreach (split(/\s+/,$test))
621 $tt="\$(OBJ_D)${o}$t${obj}";
622 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
625 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
626 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
628 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
632 if ($platform eq "linux-elf") {
634 # Generate perlasm output files
636 (cd \$(\@D)/..; PERL=perl make -f Makefile.ssl asm/\$(\@F))
639 print "###################################################################\n";
642 ###############################################
643 # strip off any trailing .[och] and append the relative directory
644 # also remembering to do nothing if we are in one of the dropped
651 return("") if $no_idea && $dir =~ /\/idea/;
652 return("") if $no_aes && $dir =~ /\/aes/;
653 return("") if $no_rc2 && $dir =~ /\/rc2/;
654 return("") if $no_rc4 && $dir =~ /\/rc4/;
655 return("") if $no_rc5 && $dir =~ /\/rc5/;
656 return("") if $no_rsa && $dir =~ /\/rsa/;
657 return("") if $no_rsa && $dir =~ /^rsaref/;
658 return("") if $no_dsa && $dir =~ /\/dsa/;
659 return("") if $no_dh && $dir =~ /\/dh/;
660 if ($no_des && $dir =~ /\/des/)
662 if ($val =~ /read_pwd/)
663 { return("$dir/read_pwd "); }
667 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
668 return("") if $no_sock && $dir =~ /\/proxy/;
669 return("") if $no_bf && $dir =~ /\/bf/;
670 return("") if $no_cast && $dir =~ /\/cast/;
672 $val =~ s/^\s*(.*)\s*$/$1/;
673 @a=split(/\s+/,$val);
674 grep(s/\.[och]$//,@a);
676 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
677 @a=grep(!/^e_.*_d$/,@a) if $no_des;
678 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
679 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
680 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
681 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
682 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
683 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
684 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
686 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
687 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
689 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
691 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
692 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
693 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
694 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160;
696 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
697 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
698 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
700 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
701 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
703 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
705 @a=grep(!/_dhp$/,@a) if $no_dh;
707 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
708 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
709 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
711 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
712 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
713 @a=grep(!/^gendsa$/,@a) if $no_sha1;
714 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
716 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
718 grep($_="$dir/$_",@a);
719 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
720 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
721 $ret=join(' ',@a)." ";
725 # change things so that each 'token' is only separated by one space
730 $w =~ s/^\s*(.*)\s*$/$1/;
737 local($var,$files,$location,$postfix)=@_;
741 $files =~ s/\//$o/g if $o ne '/';
745 foreach (split(/ /,$files))
748 $_=&bname($_) unless /^\$/;
754 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
756 else { $pf=$postfix; }
757 if ($_ =~ /BN_ASM/) { $t="$_ "; }
758 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
759 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
760 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
761 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
762 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
763 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
764 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
765 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
766 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
767 else { $t="$location${o}$_$pf "; }
777 # return the name with the leading path removed
781 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
786 ##############################################################
787 # do a rule for each file that says 'compile' to new direcory
788 # compile the files in '$files' into $to
791 local($to,$files,$ex)=@_;
794 $files =~ s/\//$o/g if $o ne '/';
795 foreach (split(/\s+/,$files))
798 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
803 ##############################################################
804 # do a rule for each file that says 'compile' to new direcory
805 sub cc_compile_target
807 local($target,$source,$ex_flags)=@_;
810 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
811 $target =~ s/\//$o/g if $o ne "/";
812 $source =~ s/\//$o/g if $o ne "/";
813 $ret ="$target: \$(SRC_D)$o$source\n\t";
814 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
818 ##############################################################
821 local($target,$src)=@_;
822 local($ret,@s,@t,$i);
824 $target =~ s/\//$o/g if $o ne "/";
825 $src =~ s/\//$o/g if $o ne "/";
827 @s=split(/\s+/,$src);
828 @t=split(/\s+/,$target);
830 for ($i=0; $i<=$#s; $i++)
832 $ret.="$t[$i]: $s[$i]\n";
833 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n";
844 ($nn=$n) =~ tr/a-z/A-Z/;
845 $ret.="$n.dll: \$(${nn}OBJ)\n";
848 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
854 # do a rule for each file that says 'copy' to new direcory on change
857 local($to,$files,$p)=@_;
858 local($ret,$_,$n,$pp);
860 $files =~ s/\//$o/g if $o ne '/';
861 foreach (split(/\s+/,$files))
864 if ($n =~ /bss_file/)
867 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
874 if (/^no-rc2$/) { $no_rc2=1; }
875 elsif (/^no-rc4$/) { $no_rc4=1; }
876 elsif (/^no-rc5$/) { $no_rc5=1; }
877 elsif (/^no-idea$/) { $no_idea=1; }
878 elsif (/^no-aes$/) { $no_aes=1; }
879 elsif (/^no-des$/) { $no_des=1; }
880 elsif (/^no-bf$/) { $no_bf=1; }
881 elsif (/^no-cast$/) { $no_cast=1; }
882 elsif (/^no-md2$/) { $no_md2=1; }
883 elsif (/^no-md4$/) { $no_md4=1; }
884 elsif (/^no-md5$/) { $no_md5=1; }
885 elsif (/^no-sha$/) { $no_sha=1; }
886 elsif (/^no-sha1$/) { $no_sha1=1; }
887 elsif (/^no-ripemd$/) { $no_ripemd=1; }
888 elsif (/^no-mdc2$/) { $no_mdc2=1; }
889 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; }
890 elsif (/^no-rsa$/) { $no_rsa=1; }
891 elsif (/^no-dsa$/) { $no_dsa=1; }
892 elsif (/^no-dh$/) { $no_dh=1; }
893 elsif (/^no-hmac$/) { $no_hmac=1; }
894 elsif (/^no-aes$/) { $no_aes=1; }
895 elsif (/^no-asm$/) { $no_asm=1; }
896 elsif (/^nasm$/) { $nasm=1; }
897 elsif (/^gaswin$/) { $gaswin=1; }
898 elsif (/^no-ssl2$/) { $no_ssl2=1; }
899 elsif (/^no-ssl3$/) { $no_ssl3=1; }
900 elsif (/^no-err$/) { $no_err=1; }
901 elsif (/^no-sock$/) { $no_sock=1; }
902 elsif (/^no-krb5$/) { $no_krb5=1; }
903 elsif (/^no-ec$/) { $no_ec=1; }
905 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
906 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
907 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1;
910 elsif (/^rsaref$/) { }
911 elsif (/^gcc$/) { $gcc=1; }
912 elsif (/^debug$/) { $debug=1; }
913 elsif (/^profile$/) { $profile=1; }
914 elsif (/^shlib$/) { $shlib=1; }
915 elsif (/^dll$/) { $shlib=1; }
916 elsif (/^shared$/) { } # We just need to ignore it for now...
917 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
918 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
919 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)