mk1mf.pl revision 162911
155714Skris#!/usr/local/bin/perl 255714Skris# A bit of an evil hack but it post processes the file ../MINFO which 355714Skris# is generated by `make files` in the top directory. 455714Skris# This script outputs one mega makefile that has no shell stuff or any 555714Skris# funny stuff 655714Skris# 755714Skris 855714Skris$INSTALLTOP="/usr/local/ssl"; 955714Skris$OPTIONS=""; 1055714Skris$ssl_version=""; 1159191Skris$banner="\t\@echo Building OpenSSL"; 1255714Skris 13160814Ssimonmy $no_static_engine = 0; 14160814Ssimonmy $engines = ""; 15160814Ssimonlocal $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 16160814Ssimonlocal $zlib_lib = ""; 17160814Ssimon 18160814Ssimon 19142425Snectaropen(IN,"<Makefile") || die "unable to open Makefile!\n"; 2055714Skriswhile(<IN>) { 2155714Skris $ssl_version=$1 if (/^VERSION=(.*)$/); 2255714Skris $OPTIONS=$1 if (/^OPTIONS=(.*)$/); 2355714Skris $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); 2455714Skris} 2555714Skrisclose(IN); 2655714Skris 27142425Snectardie "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; 2855714Skris 2955714Skris$infile="MINFO"; 3055714Skris 3155714Skris%ops=( 3255714Skris "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", 33160814Ssimon "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", 34160814Ssimon "VC-WIN64A", "Microsoft C/C++ - Win64/x64", 35109998Smarkm "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", 3655714Skris "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", 3755714Skris "Mingw32", "GNU C++ - Windows NT or 9x", 3855714Skris "Mingw32-files", "Create files with DOS copy ...", 3955714Skris "BC-NT", "Borland C++ 4.5 - Windows NT", 4055714Skris "linux-elf","Linux elf", 4155714Skris "ultrix-mips","DEC mips ultrix", 4255714Skris "FreeBSD","FreeBSD distribution", 43109998Smarkm "OS2-EMX", "EMX GCC OS/2", 44160814Ssimon "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", 45160814Ssimon "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", 46160814Ssimon "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", 4755714Skris "default","cc under unix", 4855714Skris ); 4955714Skris 5055714Skris$platform=""; 51160814Ssimonmy $xcflags=""; 5255714Skrisforeach (@ARGV) 5355714Skris { 5455714Skris if (!&read_options && !defined($ops{$_})) 5555714Skris { 5655714Skris print STDERR "unknown option - $_\n"; 5755714Skris print STDERR "usage: perl mk1mf.pl [options] [system]\n"; 5855714Skris print STDERR "\nwhere [system] can be one of the following\n"; 5955714Skris foreach $i (sort keys %ops) 6055714Skris { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } 6155714Skris print STDERR <<"EOF"; 6255714Skrisand [options] can be one of 6368651Skris no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest 6468651Skris no-ripemd 65109998Smarkm no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher 66162911Ssimon no-bf no-cast no-aes no-camellia 6755714Skris no-rsa no-dsa no-dh - Skip this public key cipher 6855714Skris no-ssl2 no-ssl3 - Skip this version of SSL 6955714Skris just-ssl - remove all non-ssl keys/digest 7055714Skris no-asm - No x86 asm 71109998Smarkm no-krb5 - No KRB5 72109998Smarkm no-ec - No EC 73160814Ssimon no-ecdsa - No ECDSA 74160814Ssimon no-ecdh - No ECDH 75111147Snectar no-engine - No engine 76111147Snectar no-hw - No hw 7755714Skris nasm - Use NASM for x86 asm 78160814Ssimon nw-nasm - Use NASM x86 asm for NetWare 79160814Ssimon nw-mwasm - Use Metrowerks x86 asm for NetWare 8059191Skris gaswin - Use GNU as with Mingw32 8155714Skris no-socks - No socket code 8255714Skris no-err - No error strings 8355714Skris dll/shlib - Build shared libraries (MS) 8455714Skris debug - Debug build 8568651Skris profile - Profiling build 8655714Skris gcc - Use Gcc (unix) 8755714Skris 8855714SkrisValues that can be set 8955714SkrisTMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 9055714Skris 9155714Skris-L<ex_lib_path> -l<ex_lib> - extra library flags (unix) 9255714Skris-<ex_cc_flags> - extra 'cc' flags, 9355714Skris added (MS), or replace (unix) 9455714SkrisEOF 9555714Skris exit(1); 9655714Skris } 9755714Skris $platform=$_; 9855714Skris } 99109998Smarkmforeach (grep(!/^$/, split(/ /, $OPTIONS))) 10055714Skris { 10155714Skris print STDERR "unknown option - $_\n" if !&read_options; 10255714Skris } 10355714Skris 104160814Ssimon$no_static_engine = 0 if (!$shlib); 105160814Ssimon 10655714Skris$no_mdc2=1 if ($no_des); 10755714Skris 10855714Skris$no_ssl3=1 if ($no_md5 || $no_sha); 10955714Skris$no_ssl3=1 if ($no_rsa && $no_dh); 11055714Skris 111109998Smarkm$no_ssl2=1 if ($no_md5); 11255714Skris$no_ssl2=1 if ($no_rsa); 11355714Skris 11455714Skris$out_def="out"; 11555714Skris$inc_def="outinc"; 11655714Skris$tmp_def="tmp"; 11755714Skris 118160814Ssimon$perl="perl" unless defined $perl; 119160814Ssimon$mkdir="-mkdir" unless defined $mkdir; 12055714Skris 12155714Skris($ssl,$crypto)=("ssl","crypto"); 12255714Skris$ranlib="echo ranlib"; 12355714Skris 12455714Skris$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 12555714Skris$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; 12655714Skris$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; 12755714Skris 12855714Skris# $bin_dir.=$o causes a core dump on my sparc :-( 12955714Skris 130160814Ssimon 13155714Skris$NT=0; 13255714Skris 13355714Skrispush(@INC,"util/pl","pl"); 134160814Ssimonif (($platform =~ /VC-(.+)/)) 13555714Skris { 136160814Ssimon $FLAVOR=$1; 137160814Ssimon $NT = 1 if $1 eq "NT"; 13855714Skris require 'VC-32.pl'; 13955714Skris } 14055714Skriselsif ($platform eq "Mingw32") 14155714Skris { 14255714Skris require 'Mingw32.pl'; 14355714Skris } 14455714Skriselsif ($platform eq "Mingw32-files") 14555714Skris { 14655714Skris require 'Mingw32f.pl'; 14755714Skris } 14855714Skriselsif ($platform eq "BC-NT") 14955714Skris { 15055714Skris $bc=1; 15155714Skris require 'BC-32.pl'; 15255714Skris } 15355714Skriselsif ($platform eq "FreeBSD") 15455714Skris { 15555714Skris require 'unix.pl'; 15655714Skris $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; 15755714Skris } 15855714Skriselsif ($platform eq "linux-elf") 15955714Skris { 16055714Skris require "unix.pl"; 16155714Skris require "linux.pl"; 16255714Skris $unix=1; 16355714Skris } 16455714Skriselsif ($platform eq "ultrix-mips") 16555714Skris { 16655714Skris require "unix.pl"; 16755714Skris require "ultrix.pl"; 16855714Skris $unix=1; 16955714Skris } 170109998Smarkmelsif ($platform eq "OS2-EMX") 171109998Smarkm { 172109998Smarkm $wc=1; 173109998Smarkm require 'OS2-EMX.pl'; 174109998Smarkm } 175160814Ssimonelsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || 176160814Ssimon ($platform eq "netware-libc-bsdsock")) 177160814Ssimon { 178160814Ssimon $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; 179160814Ssimon $BSDSOCK=1 if $platform eq "netware-libc-bsdsock"; 180160814Ssimon require 'netware.pl'; 181160814Ssimon } 18255714Skriselse 18355714Skris { 18455714Skris require "unix.pl"; 18555714Skris 18655714Skris $unix=1; 18755714Skris $cflags.=' -DTERMIO'; 18855714Skris } 18955714Skris 19055714Skris$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); 19155714Skris$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); 19255714Skris$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; 19355714Skris 19455714Skris$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 19555714Skris 196160814Ssimon$cflags= "$xcflags$cflags" if $xcflags ne ""; 197160814Ssimon 198109998Smarkm$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; 199109998Smarkm$cflags.=" -DOPENSSL_NO_AES" if $no_aes; 200162911Ssimon$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; 201109998Smarkm$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; 202109998Smarkm$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; 203109998Smarkm$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; 204109998Smarkm$cflags.=" -DOPENSSL_NO_MD2" if $no_md2; 205109998Smarkm$cflags.=" -DOPENSSL_NO_MD4" if $no_md4; 206109998Smarkm$cflags.=" -DOPENSSL_NO_MD5" if $no_md5; 207109998Smarkm$cflags.=" -DOPENSSL_NO_SHA" if $no_sha; 208109998Smarkm$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; 209111147Snectar$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; 210109998Smarkm$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; 211160814Ssimon$cflags.=" -DOPENSSL_NO_BF" if $no_bf; 212109998Smarkm$cflags.=" -DOPENSSL_NO_CAST" if $no_cast; 213109998Smarkm$cflags.=" -DOPENSSL_NO_DES" if $no_des; 214109998Smarkm$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; 215109998Smarkm$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; 216109998Smarkm$cflags.=" -DOPENSSL_NO_DH" if $no_dh; 217109998Smarkm$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; 218109998Smarkm$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; 219109998Smarkm$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 220109998Smarkm$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 221109998Smarkm$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 222109998Smarkm$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 223160814Ssimon$cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; 224160814Ssimon$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 225111147Snectar$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 226111147Snectar$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 227160814Ssimon 228160814Ssimon$cflags.= " -DZLIB" if $zlib_opt; 229160814Ssimon$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 230160814Ssimon 231160814Ssimonif ($no_static_engine) 232160814Ssimon { 233160814Ssimon $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; 234160814Ssimon } 235160814Ssimonelse 236160814Ssimon { 237160814Ssimon $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; 238160814Ssimon } 239160814Ssimon 240109998Smarkm#$cflags.=" -DRSAref" if $rsaref ne ""; 24155714Skris 24268651Skris## if ($unix) 24368651Skris## { $cflags="$c_flags" if ($c_flags ne ""); } 24468651Skris##else 24568651Skris { $cflags="$c_flags$cflags" if ($c_flags ne ""); } 24655714Skris 24755714Skris$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 24855714Skris 249160814Ssimon 250109998Smarkm%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 251109998Smarkm "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); 252109998Smarkm 25355714Skrisif ($msdos) 25455714Skris { 25555714Skris $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; 25655714Skris $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; 25755714Skris $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; 25855714Skris $banner.="\t\@echo documentation for details.\n"; 25955714Skris } 26055714Skris 26155714Skris# have to do this to allow $(CC) under unix 26255714Skris$link="$bin_dir$link" if ($link !~ /^\$/); 26355714Skris 26455714Skris$INSTALLTOP =~ s|/|$o|g; 26555714Skris 266160814Ssimon############################################# 267160814Ssimon# We parse in input file and 'store' info for later printing. 268160814Ssimonopen(IN,"<$infile") || die "unable to open $infile:$!\n"; 269160814Ssimon$_=<IN>; 270160814Ssimonfor (;;) 271160814Ssimon { 272160814Ssimon chop; 273160814Ssimon 274160814Ssimon ($key,$val)=/^([^=]+)=(.*)/; 275160814Ssimon if ($key eq "RELATIVE_DIRECTORY") 276160814Ssimon { 277160814Ssimon if ($lib ne "") 278160814Ssimon { 279160814Ssimon $uc=$lib; 280160814Ssimon $uc =~ s/^lib(.*)\.a/$1/; 281160814Ssimon $uc =~ tr/a-z/A-Z/; 282160814Ssimon $lib_nam{$uc}=$uc; 283160814Ssimon $lib_obj{$uc}.=$libobj." "; 284160814Ssimon } 285160814Ssimon last if ($val eq "FINISHED"); 286160814Ssimon $lib=""; 287160814Ssimon $libobj=""; 288160814Ssimon $dir=$val; 289160814Ssimon } 290160814Ssimon 291160814Ssimon if ($key eq "KRB5_INCLUDES") 292160814Ssimon { $cflags .= " $val";} 293160814Ssimon 294160814Ssimon if ($key eq "ZLIB_INCLUDE") 295160814Ssimon { $cflags .= " $val" if $val ne "";} 296160814Ssimon 297160814Ssimon if ($key eq "LIBZLIB") 298160814Ssimon { $zlib_lib = "$val" if $val ne "";} 299160814Ssimon 300160814Ssimon if ($key eq "LIBKRB5") 301160814Ssimon { $ex_libs .= " $val" if $val ne "";} 302160814Ssimon 303160814Ssimon if ($key eq "TEST") 304160814Ssimon { $test.=&var_add($dir,$val, 0); } 305160814Ssimon 306160814Ssimon if (($key eq "PROGS") || ($key eq "E_OBJ")) 307160814Ssimon { $e_exe.=&var_add($dir,$val, 0); } 308160814Ssimon 309160814Ssimon if ($key eq "LIB") 310160814Ssimon { 311160814Ssimon $lib=$val; 312160814Ssimon $lib =~ s/^.*\/([^\/]+)$/$1/; 313160814Ssimon } 314160814Ssimon 315160814Ssimon if ($key eq "EXHEADER") 316160814Ssimon { $exheader.=&var_add($dir,$val, 1); } 317160814Ssimon 318160814Ssimon if ($key eq "HEADER") 319160814Ssimon { $header.=&var_add($dir,$val, 1); } 320160814Ssimon 321160814Ssimon if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) 322160814Ssimon { $libobj=&var_add($dir,$val, 0); } 323160814Ssimon if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 324160814Ssimon { $engines.=$val } 325160814Ssimon 326160814Ssimon if (!($_=<IN>)) 327160814Ssimon { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 328160814Ssimon } 329160814Ssimonclose(IN); 330160814Ssimon 331160814Ssimonif ($shlib) 332160814Ssimon { 333160814Ssimon $extra_install= <<"EOF"; 334160814Ssimon \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}bin 335160814Ssimon \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}bin 336160814Ssimon \$(CP) \$(L_SSL) \$(INSTALLTOP)${o}lib 337160814Ssimon \$(CP) \$(L_CRYPTO) \$(INSTALLTOP)${o}lib 338160814SsimonEOF 339160814Ssimon if ($no_static_engine) 340160814Ssimon { 341160814Ssimon $extra_install .= <<"EOF" 342160814Ssimon \$(MKDIR) \$(INSTALLTOP)${o}lib${o}engines 343160814Ssimon \$(CP) \$(E_SHLIB) \$(INSTALLTOP)${o}lib${o}engines 344160814SsimonEOF 345160814Ssimon } 346160814Ssimon } 347160814Ssimonelse 348160814Ssimon { 349160814Ssimon $extra_install= <<"EOF"; 350160814Ssimon \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib 351160814Ssimon \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib 352160814SsimonEOF 353160814Ssimon $ex_libs .= " $zlib_lib" if $zlib_opt == 1; 354160814Ssimon } 355160814Ssimon 35655714Skris$defs= <<"EOF"; 35755714Skris# This makefile has been automatically generated from the OpenSSL distribution. 35855714Skris# This single makefile will build the complete OpenSSL distribution and 35955714Skris# by default leave the 'intertesting' output files in .${o}out and the stuff 36055714Skris# that needs deleting in .${o}tmp. 36155714Skris# The file was generated by running 'make makefile.one', which 36255714Skris# does a 'make files', which writes all the environment variables from all 36355714Skris# the makefiles to the file call MINFO. This file is used by 36455714Skris# util${o}mk1mf.pl to generate makefile.one. 36555714Skris# The 'makefile per directory' system suites me when developing this 36655714Skris# library and also so I can 'distribute' indervidual library sections. 36755714Skris# The one monster makefile better suits building in non-unix 36855714Skris# environments. 36955714Skris 370109998SmarkmEOF 371109998Smarkm 372127128Snectar$defs .= $preamble if defined $preamble; 373127128Snectar 374109998Smarkm$defs.= <<"EOF"; 37555714SkrisINSTALLTOP=$INSTALLTOP 37655714Skris 37755714Skris# Set your compiler options 37855714SkrisPLATFORM=$platform 37955714SkrisCC=$bin_dir${cc} 38055714SkrisCFLAG=$cflags 38155714SkrisAPP_CFLAG=$app_cflag 38255714SkrisLIB_CFLAG=$lib_cflag 38355714SkrisSHLIB_CFLAG=$shl_cflag 38455714SkrisAPP_EX_OBJ=$app_ex_obj 38555714SkrisSHLIB_EX_OBJ=$shlib_ex_obj 38655714Skris# add extra libraries to this define, for solaris -lsocket -lnsl would 38755714Skris# be added 38855714SkrisEX_LIBS=$ex_libs 38955714Skris 39055714Skris# The OpenSSL directory 39155714SkrisSRC_D=$src_dir 39255714Skris 39355714SkrisLINK=$link 39455714SkrisLFLAGS=$lflags 395160814SsimonRSC=$rsc 39655714Skris 39755714SkrisBN_ASM_OBJ=$bn_asm_obj 39855714SkrisBN_ASM_SRC=$bn_asm_src 39968651SkrisBNCO_ASM_OBJ=$bnco_asm_obj 40068651SkrisBNCO_ASM_SRC=$bnco_asm_src 40155714SkrisDES_ENC_OBJ=$des_enc_obj 40255714SkrisDES_ENC_SRC=$des_enc_src 40355714SkrisBF_ENC_OBJ=$bf_enc_obj 40455714SkrisBF_ENC_SRC=$bf_enc_src 40555714SkrisCAST_ENC_OBJ=$cast_enc_obj 40655714SkrisCAST_ENC_SRC=$cast_enc_src 40755714SkrisRC4_ENC_OBJ=$rc4_enc_obj 40855714SkrisRC4_ENC_SRC=$rc4_enc_src 40955714SkrisRC5_ENC_OBJ=$rc5_enc_obj 41055714SkrisRC5_ENC_SRC=$rc5_enc_src 41155714SkrisMD5_ASM_OBJ=$md5_asm_obj 41255714SkrisMD5_ASM_SRC=$md5_asm_src 41355714SkrisSHA1_ASM_OBJ=$sha1_asm_obj 41455714SkrisSHA1_ASM_SRC=$sha1_asm_src 41555714SkrisRMD160_ASM_OBJ=$rmd160_asm_obj 41655714SkrisRMD160_ASM_SRC=$rmd160_asm_src 417162911SsimonCPUID_ASM_OBJ=$cpuid_asm_obj 418162911SsimonCPUID_ASM_SRC=$cpuid_asm_src 41955714Skris 42055714Skris# The output directory for everything intersting 42155714SkrisOUT_D=$out_dir 42255714Skris# The output directory for all the temporary muck 42355714SkrisTMP_D=$tmp_dir 42455714Skris# The output directory for the header files 42555714SkrisINC_D=$inc_dir 42655714SkrisINCO_D=$inc_dir${o}openssl 42755714Skris 428160814SsimonPERL=$perl 42955714SkrisCP=$cp 43055714SkrisRM=$rm 43155714SkrisRANLIB=$ranlib 43255714SkrisMKDIR=$mkdir 43355714SkrisMKLIB=$bin_dir$mklib 43455714SkrisMLFLAGS=$mlflags 43555714SkrisASM=$bin_dir$asm 43655714Skris 43755714Skris###################################################### 43855714Skris# You should not need to touch anything below this point 43955714Skris###################################################### 44055714Skris 44155714SkrisE_EXE=openssl 44255714SkrisSSL=$ssl 44355714SkrisCRYPTO=$crypto 44455714Skris 44555714Skris# BIN_D - Binary output directory 44655714Skris# TEST_D - Binary test file output directory 44755714Skris# LIB_D - library output directory 448160814Ssimon# ENG_D - dynamic engine output directory 44955714Skris# Note: if you change these point to different directories then uncomment out 45055714Skris# the lines around the 'NB' comment below. 45155714Skris# 45255714SkrisBIN_D=\$(OUT_D) 45355714SkrisTEST_D=\$(OUT_D) 45455714SkrisLIB_D=\$(OUT_D) 455160814SsimonENG_D=\$(OUT_D) 45655714Skris 45755714Skris# INCL_D - local library directory 45855714Skris# OBJ_D - temp object file directory 45955714SkrisOBJ_D=\$(TMP_D) 46055714SkrisINCL_D=\$(TMP_D) 46155714Skris 46255714SkrisO_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 46355714SkrisO_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 46455714SkrisSO_SSL= $plib\$(SSL)$so_shlibp 46555714SkrisSO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 46655714SkrisL_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 46755714SkrisL_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 46855714Skris 46955714SkrisL_LIBS= \$(L_SSL) \$(L_CRYPTO) 47055714Skris 47155714Skris###################################################### 47255714Skris# Don't touch anything below this point 47355714Skris###################################################### 47455714Skris 47555714SkrisINC=-I\$(INC_D) -I\$(INCL_D) 47655714SkrisAPP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 47755714SkrisLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 47855714SkrisSHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 479109998SmarkmLIBS_DEP=\$(O_CRYPTO) \$(O_SSL) 48055714Skris 48155714Skris############################################# 48255714SkrisEOF 48355714Skris 48455714Skris$rules=<<"EOF"; 48555714Skrisall: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe 48655714Skris 48755714Skrisbanner: 48855714Skris$banner 48955714Skris 49055714Skris\$(TMP_D): 49155714Skris \$(MKDIR) \$(TMP_D) 49255714Skris# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different 49355714Skris#\$(BIN_D): 49455714Skris# \$(MKDIR) \$(BIN_D) 49555714Skris# 49655714Skris#\$(TEST_D): 49755714Skris# \$(MKDIR) \$(TEST_D) 49855714Skris 49955714Skris\$(LIB_D): 50055714Skris \$(MKDIR) \$(LIB_D) 50155714Skris 50255714Skris\$(INCO_D): \$(INC_D) 50355714Skris \$(MKDIR) \$(INCO_D) 50455714Skris 50555714Skris\$(INC_D): 50655714Skris \$(MKDIR) \$(INC_D) 50755714Skris 50855714Skrisheaders: \$(HEADER) \$(EXHEADER) 50968651Skris @ 51055714Skris 511160814Ssimonlib: \$(LIBS_DEP) \$(E_SHLIB) 51255714Skris 51355714Skrisexe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep 51455714Skris 515160814Ssimoninstall: all 51655714Skris \$(MKDIR) \$(INSTALLTOP) 51755714Skris \$(MKDIR) \$(INSTALLTOP)${o}bin 51855714Skris \$(MKDIR) \$(INSTALLTOP)${o}include 51955714Skris \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl 52055714Skris \$(MKDIR) \$(INSTALLTOP)${o}lib 52155714Skris \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl 52255714Skris \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin 523160814Ssimon \$(CP) apps${o}openssl.cnf \$(INSTALLTOP) 524160814Ssimon$extra_install 52555714Skris 526160814Ssimon 527160814Ssimontest: \$(T_EXE) 528160814Ssimon cd \$(BIN_D) 529160814Ssimon ..${o}ms${o}test 530160814Ssimon 53155714Skrisclean: 53255714Skris \$(RM) \$(TMP_D)$o*.* 53355714Skris 53455714Skrisvclean: 53555714Skris \$(RM) \$(TMP_D)$o*.* 53655714Skris \$(RM) \$(OUT_D)$o*.* 53755714Skris 53855714SkrisEOF 53955714Skris 54055714Skrismy $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; 54155714Skris$platform_cpp_symbol =~ s/-/_/g; 54255714Skrisif (open(IN,"crypto/buildinf.h")) 54355714Skris { 54455714Skris # Remove entry for this platform in existing file buildinf.h. 54555714Skris 54655714Skris my $old_buildinf_h = ""; 54755714Skris while (<IN>) 54855714Skris { 54955714Skris if (/^\#ifdef $platform_cpp_symbol$/) 55055714Skris { 55155714Skris while (<IN>) { last if (/^\#endif/); } 55255714Skris } 55355714Skris else 55455714Skris { 55555714Skris $old_buildinf_h .= $_; 55655714Skris } 55755714Skris } 55855714Skris close(IN); 55955714Skris 56055714Skris open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; 56155714Skris print OUT $old_buildinf_h; 56255714Skris close(OUT); 56355714Skris } 56455714Skris 56555714Skrisopen (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; 56655714Skrisprintf OUT <<EOF; 56755714Skris#ifdef $platform_cpp_symbol 56855714Skris /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ 56955714Skris #define CFLAGS "$cc $cflags" 57055714Skris #define PLATFORM "$platform" 57155714SkrisEOF 57255714Skrisprintf OUT " #define DATE \"%s\"\n", scalar gmtime(); 57355714Skrisprintf OUT "#endif\n"; 57455714Skrisclose(OUT); 57555714Skris 57655714Skris# Strip of trailing ' ' 57755714Skrisforeach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } 57855714Skris$test=&clean_up_ws($test); 57955714Skris$e_exe=&clean_up_ws($e_exe); 58055714Skris$exheader=&clean_up_ws($exheader); 58155714Skris$header=&clean_up_ws($header); 58255714Skris 58355714Skris# First we strip the exheaders from the headers list 58455714Skrisforeach (split(/\s+/,$exheader)){ $h{$_}=1; } 58555714Skrisforeach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } 58655714Skrischop($h); $header=$h; 58755714Skris 588160814Ssimon$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); 589160814Ssimon$rules.=&do_copy_rule("\$(INCL_D)",$header,""); 59055714Skris 591160814Ssimon$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); 592160814Ssimon$rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); 59355714Skris 59455714Skris$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); 59555714Skris$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); 59655714Skris 59755714Skris$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 59855714Skris$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 59955714Skris 60055714Skrisforeach (values %lib_nam) 60155714Skris { 60255714Skris $lib_obj=$lib_obj{$_}; 60355714Skris local($slib)=$shlib; 60455714Skris 60555714Skris if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) 60655714Skris { 60755714Skris $rules.="\$(O_SSL):\n\n"; 60855714Skris next; 60955714Skris } 61055714Skris 61155714Skris if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) 61255714Skris { 61355714Skris $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; 61455714Skris $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src); 61555714Skris } 61668651Skris if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO")) 61768651Skris { 61868651Skris $lib_obj .= "\$(BNCO_ASM_OBJ)"; 61968651Skris $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src); 62068651Skris } 62155714Skris if (($des_enc_obj ne "") && ($_ eq "CRYPTO")) 62255714Skris { 62355714Skris $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; 62455714Skris $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; 62555714Skris $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); 62655714Skris } 62755714Skris if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) 62855714Skris { 62955714Skris $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/; 63055714Skris $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src); 63155714Skris } 63255714Skris if (($cast_enc_obj ne "") && ($_ eq "CRYPTO")) 63355714Skris { 63455714Skris $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/; 63555714Skris $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src); 63655714Skris } 63755714Skris if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO")) 63855714Skris { 63955714Skris $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/; 64055714Skris $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src); 64155714Skris } 64255714Skris if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO")) 64355714Skris { 64455714Skris $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/; 64555714Skris $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src); 64655714Skris } 64755714Skris if (($md5_asm_obj ne "") && ($_ eq "CRYPTO")) 64855714Skris { 64955714Skris $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; 65055714Skris $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); 65155714Skris } 65255714Skris if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO")) 65355714Skris { 65455714Skris $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/; 65555714Skris $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src); 65655714Skris } 65755714Skris if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) 65855714Skris { 65955714Skris $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; 66055714Skris $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); 66155714Skris } 662162911Ssimon if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO")) 663162911Ssimon { 664162911Ssimon $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/; 665162911Ssimon $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src); 666162911Ssimon } 66755714Skris $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 668109998Smarkm $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 66955714Skris $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 67055714Skris } 67155714Skris 672160814Ssimon# hack to add version info on MSVC 673160814Ssimonif (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) { 674160814Ssimon $rules.= <<"EOF"; 675160814Ssimon\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc 676160814Ssimon \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc 677160814Ssimon 678160814Ssimon\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 679160814Ssimon \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 680160814Ssimon 681160814SsimonEOF 682160814Ssimon} 683160814Ssimon 68455714Skris$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 68555714Skrisforeach (split(/\s+/,$test)) 68655714Skris { 68755714Skris $t=&bname($_); 68855714Skris $tt="\$(OBJ_D)${o}$t${obj}"; 68955714Skris $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 69055714Skris } 69155714Skris 692160814Ssimon$defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); 693160814Ssimon 694160814Ssimonforeach (split(/\s+/,$engines)) 695160814Ssimon { 696160814Ssimon $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); 697160814Ssimon $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); 698160814Ssimon } 699160814Ssimon 700160814Ssimon 701160814Ssimon 70255714Skris$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 70355714Skris$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); 70455714Skris 705160814Ssimon$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 706160814Ssimon 70755714Skrisprint $defs; 70868651Skris 70968651Skrisif ($platform eq "linux-elf") { 71068651Skris print <<"EOF"; 71168651Skris# Generate perlasm output files 71268651Skris%.cpp: 713142425Snectar (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) 71468651SkrisEOF 71568651Skris} 71655714Skrisprint "###################################################################\n"; 71755714Skrisprint $rules; 71855714Skris 71955714Skris############################################### 72055714Skris# strip off any trailing .[och] and append the relative directory 72155714Skris# also remembering to do nothing if we are in one of the dropped 72255714Skris# directories 72355714Skrissub var_add 72455714Skris { 725160814Ssimon local($dir,$val,$keepext)=@_; 72655714Skris local(@a,$_,$ret); 72755714Skris 728111147Snectar return("") if $no_engine && $dir =~ /\/engine/; 729111147Snectar return("") if $no_hw && $dir =~ /\/hw/; 73055714Skris return("") if $no_idea && $dir =~ /\/idea/; 731109998Smarkm return("") if $no_aes && $dir =~ /\/aes/; 732162911Ssimon return("") if $no_camellia && $dir =~ /\/camellia/; 73355714Skris return("") if $no_rc2 && $dir =~ /\/rc2/; 73455714Skris return("") if $no_rc4 && $dir =~ /\/rc4/; 73555714Skris return("") if $no_rc5 && $dir =~ /\/rc5/; 73655714Skris return("") if $no_rsa && $dir =~ /\/rsa/; 73755714Skris return("") if $no_rsa && $dir =~ /^rsaref/; 73855714Skris return("") if $no_dsa && $dir =~ /\/dsa/; 73955714Skris return("") if $no_dh && $dir =~ /\/dh/; 740120631Snectar return("") if $no_ec && $dir =~ /\/ec/; 74155714Skris if ($no_des && $dir =~ /\/des/) 74255714Skris { 74355714Skris if ($val =~ /read_pwd/) 74455714Skris { return("$dir/read_pwd "); } 74555714Skris else 74655714Skris { return(""); } 74755714Skris } 74855714Skris return("") if $no_mdc2 && $dir =~ /\/mdc2/; 74955714Skris return("") if $no_sock && $dir =~ /\/proxy/; 75055714Skris return("") if $no_bf && $dir =~ /\/bf/; 75155714Skris return("") if $no_cast && $dir =~ /\/cast/; 75255714Skris 75355714Skris $val =~ s/^\s*(.*)\s*$/$1/; 75455714Skris @a=split(/\s+/,$val); 755160814Ssimon grep(s/\.[och]$//,@a) unless $keepext; 75655714Skris 75755714Skris @a=grep(!/^e_.*_3d$/,@a) if $no_des; 75855714Skris @a=grep(!/^e_.*_d$/,@a) if $no_des; 759109998Smarkm @a=grep(!/^e_.*_ae$/,@a) if $no_idea; 760109998Smarkm @a=grep(!/^e_.*_i$/,@a) if $no_aes; 76155714Skris @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 76255714Skris @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 76355714Skris @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 76455714Skris @a=grep(!/^e_.*_c$/,@a) if $no_cast; 76555714Skris @a=grep(!/^e_rc4$/,@a) if $no_rc4; 766162911Ssimon @a=grep(!/^e_camellia$/,@a) if $no_camellia; 76755714Skris 76855714Skris @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; 76955714Skris @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; 77055714Skris 77155714Skris @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 77255714Skris 77355714Skris @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 77468651Skris @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; 77555714Skris @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 776111147Snectar @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; 77755714Skris 77855714Skris @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 77955714Skris @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 78055714Skris @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; 78155714Skris 78255714Skris @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; 78355714Skris @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; 78455714Skris 78555714Skris @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; 78655714Skris 78755714Skris @a=grep(!/_dhp$/,@a) if $no_dh; 78855714Skris 78955714Skris @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; 79055714Skris @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 79155714Skris @a=grep(!/_mdc2$/,@a) if $no_mdc2; 79255714Skris 793111147Snectar @a=grep(!/^engine$/,@a) if $no_engine; 794111147Snectar @a=grep(!/^hw$/,@a) if $no_hw; 79555714Skris @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; 79655714Skris @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 79755714Skris @a=grep(!/^gendsa$/,@a) if $no_sha1; 79855714Skris @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; 79955714Skris 80055714Skris @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 80155714Skris 80255714Skris grep($_="$dir/$_",@a); 80355714Skris @a=grep(!/(^|\/)s_/,@a) if $no_sock; 80455714Skris @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; 80555714Skris $ret=join(' ',@a)." "; 80655714Skris return($ret); 80755714Skris } 80855714Skris 80955714Skris# change things so that each 'token' is only separated by one space 81055714Skrissub clean_up_ws 81155714Skris { 81255714Skris local($w)=@_; 81355714Skris 81455714Skris $w =~ s/^\s*(.*)\s*$/$1/; 81555714Skris $w =~ s/\s+/ /g; 81655714Skris return($w); 81755714Skris } 81855714Skris 81955714Skrissub do_defs 82055714Skris { 82155714Skris local($var,$files,$location,$postfix)=@_; 82255714Skris local($_,$ret,$pf); 82355714Skris local(*OUT,$tmp,$t); 82455714Skris 82555714Skris $files =~ s/\//$o/g if $o ne '/'; 82655714Skris $ret="$var="; 82755714Skris $n=1; 82855714Skris $Vars{$var}.=""; 82955714Skris foreach (split(/ /,$files)) 83055714Skris { 83155714Skris $orig=$_; 83255714Skris $_=&bname($_) unless /^\$/; 83355714Skris if ($n++ == 2) 83455714Skris { 83555714Skris $n=0; 83655714Skris $ret.="\\\n\t"; 83755714Skris } 83855714Skris if (($_ =~ /bss_file/) && ($postfix eq ".h")) 83955714Skris { $pf=".c"; } 84055714Skris else { $pf=$postfix; } 84155714Skris if ($_ =~ /BN_ASM/) { $t="$_ "; } 84268651Skris elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } 84355714Skris elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 84455714Skris elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 84555714Skris elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 84655714Skris elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } 84755714Skris elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } 84855714Skris elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } 84955714Skris elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } 85055714Skris elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } 851162911Ssimon elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } 85255714Skris else { $t="$location${o}$_$pf "; } 85355714Skris 85455714Skris $Vars{$var}.="$t "; 85555714Skris $ret.=$t; 85655714Skris } 857160814Ssimon # hack to add version info on MSVC 858160814Ssimon if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))) 859160814Ssimon { 860160814Ssimon if ($var eq "CRYPTOOBJ") 861160814Ssimon { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } 862160814Ssimon elsif ($var eq "SSLOBJ") 863160814Ssimon { $ret.="\$(OBJ_D)\\\$(SSL).res "; } 864160814Ssimon } 865160814Ssimon chomp($ret); 86655714Skris $ret.="\n\n"; 86755714Skris return($ret); 86855714Skris } 86955714Skris 87055714Skris# return the name with the leading path removed 87155714Skrissub bname 87255714Skris { 87355714Skris local($ret)=@_; 87455714Skris $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; 87555714Skris return($ret); 87655714Skris } 87755714Skris 87855714Skris 87955714Skris############################################################## 88055714Skris# do a rule for each file that says 'compile' to new direcory 88155714Skris# compile the files in '$files' into $to 88255714Skrissub do_compile_rule 88355714Skris { 88455714Skris local($to,$files,$ex)=@_; 88555714Skris local($ret,$_,$n); 88655714Skris 88755714Skris $files =~ s/\//$o/g if $o ne '/'; 88855714Skris foreach (split(/\s+/,$files)) 88955714Skris { 89055714Skris $n=&bname($_); 89155714Skris $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) 89255714Skris } 89355714Skris return($ret); 89455714Skris } 89555714Skris 89655714Skris############################################################## 89755714Skris# do a rule for each file that says 'compile' to new direcory 89855714Skrissub cc_compile_target 89955714Skris { 90055714Skris local($target,$source,$ex_flags)=@_; 90155714Skris local($ret); 90255714Skris 90355714Skris $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); 90455714Skris $target =~ s/\//$o/g if $o ne "/"; 90555714Skris $source =~ s/\//$o/g if $o ne "/"; 90655714Skris $ret ="$target: \$(SRC_D)$o$source\n\t"; 90755714Skris $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; 90855714Skris return($ret); 90955714Skris } 91055714Skris 91155714Skris############################################################## 91255714Skrissub do_asm_rule 91355714Skris { 91455714Skris local($target,$src)=@_; 91555714Skris local($ret,@s,@t,$i); 91655714Skris 91755714Skris $target =~ s/\//$o/g if $o ne "/"; 91855714Skris $src =~ s/\//$o/g if $o ne "/"; 91955714Skris 92055714Skris @s=split(/\s+/,$src); 92155714Skris @t=split(/\s+/,$target); 92255714Skris 92355714Skris for ($i=0; $i<=$#s; $i++) 92455714Skris { 92555714Skris $ret.="$t[$i]: $s[$i]\n"; 92655714Skris $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; 92755714Skris } 92855714Skris return($ret); 92955714Skris } 93055714Skris 93155714Skrissub do_shlib_rule 93255714Skris { 93355714Skris local($n,$def)=@_; 93455714Skris local($ret,$nn); 93555714Skris local($t); 93655714Skris 93755714Skris ($nn=$n) =~ tr/a-z/A-Z/; 93855714Skris $ret.="$n.dll: \$(${nn}OBJ)\n"; 93955714Skris if ($vc && $w32) 94055714Skris { 94155714Skris $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; 94255714Skris } 94355714Skris $ret.="\n"; 94455714Skris return($ret); 94555714Skris } 94655714Skris 94755714Skris# do a rule for each file that says 'copy' to new direcory on change 94855714Skrissub do_copy_rule 94955714Skris { 95055714Skris local($to,$files,$p)=@_; 95155714Skris local($ret,$_,$n,$pp); 95255714Skris 95355714Skris $files =~ s/\//$o/g if $o ne '/'; 95455714Skris foreach (split(/\s+/,$files)) 95555714Skris { 95655714Skris $n=&bname($_); 95755714Skris if ($n =~ /bss_file/) 95855714Skris { $pp=".c"; } 95955714Skris else { $pp=$p; } 96055714Skris $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n"; 96155714Skris } 96255714Skris return($ret); 96355714Skris } 96455714Skris 96555714Skrissub read_options 96655714Skris { 967160814Ssimon # Many options are handled in a similar way. In particular 968160814Ssimon # no-xxx sets zero or more scalars to 1. 969160814Ssimon # Process these using a hash containing the option name and 970160814Ssimon # reference to the scalars to set. 97155714Skris 972160814Ssimon my %valid_options = ( 973160814Ssimon "no-rc2" => \$no_rc2, 974160814Ssimon "no-rc4" => \$no_rc4, 975160814Ssimon "no-rc5" => \$no_rc5, 976160814Ssimon "no-idea" => \$no_idea, 977160814Ssimon "no-aes" => \$no_aes, 978162911Ssimon "no-camellia" => \$no_camellia, 979160814Ssimon "no-des" => \$no_des, 980160814Ssimon "no-bf" => \$no_bf, 981160814Ssimon "no-cast" => \$no_cast, 982160814Ssimon "no-md2" => \$no_md2, 983160814Ssimon "no-md4" => \$no_md4, 984160814Ssimon "no-md5" => \$no_md5, 985160814Ssimon "no-sha" => \$no_sha, 986160814Ssimon "no-sha1" => \$no_sha1, 987160814Ssimon "no-ripemd" => \$no_ripemd, 988160814Ssimon "no-mdc2" => \$no_mdc2, 989160814Ssimon "no-patents" => 990160814Ssimon [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], 991160814Ssimon "no-rsa" => \$no_rsa, 992160814Ssimon "no-dsa" => \$no_dsa, 993160814Ssimon "no-dh" => \$no_dh, 994160814Ssimon "no-hmac" => \$no_hmac, 995160814Ssimon "no-aes" => \$no_aes, 996162911Ssimon "no-camellia" => \$no_camellia, 997160814Ssimon "no-asm" => \$no_asm, 998160814Ssimon "nasm" => \$nasm, 999160814Ssimon "nw-nasm" => \$nw_nasm, 1000160814Ssimon "nw-mwasm" => \$nw_mwasm, 1001160814Ssimon "gaswin" => \$gaswin, 1002160814Ssimon "no-ssl2" => \$no_ssl2, 1003160814Ssimon "no-ssl3" => \$no_ssl3, 1004160814Ssimon "no-err" => \$no_err, 1005160814Ssimon "no-sock" => \$no_sock, 1006160814Ssimon "no-krb5" => \$no_krb5, 1007160814Ssimon "no-ec" => \$no_ec, 1008160814Ssimon "no-ecdsa" => \$no_ecdsa, 1009160814Ssimon "no-ecdh" => \$no_ecdh, 1010160814Ssimon "no-engine" => \$no_engine, 1011160814Ssimon "no-hw" => \$no_hw, 1012160814Ssimon "just-ssl" => 1013160814Ssimon [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, 1014160814Ssimon \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, 1015160814Ssimon \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, 1016162911Ssimon \$no_aes, \$no_camellia], 1017160814Ssimon "rsaref" => 0, 1018160814Ssimon "gcc" => \$gcc, 1019160814Ssimon "debug" => \$debug, 1020160814Ssimon "profile" => \$profile, 1021160814Ssimon "shlib" => \$shlib, 1022160814Ssimon "dll" => \$shlib, 1023160814Ssimon "shared" => 0, 1024160814Ssimon "no-gmp" => 0, 1025160814Ssimon "no-shared" => 0, 1026160814Ssimon "no-zlib" => 0, 1027160814Ssimon "no-zlib-dynamic" => 0, 1028160814Ssimon ); 102955714Skris 1030160814Ssimon if (exists $valid_options{$_}) 1031160814Ssimon { 1032160814Ssimon my $r = $valid_options{$_}; 1033160814Ssimon if ( ref $r eq "SCALAR") 1034160814Ssimon { $$r = 1;} 1035160814Ssimon elsif ( ref $r eq "ARRAY") 1036160814Ssimon { 1037160814Ssimon my $r2; 1038160814Ssimon foreach $r2 (@$r) 1039160814Ssimon { 1040160814Ssimon $$r2 = 1; 1041160814Ssimon } 1042160814Ssimon } 1043160814Ssimon } 1044160814Ssimon elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } 1045160814Ssimon elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } 1046160814Ssimon elsif (/^enable-zlib-dynamic$/) 1047160814Ssimon { 1048160814Ssimon $zlib_opt = 2; 1049160814Ssimon } 1050160814Ssimon elsif (/^no-static-engine/) 1051160814Ssimon { 1052160814Ssimon $no_static_engine = 1; 1053160814Ssimon } 1054160814Ssimon elsif (/^enable-static-engine/) 1055160814Ssimon { 1056160814Ssimon $no_static_engine = 0; 1057160814Ssimon } 1058160814Ssimon # There are also enable-xxx options which correspond to 1059160814Ssimon # the no-xxx. Since the scalars are enabled by default 1060160814Ssimon # these can be ignored. 1061160814Ssimon elsif (/^enable-/) 1062160814Ssimon { 1063160814Ssimon my $t = $_; 1064160814Ssimon $t =~ s/^enable/no/; 1065160814Ssimon if (exists $valid_options{$t}) 1066160814Ssimon {return 1;} 1067160814Ssimon return 0; 1068160814Ssimon } 1069160814Ssimon elsif (/^--with-krb5-flavor=(.*)$/) 1070160814Ssimon { 1071160814Ssimon my $krb5_flavor = $1; 1072160814Ssimon if ($krb5_flavor =~ /^force-[Hh]eimdal$/) 1073160814Ssimon { 1074160814Ssimon $xcflags="-DKRB5_HEIMDAL $xcflags"; 1075160814Ssimon } 1076160814Ssimon elsif ($krb5_flavor =~ /^MIT/i) 1077160814Ssimon { 1078160814Ssimon $xcflags="-DKRB5_MIT $xcflags"; 1079160814Ssimon if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) 1080160814Ssimon { 1081160814Ssimon $xcflags="-DKRB5_MIT_OLD11 $xcflags" 1082160814Ssimon } 1083160814Ssimon } 1084160814Ssimon } 108555714Skris elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } 108655714Skris elsif (/^-[lL].*$/) { $l_flags.="$_ "; } 108755714Skris elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) 108855714Skris { $c_flags.="$_ "; } 108955714Skris else { return(0); } 109055714Skris return(1); 109155714Skris } 1092