mk1mf.pl revision 273399
1148330Snetchild#!/usr/local/bin/perl 2148330Snetchild# A bit of an evil hack but it post processes the file ../MINFO which 3148330Snetchild# is generated by `make files` in the top directory. 4148330Snetchild# This script outputs one mega makefile that has no shell stuff or any 5148330Snetchild# funny stuff 6148330Snetchild# 7148330Snetchild 8148330Snetchild$INSTALLTOP="/usr/local/ssl"; 9148330Snetchild$OPENSSLDIR="/usr/local/ssl"; 10148330Snetchild$OPTIONS=""; 11148330Snetchild$ssl_version=""; 12148330Snetchild$banner="\t\@echo Building OpenSSL"; 13148330Snetchild 14148543Snetchildmy $no_static_engine = 1; 15148543Snetchildmy $engines = ""; 16148330Snetchildmy $otherlibs = ""; 17158687Sphklocal $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 18158687Sphklocal $zlib_lib = ""; 19158687Sphklocal $perl_asm = 0; # 1 to autobuild asm files from perl scripts 20158687Sphk 21158687Sphkmy $ex_l_libs = ""; 22158687Sphk 23158687Sphk# Options to import from top level Makefile 24158687Sphk 25158687Sphkmy %mf_import = ( 26158687Sphk VERSION => \$ssl_version, 27158687Sphk OPTIONS => \$OPTIONS, 28158687Sphk INSTALLTOP => \$INSTALLTOP, 29158687Sphk OPENSSLDIR => \$OPENSSLDIR, 30158687Sphk PLATFORM => \$mf_platform, 31158687Sphk CFLAG => \$mf_cflag, 32158687Sphk DEPFLAG => \$mf_depflag, 33158687Sphk CPUID_OBJ => \$mf_cpuid_asm, 34158687Sphk BN_ASM => \$mf_bn_asm, 35158687Sphk DES_ENC => \$mf_des_asm, 36158687Sphk AES_ENC => \$mf_aes_asm, 37158687Sphk BF_ENC => \$mf_bf_asm, 38158687Sphk CAST_ENC => \$mf_cast_asm, 39158687Sphk RC4_ENC => \$mf_rc4_asm, 40158687Sphk RC5_ENC => \$mf_rc5_asm, 41158687Sphk MD5_ASM_OBJ => \$mf_md5_asm, 42158687Sphk SHA1_ASM_OBJ => \$mf_sha_asm, 43158687Sphk RMD160_ASM_OBJ => \$mf_rmd_asm, 44158687Sphk WP_ASM_OBJ => \$mf_wp_asm, 45158687Sphk CMLL_ENC => \$mf_cm_asm, 46158687Sphk BASEADDR => \$baseaddr, 47158687Sphk FIPSDIR => \$fipsdir, 48158687Sphk); 49158687Sphk 50158687Sphk 51158687Sphkopen(IN,"<Makefile") || die "unable to open Makefile!\n"; 52158687Sphkwhile(<IN>) { 53158687Sphk my ($mf_opt, $mf_ref); 54158687Sphk while (($mf_opt, $mf_ref) = each %mf_import) { 55158687Sphk if (/^$mf_opt\s*=\s*(.*)$/) { 56158687Sphk $$mf_ref = $1; 57158687Sphk } 58158687Sphk } 59158687Sphk} 60158687Sphkclose(IN); 61158687Sphk 62158687Sphk$debug = 1 if $mf_platform =~ /^debug-/; 63158687Sphk 64158687Sphkdie "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; 65158687Sphk 66158687Sphk$infile="MINFO"; 67158687Sphk 68158687Sphk%ops=( 69158687Sphk "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", 70158618Smaxim "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", 71158618Smaxim "VC-WIN64A", "Microsoft C/C++ - Win64/x64", 72158618Smaxim "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", 73158512Smlaier "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", 74158512Smlaier "Mingw32", "GNU C++ - Windows NT or 9x", 75158512Smlaier "Mingw32-files", "Create files with DOS copy ...", 76158512Smlaier "BC-NT", "Borland C++ 4.5 - Windows NT", 77158512Smlaier "linux-elf","Linux elf", 78158754Smarcel "ultrix-mips","DEC mips ultrix", 79158754Smarcel "FreeBSD","FreeBSD distribution", 80157221Ssimon "OS2-EMX", "EMX GCC OS/2", 81157221Ssimon "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", 82156676Sharti "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets", 83156676Sharti "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", 84153662Sjhb "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", 85153662Sjhb "default","cc under unix", 86153430Siedowse "auto", "auto detect from top level Makefile" 87153430Siedowse ); 88153430Siedowse 89153430Siedowse$platform=""; 90153430Siedowsemy $xcflags=""; 91151845Syarforeach (@ARGV) 92151845Syar { 93151271Spjd if (!&read_options && !defined($ops{$_})) 94151271Spjd { 95150676Smlaier print STDERR "unknown option - $_\n"; 96150677Smlaier print STDERR "usage: perl mk1mf.pl [options] [system]\n"; 97150002Snetchild print STDERR "\nwhere [system] can be one of the following\n"; 98150002Snetchild foreach $i (sort keys %ops) 99150002Snetchild { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } 100150002Snetchild print STDERR <<"EOF"; 101149454Sglebiusand [options] can be one of 102148808Sru no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest 103148808Sru no-ripemd 104148825Snetchild no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher 105148825Snetchild no-bf no-cast no-aes no-camellia no-seed 106148356Sdougb no-rsa no-dsa no-dh - Skip this public key cipher 107148356Sdougb no-ssl2 no-ssl3 - Skip this version of SSL 108148572Snetchild just-ssl - remove all non-ssl keys/digest 109148330Snetchild no-asm - No x86 asm 110148330Snetchild no-krb5 - No KRB5 111148330Snetchild no-srp - No SRP 112148330Snetchild no-ec - No EC 113148572Snetchild no-ecdsa - No ECDSA 114148572Snetchild no-ecdh - No ECDH 115149105Simp no-engine - No engine 116148572Snetchild no-hw - No hw 117148572Snetchild nasm - Use NASM for x86 asm 118148572Snetchild nw-nasm - Use NASM x86 asm for NetWare 119148572Snetchild nw-mwasm - Use Metrowerks x86 asm for NetWare 120148572Snetchild gaswin - Use GNU as with Mingw32 121148572Snetchild no-socks - No socket code 122148572Snetchild no-err - No error strings 123148572Snetchild dll/shlib - Build shared libraries (MS) 124148572Snetchild debug - Debug build 125148572Snetchild profile - Profiling build 126148572Snetchild gcc - Use Gcc (unix) 127148572Snetchild 128148572SnetchildValues that can be set 129148572SnetchildTMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 130153939Snetchild 131153939Snetchild-L<ex_lib_path> -l<ex_lib> - extra library flags (unix) 132153939Snetchild-<ex_cc_flags> - extra 'cc' flags, 133153939Snetchild added (MS), or replace (unix) 134148330SnetchildEOF 135148330Snetchild exit(1); 136148423Sdougb } 137148423Sdougb $platform=$_; 138148330Snetchild } 139148330Snetchildforeach (grep(!/^$/, split(/ /, $OPTIONS))) 140148330Snetchild { 141148330Snetchild print STDERR "unknown option - $_\n" if !&read_options; 142148572Snetchild } 143148572Snetchild 144148353Sdougb$no_static_engine = 0 if (!$shlib); 145148353Sdougb 146149105Simp$no_mdc2=1 if ($no_des); 147149105Simp 148148572Snetchild$no_ssl3=1 if ($no_md5 || $no_sha); 149148572Snetchild$no_ssl3=1 if ($no_rsa && $no_dh); 150149105Simp 151148572Snetchild$no_ssl2=1 if ($no_md5); 152155813Snetchild$no_ssl2=1 if ($no_rsa); 153155813Snetchild 154155813Snetchild$out_def="out"; 155155813Snetchild$inc_def="outinc"; 156148330Snetchild$tmp_def="tmp"; 157148330Snetchild 158148330Snetchild$perl="perl" unless defined $perl; 159148330Snetchild$mkdir="-mkdir" unless defined $mkdir; 160148330Snetchild 161148330Snetchild($ssl,$crypto)=("ssl","crypto"); 162148330Snetchild$ranlib="echo ranlib"; 163155813Snetchild 164148330Snetchild$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 165148330Snetchild$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; 166148330Snetchild$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; 167148330Snetchild 168148330Snetchild# $bin_dir.=$o causes a core dump on my sparc :-( 169148330Snetchild 170148543Snetchild 171148543Snetchild$NT=0; 172148543Snetchild 173148543Snetchildpush(@INC,"util/pl","pl"); 174148543Snetchild 175148543Snetchildif ($platform eq "auto") { 176148543Snetchild $platform = $mf_platform; 177148543Snetchild print STDERR "Imported platform $mf_platform\n"; 178148543Snetchild} 179148543Snetchild 180148543Snetchildif (($platform =~ /VC-(.+)/)) 181148543Snetchild { 182148543Snetchild $FLAVOR=$1; 183148543Snetchild $NT = 1 if $1 eq "NT"; 184148543Snetchild require 'VC-32.pl'; 185148543Snetchild } 186148543Snetchildelsif ($platform eq "Mingw32") 187148543Snetchild { 188148543Snetchild require 'Mingw32.pl'; 189148543Snetchild } 190148543Snetchildelsif ($platform eq "Mingw32-files") 191148572Snetchild { 192148572Snetchild require 'Mingw32f.pl'; 193148572Snetchild } 194148572Snetchildelsif ($platform eq "BC-NT") 195148572Snetchild { 196148572Snetchild $bc=1; 197148572Snetchild require 'BC-32.pl'; 198148572Snetchild } 199148572Snetchildelsif ($platform eq "FreeBSD") 200148572Snetchild { 201148572Snetchild require 'unix.pl'; 202148572Snetchild $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; 203148572Snetchild } 204148572Snetchildelsif ($platform eq "linux-elf") 205148572Snetchild { 206148572Snetchild require "unix.pl"; 207148572Snetchild require "linux.pl"; 208148572Snetchild $unix=1; 209148572Snetchild } 210148572Snetchildelsif ($platform eq "ultrix-mips") 211148572Snetchild { 212148572Snetchild require "unix.pl"; 213148572Snetchild require "ultrix.pl"; 214148572Snetchild $unix=1; 215148572Snetchild } 216148572Snetchildelsif ($platform eq "OS2-EMX") 217148572Snetchild { 218148572Snetchild $wc=1; 219148572Snetchild require 'OS2-EMX.pl'; 220148572Snetchild } 221148572Snetchildelsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || 222148572Snetchild ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock")) 223148572Snetchild { 224148572Snetchild $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; 225148572Snetchild $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock"); 226148572Snetchild require 'netware.pl'; 227148572Snetchild } 228148572Snetchildelse 229148572Snetchild { 230148572Snetchild require "unix.pl"; 231148572Snetchild 232148572Snetchild $unix=1; 233148572Snetchild $cflags.=' -DTERMIO'; 234148572Snetchild } 235148572Snetchild 236148572Snetchild$fipsdir =~ s/\//${o}/g; 237148572Snetchild 238148572Snetchild$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); 239148572Snetchild$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); 240148572Snetchild$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; 241148572Snetchild 242148572Snetchild$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 243148572Snetchild 244148572Snetchild$cflags= "$xcflags$cflags" if $xcflags ne ""; 245148572Snetchild 246148572Snetchild$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; 247148572Snetchild$cflags.=" -DOPENSSL_NO_AES" if $no_aes; 248148572Snetchild$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; 249148572Snetchild$cflags.=" -DOPENSSL_NO_SEED" if $no_seed; 250148572Snetchild$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; 251148572Snetchild$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; 252148572Snetchild$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; 253148572Snetchild$cflags.=" -DOPENSSL_NO_MD2" if $no_md2; 254148572Snetchild$cflags.=" -DOPENSSL_NO_MD4" if $no_md4; 255148572Snetchild$cflags.=" -DOPENSSL_NO_MD5" if $no_md5; 256148572Snetchild$cflags.=" -DOPENSSL_NO_SHA" if $no_sha; 257148572Snetchild$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; 258148572Snetchild$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; 259148572Snetchild$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; 260148572Snetchild$cflags.=" -DOPENSSL_NO_BF" if $no_bf; 261148572Snetchild$cflags.=" -DOPENSSL_NO_CAST" if $no_cast; 262148572Snetchild$cflags.=" -DOPENSSL_NO_DES" if $no_des; 263148572Snetchild$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; 264148572Snetchild$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; 265148572Snetchild$cflags.=" -DOPENSSL_NO_DH" if $no_dh; 266148572Snetchild$cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool; 267148572Snetchild$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; 268148572Snetchild$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; 269148572Snetchild$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 270148572Snetchild$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; 271148572Snetchild$cflags.=" -DOPENSSL_NO_SRP" if $no_srp; 272148572Snetchild$cflags.=" -DOPENSSL_NO_CMS" if $no_cms; 273148572Snetchild$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 274148572Snetchild$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 275148572Snetchild$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 276148572Snetchild$cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; 277148572Snetchild$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 278148572Snetchild$cflags.=" -DOPENSSL_NO_GOST" if $no_gost; 279148572Snetchild$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 280148572Snetchild$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 281148572Snetchild$cflags.=" -DOPENSSL_FIPS" if $fips; 282148572Snetchild$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake; 283148572Snetchild$cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m; 284148572Snetchild$cflags.= " -DZLIB" if $zlib_opt; 285148572Snetchild$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 286148572Snetchild 287148572Snetchildif ($no_static_engine) 288148572Snetchild { 289148572Snetchild $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; 290148572Snetchild } 291148572Snetchildelse 292148572Snetchild { 293148572Snetchild $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; 294148572Snetchild } 295148572Snetchild 296148572Snetchild#$cflags.=" -DRSAref" if $rsaref ne ""; 297148572Snetchild 298148572Snetchild## if ($unix) 299148330Snetchild## { $cflags="$c_flags" if ($c_flags ne ""); } 300148330Snetchild##else 301148330Snetchild { $cflags="$c_flags$cflags" if ($c_flags ne ""); } 302148330Snetchild 303148330Snetchild$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 304148572Snetchild 305148572Snetchild 306148572Snetchild%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 307148572Snetchild "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); 308148572Snetchild 309148572Snetchildif ($msdos) 310148572Snetchild { 311148572Snetchild $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; 312148572Snetchild $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; 313148572Snetchild $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; 314149113Simp $banner.="\t\@echo documentation for details.\n"; 315149113Simp } 316149113Simp 317149113Simp# have to do this to allow $(CC) under unix 318149113Simp$link="$bin_dir$link" if ($link !~ /^\$/); 319149113Simp 320149113Simp$INSTALLTOP =~ s|/|$o|g; 321148572Snetchild$OPENSSLDIR =~ s|/|$o|g; 322148572Snetchild 323148572Snetchild############################################# 324148572Snetchild# We parse in input file and 'store' info for later printing. 325148572Snetchildopen(IN,"<$infile") || die "unable to open $infile:$!\n"; 326149105Simp$_=<IN>; 327148572Snetchildfor (;;) 328148572Snetchild { 329148572Snetchild chop; 330148572Snetchild 331148572Snetchild ($key,$val)=/^([^=]+)=(.*)/; 332148572Snetchild if ($key eq "RELATIVE_DIRECTORY") 333148572Snetchild { 334148572Snetchild if ($lib ne "") 335148683Sru { 336148330Snetchild $uc=$lib; 337148330Snetchild $uc =~ s/^lib(.*)\.a/$1/; 338148330Snetchild $uc =~ tr/a-z/A-Z/; 339148330Snetchild $lib_nam{$uc}=$uc; 340156385Syar $lib_obj{$uc}.=$libobj." "; 341156385Syar } 342148330Snetchild last if ($val eq "FINISHED"); 343148330Snetchild $lib=""; 344148330Snetchild $libobj=""; 345148330Snetchild $dir=$val; 346148330Snetchild } 347148330Snetchild 348148330Snetchild if ($key eq "KRB5_INCLUDES") 349148330Snetchild { $cflags .= " $val";} 350148330Snetchild 351148330Snetchild if ($key eq "ZLIB_INCLUDE") 352148330Snetchild { $cflags .= " $val" if $val ne "";} 353148330Snetchild 354148330Snetchild if ($key eq "LIBZLIB") 355148330Snetchild { $zlib_lib = "$val" if $val ne "";} 356148330Snetchild 357148330Snetchild if ($key eq "LIBKRB5") 358148330Snetchild { $ex_libs .= " $val" if $val ne "";} 359148330Snetchild 360148330Snetchild if ($key eq "TEST") 361148330Snetchild { $test.=&var_add($dir,$val, 0); } 362148330Snetchild 363148572Snetchild if (($key eq "PROGS") || ($key eq "E_OBJ")) 364148572Snetchild { $e_exe.=&var_add($dir,$val, 0); } 365149105Simp 366148572Snetchild if ($key eq "LIB") 367148572Snetchild { 368148572Snetchild $lib=$val; 369148572Snetchild $lib =~ s/^.*\/([^\/]+)$/$1/; 370148572Snetchild } 371148572Snetchild if ($key eq "LIBNAME" && $no_static_engine) 372148572Snetchild { 373155279Savatar $lib=$val; 374155279Savatar $lib =~ s/^.*\/([^\/]+)$/$1/; 375155279Savatar $otherlibs .= " $lib"; 376155279Savatar } 377148572Snetchild 378148572Snetchild if ($key eq "EXHEADER") 379148572Snetchild { $exheader.=&var_add($dir,$val, 1); } 380148330Snetchild 381148330Snetchild if ($key eq "HEADER") 382148330Snetchild { $header.=&var_add($dir,$val, 1); } 383148330Snetchild 384148330Snetchild if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) 385148330Snetchild { $libobj=&var_add($dir,$val, 0); } 386148330Snetchild if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 387148330Snetchild { $engines.=$val } 388148330Snetchild 389148330Snetchild if (!($_=<IN>)) 390148330Snetchild { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 391148330Snetchild } 392148330Snetchildclose(IN); 393148330Snetchild 394148330Snetchildif ($shlib) 395148330Snetchild { 396149105Simp $extra_install= <<"EOF"; 397149105Simp \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\" 398148572Snetchild \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\" 399148572Snetchild \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\" 400148572Snetchild \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" 401148572SnetchildEOF 402148330Snetchild if ($no_static_engine) 403148330Snetchild { 404148330Snetchild $extra_install .= <<"EOF" 405148330Snetchild \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" 406148330Snetchild \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" 407148330SnetchildEOF 408148330Snetchild } 409148330Snetchild } 410148330Snetchildelse 411148330Snetchild { 412148330Snetchild $extra_install= <<"EOF"; 413148330Snetchild \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\" 414148330Snetchild \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" 415148330SnetchildEOF 416148330Snetchild $ex_libs .= " $zlib_lib" if $zlib_opt == 1; 417148330Snetchild if ($fips) 418148330Snetchild { 419148330Snetchild $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)"; 420148330Snetchild $ex_l_libs .= " \$(O_FIPSCANISTER)"; 421148330Snetchild } 422148330Snetchild } 423148330Snetchild 424148330Snetchild$defs= <<"EOF"; 425148572Snetchild# This makefile has been automatically generated from the OpenSSL distribution. 426148572Snetchild# This single makefile will build the complete OpenSSL distribution and 427148572Snetchild# by default leave the 'intertesting' output files in .${o}out and the stuff 428148572Snetchild# that needs deleting in .${o}tmp. 429148572Snetchild# The file was generated by running 'make makefile.one', which 430148572Snetchild# does a 'make files', which writes all the environment variables from all 431148572Snetchild# the makefiles to the file call MINFO. This file is used by 432148572Snetchild# util${o}mk1mf.pl to generate makefile.one. 433148572Snetchild# The 'makefile per directory' system suites me when developing this 434148572Snetchild# library and also so I can 'distribute' indervidual library sections. 435148572Snetchild# The one monster makefile better suits building in non-unix 436148572Snetchild# environments. 437148572Snetchild 438148572SnetchildEOF 439148572Snetchild 440148572Snetchild$defs .= $preamble if defined $preamble; 441148572Snetchild 442148572Snetchild$defs.= <<"EOF"; 443148572SnetchildINSTALLTOP=$INSTALLTOP 444148572SnetchildOPENSSLDIR=$OPENSSLDIR 445148572Snetchild 446148572Snetchild# Set your compiler options 447148572SnetchildPLATFORM=$platform 448148572SnetchildCC=$bin_dir${cc} 449148572SnetchildCFLAG=$cflags 450148572SnetchildAPP_CFLAG=$app_cflag 451148572SnetchildLIB_CFLAG=$lib_cflag 452148572SnetchildSHLIB_CFLAG=$shl_cflag 453148572SnetchildAPP_EX_OBJ=$app_ex_obj 454148572SnetchildSHLIB_EX_OBJ=$shlib_ex_obj 455148572Snetchild# add extra libraries to this define, for solaris -lsocket -lnsl would 456148572Snetchild# be added 457148572SnetchildEX_LIBS=$ex_libs 458148572Snetchild 459148572Snetchild# The OpenSSL directory 460148572SnetchildSRC_D=$src_dir 461148572Snetchild 462148572SnetchildLINK=$link 463148572SnetchildLFLAGS=$lflags 464148572SnetchildRSC=$rsc 465148572Snetchild 466148572Snetchild# The output directory for everything intersting 467148572SnetchildOUT_D=$out_dir 468148572Snetchild# The output directory for all the temporary muck 469148572SnetchildTMP_D=$tmp_dir 470148572Snetchild# The output directory for the header files 471148572SnetchildINC_D=$inc_dir 472148572SnetchildINCO_D=$inc_dir${o}openssl 473148572Snetchild 474148572SnetchildPERL=$perl 475148572SnetchildCP=$cp 476148572SnetchildRM=$rm 477148572SnetchildRANLIB=$ranlib 478148572SnetchildMKDIR=$mkdir 479148572SnetchildMKLIB=$bin_dir$mklib 480148572SnetchildMLFLAGS=$mlflags 481148572SnetchildASM=$bin_dir$asm 482148572Snetchild 483148572Snetchild# FIPS validated module and support file locations 484148572Snetchild 485148572SnetchildFIPSDIR=$fipsdir 486148572SnetchildBASEADDR=$baseaddr 487148572SnetchildFIPSLIB_D=\$(FIPSDIR)${o}lib 488148572SnetchildFIPS_PREMAIN_SRC=\$(FIPSLIB_D)${o}fips_premain.c 489148572SnetchildO_FIPSCANISTER=\$(FIPSLIB_D)${o}fipscanister.lib 490148572SnetchildFIPS_SHA1_EXE=\$(FIPSDIR)${o}bin${o}fips_standalone_sha1${exep} 491148572SnetchildE_PREMAIN_DSO=fips_premain_dso 492148572SnetchildPREMAIN_DSO_EXE=\$(BIN_D)${o}fips_premain_dso$exep 493148572SnetchildFIPSLINK=\$(PERL) \$(FIPSDIR)${o}bin${o}fipslink.pl 494148572Snetchild 495148572Snetchild###################################################### 496148572Snetchild# You should not need to touch anything below this point 497148572Snetchild###################################################### 498148572Snetchild 499148572SnetchildE_EXE=openssl 500148572SnetchildSSL=$ssl 501148572SnetchildCRYPTO=$crypto 502148572Snetchild 503148572Snetchild# BIN_D - Binary output directory 504148572Snetchild# TEST_D - Binary test file output directory 505148572Snetchild# LIB_D - library output directory 506148572Snetchild# ENG_D - dynamic engine output directory 507148572Snetchild# Note: if you change these point to different directories then uncomment out 508148572Snetchild# the lines around the 'NB' comment below. 509148572Snetchild# 510148572SnetchildBIN_D=\$(OUT_D) 511148572SnetchildTEST_D=\$(OUT_D) 512148572SnetchildLIB_D=\$(OUT_D) 513148572SnetchildENG_D=\$(OUT_D) 514148572Snetchild 515148572Snetchild# INCL_D - local library directory 516148572Snetchild# OBJ_D - temp object file directory 517148572SnetchildOBJ_D=\$(TMP_D) 518148572SnetchildINCL_D=\$(TMP_D) 519148572Snetchild 520148572SnetchildO_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 521148572SnetchildO_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 522148572SnetchildSO_SSL= $plib\$(SSL)$so_shlibp 523148572SnetchildSO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 524149105SimpL_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 525149105SimpL_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 526149105Simp 527149105SimpL_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs 528148572Snetchild 529148572Snetchild###################################################### 530148572Snetchild# Don't touch anything below this point 531148572Snetchild###################################################### 532148572Snetchild 533148572SnetchildINC=-I\$(INC_D) -I\$(INCL_D) 534148572SnetchildAPP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 535148572SnetchildLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 536148572SnetchildSHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 537148572SnetchildLIBS_DEP=\$(O_CRYPTO) \$(O_SSL) 538148572Snetchild 539148572Snetchild############################################# 540148572SnetchildEOF 541148572Snetchild 542148572Snetchild$rules=<<"EOF"; 543148572Snetchildall: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe $build_targets 544148572Snetchild 545148572Snetchildbanner: 546148572Snetchild$banner 547148572Snetchild 548148572Snetchild\$(TMP_D): 549148572Snetchild \$(MKDIR) \"\$(TMP_D)\" 550148572Snetchild# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different 551148572Snetchild#\$(BIN_D): 552148572Snetchild# \$(MKDIR) \$(BIN_D) 553148572Snetchild# 554148572Snetchild#\$(TEST_D): 555148572Snetchild# \$(MKDIR) \$(TEST_D) 556148572Snetchild 557148572Snetchild\$(LIB_D): 558148572Snetchild \$(MKDIR) \"\$(LIB_D)\" 559148572Snetchild 560148572Snetchild\$(INCO_D): \$(INC_D) 561148572Snetchild \$(MKDIR) \"\$(INCO_D)\" 562148572Snetchild 563148572Snetchild\$(INC_D): 564148572Snetchild \$(MKDIR) \"\$(INC_D)\" 565148572Snetchild 566148572Snetchildheaders: \$(HEADER) \$(EXHEADER) 567148572Snetchild @ 568148572Snetchild 569148572Snetchildlib: \$(LIBS_DEP) \$(E_SHLIB) 570148572Snetchild 571148572Snetchildexe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep 572148572Snetchild 573148572Snetchildinstall: all 574148572Snetchild \$(MKDIR) \"\$(INSTALLTOP)\" 575148572Snetchild \$(MKDIR) \"\$(INSTALLTOP)${o}bin\" 576148572Snetchild \$(MKDIR) \"\$(INSTALLTOP)${o}include\" 577148572Snetchild \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" 578148572Snetchild \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" 579148572Snetchild \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" 580148572Snetchild \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\" 581148572Snetchild \$(MKDIR) \"\$(OPENSSLDIR)\" 582148572Snetchild \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\" 583148572Snetchild$extra_install 584148572Snetchild 585148572Snetchild 586148572Snetchildtest: \$(T_EXE) 587149105Simp cd \$(BIN_D) 588149105Simp ..${o}ms${o}test 589149105Simp 590149105Simpclean: 591149105Simp \$(RM) \$(TMP_D)$o*.* 592149105Simp 593149105Simpvclean: 594149105Simp \$(RM) \$(TMP_D)$o*.* 595148572Snetchild \$(RM) \$(OUT_D)$o*.* 596148572Snetchild 597148330SnetchildEOF 598148330Snetchild 599148330Snetchildmy $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; 600149105Simp$platform_cpp_symbol =~ s/-/_/g; 601149105Simpif (open(IN,"crypto/buildinf.h")) 602149105Simp { 603149105Simp # Remove entry for this platform in existing file buildinf.h. 604149105Simp 605149105Simp my $old_buildinf_h = ""; 606149105Simp while (<IN>) 607149105Simp { 608149105Simp if (/^\#ifdef $platform_cpp_symbol$/) 609149105Simp { 610149105Simp while (<IN>) { last if (/^\#endif/); } 611149105Simp } 612149105Simp else 613149105Simp { 614149105Simp $old_buildinf_h .= $_; 615149105Simp } 616149105Simp } 617149105Simp close(IN); 618149105Simp 619149105Simp open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; 620149105Simp print OUT $old_buildinf_h; 621149105Simp close(OUT); 622149105Simp } 623149105Simp 624149105Simpopen (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; 625148330Snetchildprintf OUT <<EOF; 626148330Snetchild#ifdef $platform_cpp_symbol 627148330Snetchild /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ 628148330Snetchild #define CFLAGS "$cc $cflags" 629148330Snetchild #define PLATFORM "$platform" 630148330SnetchildEOF 631148330Snetchildprintf OUT " #define DATE \"%s\"\n", scalar gmtime(); 632148330Snetchildprintf OUT "#endif\n"; 633149105Simpclose(OUT); 634149105Simp 635149105Simp# Strip of trailing ' ' 636149105Simpforeach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } 637149105Simp$test=&clean_up_ws($test); 638148330Snetchild$e_exe=&clean_up_ws($e_exe); 639149105Simp$exheader=&clean_up_ws($exheader); 640149105Simp$header=&clean_up_ws($header); 641149105Simp 642149105Simp# First we strip the exheaders from the headers list 643149105Simpforeach (split(/\s+/,$exheader)){ $h{$_}=1; } 644149105Simpforeach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } 645149105Simpchop($h); $header=$h; 646149105Simp 647149105Simp$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); 648149105Simp$rules.=&do_copy_rule("\$(INCL_D)",$header,""); 649149105Simp 650149105Simp$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); 651149105Simp$rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); 652148330Snetchild 653148330Snetchild$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); 654148330Snetchild$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); 655148330Snetchild 656149105Simp$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 657149105Simp$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 658149105Simp 659148330Snetchild# Special case rule for fips_premain_dso 660148330Snetchild 661148330Snetchildif ($fips) 662148330Snetchild { 663148330Snetchild $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj", 664148330Snetchild "\$(FIPS_PREMAIN_SRC)", 665148330Snetchild "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)", ""); 666148330Snetchild $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1); 667148330Snetchild } 668148330Snetchild 669148330Snetchildforeach (values %lib_nam) 670148330Snetchild { 671148330Snetchild $lib_obj=$lib_obj{$_}; 672148330Snetchild local($slib)=$shlib; 673148330Snetchild 674148330Snetchild if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) 675148543Snetchild { 676149113Simp $rules.="\$(O_SSL):\n\n"; 677149113Simp next; 678149113Simp } 679149113Simp 680149113Simp $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 681149113Simp $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 682149113Simp $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 683149113Simp } 684149113Simp 685149113Simp# hack to add version info on MSVC 686149113Simpif (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A") 687148330Snetchild || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) { 688148330Snetchild $rules.= <<"EOF"; 689149113Simp\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc 690149113Simp \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc 691149113Simp 692149113Simp\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 693149113Simp \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 694149113Simp 695149113SimpEOF 696149113Simp} 697149113Simp 698149113Simp$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 699149113Simpforeach (split(/\s+/,$test)) 700149113Simp { 701149113Simp $t=&bname($_); 702149113Simp $tt="\$(OBJ_D)${o}$t${obj}"; 703149113Simp $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 704149113Simp } 705149113Simp 706149113Simp$defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp); 707149113Simp 708149113Simpforeach (split(/\s+/,$engines)) 709149113Simp { 710149113Simp $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); 711149113Simp $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); 712149113Simp } 713149113Simp 714149113Simp 715149113Simp 716149113Simp$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 717149113Simp 718149113Simpif ($fips) 719149113Simp { 720149113Simp if ($shlib) 721148330Snetchild { 722148330Snetchild $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", 723148330Snetchild "\$(O_CRYPTO)", "$crypto", 724148330Snetchild $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)"); 725148330Snetchild } 726148330Snetchild else 727148330Snetchild { 728151378Snetchild $rules.= &do_lib_rule("\$(CRYPTOOBJ)", 729151378Snetchild "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", ""); 730151378Snetchild $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", 731151378Snetchild "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", ""); 732151378Snetchild } 733151378Snetchild } 734151378Snetchild else 735151378Snetchild { 736151378Snetchild $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib, 737151378Snetchild "\$(SO_CRYPTO)"); 738151378Snetchild } 739151378Snetchild 740151378Snetchildforeach (split(" ",$otherlibs)) 741151378Snetchild { 742151378Snetchild my $uc = $_; 743151378Snetchild $uc =~ tr /a-z/A-Z/; 744151378Snetchild $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, ""); 745151378Snetchild 746151378Snetchild } 747151378Snetchild 748151378Snetchild$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); 749151378Snetchild 750151378Snetchildprint $defs; 751151378Snetchild 752151378Snetchildif ($platform eq "linux-elf") { 753151378Snetchild print <<"EOF"; 754151378Snetchild# Generate perlasm output files 755151378Snetchild%.cpp: 756151378Snetchild (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) 757151378SnetchildEOF 758151378Snetchild} 759151378Snetchildprint "###################################################################\n"; 760151378Snetchildprint $rules; 761151378Snetchild 762151378Snetchild############################################### 763151378Snetchild# strip off any trailing .[och] and append the relative directory 764151378Snetchild# also remembering to do nothing if we are in one of the dropped 765151378Snetchild# directories 766151378Snetchildsub var_add 767151378Snetchild { 768151378Snetchild local($dir,$val,$keepext)=@_; 769151378Snetchild local(@a,$_,$ret); 770151378Snetchild 771151378Snetchild return("") if $no_engine && $dir =~ /\/engine/; 772151378Snetchild return("") if $no_hw && $dir =~ /\/hw/; 773151378Snetchild return("") if $no_idea && $dir =~ /\/idea/; 774151378Snetchild return("") if $no_aes && $dir =~ /\/aes/; 775151378Snetchild return("") if $no_camellia && $dir =~ /\/camellia/; 776151378Snetchild return("") if $no_seed && $dir =~ /\/seed/; 777151378Snetchild return("") if $no_rc2 && $dir =~ /\/rc2/; 778151378Snetchild return("") if $no_rc4 && $dir =~ /\/rc4/; 779151378Snetchild return("") if $no_rc5 && $dir =~ /\/rc5/; 780151378Snetchild return("") if $no_rsa && $dir =~ /\/rsa/; 781151378Snetchild return("") if $no_rsa && $dir =~ /^rsaref/; 782151378Snetchild return("") if $no_dsa && $dir =~ /\/dsa/; 783151378Snetchild return("") if $no_dh && $dir =~ /\/dh/; 784151378Snetchild return("") if $no_ec && $dir =~ /\/ec/; 785151378Snetchild return("") if $no_gost && $dir =~ /\/ccgost/; 786151378Snetchild return("") if $no_cms && $dir =~ /\/cms/; 787151378Snetchild return("") if $no_jpake && $dir =~ /\/jpake/; 788151378Snetchild if ($no_des && $dir =~ /\/des/) 789151378Snetchild { 790151378Snetchild if ($val =~ /read_pwd/) 791151378Snetchild { return("$dir/read_pwd "); } 792151378Snetchild else 793151378Snetchild { return(""); } 794151378Snetchild } 795151378Snetchild return("") if $no_mdc2 && $dir =~ /\/mdc2/; 796151378Snetchild return("") if $no_sock && $dir =~ /\/proxy/; 797151378Snetchild return("") if $no_bf && $dir =~ /\/bf/; 798151378Snetchild return("") if $no_cast && $dir =~ /\/cast/; 799151378Snetchild return("") if $no_whirlpool && $dir =~ /\/whrlpool/; 800151378Snetchild 801151378Snetchild $val =~ s/^\s*(.*)\s*$/$1/; 802151378Snetchild @a=split(/\s+/,$val); 803151378Snetchild grep(s/\.[och]$//,@a) unless $keepext; 804151378Snetchild 805151378Snetchild @a=grep(!/^e_.*_3d$/,@a) if $no_des; 806151378Snetchild @a=grep(!/^e_.*_d$/,@a) if $no_des; 807151378Snetchild @a=grep(!/^e_.*_ae$/,@a) if $no_idea; 808151378Snetchild @a=grep(!/^e_.*_i$/,@a) if $no_aes; 809151378Snetchild @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 810151378Snetchild @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 811151378Snetchild @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 812151378Snetchild @a=grep(!/^e_.*_c$/,@a) if $no_cast; 813151378Snetchild @a=grep(!/^e_rc4$/,@a) if $no_rc4; 814151378Snetchild @a=grep(!/^e_camellia$/,@a) if $no_camellia; 815151378Snetchild @a=grep(!/^e_seed$/,@a) if $no_seed; 816151378Snetchild 817151378Snetchild #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; 818151378Snetchild #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; 819151378Snetchild 820151378Snetchild @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 821151378Snetchild 822151378Snetchild @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 823151378Snetchild @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; 824151378Snetchild @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 825151378Snetchild @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; 826151378Snetchild 827151378Snetchild @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 828151378Snetchild @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 829151378Snetchild @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; 830151378Snetchild 831151378Snetchild @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; 832151378Snetchild @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; 833151378Snetchild 834151378Snetchild @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; 835151378Snetchild 836151378Snetchild @a=grep(!/_dhp$/,@a) if $no_dh; 837151378Snetchild 838151378Snetchild @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; 839151378Snetchild @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 840151378Snetchild @a=grep(!/_mdc2$/,@a) if $no_mdc2; 841151378Snetchild 842151378Snetchild @a=grep(!/(srp)/,@a) if $no_srp; 843151378Snetchild 844151378Snetchild @a=grep(!/^engine$/,@a) if $no_engine; 845151378Snetchild @a=grep(!/^hw$/,@a) if $no_hw; 846151378Snetchild @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; 847151378Snetchild @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 848151378Snetchild @a=grep(!/^gendsa$/,@a) if $no_sha1; 849151378Snetchild @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; 850151378Snetchild 851151378Snetchild @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 852151378Snetchild 853151378Snetchild grep($_="$dir/$_",@a); 854151378Snetchild @a=grep(!/(^|\/)s_/,@a) if $no_sock; 855151378Snetchild @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; 856151378Snetchild $ret=join(' ',@a)." "; 857151378Snetchild return($ret); 858151378Snetchild } 859151378Snetchild 860151378Snetchild# change things so that each 'token' is only separated by one space 861151378Snetchildsub clean_up_ws 862151378Snetchild { 863151378Snetchild local($w)=@_; 864151378Snetchild 865151378Snetchild $w =~ s/^\s*(.*)\s*$/$1/; 866151378Snetchild $w =~ s/\s+/ /g; 867151378Snetchild return($w); 868151378Snetchild } 869151378Snetchild 870151378Snetchildsub do_defs 871151378Snetchild { 872151378Snetchild local($var,$files,$location,$postfix)=@_; 873151378Snetchild local($_,$ret,$pf); 874151378Snetchild local(*OUT,$tmp,$t); 875151378Snetchild 876151378Snetchild $files =~ s/\//$o/g if $o ne '/'; 877151378Snetchild $ret="$var="; 878151378Snetchild $n=1; 879151378Snetchild $Vars{$var}.=""; 880151378Snetchild foreach (split(/ /,$files)) 881151378Snetchild { 882151378Snetchild $orig=$_; 883151378Snetchild $_=&bname($_) unless /^\$/; 884151378Snetchild if ($n++ == 2) 885151378Snetchild { 886151378Snetchild $n=0; 887151378Snetchild $ret.="\\\n\t"; 888151378Snetchild } 889151378Snetchild if (($_ =~ /bss_file/) && ($postfix eq ".h")) 890151378Snetchild { $pf=".c"; } 891151378Snetchild else { $pf=$postfix; } 892151378Snetchild if ($_ =~ /BN_ASM/) { $t="$_ "; } 893151378Snetchild elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } 894151378Snetchild elsif ($_ =~ /AES_ASM/){ $t="$_ "; } 895151378Snetchild elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 896151378Snetchild elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 897151378Snetchild elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 898151378Snetchild elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } 899151378Snetchild elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } 900151378Snetchild elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } 901151378Snetchild elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } 902151378Snetchild elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } 903151378Snetchild elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; } 904151378Snetchild elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } 905151378Snetchild else { $t="$location${o}$_$pf "; } 906151378Snetchild 907151378Snetchild $Vars{$var}.="$t "; 908151378Snetchild $ret.=$t; 909151378Snetchild } 910151378Snetchild # hack to add version info on MSVC 911151378Snetchild if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT"))) 912151378Snetchild { 913151378Snetchild if ($var eq "CRYPTOOBJ") 914151378Snetchild { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } 915151378Snetchild elsif ($var eq "SSLOBJ") 916151378Snetchild { $ret.="\$(OBJ_D)\\\$(SSL).res "; } 917151378Snetchild } 918151378Snetchild chomp($ret); 919151378Snetchild $ret.="\n\n"; 920151378Snetchild return($ret); 921151378Snetchild } 922151378Snetchild 923151378Snetchild# return the name with the leading path removed 924151378Snetchildsub bname 925151378Snetchild { 926151378Snetchild local($ret)=@_; 927151378Snetchild $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; 928151378Snetchild return($ret); 929151378Snetchild } 930151378Snetchild 931151378Snetchild# return the leading path 932151378Snetchildsub dname 933151378Snetchild { 934151378Snetchild my $ret=shift; 935151378Snetchild $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/; 936151378Snetchild return($ret); 937151378Snetchild } 938151378Snetchild 939151378Snetchild############################################################## 940151378Snetchild# do a rule for each file that says 'compile' to new direcory 941151378Snetchild# compile the files in '$files' into $to 942151378Snetchildsub do_compile_rule 943151378Snetchild { 944151378Snetchild local($to,$files,$ex)=@_; 945151378Snetchild local($ret,$_,$n,$d,$s); 946151378Snetchild 947151378Snetchild $files =~ s/\//$o/g if $o ne '/'; 948151378Snetchild foreach (split(/\s+/,$files)) 949151378Snetchild { 950151378Snetchild $n=&bname($_); 951151378Snetchild $d=&dname($_); 952151378Snetchild if (-f "${_}.c") 953151378Snetchild { 954151378Snetchild $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) 955151378Snetchild } 956151378Snetchild elsif (-f ($s="${d}${o}asm${o}${n}.pl") or 957151378Snetchild ($s=~s/sha256/sha512/ and -f $s) or 958151378Snetchild -f ($s="${d}${o}${n}.pl")) 959151378Snetchild { 960151378Snetchild $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n); 961151378Snetchild } 962151378Snetchild elsif (-f ($s="${d}${o}asm${o}${n}.S") or 963151378Snetchild -f ($s="${d}${o}${n}.S")) 964151378Snetchild { 965151378Snetchild $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n); 966151378Snetchild } 967151378Snetchild else { die "no rule for $_"; } 968151378Snetchild } 969151378Snetchild return($ret); 970151378Snetchild } 971151378Snetchild 972151378Snetchild############################################################## 973151378Snetchild# do a rule for each file that says 'compile' to new direcory 974151378Snetchildsub perlasm_compile_target 975151378Snetchild { 976151378Snetchild my($target,$source,$bname)=@_; 977151378Snetchild my($ret); 978151378Snetchild 979151378Snetchild $bname =~ s/(.*)\.[^\.]$/$1/; 980151378Snetchild $ret ="\$(TMP_D)$o$bname.asm: $source\n"; 981151378Snetchild $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n"; 982151378Snetchild $ret.="$target: \$(TMP_D)$o$bname.asm\n"; 983151378Snetchild $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; 984151378Snetchild return($ret); 985151378Snetchild } 986151378Snetchild 987151378Snetchildsub Sasm_compile_target 988151378Snetchild { 989151378Snetchild my($target,$source,$bname)=@_; 990151378Snetchild my($ret); 991151378Snetchild 992151378Snetchild $bname =~ s/(.*)\.[^\.]$/$1/; 993151378Snetchild $ret ="\$(TMP_D)$o$bname.asm: $source\n"; 994151378Snetchild $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n"; 995151378Snetchild $ret.="$target: \$(TMP_D)$o$bname.asm\n"; 996151378Snetchild $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; 997151378Snetchild return($ret); 998151378Snetchild } 999151378Snetchild 1000151378Snetchildsub cc_compile_target 1001151378Snetchild { 1002151378Snetchild local($target,$source,$ex_flags, $srcd)=@_; 1003151378Snetchild local($ret); 1004151378Snetchild 1005151378Snetchild $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); 1006151378Snetchild $target =~ s/\//$o/g if $o ne "/"; 1007151378Snetchild $source =~ s/\//$o/g if $o ne "/"; 1008151378Snetchild $srcd = "\$(SRC_D)$o" unless defined $srcd; 1009151378Snetchild $ret ="$target: $srcd$source\n\t"; 1010151378Snetchild $ret.="\$(CC) ${ofile}$target $ex_flags -c $srcd$source\n\n"; 1011151378Snetchild return($ret); 1012151378Snetchild } 1013151378Snetchild 1014151378Snetchild############################################################## 1015151378Snetchildsub do_asm_rule 1016151378Snetchild { 1017151378Snetchild local($target,$src)=@_; 1018151378Snetchild local($ret,@s,@t,$i); 1019151378Snetchild 1020151378Snetchild $target =~ s/\//$o/g if $o ne "/"; 1021151378Snetchild $src =~ s/\//$o/g if $o ne "/"; 1022151378Snetchild 1023151378Snetchild @t=split(/\s+/,$target); 1024151378Snetchild @s=split(/\s+/,$src); 1025151378Snetchild 1026151378Snetchild 1027151378Snetchild for ($i=0; $i<=$#s; $i++) 1028151378Snetchild { 1029151378Snetchild my $objfile = $t[$i]; 1030151378Snetchild my $srcfile = $s[$i]; 1031151378Snetchild 1032151378Snetchild if ($perl_asm == 1) 1033151378Snetchild { 1034151378Snetchild my $plasm = $objfile; 1035151378Snetchild $plasm =~ s/${obj}/.pl/; 1036151378Snetchild $ret.="$srcfile: $plasm\n"; 1037151378Snetchild $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n"; 1038151378Snetchild } 1039151378Snetchild 1040151378Snetchild $ret.="$objfile: $srcfile\n"; 1041151378Snetchild $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n"; 1042151378Snetchild } 1043151378Snetchild return($ret); 1044151378Snetchild } 1045151378Snetchild 1046151378Snetchildsub do_shlib_rule 1047151378Snetchild { 1048151378Snetchild local($n,$def)=@_; 1049151378Snetchild local($ret,$nn); 1050151378Snetchild local($t); 1051151378Snetchild 1052151378Snetchild ($nn=$n) =~ tr/a-z/A-Z/; 1053151378Snetchild $ret.="$n.dll: \$(${nn}OBJ)\n"; 1054151378Snetchild if ($vc && $w32) 1055151378Snetchild { 1056151378Snetchild $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; 1057151378Snetchild } 1058151378Snetchild $ret.="\n"; 1059151378Snetchild return($ret); 1060151378Snetchild } 1061151378Snetchild 1062151378Snetchild# do a rule for each file that says 'copy' to new direcory on change 1063151378Snetchildsub do_copy_rule 1064151378Snetchild { 1065151378Snetchild local($to,$files,$p)=@_; 1066151378Snetchild local($ret,$_,$n,$pp); 1067151378Snetchild 1068151378Snetchild $files =~ s/\//$o/g if $o ne '/'; 1069151378Snetchild foreach (split(/\s+/,$files)) 1070151378Snetchild { 1071151378Snetchild $n=&bname($_); 1072151378Snetchild if ($n =~ /bss_file/) 1073151378Snetchild { $pp=".c"; } 1074151378Snetchild else { $pp=$p; } 1075151378Snetchild $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; 1076151378Snetchild } 1077151378Snetchild return($ret); 1078151378Snetchild } 1079151378Snetchild 1080151378Snetchildsub read_options 1081151378Snetchild { 1082151378Snetchild # Many options are handled in a similar way. In particular 1083151378Snetchild # no-xxx sets zero or more scalars to 1. 1084151378Snetchild # Process these using a hash containing the option name and 1085151378Snetchild # reference to the scalars to set. 1086151378Snetchild 1087151378Snetchild my %valid_options = ( 1088151378Snetchild "no-rc2" => \$no_rc2, 1089151378Snetchild "no-rc4" => \$no_rc4, 1090151378Snetchild "no-rc5" => \$no_rc5, 1091151378Snetchild "no-idea" => \$no_idea, 1092151378Snetchild "no-aes" => \$no_aes, 1093151378Snetchild "no-camellia" => \$no_camellia, 1094151378Snetchild "no-seed" => \$no_seed, 1095151378Snetchild "no-des" => \$no_des, 1096151378Snetchild "no-bf" => \$no_bf, 1097151378Snetchild "no-cast" => \$no_cast, 1098151378Snetchild "no-md2" => \$no_md2, 1099151378Snetchild "no-md4" => \$no_md4, 1100151378Snetchild "no-md5" => \$no_md5, 1101151378Snetchild "no-sha" => \$no_sha, 1102151378Snetchild "no-sha1" => \$no_sha1, 1103151378Snetchild "no-ripemd" => \$no_ripemd, 1104151378Snetchild "no-mdc2" => \$no_mdc2, 1105151378Snetchild "no-whirlpool" => \$no_whirlpool, 1106151378Snetchild "no-patents" => 1107151378Snetchild [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], 1108151378Snetchild "no-rsa" => \$no_rsa, 1109151378Snetchild "no-dsa" => \$no_dsa, 1110151378Snetchild "no-dh" => \$no_dh, 1111151378Snetchild "no-hmac" => \$no_hmac, 1112151378Snetchild "no-asm" => \$no_asm, 1113151378Snetchild "nasm" => \$nasm, 1114151378Snetchild "nw-nasm" => \$nw_nasm, 1115151378Snetchild "nw-mwasm" => \$nw_mwasm, 1116151378Snetchild "gaswin" => \$gaswin, 1117151378Snetchild "no-ssl2" => \$no_ssl2, 1118151378Snetchild "no-ssl3" => \$no_ssl3, 1119151378Snetchild "no-tlsext" => \$no_tlsext, 1120151378Snetchild "no-srp" => \$no_srp, 1121151378Snetchild "no-cms" => \$no_cms, 1122151378Snetchild "no-ec2m" => \$no_ec2m, 1123151378Snetchild "no-jpake" => \$no_jpake, 1124151378Snetchild "no-ec_nistp_64_gcc_128" => 0, 1125151378Snetchild "no-err" => \$no_err, 1126151378Snetchild "no-sock" => \$no_sock, 1127151378Snetchild "no-krb5" => \$no_krb5, 1128151378Snetchild "no-ec" => \$no_ec, 1129151378Snetchild "no-ecdsa" => \$no_ecdsa, 1130151378Snetchild "no-ecdh" => \$no_ecdh, 1131151378Snetchild "no-gost" => \$no_gost, 1132151378Snetchild "no-engine" => \$no_engine, 1133151378Snetchild "no-hw" => \$no_hw, 1134151378Snetchild "no-rsax" => 0, 1135151378Snetchild "just-ssl" => 1136151378Snetchild [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, 1137151378Snetchild \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, 1138151378Snetchild \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, 1139151378Snetchild \$no_aes, \$no_camellia, \$no_seed, \$no_srp], 1140151378Snetchild "rsaref" => 0, 1141151378Snetchild "gcc" => \$gcc, 1142151378Snetchild "debug" => \$debug, 1143151378Snetchild "profile" => \$profile, 1144151378Snetchild "shlib" => \$shlib, 1145151378Snetchild "dll" => \$shlib, 1146151378Snetchild "shared" => 0, 1147151378Snetchild "no-sctp" => 0, 1148151378Snetchild "no-srtp" => 0, 1149151378Snetchild "no-gmp" => 0, 1150151378Snetchild "no-rfc3779" => 0, 1151151378Snetchild "no-montasm" => 0, 1152151378Snetchild "no-shared" => 0, 1153151378Snetchild "no-store" => 0, 1154151378Snetchild "no-unit-test" => 0, 1155151378Snetchild "no-zlib" => 0, 1156151378Snetchild "no-zlib-dynamic" => 0, 1157151378Snetchild "fips" => \$fips 1158151378Snetchild ); 1159151378Snetchild 1160151378Snetchild if (exists $valid_options{$_}) 1161151378Snetchild { 1162151378Snetchild my $r = $valid_options{$_}; 1163151378Snetchild if ( ref $r eq "SCALAR") 1164151378Snetchild { $$r = 1;} 1165151378Snetchild elsif ( ref $r eq "ARRAY") 1166151378Snetchild { 1167151378Snetchild my $r2; 1168151378Snetchild foreach $r2 (@$r) 1169151378Snetchild { 1170151378Snetchild $$r2 = 1; 1171151378Snetchild } 1172151378Snetchild } 1173151378Snetchild } 1174151378Snetchild elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } 1175151378Snetchild elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } 1176151378Snetchild elsif (/^enable-zlib-dynamic$/) 1177151378Snetchild { 1178151378Snetchild $zlib_opt = 2; 1179151378Snetchild } 1180151378Snetchild elsif (/^no-static-engine/) 1181151378Snetchild { 1182151378Snetchild $no_static_engine = 1; 1183151378Snetchild } 1184151378Snetchild elsif (/^enable-static-engine/) 1185151378Snetchild { 1186151378Snetchild $no_static_engine = 0; 1187151378Snetchild } 1188151378Snetchild # There are also enable-xxx options which correspond to 1189151378Snetchild # the no-xxx. Since the scalars are enabled by default 1190151378Snetchild # these can be ignored. 1191151378Snetchild elsif (/^enable-/) 1192151378Snetchild { 1193151378Snetchild my $t = $_; 1194151378Snetchild $t =~ s/^enable/no/; 1195151378Snetchild if (exists $valid_options{$t}) 1196151378Snetchild {return 1;} 1197151378Snetchild return 0; 1198151378Snetchild } 1199151378Snetchild # experimental-xxx is mostly like enable-xxx, but opensslconf.v 1200151378Snetchild # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx. 1201151378Snetchild # (No need to fail if we don't know the algorithm -- this is for adventurous users only.) 1202151378Snetchild elsif (/^experimental-/) 1203151378Snetchild { 1204151378Snetchild my $algo, $ALGO; 1205151378Snetchild ($algo = $_) =~ s/^experimental-//; 1206151378Snetchild ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/; 1207151378Snetchild 1208151378Snetchild $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags"; 1209151378Snetchild 1210151378Snetchild } 1211151378Snetchild elsif (/^--with-krb5-flavor=(.*)$/) 1212151378Snetchild { 1213151378Snetchild my $krb5_flavor = $1; 1214151378Snetchild if ($krb5_flavor =~ /^force-[Hh]eimdal$/) 1215151378Snetchild { 1216151378Snetchild $xcflags="-DKRB5_HEIMDAL $xcflags"; 1217151378Snetchild } 1218151378Snetchild elsif ($krb5_flavor =~ /^MIT/i) 1219151378Snetchild { 1220151378Snetchild $xcflags="-DKRB5_MIT $xcflags"; 1221151378Snetchild if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) 1222151378Snetchild { 1223151378Snetchild $xcflags="-DKRB5_MIT_OLD11 $xcflags" 1224151378Snetchild } 1225151378Snetchild } 1226151378Snetchild } 1227151378Snetchild elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } 1228151378Snetchild elsif (/^-[lL].*$/) { $l_flags.="$_ "; } 1229151378Snetchild elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) 1230151378Snetchild { $c_flags.="$_ "; } 1231151378Snetchild else { return(0); } 1232151378Snetchild return(1); 1233151378Snetchild } 1234151378Snetchild