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";
13 "VC-WIN32", "Microsoft Visual C++ 4.[01] - Windows NT [34].x",
14 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
15 "VC-WIN16", "Alias for VC-W31-32",
16 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+",
17 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS",
18 "BC-NT", "Borland C++ 4.5 - Windows NT - PROBABLY NOT WORKING",
19 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING",
20 "BC-MSDOS","Borland C++ 4.5 - MSDOS",
21 "FreeBSD","FreeBSD distribution",
22 "default","cc under unix",
28 if (/^no-rc2$/) { $no_rc2=1; }
29 elsif (/^no-rc4$/) { $no_rc4=1; }
30 elsif (/^no-idea$/) { $no_idea=1; }
31 elsif (/^no-des$/) { $no_des=1; }
32 elsif (/^no-bf$/) { $no_bf=1; }
33 elsif (/^no-md2$/) { $no_md2=1; }
34 elsif (/^no-md5$/) { $no_md5=1; }
35 elsif (/^no-sha$/) { $no_sha=1; }
36 elsif (/^no-sha1$/) { $no_sha1=1; }
37 elsif (/^no-mdc2$/) { $no_mdc2=1; }
38 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_idea=$no_sha1=$no_rsa=1; }
39 elsif (/^no-rsa$/) { $no_rsa=1; }
40 elsif (/^no-dsa$/) { $no_dsa=1; }
41 elsif (/^no-dh$/) { $no_dh=1; }
42 elsif (/^no-asm$/) { $no_asm=1; }
43 elsif (/^no-ssl2$/) { $no_ssl2=1; }
44 elsif (/^no-ssl3$/) { $no_ssl3=1; }
45 elsif (/^no-err$/) { $no_err=1; }
46 elsif (/^no-sock$/) { $no_sock=1; }
48 elsif (/^rsaref$/) { $rsaref=1; }
49 elsif (/^gcc$/) { $gcc=1; }
50 elsif (/^debug$/) { $debug=1; }
51 elsif (/^shlib$/) { $shlib=1; }
52 elsif (/^dll$/) { $shlib=1; }
53 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
54 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
55 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
59 if (!defined($ops{$_}))
61 print STDERR "unknown option - $_\n";
62 print STDERR "usage: perl mk1mf.pl [system] [options]\n";
63 print STDERR "\nwhere [system] can be one of the following\n";
64 foreach $i (sort keys %ops)
65 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
67 and [options] can be one of
68 no-md2 no-md5 no-sha no-sha1 no-mdc2 - Skip this digest
69 no-rc2 no-rc4 no-idea no-des no-bf - Skip this symetriccipher
70 no-rsa no-dsa no-dh - Skip this public key cipher
71 no-ssl2 no-ssl3 - Skip this version of SSL
72 just-ssl - remove all non-ssl keys/digest
74 no-socks - No socket code
75 no-err - No error strings
76 dll/shlib - Build shared libraries (MS)
79 rsaref - Build to require RSAref
81 Values that can be set
82 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath CC=C-compiler
84 -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
85 -<ex_cc_flags> - extra 'cc' flags,
86 added (MS), or replace (unix)
94 $no_mdc2=1 if ($no_des);
96 $no_ssl3=1 if ($no_md5 || $no_sha1);
97 $no_ssl3=1 if ($no_rsa && $no_dh);
99 $no_ssl2=1 if ($no_md5 || $no_rsa);
100 $no_ssl2=1 if ($no_rsa);
102 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
103 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
104 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:'out';
105 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:'tmp';
106 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
108 ($ssl,$crypto)=("ssl","crypto");
110 $ranlib="echo ranlib";
112 push(@INC,"util/pl","pl");
113 if ($type eq "VC-MSDOS")
119 elsif ($type eq "VC-W31-16")
125 elsif (($type eq "VC-W31-32") || ($type eq "VC-WIN16"))
131 elsif (($type eq "VC-WIN32") || ($type eq "VC-NT"))
135 elsif ($type eq "BC-NT")
140 elsif ($type eq "BC-W31")
146 elsif ($type eq "BC-Q16")
148 $msdos=1; $w16=1; $shlib=0; $qw=1;
151 elsif ($type eq "BC-MSDOS")
157 elsif ($type eq "FreeBSD")
160 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
167 $cflags.=' -DTERMIO';
170 # $bin_dir.=$o causes a core dump on my sparc :-(
171 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
173 $cflags.=" -DNO_IDEA" if $no_idea;
174 $cflags.=" -DNO_RC2" if $no_rc2;
175 $cflags.=" -DNO_RC4" if $no_rc4;
176 $cflags.=" -DNO_MD2" if $no_md2;
177 $cflags.=" -DNO_MD5" if $no_md5;
178 $cflags.=" -DNO_SHA" if $no_sha;
179 $cflags.=" -DNO_SHA1" if $no_sha1;
180 $cflags.=" -DNO_MDC2" if $no_mdc2;
181 $cflags.=" -DNO_BLOWFISH" if $no_bf;
182 $cflags.=" -DNO_DES" if $no_des;
183 $cflags.=" -DNO_RSA" if $no_rsa;
184 $cflags.=" -DNO_DSA" if $no_dsa;
185 $cflags.=" -DNO_DH" if $no_dh;
186 $cflags.=" -DNO_SOCK" if $no_sock;
187 $cflags.=" -DNO_SSL2" if $no_ssl2;
188 $cflags.=" -DNO_SSL3" if $no_ssl3;
189 $cflags.=" -DNO_ERR" if $no_err;
190 $cflags.=" -DRSAref" if $rsaref ne "";
193 { $cflags="$c_flags" if ($c_flags ne ""); }
194 else { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
196 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
200 $ranlib="\$(SRC_D)$o$ranlib";
205 $banner ="\t\@echo Make sure you have run 'perl Configure $type' in the\n";
206 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
207 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
208 $banner.="\t\@echo documentation for details.\n";
211 # have to do this to allow $(CC) under unix
212 $link="$bin_dir$link" if ($link !~ /^\$/);
214 $INSTALLTOP =~ s|/|$o|g;
217 # This makefile has been automatically generated from the SSLeay distribution.
218 # This single makefile will build the complete SSLeay distribution and
219 # by default leave the 'intertesting' output files in .${o}out and the stuff
220 # that needs deleting in .${o}tmp.
221 # The file was generated by running 'make makefile.one', which
222 # does a 'make files', which writes all the environment variables from all
223 # the makefiles to the file call MINFO. This file is used by
224 # util${o}mk1mf.pl to generate makefile.one.
225 # The 'makefile per directory' system suites me when developing this
226 # library and also so I can 'distribute' indervidual library sections.
227 # The one monster makefile better suits building in non-unix
230 INSTALLTOP=$INSTALLTOP
232 # Set your compiler options
237 APP_EX_OBJ=$app_ex_obj
238 SHLIB_EX_OBJ=$shlib_ex_obj
239 # add extra libraries to this define, for solaris -lsocket -lnsl would
243 # The SSLeay directory
249 BN_MULW_OBJ=$bn_mulw_obj
250 BN_MULW_SRC=$bn_mulw_src
251 DES_ENC_OBJ=$des_enc_obj
252 DES_ENC_SRC=$des_enc_src
253 DES_CRYPT_OBJ=$des_crypt_obj
254 DES_CRYPT_SRC=$des_crypt_src
255 BF_ENC_OBJ=$bf_enc_obj
256 BF_ENC_SRC=$bf_enc_src
258 # The output directory for everything intersting
260 # The output directory for all the temporary muck
271 ######################################################
272 # You should not need to touch anything below this point
273 ######################################################
280 # BIN_D - Binary output directory
281 # TEST_D - Binary test file output directory
282 # LIB_D - library output directory
283 # INC_D - include directory
289 # INCL_D - local library directory
290 # OBJ_D - temp object file directory
294 O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
295 O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
296 O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp
297 L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
298 L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
300 L_LIBS= \$(L_SSL) \$(L_CRYPTO)
301 #L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO)
303 ######################################################
304 # Don't touch anything below this point
305 ######################################################
307 INC=-DFLAT_INC -I\$(INC_D) -I\$(INCL_D)
308 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
309 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
310 LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL)
312 #############################################
316 all: banner \$(OUT_D) \$(TMP_D) headers lib exe
327 headers: \$(HEADER) \$(EXHEADER)
331 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
334 \$(MKDIR) \$(INSTALLTOP)
335 \$(MKDIR) \$(INSTALLTOP)${o}bin
336 \$(MKDIR) \$(INSTALLTOP)${o}include
337 \$(MKDIR) \$(INSTALLTOP)${o}lib
338 \$(CP) \$(INC_D)${o}*.h \$(INSTALLTOP)${o}include
339 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
340 \$(CP) \$(LIB_D)$o\$(O_SSL) \$(INSTALLTOP)${o}lib
341 \$(CP) \$(LIB_D)$o\$(O_CRYPTO) \$(INSTALLTOP)${o}lib
344 \$(RM) \$(TMP_D)$o*.*
347 \$(RM) \$(TMP_D)$o*.*
348 \$(RM) \$(OUT_D)$o*.*
352 #############################################
353 # We parse in input file and 'store' info for later printing.
354 open(IN,"<$infile") || die "unable to open $infile:$!\n";
360 ($key,$val)=/^([^=]+)=(.*)/;
361 if ($key eq "RELATIVE_DIRECTORY")
366 $uc =~ s/^lib(.*)\.a/$1/;
369 $lib_obj{$uc}.=$libobj." ";
371 last if ($val eq "FINISHED");
378 { $test.=&var_add($dir,$val); }
380 if (($key eq "PROGS") || ($key eq "E_OBJ"))
381 { $e_exe.=&var_add($dir,$val); }
386 $lib =~ s/^.*\/([^\/]+)$/$1/;
389 if ($key eq "EXHEADER")
390 { $exheader.=&var_add($dir,$val); }
392 if ($key eq "HEADER")
393 { $header.=&var_add($dir,$val); }
395 if ($key eq "LIBOBJ")
396 { $libobj=&var_add($dir,$val); }
399 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
403 # Strip of trailing ' '
404 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
405 $test=&clean_up_ws($test);
406 $e_exe=&clean_up_ws($e_exe);
407 $exheader=&clean_up_ws($exheader);
408 $header=&clean_up_ws($header);
410 # First we strip the exheaders from the headers list
411 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
412 foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
413 chop($h); $header=$h;
415 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h");
416 $rules.=&do_copy_rule("\$(INCL_D)",$header,".h");
418 $defs.=&do_defs("EXHEADER",$exheader,"\$(INC_D)",".h");
419 $rules.=&do_copy_rule("\$(INC_D)",$exheader,".h");
421 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
422 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
424 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
425 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
427 foreach (values %lib_nam)
429 $lib_obj=$lib_obj{$_};
431 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
433 $rules.="\$(O_SSL):\n\n";
437 if (($_ eq "RSAGLUE") && $no_rsa)
439 $rules.="\$(O_RSAGLUE):\n\n";
443 if (($bn_mulw_obj ne "") && ($_ eq "CRYPTO"))
445 $lib_obj =~ s/\S*bn_mulw\S*/\$(BN_MULW_OBJ)/;
446 $rules.=&do_asm_rule($bn_mulw_obj,$bn_mulw_src);
448 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
450 $lib_obj =~ s/\S*des_enc\S*/\$(DES_ENC_OBJ)/;
451 $lib_obj =~ s/\S*fcrypt_b\S*\s*//;
452 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
454 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
456 $lib_obj =~ s/\S*bf_enc\S*/\$(BF_ENC_OBJ)/;
457 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
459 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
460 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},"\$(LIB_CFLAGS)");
463 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
464 foreach (split(/\s+/,$test))
467 $tt="\$(OBJ_D)${o}$t${obj}";
468 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
471 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib);
472 $rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0)
474 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib);
476 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
479 print "###################################################################\n";
482 ###############################################
483 # strip off any trailing .[och] and append the relative directory
484 # also remembering to do nothing if we are in one of the dropped
491 return("") if $no_idea && $dir =~ /\/idea/;
492 return("") if $no_rc2 && $dir =~ /\/rc2/;
493 return("") if $no_rc4 && $dir =~ /\/rc4/;
494 return("") if $no_rsa && $dir =~ /\/rsa/;
495 return("") if $no_rsa && $dir =~ /^rsaref/;
496 return("") if $no_dsa && $dir =~ /\/dsa/;
497 return("") if $no_dh && $dir =~ /\/dh/;
498 if ($no_des && $dir =~ /\/des/)
500 if ($val =~ /read_pwd/)
501 { return("$dir/read_pwd "); }
505 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
506 return("") if $no_sock && $dir =~ /\/proxy/;
507 return("") if $no_bf && $dir =~ /\/bf/;
509 $val =~ s/^\s*(.*)\s*$/$1/;
510 @a=split(/\s+/,$val);
511 grep(s/\.[och]$//,@a);
513 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
514 @a=grep(!/^e_.*_d$/,@a) if $no_des;
515 @a=grep(!/^e_.*_i$/,@a) if $no_idea;
516 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
517 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
518 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
520 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
521 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
523 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
525 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
526 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
528 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
529 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
530 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
532 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
533 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
535 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
537 @a=grep(!/_dhp$/,@a) if $no_dh;
539 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
540 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
541 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
543 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa;
544 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
545 @a=grep(!/^gendsa$/,@a) if $no_sha1;
546 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
548 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
550 grep($_="$dir/$_",@a);
551 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
552 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
553 $ret=join(' ',@a)." ";
557 # change things so that each 'token' is only separated by one space
562 $w =~ s/^\s*(.*)\s*$/$1/;
569 local($var,$files,$location,$postfix)=@_;
573 $files =~ s/\//$o/g if $o ne '/';
577 foreach (split(/ /,$files))
579 $_=&bname($_) unless /^\$/;
587 elsif ($_ =~ /DES_ENC/)
589 elsif ($_ =~ /BF_ENC/)
591 else { $t="$location${o}$_$postfix "; }
601 # return the name with the leading path removed
605 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
609 # do a rule for each file that says 'copy' to new direcory on change
612 local($to,$files,$p)=@_;
615 $files =~ s/\//$o/g if $o ne '/';
616 foreach (split(/\s+/,$files))
619 $ret.="$to${o}$n$p: \$(SRC_D)$o$_$p\n\t\$(CP) \$(SRC_D)$o$_$p $to${o}$n$p\n\n";
624 ##############################################################
625 # do a rule for each file that says 'compile' to new direcory
626 # compile the files in '$files' into $to
629 local($to,$files,$ex)=@_;
632 $files =~ s/\//$o/g if $o ne '/';
633 foreach (split(/\s+/,$files))
636 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
641 ##############################################################
642 # do a rule for each file that says 'compile' to new direcory
643 sub cc_compile_target
645 local($target,$source,$ex_flags)=@_;
649 $ex_flags.=' -DCFLAGS="\"$(CC) $(CFLAG)\""' if ($source =~ /cversion/);
650 $target =~ s/\//$o/g if $o ne "/";
651 $source =~ s/\//$o/g if $o ne "/";
652 $ret ="$target: \$(SRC_D)$o$source\n\t";
653 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
657 ##############################################################
660 local($target,$src)=@_;
661 local($ret,@s,@t,$i);
663 $target =~ s/\//$o/g if $o ne "/";
664 $src =~ s/\//$o/g if $o ne "/";
666 @s=split(/\s+/,$src);
667 @t=split(/\s+/,$target);
669 for ($i=0; $i<=$#s; $i++)
671 $ret.="$t[$i]: $s[$i]\n";
672 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n";
683 ($nn=$n) =~ tr/a-z/A-Z/;
684 $ret.="$n.dll: \$(${nn}OBJ)\n";
687 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";