mk1mf.pl revision 167612
133965Sjdp#!/usr/local/bin/perl 2218822Sdim# A bit of an evil hack but it post processes the file ../MINFO which 3218822Sdim# is generated by `make files` in the top directory. 433965Sjdp# This script outputs one mega makefile that has no shell stuff or any 533965Sjdp# funny stuff 6104834Sobrien# 733965Sjdp 8104834Sobrien$INSTALLTOP="/usr/local/ssl"; 9104834Sobrien$OPTIONS=""; 10104834Sobrien$ssl_version=""; 11104834Sobrien$banner="\t\@echo Building OpenSSL"; 1233965Sjdp 13104834Sobrienmy $no_static_engine = 0; 14104834Sobrienmy $engines = ""; 15104834Sobrienlocal $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 16104834Sobrienlocal $zlib_lib = ""; 1733965Sjdp 18104834Sobrien 19104834Sobrienopen(IN,"<Makefile") || die "unable to open Makefile!\n"; 20218822Sdimwhile(<IN>) { 2133965Sjdp $ssl_version=$1 if (/^VERSION=(.*)$/); 2233965Sjdp $OPTIONS=$1 if (/^OPTIONS=(.*)$/); 2333965Sjdp $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); 2433965Sjdp} 2533965Sjdpclose(IN); 2633965Sjdp 2733965Sjdpdie "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; 2833965Sjdp 2933965Sjdp$infile="MINFO"; 3033965Sjdp 3133965Sjdp%ops=( 3233965Sjdp "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", 3333965Sjdp "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", 3433965Sjdp "VC-WIN64A", "Microsoft C/C++ - Win64/x64", 3533965Sjdp "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", 3633965Sjdp "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", 3733965Sjdp "Mingw32", "GNU C++ - Windows NT or 9x", 3889857Sobrien "Mingw32-files", "Create files with DOS copy ...", 3989857Sobrien "BC-NT", "Borland C++ 4.5 - Windows NT", 4033965Sjdp "linux-elf","Linux elf", 4133965Sjdp "ultrix-mips","DEC mips ultrix", 4233965Sjdp "FreeBSD","FreeBSD distribution", 4333965Sjdp "OS2-EMX", "EMX GCC OS/2", 4489857Sobrien "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", 4589857Sobrien "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", 4689857Sobrien "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", 4789857Sobrien "default","cc under unix", 4889857Sobrien ); 4989857Sobrien 5089857Sobrien$platform=""; 5189857Sobrienmy $xcflags=""; 5289857Sobrienforeach (@ARGV) 5333965Sjdp { 5433965Sjdp if (!&read_options && !defined($ops{$_})) 5533965Sjdp { 5633965Sjdp print STDERR "unknown option - $_\n"; 5733965Sjdp print STDERR "usage: perl mk1mf.pl [options] [system]\n"; 5833965Sjdp print STDERR "\nwhere [system] can be one of the following\n"; 5933965Sjdp foreach $i (sort keys %ops) 6033965Sjdp { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } 6133965Sjdp print STDERR <<"EOF"; 6233965Sjdpand [options] can be one of 6333965Sjdp no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest 6433965Sjdp no-ripemd 6533965Sjdp no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher 6633965Sjdp no-bf no-cast no-aes no-camellia 6733965Sjdp no-rsa no-dsa no-dh - Skip this public key cipher 6833965Sjdp no-ssl2 no-ssl3 - Skip this version of SSL 69130561Sobrien just-ssl - remove all non-ssl keys/digest 70130561Sobrien no-asm - No x86 asm 71130561Sobrien no-krb5 - No KRB5 72130561Sobrien no-ec - No EC 73130561Sobrien no-ecdsa - No ECDSA 74130561Sobrien no-ecdh - No ECDH 75130561Sobrien no-engine - No engine 76130561Sobrien no-hw - No hw 7733965Sjdp nasm - Use NASM for x86 asm 7833965Sjdp nw-nasm - Use NASM x86 asm for NetWare 7933965Sjdp nw-mwasm - Use Metrowerks x86 asm for NetWare 8033965Sjdp gaswin - Use GNU as with Mingw32 8133965Sjdp no-socks - No socket code 8233965Sjdp no-err - No error strings 8333965Sjdp dll/shlib - Build shared libraries (MS) 84130561Sobrien debug - Debug build 8533965Sjdp profile - Profiling build 8633965Sjdp gcc - Use Gcc (unix) 8733965Sjdp 8833965SjdpValues that can be set 8933965SjdpTMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 9033965Sjdp 9133965Sjdp-L<ex_lib_path> -l<ex_lib> - extra library flags (unix) 9233965Sjdp-<ex_cc_flags> - extra 'cc' flags, 9333965Sjdp added (MS), or replace (unix) 9433965SjdpEOF 95218822Sdim exit(1); 96218822Sdim } 97218822Sdim $platform=$_; 98218822Sdim } 99218822Sdimforeach (grep(!/^$/, split(/ /, $OPTIONS))) 100218822Sdim { 101218822Sdim print STDERR "unknown option - $_\n" if !&read_options; 102218822Sdim } 103218822Sdim 104218822Sdim$no_static_engine = 0 if (!$shlib); 105218822Sdim 106218822Sdim$no_mdc2=1 if ($no_des); 107218822Sdim 108218822Sdim$no_ssl3=1 if ($no_md5 || $no_sha); 109218822Sdim$no_ssl3=1 if ($no_rsa && $no_dh); 110218822Sdim 111218822Sdim$no_ssl2=1 if ($no_md5); 112218822Sdim$no_ssl2=1 if ($no_rsa); 113218822Sdim 114218822Sdim$out_def="out"; 11533965Sjdp$inc_def="outinc"; 116218822Sdim$tmp_def="tmp"; 11733965Sjdp 11833965Sjdp$perl="perl" unless defined $perl; 11933965Sjdp$mkdir="-mkdir" unless defined $mkdir; 12033965Sjdp 121218822Sdim($ssl,$crypto)=("ssl","crypto"); 122218822Sdim$ranlib="echo ranlib"; 12333965Sjdp 12433965Sjdp$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 12533965Sjdp$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; 12633965Sjdp$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; 12733965Sjdp 128218822Sdim# $bin_dir.=$o causes a core dump on my sparc :-( 12933965Sjdp 13033965Sjdp 13133965Sjdp$NT=0; 13233965Sjdp 13333965Sjdppush(@INC,"util/pl","pl"); 13433965Sjdpif (($platform =~ /VC-(.+)/)) 135218822Sdim { 13633965Sjdp $FLAVOR=$1; 137130561Sobrien $NT = 1 if $1 eq "NT"; 138130561Sobrien require 'VC-32.pl'; 139130561Sobrien } 140130561Sobrienelsif ($platform eq "Mingw32") 141130561Sobrien { 142130561Sobrien require 'Mingw32.pl'; 143130561Sobrien } 144130561Sobrienelsif ($platform eq "Mingw32-files") 14533965Sjdp { 14633965Sjdp require 'Mingw32f.pl'; 14733965Sjdp } 14833965Sjdpelsif ($platform eq "BC-NT") 14933965Sjdp { 150218822Sdim $bc=1; 15133965Sjdp require 'BC-32.pl'; 15233965Sjdp } 15333965Sjdpelsif ($platform eq "FreeBSD") 15433965Sjdp { 15533965Sjdp require 'unix.pl'; 15633965Sjdp $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; 15733965Sjdp } 15833965Sjdpelsif ($platform eq "linux-elf") 15933965Sjdp { 16033965Sjdp require "unix.pl"; 16133965Sjdp require "linux.pl"; 16233965Sjdp $unix=1; 16333965Sjdp } 16433965Sjdpelsif ($platform eq "ultrix-mips") 16533965Sjdp { 16633965Sjdp require "unix.pl"; 16733965Sjdp require "ultrix.pl"; 16833965Sjdp $unix=1; 16933965Sjdp } 17033965Sjdpelsif ($platform eq "OS2-EMX") 17133965Sjdp { 172130561Sobrien $wc=1; 17389857Sobrien require 'OS2-EMX.pl'; 17433965Sjdp } 17533965Sjdpelsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || 176130561Sobrien ($platform eq "netware-libc-bsdsock")) 17733965Sjdp { 17833965Sjdp $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; 17933965Sjdp $BSDSOCK=1 if $platform eq "netware-libc-bsdsock"; 180130561Sobrien require 'netware.pl'; 181130561Sobrien } 18233965Sjdpelse 18333965Sjdp { 18433965Sjdp require "unix.pl"; 18533965Sjdp 18633965Sjdp $unix=1; 18733965Sjdp $cflags.=' -DTERMIO'; 188130561Sobrien } 189130561Sobrien 19033965Sjdp$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); 19133965Sjdp$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); 19233965Sjdp$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; 193130561Sobrien 194130561Sobrien$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 195130561Sobrien 19633965Sjdp$cflags= "$xcflags$cflags" if $xcflags ne ""; 19733965Sjdp 19833965Sjdp$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; 199130561Sobrien$cflags.=" -DOPENSSL_NO_AES" if $no_aes; 200104834Sobrien$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; 201218822Sdim$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; 202218822Sdim$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; 203218822Sdim$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; 204218822Sdim$cflags.=" -DOPENSSL_NO_MD2" if $no_md2; 205104834Sobrien$cflags.=" -DOPENSSL_NO_MD4" if $no_md4; 206104834Sobrien$cflags.=" -DOPENSSL_NO_MD5" if $no_md5; 207104834Sobrien$cflags.=" -DOPENSSL_NO_SHA" if $no_sha; 208104834Sobrien$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; 209104834Sobrien$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; 21033965Sjdp$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; 211130561Sobrien$cflags.=" -DOPENSSL_NO_BF" if $no_bf; 212130561Sobrien$cflags.=" -DOPENSSL_NO_CAST" if $no_cast; 213130561Sobrien$cflags.=" -DOPENSSL_NO_DES" if $no_des; 214130561Sobrien$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; 215130561Sobrien$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; 216130561Sobrien$cflags.=" -DOPENSSL_NO_DH" if $no_dh; 217130561Sobrien$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; 218130561Sobrien$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; 219130561Sobrien$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 220130561Sobrien$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 221130561Sobrien$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 222130561Sobrien$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 223130561Sobrien$cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; 224218822Sdim$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 225218822Sdim$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 22633965Sjdp$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 22733965Sjdp 22833965Sjdp$cflags.= " -DZLIB" if $zlib_opt; 22933965Sjdp$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 23033965Sjdp 231130561Sobrienif ($no_static_engine) 232130561Sobrien { 233104834Sobrien $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; 234130561Sobrien } 235104834Sobrienelse 236130561Sobrien { 237104834Sobrien $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; 238130561Sobrien } 239104834Sobrien 240104834Sobrien#$cflags.=" -DRSAref" if $rsaref ne ""; 241130561Sobrien 242104834Sobrien## if ($unix) 243130561Sobrien## { $cflags="$c_flags" if ($c_flags ne ""); } 244130561Sobrien##else 245104834Sobrien { $cflags="$c_flags$cflags" if ($c_flags ne ""); } 246130561Sobrien 247130561Sobrien$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 248104834Sobrien 249130561Sobrien 25089857Sobrien%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 251130561Sobrien "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); 252104834Sobrien 253130561Sobrienif ($msdos) 254130561Sobrien { 255104834Sobrien $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; 256130561Sobrien $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; 25733965Sjdp $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; 25833965Sjdp $banner.="\t\@echo documentation for details.\n"; 25933965Sjdp } 260130561Sobrien 261104834Sobrien# have to do this to allow $(CC) under unix 262130561Sobrien$link="$bin_dir$link" if ($link !~ /^\$/); 26360484Sobrien 264130561Sobrien$INSTALLTOP =~ s|/|$o|g; 265104834Sobrien 266130561Sobrien############################################# 267130561Sobrien# We parse in input file and 'store' info for later printing. 268104834Sobrienopen(IN,"<$infile") || die "unable to open $infile:$!\n"; 269130561Sobrien$_=<IN>; 270130561Sobrienfor (;;) 271104834Sobrien { 272218822Sdim chop; 273218822Sdim 274218822Sdim ($key,$val)=/^([^=]+)=(.*)/; 275218822Sdim if ($key eq "RELATIVE_DIRECTORY") 276218822Sdim { 277218822Sdim if ($lib ne "") 278218822Sdim { 279218822Sdim $uc=$lib; 280130561Sobrien $uc =~ s/^lib(.*)\.a/$1/; 281130561Sobrien $uc =~ tr/a-z/A-Z/; 282130561Sobrien $lib_nam{$uc}=$uc; 283104834Sobrien $lib_obj{$uc}.=$libobj." "; 284130561Sobrien } 285130561Sobrien last if ($val eq "FINISHED"); 286130561Sobrien $lib=""; 287104834Sobrien $libobj=""; 288130561Sobrien $dir=$val; 289130561Sobrien } 290130561Sobrien 291130561Sobrien if ($key eq "KRB5_INCLUDES") 292130561Sobrien { $cflags .= " $val";} 293130561Sobrien 294130561Sobrien if ($key eq "ZLIB_INCLUDE") 295130561Sobrien { $cflags .= " $val" if $val ne "";} 296130561Sobrien 297130561Sobrien if ($key eq "LIBZLIB") 298130561Sobrien { $zlib_lib = "$val" if $val ne "";} 299130561Sobrien 300130561Sobrien if ($key eq "LIBKRB5") 301130561Sobrien { $ex_libs .= " $val" if $val ne "";} 302130561Sobrien 303130561Sobrien if ($key eq "TEST") 304130561Sobrien { $test.=&var_add($dir,$val, 0); } 305130561Sobrien 306130561Sobrien if (($key eq "PROGS") || ($key eq "E_OBJ")) 307130561Sobrien { $e_exe.=&var_add($dir,$val, 0); } 308130561Sobrien 309130561Sobrien if ($key eq "LIB") 310130561Sobrien { 311130561Sobrien $lib=$val; 312130561Sobrien $lib =~ s/^.*\/([^\/]+)$/$1/; 313130561Sobrien } 314130561Sobrien 315130561Sobrien if ($key eq "EXHEADER") 316130561Sobrien { $exheader.=&var_add($dir,$val, 1); } 317130561Sobrien 318130561Sobrien if ($key eq "HEADER") 319130561Sobrien { $header.=&var_add($dir,$val, 1); } 320218822Sdim 321218822Sdim if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) 322218822Sdim { $libobj=&var_add($dir,$val, 0); } 323218822Sdim if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 324218822Sdim { $engines.=$val } 325218822Sdim 326218822Sdim if (!($_=<IN>)) 327218822Sdim { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 328218822Sdim } 329218822Sdimclose(IN); 330218822Sdim 331218822Sdimif ($shlib) 332218822Sdim { 333218822Sdim $extra_install= <<"EOF"; 334218822Sdim \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}bin 335218822Sdim \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}bin 336218822Sdim \$(CP) \$(L_SSL) \$(INSTALLTOP)${o}lib 337218822Sdim \$(CP) \$(L_CRYPTO) \$(INSTALLTOP)${o}lib 338218822SdimEOF 339218822Sdim if ($no_static_engine) 340218822Sdim { 341218822Sdim $extra_install .= <<"EOF" 342218822Sdim \$(MKDIR) \$(INSTALLTOP)${o}lib${o}engines 343218822Sdim \$(CP) \$(E_SHLIB) \$(INSTALLTOP)${o}lib${o}engines 344218822SdimEOF 345218822Sdim } 346218822Sdim } 347218822Sdimelse 348218822Sdim { 349218822Sdim $extra_install= <<"EOF"; 350130561Sobrien \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib 351130561Sobrien \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib 352130561SobrienEOF 353130561Sobrien $ex_libs .= " $zlib_lib" if $zlib_opt == 1; 354130561Sobrien } 355130561Sobrien 356130561Sobrien$defs= <<"EOF"; 357130561Sobrien# This makefile has been automatically generated from the OpenSSL distribution. 358130561Sobrien# This single makefile will build the complete OpenSSL distribution and 359130561Sobrien# by default leave the 'intertesting' output files in .${o}out and the stuff 360130561Sobrien# that needs deleting in .${o}tmp. 36133965Sjdp# The file was generated by running 'make makefile.one', which 36233965Sjdp# does a 'make files', which writes all the environment variables from all 363104834Sobrien# the makefiles to the file call MINFO. This file is used by 36433965Sjdp# util${o}mk1mf.pl to generate makefile.one. 36533965Sjdp# The 'makefile per directory' system suites me when developing this 366104834Sobrien# library and also so I can 'distribute' indervidual library sections. 367130561Sobrien# The one monster makefile better suits building in non-unix 368130561Sobrien# environments. 369130561Sobrien 370104834SobrienEOF 371130561Sobrien 372130561Sobrien$defs .= $preamble if defined $preamble; 373130561Sobrien 374130561Sobrien$defs.= <<"EOF"; 375104834SobrienINSTALLTOP=$INSTALLTOP 376130561Sobrien 377130561Sobrien# Set your compiler options 378104834SobrienPLATFORM=$platform 37933965SjdpCC=$bin_dir${cc} 38033965SjdpCFLAG=$cflags 381104834SobrienAPP_CFLAG=$app_cflag 38233965SjdpLIB_CFLAG=$lib_cflag 38333965SjdpSHLIB_CFLAG=$shl_cflag 38433965SjdpAPP_EX_OBJ=$app_ex_obj 385104834SobrienSHLIB_EX_OBJ=$shlib_ex_obj 38633965Sjdp# add extra libraries to this define, for solaris -lsocket -lnsl would 387130561Sobrien# be added 38833965SjdpEX_LIBS=$ex_libs 38933965Sjdp 390104834Sobrien# The OpenSSL directory 39133965SjdpSRC_D=$src_dir 39233965Sjdp 39333965SjdpLINK=$link 394104834SobrienLFLAGS=$lflags 395130561SobrienRSC=$rsc 396130561Sobrien 397130561SobrienBN_ASM_OBJ=$bn_asm_obj 398218822SdimBN_ASM_SRC=$bn_asm_src 399130561SobrienBNCO_ASM_OBJ=$bnco_asm_obj 400130561SobrienBNCO_ASM_SRC=$bnco_asm_src 401130561SobrienDES_ENC_OBJ=$des_enc_obj 402130561SobrienDES_ENC_SRC=$des_enc_src 403130561SobrienBF_ENC_OBJ=$bf_enc_obj 404130561SobrienBF_ENC_SRC=$bf_enc_src 405130561SobrienCAST_ENC_OBJ=$cast_enc_obj 406130561SobrienCAST_ENC_SRC=$cast_enc_src 407130561SobrienRC4_ENC_OBJ=$rc4_enc_obj 408130561SobrienRC4_ENC_SRC=$rc4_enc_src 409130561SobrienRC5_ENC_OBJ=$rc5_enc_obj 410130561SobrienRC5_ENC_SRC=$rc5_enc_src 41133965SjdpMD5_ASM_OBJ=$md5_asm_obj 412130561SobrienMD5_ASM_SRC=$md5_asm_src 41360484SobrienSHA1_ASM_OBJ=$sha1_asm_obj 41460484SobrienSHA1_ASM_SRC=$sha1_asm_src 41560484SobrienRMD160_ASM_OBJ=$rmd160_asm_obj 41660484SobrienRMD160_ASM_SRC=$rmd160_asm_src 417104834SobrienCPUID_ASM_OBJ=$cpuid_asm_obj 41860484SobrienCPUID_ASM_SRC=$cpuid_asm_src 41960484Sobrien 42060484Sobrien# The output directory for everything intersting 42177298SobrienOUT_D=$out_dir 422218822Sdim# The output directory for all the temporary muck 423218822SdimTMP_D=$tmp_dir 424218822Sdim# The output directory for the header files 425218822SdimINC_D=$inc_dir 426218822SdimINCO_D=$inc_dir${o}openssl 427218822Sdim 428218822SdimPERL=$perl 429218822SdimCP=$cp 430218822SdimRM=$rm 431218822SdimRANLIB=$ranlib 432218822SdimMKDIR=$mkdir 433130561SobrienMKLIB=$bin_dir$mklib 434104834SobrienMLFLAGS=$mlflags 435104834SobrienASM=$bin_dir$asm 436104834Sobrien 43789857Sobrien###################################################### 438130561Sobrien# You should not need to touch anything below this point 439130561Sobrien###################################################### 440130561Sobrien 441130561SobrienE_EXE=openssl 44289857SobrienSSL=$ssl 443130561SobrienCRYPTO=$crypto 444130561Sobrien 44589857Sobrien# BIN_D - Binary output directory 446130561Sobrien# TEST_D - Binary test file output directory 447130561Sobrien# LIB_D - library output directory 44889857Sobrien# ENG_D - dynamic engine output directory 449130561Sobrien# Note: if you change these point to different directories then uncomment out 450130561Sobrien# the lines around the 'NB' comment below. 451218822Sdim# 452218822SdimBIN_D=\$(OUT_D) 453218822SdimTEST_D=\$(OUT_D) 454218822SdimLIB_D=\$(OUT_D) 455218822SdimENG_D=\$(OUT_D) 456218822Sdim 45733965Sjdp# INCL_D - local library directory 45833965Sjdp# OBJ_D - temp object file directory 459218822SdimOBJ_D=\$(TMP_D) 460218822SdimINCL_D=\$(TMP_D) 461218822Sdim 462218822SdimO_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 463218822SdimO_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 464218822SdimSO_SSL= $plib\$(SSL)$so_shlibp 46533965SjdpSO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 46633965SjdpL_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 46733965SjdpL_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 46833965Sjdp 46933965SjdpL_LIBS= \$(L_SSL) \$(L_CRYPTO) 47033965Sjdp 47133965Sjdp###################################################### 472130561Sobrien# Don't touch anything below this point 473130561Sobrien###################################################### 47433965Sjdp 47533965SjdpINC=-I\$(INC_D) -I\$(INCL_D) 47633965SjdpAPP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 47733965SjdpLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 47833965SjdpSHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 47933965SjdpLIBS_DEP=\$(O_CRYPTO) \$(O_SSL) 480130561Sobrien 481130561Sobrien############################################# 482130561SobrienEOF 483130561Sobrien 48433965Sjdp$rules=<<"EOF"; 48533965Sjdpall: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe 48633965Sjdp 48733965Sjdpbanner: 48833965Sjdp$banner 48933965Sjdp 49033965Sjdp\$(TMP_D): 49133965Sjdp \$(MKDIR) \$(TMP_D) 49233965Sjdp# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different 49333965Sjdp#\$(BIN_D): 49433965Sjdp# \$(MKDIR) \$(BIN_D) 495130561Sobrien# 496130561Sobrien#\$(TEST_D): 497130561Sobrien# \$(MKDIR) \$(TEST_D) 498130561Sobrien 49933965Sjdp\$(LIB_D): 50033965Sjdp \$(MKDIR) \$(LIB_D) 50133965Sjdp 502130561Sobrien\$(INCO_D): \$(INC_D) 50333965Sjdp \$(MKDIR) \$(INCO_D) 50433965Sjdp 505130561Sobrien\$(INC_D): 506130561Sobrien \$(MKDIR) \$(INC_D) 507130561Sobrien 50833965Sjdpheaders: \$(HEADER) \$(EXHEADER) 50933965Sjdp @ 510130561Sobrien 51133965Sjdplib: \$(LIBS_DEP) \$(E_SHLIB) 512130561Sobrien 51333965Sjdpexe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep 514130561Sobrien 515130561Sobrieninstall: all 516130561Sobrien \$(MKDIR) \$(INSTALLTOP) 51733965Sjdp \$(MKDIR) \$(INSTALLTOP)${o}bin 51833965Sjdp \$(MKDIR) \$(INSTALLTOP)${o}include 51933965Sjdp \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl 52033965Sjdp \$(MKDIR) \$(INSTALLTOP)${o}lib 52133965Sjdp \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl 52233965Sjdp \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin 52333965Sjdp \$(CP) apps${o}openssl.cnf \$(INSTALLTOP) 524130561Sobrien$extra_install 525130561Sobrien 526130561Sobrien 52733965Sjdptest: \$(T_EXE) 52833965Sjdp cd \$(BIN_D) 52933965Sjdp ..${o}ms${o}test 53060484Sobrien 53160484Sobrienclean: 532130561Sobrien \$(RM) \$(TMP_D)$o*.* 533130561Sobrien 534130561Sobrienvclean: 535218822Sdim \$(RM) \$(TMP_D)$o*.* 536218822Sdim \$(RM) \$(OUT_D)$o*.* 537218822Sdim 538218822SdimEOF 539218822Sdim 54033965Sjdpmy $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; 54133965Sjdp$platform_cpp_symbol =~ s/-/_/g; 54233965Sjdpif (open(IN,"crypto/buildinf.h")) 543130561Sobrien { 544218822Sdim # Remove entry for this platform in existing file buildinf.h. 545218822Sdim 546218822Sdim my $old_buildinf_h = ""; 54733965Sjdp while (<IN>) 548218822Sdim { 54933965Sjdp if (/^\#ifdef $platform_cpp_symbol$/) 55033965Sjdp { 55133965Sjdp while (<IN>) { last if (/^\#endif/); } 55233965Sjdp } 553130561Sobrien else 554130561Sobrien { 555130561Sobrien $old_buildinf_h .= $_; 55633965Sjdp } 55733965Sjdp } 55833965Sjdp close(IN); 55933965Sjdp 56033965Sjdp open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; 56133965Sjdp print OUT $old_buildinf_h; 562130561Sobrien close(OUT); 563130561Sobrien } 564130561Sobrien 56533965Sjdpopen (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; 56633965Sjdpprintf OUT <<EOF; 56733965Sjdp#ifdef $platform_cpp_symbol 56833965Sjdp /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ 569130561Sobrien #define CFLAGS "$cc $cflags" 570130561Sobrien #define PLATFORM "$platform" 571130561SobrienEOF 572218822Sdimprintf OUT " #define DATE \"%s\"\n", scalar gmtime(); 573218822Sdimprintf OUT "#endif\n"; 574218822Sdimclose(OUT); 575218822Sdim 576218822Sdim# Strip of trailing ' ' 577218822Sdimforeach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } 578218822Sdim$test=&clean_up_ws($test); 579218822Sdim$e_exe=&clean_up_ws($e_exe); 580218822Sdim$exheader=&clean_up_ws($exheader); 581218822Sdim$header=&clean_up_ws($header); 582218822Sdim 583218822Sdim# First we strip the exheaders from the headers list 584218822Sdimforeach (split(/\s+/,$exheader)){ $h{$_}=1; } 585218822Sdimforeach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } 586218822Sdimchop($h); $header=$h; 587218822Sdim 58833965Sjdp$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); 58933965Sjdp$rules.=&do_copy_rule("\$(INCL_D)",$header,""); 59033965Sjdp 59133965Sjdp$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); 59233965Sjdp$rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); 59333965Sjdp 59433965Sjdp$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); 59533965Sjdp$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); 59633965Sjdp 59733965Sjdp$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 59833965Sjdp$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 59933965Sjdp 60033965Sjdpforeach (values %lib_nam) 60133965Sjdp { 60233965Sjdp $lib_obj=$lib_obj{$_}; 60333965Sjdp local($slib)=$shlib; 60433965Sjdp 605218822Sdim if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) 60633965Sjdp { 607130561Sobrien $rules.="\$(O_SSL):\n\n"; 60833965Sjdp next; 60933965Sjdp } 61033965Sjdp 61133965Sjdp if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) 61233965Sjdp { 61333965Sjdp $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; 614130561Sobrien $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src); 61533965Sjdp } 61633965Sjdp if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO")) 61733965Sjdp { 618130561Sobrien $lib_obj .= "\$(BNCO_ASM_OBJ)"; 61933965Sjdp $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src); 620130561Sobrien } 62133965Sjdp if (($des_enc_obj ne "") && ($_ eq "CRYPTO")) 62233965Sjdp { 62333965Sjdp $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; 62433965Sjdp $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; 625218822Sdim $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); 62633965Sjdp } 62733965Sjdp if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) 62833965Sjdp { 62933965Sjdp $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/; 63033965Sjdp $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src); 63133965Sjdp } 632104834Sobrien if (($cast_enc_obj ne "") && ($_ eq "CRYPTO")) 633104834Sobrien { 634104834Sobrien $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/; 635104834Sobrien $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src); 636104834Sobrien } 637104834Sobrien if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO")) 63833965Sjdp { 63933965Sjdp $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/; 64033965Sjdp $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src); 64133965Sjdp } 64233965Sjdp if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO")) 64333965Sjdp { 64433965Sjdp $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/; 64533965Sjdp $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src); 64633965Sjdp } 64733965Sjdp if (($md5_asm_obj ne "") && ($_ eq "CRYPTO")) 64833965Sjdp { 64933965Sjdp $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; 65033965Sjdp $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); 65133965Sjdp } 65233965Sjdp if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO")) 65333965Sjdp { 65433965Sjdp $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/; 65533965Sjdp $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src); 65633965Sjdp } 65733965Sjdp if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) 65833965Sjdp { 65933965Sjdp $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; 66033965Sjdp $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); 66133965Sjdp } 66233965Sjdp if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO")) 66333965Sjdp { 66433965Sjdp $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/; 66533965Sjdp $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src); 66633965Sjdp } 66733965Sjdp $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 66833965Sjdp $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 66933965Sjdp $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 67033965Sjdp } 67133965Sjdp 67233965Sjdp# hack to add version info on MSVC 67333965Sjdpif (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) { 67433965Sjdp $rules.= <<"EOF"; 67533965Sjdp\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc 67633965Sjdp \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc 67733965Sjdp 67833965Sjdp\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 67933965Sjdp \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 68033965Sjdp 68133965SjdpEOF 68233965Sjdp} 68333965Sjdp 68433965Sjdp$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 68533965Sjdpforeach (split(/\s+/,$test)) 68633965Sjdp { 687130561Sobrien $t=&bname($_); 68833965Sjdp $tt="\$(OBJ_D)${o}$t${obj}"; 68933965Sjdp $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 69033965Sjdp } 69133965Sjdp 69233965Sjdp$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); 69333965Sjdp 694130561Sobrienforeach (split(/\s+/,$engines)) 69533965Sjdp { 69633965Sjdp $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); 69733965Sjdp $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); 698130561Sobrien } 69933965Sjdp 700130561Sobrien 70160484Sobrien 702130561Sobrien$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 703130561Sobrien$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); 704104834Sobrien 705130561Sobrien$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 706104834Sobrien 707104834Sobrienprint $defs; 708130561Sobrien 709130561Sobrienif ($platform eq "linux-elf") { 710130561Sobrien print <<"EOF"; 711130561Sobrien# Generate perlasm output files 712130561Sobrien%.cpp: 71333965Sjdp (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) 71433965SjdpEOF 715130561Sobrien} 716130561Sobrienprint "###################################################################\n"; 717130561Sobrienprint $rules; 718130561Sobrien 719130561Sobrien############################################### 720130561Sobrien# strip off any trailing .[och] and append the relative directory 721130561Sobrien# also remembering to do nothing if we are in one of the dropped 722130561Sobrien# directories 723130561Sobriensub var_add 724130561Sobrien { 725130561Sobrien local($dir,$val,$keepext)=@_; 726130561Sobrien local(@a,$_,$ret); 72733965Sjdp 72833965Sjdp return("") if $no_engine && $dir =~ /\/engine/; 72933965Sjdp return("") if $no_hw && $dir =~ /\/hw/; 73033965Sjdp return("") if $no_idea && $dir =~ /\/idea/; 73133965Sjdp return("") if $no_aes && $dir =~ /\/aes/; 73233965Sjdp return("") if $no_camellia && $dir =~ /\/camellia/; 73333965Sjdp return("") if $no_rc2 && $dir =~ /\/rc2/; 73433965Sjdp return("") if $no_rc4 && $dir =~ /\/rc4/; 73533965Sjdp return("") if $no_rc5 && $dir =~ /\/rc5/; 73633965Sjdp return("") if $no_rsa && $dir =~ /\/rsa/; 73733965Sjdp return("") if $no_rsa && $dir =~ /^rsaref/; 73833965Sjdp return("") if $no_dsa && $dir =~ /\/dsa/; 73933965Sjdp return("") if $no_dh && $dir =~ /\/dh/; 74033965Sjdp return("") if $no_ec && $dir =~ /\/ec/; 74133965Sjdp if ($no_des && $dir =~ /\/des/) 74233965Sjdp { 74333965Sjdp if ($val =~ /read_pwd/) 74433965Sjdp { return("$dir/read_pwd "); } 74533965Sjdp else 74633965Sjdp { return(""); } 74733965Sjdp } 748130561Sobrien return("") if $no_mdc2 && $dir =~ /\/mdc2/; 74933965Sjdp return("") if $no_sock && $dir =~ /\/proxy/; 750130561Sobrien return("") if $no_bf && $dir =~ /\/bf/; 75133965Sjdp return("") if $no_cast && $dir =~ /\/cast/; 75233965Sjdp 75333965Sjdp $val =~ s/^\s*(.*)\s*$/$1/; 75433965Sjdp @a=split(/\s+/,$val); 75533965Sjdp grep(s/\.[och]$//,@a) unless $keepext; 75633965Sjdp 757130561Sobrien @a=grep(!/^e_.*_3d$/,@a) if $no_des; 758130561Sobrien @a=grep(!/^e_.*_d$/,@a) if $no_des; 759130561Sobrien @a=grep(!/^e_.*_ae$/,@a) if $no_idea; 760130561Sobrien @a=grep(!/^e_.*_i$/,@a) if $no_aes; 76133965Sjdp @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 76233965Sjdp @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 763218822Sdim @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 764218822Sdim @a=grep(!/^e_.*_c$/,@a) if $no_cast; 765218822Sdim @a=grep(!/^e_rc4$/,@a) if $no_rc4; 766218822Sdim @a=grep(!/^e_camellia$/,@a) if $no_camellia; 767218822Sdim 768218822Sdim @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; 769218822Sdim @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; 770218822Sdim 77133965Sjdp @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 772 773 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 774 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; 775 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 776 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; 777 778 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 779 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 780 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; 781 782 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; 783 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; 784 785 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; 786 787 @a=grep(!/_dhp$/,@a) if $no_dh; 788 789 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; 790 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 791 @a=grep(!/_mdc2$/,@a) if $no_mdc2; 792 793 @a=grep(!/^engine$/,@a) if $no_engine; 794 @a=grep(!/^hw$/,@a) if $no_hw; 795 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; 796 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 797 @a=grep(!/^gendsa$/,@a) if $no_sha1; 798 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; 799 800 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 801 802 grep($_="$dir/$_",@a); 803 @a=grep(!/(^|\/)s_/,@a) if $no_sock; 804 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; 805 $ret=join(' ',@a)." "; 806 return($ret); 807 } 808 809# change things so that each 'token' is only separated by one space 810sub clean_up_ws 811 { 812 local($w)=@_; 813 814 $w =~ s/^\s*(.*)\s*$/$1/; 815 $w =~ s/\s+/ /g; 816 return($w); 817 } 818 819sub do_defs 820 { 821 local($var,$files,$location,$postfix)=@_; 822 local($_,$ret,$pf); 823 local(*OUT,$tmp,$t); 824 825 $files =~ s/\//$o/g if $o ne '/'; 826 $ret="$var="; 827 $n=1; 828 $Vars{$var}.=""; 829 foreach (split(/ /,$files)) 830 { 831 $orig=$_; 832 $_=&bname($_) unless /^\$/; 833 if ($n++ == 2) 834 { 835 $n=0; 836 $ret.="\\\n\t"; 837 } 838 if (($_ =~ /bss_file/) && ($postfix eq ".h")) 839 { $pf=".c"; } 840 else { $pf=$postfix; } 841 if ($_ =~ /BN_ASM/) { $t="$_ "; } 842 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } 843 elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 844 elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 845 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 846 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } 847 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } 848 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } 849 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } 850 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } 851 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } 852 else { $t="$location${o}$_$pf "; } 853 854 $Vars{$var}.="$t "; 855 $ret.=$t; 856 } 857 # hack to add version info on MSVC 858 if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))) 859 { 860 if ($var eq "CRYPTOOBJ") 861 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } 862 elsif ($var eq "SSLOBJ") 863 { $ret.="\$(OBJ_D)\\\$(SSL).res "; } 864 } 865 chomp($ret); 866 $ret.="\n\n"; 867 return($ret); 868 } 869 870# return the name with the leading path removed 871sub bname 872 { 873 local($ret)=@_; 874 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; 875 return($ret); 876 } 877 878 879############################################################## 880# do a rule for each file that says 'compile' to new direcory 881# compile the files in '$files' into $to 882sub do_compile_rule 883 { 884 local($to,$files,$ex)=@_; 885 local($ret,$_,$n); 886 887 $files =~ s/\//$o/g if $o ne '/'; 888 foreach (split(/\s+/,$files)) 889 { 890 $n=&bname($_); 891 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) 892 } 893 return($ret); 894 } 895 896############################################################## 897# do a rule for each file that says 'compile' to new direcory 898sub cc_compile_target 899 { 900 local($target,$source,$ex_flags)=@_; 901 local($ret); 902 903 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); 904 $target =~ s/\//$o/g if $o ne "/"; 905 $source =~ s/\//$o/g if $o ne "/"; 906 $ret ="$target: \$(SRC_D)$o$source\n\t"; 907 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; 908 return($ret); 909 } 910 911############################################################## 912sub do_asm_rule 913 { 914 local($target,$src)=@_; 915 local($ret,@s,@t,$i); 916 917 $target =~ s/\//$o/g if $o ne "/"; 918 $src =~ s/\//$o/g if $o ne "/"; 919 920 @s=split(/\s+/,$src); 921 @t=split(/\s+/,$target); 922 923 for ($i=0; $i<=$#s; $i++) 924 { 925 $ret.="$t[$i]: $s[$i]\n"; 926 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; 927 } 928 return($ret); 929 } 930 931sub do_shlib_rule 932 { 933 local($n,$def)=@_; 934 local($ret,$nn); 935 local($t); 936 937 ($nn=$n) =~ tr/a-z/A-Z/; 938 $ret.="$n.dll: \$(${nn}OBJ)\n"; 939 if ($vc && $w32) 940 { 941 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; 942 } 943 $ret.="\n"; 944 return($ret); 945 } 946 947# do a rule for each file that says 'copy' to new direcory on change 948sub do_copy_rule 949 { 950 local($to,$files,$p)=@_; 951 local($ret,$_,$n,$pp); 952 953 $files =~ s/\//$o/g if $o ne '/'; 954 foreach (split(/\s+/,$files)) 955 { 956 $n=&bname($_); 957 if ($n =~ /bss_file/) 958 { $pp=".c"; } 959 else { $pp=$p; } 960 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n"; 961 } 962 return($ret); 963 } 964 965sub read_options 966 { 967 # Many options are handled in a similar way. In particular 968 # no-xxx sets zero or more scalars to 1. 969 # Process these using a hash containing the option name and 970 # reference to the scalars to set. 971 972 my %valid_options = ( 973 "no-rc2" => \$no_rc2, 974 "no-rc4" => \$no_rc4, 975 "no-rc5" => \$no_rc5, 976 "no-idea" => \$no_idea, 977 "no-aes" => \$no_aes, 978 "no-camellia" => \$no_camellia, 979 "no-des" => \$no_des, 980 "no-bf" => \$no_bf, 981 "no-cast" => \$no_cast, 982 "no-md2" => \$no_md2, 983 "no-md4" => \$no_md4, 984 "no-md5" => \$no_md5, 985 "no-sha" => \$no_sha, 986 "no-sha1" => \$no_sha1, 987 "no-ripemd" => \$no_ripemd, 988 "no-mdc2" => \$no_mdc2, 989 "no-patents" => 990 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], 991 "no-rsa" => \$no_rsa, 992 "no-dsa" => \$no_dsa, 993 "no-dh" => \$no_dh, 994 "no-hmac" => \$no_hmac, 995 "no-aes" => \$no_aes, 996 "no-camellia" => \$no_camellia, 997 "no-asm" => \$no_asm, 998 "nasm" => \$nasm, 999 "nw-nasm" => \$nw_nasm, 1000 "nw-mwasm" => \$nw_mwasm, 1001 "gaswin" => \$gaswin, 1002 "no-ssl2" => \$no_ssl2, 1003 "no-ssl3" => \$no_ssl3, 1004 "no-err" => \$no_err, 1005 "no-sock" => \$no_sock, 1006 "no-krb5" => \$no_krb5, 1007 "no-ec" => \$no_ec, 1008 "no-ecdsa" => \$no_ecdsa, 1009 "no-ecdh" => \$no_ecdh, 1010 "no-engine" => \$no_engine, 1011 "no-hw" => \$no_hw, 1012 "just-ssl" => 1013 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, 1014 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, 1015 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, 1016 \$no_aes, \$no_camellia], 1017 "rsaref" => 0, 1018 "gcc" => \$gcc, 1019 "debug" => \$debug, 1020 "profile" => \$profile, 1021 "shlib" => \$shlib, 1022 "dll" => \$shlib, 1023 "shared" => 0, 1024 "no-gmp" => 0, 1025 "no-rfc3779" => 0, 1026 "no-shared" => 0, 1027 "no-zlib" => 0, 1028 "no-zlib-dynamic" => 0, 1029 ); 1030 1031 if (exists $valid_options{$_}) 1032 { 1033 my $r = $valid_options{$_}; 1034 if ( ref $r eq "SCALAR") 1035 { $$r = 1;} 1036 elsif ( ref $r eq "ARRAY") 1037 { 1038 my $r2; 1039 foreach $r2 (@$r) 1040 { 1041 $$r2 = 1; 1042 } 1043 } 1044 } 1045 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } 1046 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } 1047 elsif (/^enable-zlib-dynamic$/) 1048 { 1049 $zlib_opt = 2; 1050 } 1051 elsif (/^no-static-engine/) 1052 { 1053 $no_static_engine = 1; 1054 } 1055 elsif (/^enable-static-engine/) 1056 { 1057 $no_static_engine = 0; 1058 } 1059 # There are also enable-xxx options which correspond to 1060 # the no-xxx. Since the scalars are enabled by default 1061 # these can be ignored. 1062 elsif (/^enable-/) 1063 { 1064 my $t = $_; 1065 $t =~ s/^enable/no/; 1066 if (exists $valid_options{$t}) 1067 {return 1;} 1068 return 0; 1069 } 1070 elsif (/^--with-krb5-flavor=(.*)$/) 1071 { 1072 my $krb5_flavor = $1; 1073 if ($krb5_flavor =~ /^force-[Hh]eimdal$/) 1074 { 1075 $xcflags="-DKRB5_HEIMDAL $xcflags"; 1076 } 1077 elsif ($krb5_flavor =~ /^MIT/i) 1078 { 1079 $xcflags="-DKRB5_MIT $xcflags"; 1080 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) 1081 { 1082 $xcflags="-DKRB5_MIT_OLD11 $xcflags" 1083 } 1084 } 1085 } 1086 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } 1087 elsif (/^-[lL].*$/) { $l_flags.="$_ "; } 1088 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) 1089 { $c_flags.="$_ "; } 1090 else { return(0); } 1091 return(1); 1092 } 1093