1#!/usr/local/bin/perl 2# A bit of an evil hack but it post processes the file ../MINFO which 3# is generated by `make files` in the top directory. 4# This script outputs one mega makefile that has no shell stuff or any 5# funny stuff (if the target is not "copy"). 6# If the target is "copy", then it tries to create a makefile that can be 7# safely used with the -j flag and that is compatible with the top-level 8# Makefile, in the sense that it uses the same options and assembler files etc. 9 10use Cwd; 11 12$INSTALLTOP="/usr/local/ssl"; 13$OPENSSLDIR="/usr/local/ssl"; 14$OPTIONS=""; 15$ssl_version=""; 16$banner="\t\@echo Building OpenSSL"; 17 18my $no_static_engine = 1; 19my $engines = ""; 20my $otherlibs = ""; 21local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic 22local $zlib_lib = ""; 23local $perl_asm = 0; # 1 to autobuild asm files from perl scripts 24 25my $ex_l_libs = ""; 26 27# Options to import from top level Makefile 28 29my %mf_import = ( 30 VERSION => \$ssl_version, 31 OPTIONS => \$OPTIONS, 32 INSTALLTOP => \$INSTALLTOP, 33 OPENSSLDIR => \$OPENSSLDIR, 34 PLATFORM => \$mf_platform, 35 CC => \$mf_cc, 36 CFLAG => \$mf_cflag, 37 DEPFLAG => \$mf_depflag, 38 CPUID_OBJ => \$mf_cpuid_asm, 39 BN_ASM => \$mf_bn_asm, 40 DES_ENC => \$mf_des_asm, 41 AES_ENC => \$mf_aes_asm, 42 BF_ENC => \$mf_bf_asm, 43 CAST_ENC => \$mf_cast_asm, 44 RC4_ENC => \$mf_rc4_asm, 45 RC5_ENC => \$mf_rc5_asm, 46 MD5_ASM_OBJ => \$mf_md5_asm, 47 SHA1_ASM_OBJ => \$mf_sha_asm, 48 RMD160_ASM_OBJ => \$mf_rmd_asm, 49 WP_ASM_OBJ => \$mf_wp_asm, 50 CMLL_ENC => \$mf_cm_asm, 51 MODES_ASM_OBJ => \$mf_modes_asm, 52 ENGINES_ASM_OBJ=> \$mf_engines_asm, 53 BASEADDR => \$baseaddr, 54 FIPSDIR => \$fipsdir, 55 EC_ASM => \$mf_ec_asm, 56); 57 58open(IN,"<Makefile") || die "unable to open Makefile!\n"; 59while(<IN>) { 60 my ($mf_opt, $mf_ref); 61 while (($mf_opt, $mf_ref) = each %mf_import) { 62 if (/^$mf_opt\s*=\s*(.*)$/ && !defined($$mfref)) { 63 $$mf_ref = $1; 64 } 65 } 66} 67close(IN); 68 69$debug = 1 if $mf_platform =~ /^debug-/; 70 71die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; 72 73$infile="MINFO"; 74 75%ops=( 76 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", 77 "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", 78 "VC-WIN64A", "Microsoft C/C++ - Win64/x64", 79 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", 80 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", 81 "Mingw32", "GNU C++ - Windows NT or 9x", 82 "Mingw32-files", "Create files with DOS copy ...", 83 "BC-NT", "Borland C++ 4.5 - Windows NT", 84 "linux-elf","Linux elf", 85 "ultrix-mips","DEC mips ultrix", 86 "FreeBSD","FreeBSD distribution", 87 "OS2-EMX", "EMX GCC OS/2", 88 "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", 89 "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets", 90 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", 91 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", 92 "default","cc under unix", 93 "auto", "auto detect from top level Makefile", 94 "copy", "copy from top level Makefile" 95 ); 96 97$platform=""; 98my $xcflags=""; 99foreach (@ARGV) 100 { 101 if (!&read_options && !defined($ops{$_})) 102 { 103 print STDERR "unknown option - $_\n"; 104 print STDERR "usage: perl mk1mf.pl [options] [system]\n"; 105 print STDERR "\nwhere [system] can be one of the following\n"; 106 foreach $i (sort keys %ops) 107 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } 108 print STDERR <<"EOF"; 109and [options] can be one of 110 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest 111 no-ripemd 112 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher 113 no-bf no-cast no-aes no-camellia no-seed 114 no-rsa no-dsa no-dh - Skip this public key cipher 115 no-ssl2 no-ssl3 - Skip this version of SSL 116 just-ssl - remove all non-ssl keys/digest 117 no-asm - No x86 asm 118 no-krb5 - No KRB5 119 no-srp - No SRP 120 no-ec - No EC 121 no-ecdsa - No ECDSA 122 no-ecdh - No ECDH 123 no-engine - No engine 124 no-hw - No hw 125 nasm - Use NASM for x86 asm 126 nw-nasm - Use NASM x86 asm for NetWare 127 nw-mwasm - Use Metrowerks x86 asm for NetWare 128 gaswin - Use GNU as with Mingw32 129 no-socks - No socket code 130 no-err - No error strings 131 dll/shlib - Build shared libraries (MS) 132 debug - Debug build 133 profile - Profiling build 134 gcc - Use Gcc (unix) 135 136Values that can be set 137TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 138 139-L<ex_lib_path> -l<ex_lib> - extra library flags (unix) 140-<ex_cc_flags> - extra 'cc' flags, 141 added (MS), or replace (unix) 142EOF 143 exit(1); 144 } 145 $platform=$_; 146 } 147foreach (grep(!/^$/, split(/ /, $OPTIONS))) 148 { 149 print STDERR "unknown option - $_\n" if !&read_options; 150 } 151 152$no_static_engine = 0 if (!$shlib); 153 154$no_mdc2=1 if ($no_des); 155 156$no_ssl3=1 if ($no_md5 || $no_sha); 157$no_ssl3=1 if ($no_rsa && $no_dh); 158 159$no_ssl2=1 if ($no_md5); 160$no_ssl2=1 if ($no_rsa); 161 162$out_def="out"; 163$inc_def="outinc"; 164$tmp_def="tmp"; 165 166$perl="perl" unless defined $perl; 167$mkdir="-mkdir" unless defined $mkdir; 168 169($ssl,$crypto)=("ssl","crypto"); 170$ranlib="echo ranlib"; 171 172$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 173$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}: $platform eq 'copy' ? getcwd() : '.'; 174$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; 175 176# $bin_dir.=$o causes a core dump on my sparc :-( 177 178 179$NT=0; 180 181push(@INC,"util/pl","pl"); 182 183if ($platform eq "auto" || $platform eq 'copy') { 184 $orig_platform = $platform; 185 $platform = $mf_platform; 186 print STDERR "Imported platform $mf_platform\n"; 187} 188 189if (($platform =~ /VC-(.+)/)) 190 { 191 $FLAVOR=$1; 192 $NT = 1 if $1 eq "NT"; 193 require 'VC-32.pl'; 194 } 195elsif ($platform eq "Mingw32") 196 { 197 require 'Mingw32.pl'; 198 } 199elsif ($platform eq "Mingw32-files") 200 { 201 require 'Mingw32f.pl'; 202 } 203elsif ($platform eq "BC-NT") 204 { 205 $bc=1; 206 require 'BC-32.pl'; 207 } 208elsif ($platform eq "FreeBSD") 209 { 210 require 'unix.pl'; 211 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; 212 } 213elsif ($platform eq "linux-elf") 214 { 215 require "unix.pl"; 216 require "linux.pl"; 217 $unix=1; 218 } 219elsif ($platform eq "ultrix-mips") 220 { 221 require "unix.pl"; 222 require "ultrix.pl"; 223 $unix=1; 224 } 225elsif ($platform eq "OS2-EMX") 226 { 227 $wc=1; 228 require 'OS2-EMX.pl'; 229 } 230elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || 231 ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock")) 232 { 233 $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; 234 $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock"); 235 require 'netware.pl'; 236 } 237else 238 { 239 require "unix.pl"; 240 241 $unix=1; 242 $cflags.=' -DTERMIO'; 243 } 244 245$fipsdir =~ s/\//${o}/g; 246 247$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); 248$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); 249$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; 250 251$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 252 253$cflags= "$xcflags$cflags" if $xcflags ne ""; 254 255$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; 256$cflags.=" -DOPENSSL_NO_AES" if $no_aes; 257$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; 258$cflags.=" -DOPENSSL_NO_SEED" if $no_seed; 259$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; 260$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; 261$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; 262$cflags.=" -DOPENSSL_NO_MD2" if $no_md2; 263$cflags.=" -DOPENSSL_NO_MD4" if $no_md4; 264$cflags.=" -DOPENSSL_NO_MD5" if $no_md5; 265$cflags.=" -DOPENSSL_NO_SHA" if $no_sha; 266$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; 267$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; 268$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; 269$cflags.=" -DOPENSSL_NO_BF" if $no_bf; 270$cflags.=" -DOPENSSL_NO_CAST" if $no_cast; 271$cflags.=" -DOPENSSL_NO_DES" if $no_des; 272$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; 273$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; 274$cflags.=" -DOPENSSL_NO_DH" if $no_dh; 275$cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool; 276$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; 277$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; 278$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; 279$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; 280$cflags.=" -DOPENSSL_NO_SRP" if $no_srp; 281$cflags.=" -DOPENSSL_NO_CMS" if $no_cms; 282$cflags.=" -DOPENSSL_NO_ERR" if $no_err; 283$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; 284$cflags.=" -DOPENSSL_NO_EC" if $no_ec; 285$cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; 286$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; 287$cflags.=" -DOPENSSL_NO_GOST" if $no_gost; 288$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; 289$cflags.=" -DOPENSSL_NO_HW" if $no_hw; 290$cflags.=" -DOPENSSL_FIPS" if $fips; 291$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake; 292$cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m; 293$cflags.= " -DZLIB" if $zlib_opt; 294$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; 295 296if ($no_static_engine) 297 { 298 $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; 299 } 300else 301 { 302 $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; 303 } 304 305#$cflags.=" -DRSAref" if $rsaref ne ""; 306 307## if ($unix) 308## { $cflags="$c_flags" if ($c_flags ne ""); } 309##else 310 { $cflags="$c_flags$cflags" if ($c_flags ne ""); } 311 312if ($orig_platform eq 'copy') { 313 $cflags = $mf_cflag; 314 $cc = $mf_cc; 315} 316 317$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 318 319 320%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", 321 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); 322 323if ($msdos) 324 { 325 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; 326 $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; 327 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; 328 $banner.="\t\@echo documentation for details.\n"; 329 } 330 331# have to do this to allow $(CC) under unix 332$link="$bin_dir$link" if ($link !~ /^\$/); 333 334$INSTALLTOP =~ s|/|$o|g; 335$OPENSSLDIR =~ s|/|$o|g; 336 337############################################# 338# We parse in input file and 'store' info for later printing. 339open(IN,"<$infile") || die "unable to open $infile:$!\n"; 340$_=<IN>; 341for (;;) 342 { 343 s/\s*$//; # was chop, didn't work in mixture of perls for Windows... 344 345 ($key,$val)=/^([^=]+)=(.*)/; 346 if ($key eq "RELATIVE_DIRECTORY") 347 { 348 if ($lib ne "") 349 { 350 $uc=$lib; 351 $uc =~ s/^lib(.*)\.a/$1/; 352 $uc =~ tr/a-z/A-Z/; 353 $lib_nam{$uc}=$uc; 354 $lib_obj{$uc}.=$libobj." "; 355 } 356 last if ($val eq "FINISHED"); 357 $lib=""; 358 $libobj=""; 359 $dir=$val; 360 } 361 362 if ($key eq "KRB5_INCLUDES") 363 { $cflags .= " $val";} 364 365 if ($key eq "ZLIB_INCLUDE") 366 { $cflags .= " $val" if $val ne "";} 367 368 if ($key eq "LIBZLIB") 369 { $zlib_lib = "$val" if $val ne "";} 370 371 if ($key eq "LIBKRB5") 372 { $ex_libs .= " $val" if $val ne "";} 373 374 if ($key eq "TEST") 375 { $test.=&var_add($dir,$val, 0); } 376 377 if (($key eq "PROGS") || ($key eq "E_OBJ")) 378 { $e_exe.=&var_add($dir,$val, 0); } 379 380 if ($key eq "LIB") 381 { 382 $lib=$val; 383 $lib =~ s/^.*\/([^\/]+)$/$1/; 384 } 385 if ($key eq "LIBNAME" && $no_static_engine) 386 { 387 $lib=$val; 388 $lib =~ s/^.*\/([^\/]+)$/$1/; 389 $otherlibs .= " $lib"; 390 } 391 392 if ($key eq "EXHEADER") 393 { $exheader.=&var_add($dir,$val, 1); } 394 395 if ($key eq "HEADER") 396 { $header.=&var_add($dir,$val, 1); } 397 398 if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) 399 { $libobj=&var_add($dir,$val, 0); } 400 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) 401 { $engines.=$val } 402 403 if (!($_=<IN>)) 404 { $_="RELATIVE_DIRECTORY=FINISHED\n"; } 405 } 406close(IN); 407 408if ($orig_platform eq 'copy') 409 { 410 # Remove opensslconf.h so it doesn't get updated if we configure a 411 # different branch. 412 $exheader =~ s/[^ ]+\/opensslconf.h//; 413 $header =~ s/[^ ]+\/opensslconf.h//; 414 } 415 416if ($shlib) 417 { 418 $extra_install= <<"EOF"; 419 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\" 420 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\" 421 \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\" 422 \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" 423EOF 424 if ($no_static_engine) 425 { 426 $extra_install .= <<"EOF" 427 \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" 428 \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" 429EOF 430 } 431 } 432else 433 { 434 $extra_install= <<"EOF"; 435 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\" 436 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" 437EOF 438 $ex_libs .= " $zlib_lib" if $zlib_opt == 1; 439 if ($fips) 440 { 441 $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)"; 442 $ex_l_libs .= " \$(O_FIPSCANISTER)"; 443 } 444 } 445 446$defs= <<"EOF"; 447# N.B. You MUST use -j on FreeBSD. 448# This makefile has been automatically generated from the OpenSSL distribution. 449# This single makefile will build the complete OpenSSL distribution and 450# by default leave the 'intertesting' output files in .${o}out and the stuff 451# that needs deleting in .${o}tmp. 452# The file was generated by running 'make makefile.one', which 453# does a 'make files', which writes all the environment variables from all 454# the makefiles to the file call MINFO. This file is used by 455# util${o}mk1mf.pl to generate makefile.one. 456# The 'makefile per directory' system suites me when developing this 457# library and also so I can 'distribute' indervidual library sections. 458# The one monster makefile better suits building in non-unix 459# environments. 460 461EOF 462 463$defs .= $preamble if defined $preamble; 464 465$defs.= <<"EOF"; 466INSTALLTOP=$INSTALLTOP 467OPENSSLDIR=$OPENSSLDIR 468 469# Set your compiler options 470PLATFORM=$platform 471CC=$bin_dir${cc} 472CFLAG=$cflags 473APP_CFLAG=$app_cflag 474LIB_CFLAG=$lib_cflag 475SHLIB_CFLAG=$shl_cflag 476APP_EX_OBJ=$app_ex_obj 477SHLIB_EX_OBJ=$shlib_ex_obj 478# add extra libraries to this define, for solaris -lsocket -lnsl would 479# be added 480EX_LIBS=$ex_libs 481 482# The OpenSSL directory 483SRC_D=$src_dir 484 485LINK=$link 486LFLAGS=$lflags 487RSC=$rsc 488 489# The output directory for everything interesting 490OUT_D=$out_dir 491# The output directory for all the temporary muck 492TMP_D=$tmp_dir 493# The output directory for the header files 494INC_D=$inc_dir 495INCO_D=$inc_dir${o}openssl 496 497PERL=$perl 498CP=$cp 499RM=$rm 500RANLIB=$ranlib 501MKDIR=$mkdir 502MKLIB=$bin_dir$mklib 503MLFLAGS=$mlflags 504ASM=$bin_dir$asm 505 506# FIPS validated module and support file locations 507 508E_PREMAIN_DSO=fips_premain_dso 509 510FIPSDIR=$fipsdir 511BASEADDR=$baseaddr 512FIPSLIB_D=\$(FIPSDIR)${o}lib 513FIPS_PREMAIN_SRC=\$(FIPSLIB_D)${o}fips_premain.c 514O_FIPSCANISTER=\$(FIPSLIB_D)${o}fipscanister.lib 515FIPS_SHA1_EXE=\$(FIPSDIR)${o}bin${o}fips_standalone_sha1${exep} 516PREMAIN_DSO_EXE=\$(BIN_D)${o}fips_premain_dso$exep 517FIPSLINK=\$(PERL) \$(FIPSDIR)${o}bin${o}fipslink.pl 518 519###################################################### 520# You should not need to touch anything below this point 521###################################################### 522 523E_EXE=openssl 524SSL=$ssl 525CRYPTO=$crypto 526 527# BIN_D - Binary output directory 528# TEST_D - Binary test file output directory 529# LIB_D - library output directory 530# ENG_D - dynamic engine output directory 531# Note: if you change these point to different directories then uncomment out 532# the lines around the 'NB' comment below. 533# 534BIN_D=\$(OUT_D) 535TEST_D=\$(OUT_D) 536LIB_D=\$(OUT_D) 537ENG_D=\$(OUT_D) 538 539# INCL_D - local library directory 540# OBJ_D - temp object file directory 541OBJ_D=\$(TMP_D) 542INCL_D=\$(TMP_D) 543 544O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 545O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 546SO_SSL= $plib\$(SSL)$so_shlibp 547SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 548L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 549L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 550 551L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs 552 553###################################################### 554# Don't touch anything below this point 555###################################################### 556 557INC=-I\$(INC_D) -I\$(INCL_D) 558APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 559LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 560SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 561LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) 562 563############################################# 564EOF 565 566$rules=<<"EOF"; 567all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe $build_targets 568 569banner: 570$banner 571 572\$(TMP_D): 573 \$(MKDIR) \"\$(TMP_D)\" 574# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different 575#\$(BIN_D): 576# \$(MKDIR) \$(BIN_D) 577# 578#\$(TEST_D): 579# \$(MKDIR) \$(TEST_D) 580 581\$(LIB_D): 582 \$(MKDIR) \"\$(LIB_D)\" 583 584\$(INCO_D): \$(INC_D) 585 \$(MKDIR) \"\$(INCO_D)\" 586 587\$(INC_D): 588 \$(MKDIR) \"\$(INC_D)\" 589 590# This needs to be invoked once, when the makefile is first constructed, or 591# after cleaning. 592init: \$(TMP_D) \$(LIB_D) \$(INC_D) \$(INCO_D) \$(BIN_D) \$(TEST_D) headers 593 \$(PERL) \$(SRC_D)/util/copy-if-different.pl "\$(SRC_D)/crypto/opensslconf.h" "\$(INCO_D)/opensslconf.h" 594 595headers: \$(HEADER) \$(EXHEADER) 596 597lib: \$(LIBS_DEP) \$(E_SHLIB) 598 599exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep 600 601install: all 602 \$(MKDIR) \"\$(INSTALLTOP)\" 603 \$(MKDIR) \"\$(INSTALLTOP)${o}bin\" 604 \$(MKDIR) \"\$(INSTALLTOP)${o}include\" 605 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" 606 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" 607 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" 608 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\" 609 \$(MKDIR) \"\$(OPENSSLDIR)\" 610 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\" 611$extra_install 612 613clean: 614 \$(RM) \$(TMP_D)$o*.* 615 616vclean: 617 \$(RM) \$(TMP_D)$o*.* 618 \$(RM) \$(OUT_D)$o*.* 619 620reallyclean: 621 \$(RM) -rf \$(TMP_D) 622 \$(RM) -rf \$(BIN_D) 623 \$(RM) -rf \$(TEST_D) 624 \$(RM) -rf \$(LIB_D) 625 \$(RM) -rf \$(INC_D) 626 627EOF 628 629if ($orig_platform ne 'copy') 630 { 631 $rules .= <<"EOF"; 632test: \$(T_EXE) 633 cd \$(BIN_D) 634 ..${o}ms${o}test 635 636EOF 637 } 638 639my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; 640$platform_cpp_symbol =~ s/-/_/g; 641if (open(IN,"crypto/buildinf.h")) 642 { 643 # Remove entry for this platform in existing file buildinf.h. 644 645 my $old_buildinf_h = ""; 646 while (<IN>) 647 { 648 if (/^\#ifdef $platform_cpp_symbol$/) 649 { 650 while (<IN>) { last if (/^\#endif/); } 651 } 652 else 653 { 654 $old_buildinf_h .= $_; 655 } 656 } 657 close(IN); 658 659 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; 660 print OUT $old_buildinf_h; 661 close(OUT); 662 } 663 664open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; 665printf OUT <<EOF; 666#ifdef $platform_cpp_symbol 667 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ 668 #define CFLAGS "compiler: $cc $cflags" 669 #define PLATFORM "$platform" 670EOF 671printf OUT " #define DATE \"%s\"\n", scalar gmtime(); 672printf OUT "#endif\n"; 673close(OUT); 674 675# Strip off trailing ' ' 676foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } 677$test=&clean_up_ws($test); 678$e_exe=&clean_up_ws($e_exe); 679$exheader=&clean_up_ws($exheader); 680$header=&clean_up_ws($header); 681 682# First we strip the exheaders from the headers list 683foreach (split(/\s+/,$exheader)){ $h{$_}=1; } 684foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } 685chop($h); $header=$h; 686 687$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); 688$rules.=&do_copy_rule("\$(INCL_D)",$header,""); 689 690$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); 691$rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); 692 693$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); 694$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); 695 696$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); 697$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); 698 699# Special case rule for fips_premain_dso 700 701if ($fips) 702 { 703 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj", 704 "\$(FIPS_PREMAIN_SRC)", 705 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)", ""); 706 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1); 707 } 708 709sub fix_asm 710 { 711 my($asm, $dir) = @_; 712 713 return '' if $asm eq ''; 714 715 $asm = " $asm"; 716 $asm =~ s/\s+/ $dir\//g; 717 $asm =~ s/\.o//g; 718 $asm =~ s/^ //; 719 720 return $asm . ' '; 721 } 722 723if ($orig_platform eq 'copy') { 724 $lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5'); 725 $lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn'); 726 # cpuid is included by the crypto dir 727 #$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto'); 728 # AES asm files DON'T end up included by the aes dir itself 729 $lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes'); 730 $lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha'); 731 $lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines'); 732 $lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4'); 733 $lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes'); 734 $lib_obj{CRYPTO} .= fix_asm($mf_ec_asm, 'crypto/ec'); 735} 736 737foreach (values %lib_nam) 738 { 739 $lib_obj=$lib_obj{$_}; 740 local($slib)=$shlib; 741 742 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 743 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; 744 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 745 } 746 747# hack to add version info on MSVC 748if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A") 749 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) { 750 $rules.= <<"EOF"; 751\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc 752 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc 753 754\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc 755 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc 756 757EOF 758} 759 760$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); 761foreach (split(/\s+/,$test)) 762 { 763 $t=&bname($_); 764 $tt="\$(OBJ_D)${o}$t${obj}"; 765 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 766 } 767 768$defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp); 769 770foreach (split(/\s+/,$engines)) 771 { 772 $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); 773 $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); 774 } 775 776 777 778$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 779 780if ($fips) 781 { 782 if ($shlib) 783 { 784 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", 785 "\$(O_CRYPTO)", "$crypto", 786 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)"); 787 } 788 else 789 { 790 $rules.= &do_lib_rule("\$(CRYPTOOBJ)", 791 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", ""); 792 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", 793 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", ""); 794 } 795 } 796 else 797 { 798 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib, 799 "\$(SO_CRYPTO)"); 800 } 801 802foreach (split(" ",$otherlibs)) 803 { 804 my $uc = $_; 805 $uc =~ tr /a-z/A-Z/; 806 $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, ""); 807 808 } 809 810$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); 811 812$rules .= get_tests('test/Makefile') if $orig_platform eq 'copy'; 813 814print $defs; 815 816if ($platform eq "linux-elf") { 817 print <<"EOF"; 818# Generate perlasm output files 819%.cpp: 820 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) 821EOF 822} 823print "###################################################################\n"; 824print $rules; 825 826############################################### 827# strip off any trailing .[och] and append the relative directory 828# also remembering to do nothing if we are in one of the dropped 829# directories 830sub var_add 831 { 832 local($dir,$val,$keepext)=@_; 833 local(@a,$_,$ret); 834 835 return("") if $no_engine && $dir =~ /\/engine/; 836 return("") if $no_hw && $dir =~ /\/hw/; 837 return("") if $no_idea && $dir =~ /\/idea/; 838 return("") if $no_aes && $dir =~ /\/aes/; 839 return("") if $no_camellia && $dir =~ /\/camellia/; 840 return("") if $no_seed && $dir =~ /\/seed/; 841 return("") if $no_rc2 && $dir =~ /\/rc2/; 842 return("") if $no_rc4 && $dir =~ /\/rc4/; 843 return("") if $no_rc5 && $dir =~ /\/rc5/; 844 return("") if $no_rsa && $dir =~ /\/rsa/; 845 return("") if $no_rsa && $dir =~ /^rsaref/; 846 return("") if $no_dsa && $dir =~ /\/dsa/; 847 return("") if $no_dh && $dir =~ /\/dh/; 848 return("") if $no_ec && $dir =~ /\/ec/; 849 return("") if $no_gost && $dir =~ /\/ccgost/; 850 return("") if $no_cms && $dir =~ /\/cms/; 851 return("") if $no_jpake && $dir =~ /\/jpake/; 852 if ($no_des && $dir =~ /\/des/) 853 { 854 if ($val =~ /read_pwd/) 855 { return("$dir/read_pwd "); } 856 else 857 { return(""); } 858 } 859 return("") if $no_mdc2 && $dir =~ /\/mdc2/; 860 return("") if $no_sock && $dir =~ /\/proxy/; 861 return("") if $no_bf && $dir =~ /\/bf/; 862 return("") if $no_cast && $dir =~ /\/cast/; 863 return("") if $no_whirlpool && $dir =~ /\/whrlpool/; 864 865 $val =~ s/^\s*(.*)\s*$/$1/; 866 @a=split(/\s+/,$val); 867 grep(s/\.[och]$//,@a) unless $keepext; 868 869 @a=grep(!/^e_.*_3d$/,@a) if $no_des; 870 @a=grep(!/^e_.*_d$/,@a) if $no_des; 871 @a=grep(!/^e_.*_ae$/,@a) if $no_idea; 872 @a=grep(!/^e_.*_i$/,@a) if $no_aes; 873 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 874 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 875 @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 876 @a=grep(!/^e_.*_c$/,@a) if $no_cast; 877 @a=grep(!/^e_rc4$/,@a) if $no_rc4; 878 @a=grep(!/^e_camellia$/,@a) if $no_camellia; 879 @a=grep(!/^e_seed$/,@a) if $no_seed; 880 881 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; 882 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; 883 884 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 885 886 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 887 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; 888 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 889 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; 890 891 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 892 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 893 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; 894 895 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; 896 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; 897 898 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; 899 900 @a=grep(!/_dhp$/,@a) if $no_dh; 901 902 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; 903 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 904 @a=grep(!/_mdc2$/,@a) if $no_mdc2; 905 906 @a=grep(!/(srp)/,@a) if $no_srp; 907 908 @a=grep(!/^engine$/,@a) if $no_engine; 909 @a=grep(!/^hw$/,@a) if $no_hw; 910 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; 911 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 912 @a=grep(!/^gendsa$/,@a) if $no_sha1; 913 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; 914 915 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 916 917 grep($_="$dir/$_",@a); 918 @a=grep(!/(^|\/)s_/,@a) if $no_sock; 919 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; 920 $ret=join(' ',@a)." "; 921 return($ret); 922 } 923 924# change things so that each 'token' is only separated by one space 925sub clean_up_ws 926 { 927 local($w)=@_; 928 929 $w =~ s/^\s*(.*)\s*$/$1/; 930 $w =~ s/\s+/ /g; 931 return($w); 932 } 933 934sub do_defs 935 { 936 local($var,$files,$location,$postfix)=@_; 937 local($_,$ret,$pf); 938 local(*OUT,$tmp,$t); 939 940 $files =~ s/\//$o/g if $o ne '/'; 941 $ret="$var="; 942 $n=1; 943 $Vars{$var}.=""; 944 foreach (split(/ /,$files)) 945 { 946 $orig=$_; 947 $_=&bname($_) unless /^\$/; 948 if ($n++ == 2) 949 { 950 $n=0; 951 $ret.="\\\n\t"; 952 } 953 if (($_ =~ /bss_file/) && ($postfix eq ".h")) 954 { $pf=".c"; } 955 else { $pf=$postfix; } 956 if ($_ =~ /BN_ASM/) { $t="$_ "; } 957 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } 958 elsif ($_ =~ /AES_ASM/){ $t="$_ "; } 959 elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 960 elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 961 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 962 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } 963 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } 964 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } 965 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } 966 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } 967 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; } 968 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } 969 else { $t="$location${o}$_$pf "; } 970 971 $Vars{$var}.="$t "; 972 $ret.=$t; 973 } 974 # hack to add version info on MSVC 975 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT"))) 976 { 977 if ($var eq "CRYPTOOBJ") 978 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } 979 elsif ($var eq "SSLOBJ") 980 { $ret.="\$(OBJ_D)\\\$(SSL).res "; } 981 } 982 chomp($ret); 983 $ret.="\n\n"; 984 return($ret); 985 } 986 987# return the name with the leading path removed 988sub bname 989 { 990 local($ret)=@_; 991 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; 992 return($ret); 993 } 994 995# return the leading path 996sub dname 997 { 998 my $ret=shift; 999 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/; 1000 return($ret); 1001 } 1002 1003############################################################## 1004# do a rule for each file that says 'compile' to new direcory 1005# compile the files in '$files' into $to 1006sub do_compile_rule 1007 { 1008 local($to,$files,$ex)=@_; 1009 local($ret,$_,$n,$d,$s); 1010 1011 $files =~ s/\//$o/g if $o ne '/'; 1012 foreach (split(/\s+/,$files)) 1013 { 1014 $n=&bname($_); 1015 $d=&dname($_); 1016 if (-f "${_}.c") 1017 { 1018 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) 1019 } 1020 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or 1021 ($s=~s/sha256/sha512/ and -f $s) or 1022 -f ($s="${d}${o}${n}.pl")) 1023 { 1024 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n); 1025 } 1026 elsif (-f ($s="${d}${o}asm${o}${n}.S") or 1027 -f ($s="${d}${o}${n}.S")) 1028 { 1029 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n); 1030 } 1031 elsif (defined &special_compile_target and 1032 ($s=special_compile_target($_))) 1033 { 1034 $ret.=$s; 1035 } 1036 else { die "no rule for $_"; } 1037 } 1038 return($ret); 1039 } 1040 1041############################################################## 1042# do a rule for each file that says 'compile' to new direcory 1043sub perlasm_compile_target 1044 { 1045 my($target,$source,$bname)=@_; 1046 1047 return platform_perlasm_compile_target($target, $source, $bname) 1048 if defined &platform_perlasm_compile_target; 1049 1050 my($ret); 1051 1052 $bname =~ s/(.*)\.[^\.]$/$1/; 1053 $ret ="\$(TMP_D)$o$bname.asm: $source\n"; 1054 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n"; 1055 $ret.="$target: \$(TMP_D)$o$bname.asm\n"; 1056 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; 1057 return($ret); 1058 } 1059 1060sub Sasm_compile_target 1061 { 1062 my($target,$source,$bname)=@_; 1063 my($ret); 1064 1065 $bname =~ s/(.*)\.[^\.]$/$1/; 1066 $ret ="\$(TMP_D)$o$bname.asm: $source\n"; 1067 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n"; 1068 $ret.="$target: \$(TMP_D)$o$bname.asm\n"; 1069 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; 1070 return($ret); 1071 } 1072 1073sub cc_compile_target 1074 { 1075 local($target,$source,$ex_flags, $srcd)=@_; 1076 local($ret); 1077 1078 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); 1079 $target =~ s/\//$o/g if $o ne "/"; 1080 $source =~ s/\//$o/g if $o ne "/"; 1081 $srcd = "\$(SRC_D)$o" unless defined $srcd && $platform ne 'copy'; 1082 $ret ="$target: $srcd$source\n\t"; 1083 $ret.="\$(CC)"; 1084 $ret.= " -MMD" if $orig_platform eq "copy"; 1085 $ret.= " ${ofile}$target $ex_flags -c $srcd$source\n\n"; 1086 $target =~ s/\.o$/.d/; 1087 $ret.=".sinclude \"$target\"\n\n" if $orig_platform eq "copy"; 1088 return($ret); 1089 } 1090 1091############################################################## 1092sub do_asm_rule 1093 { 1094 local($target,$src)=@_; 1095 local($ret,@s,@t,$i); 1096 1097 $target =~ s/\//$o/g if $o ne "/"; 1098 $src =~ s/\//$o/g if $o ne "/"; 1099 1100 @t=split(/\s+/,$target); 1101 @s=split(/\s+/,$src); 1102 1103 1104 for ($i=0; $i<=$#s; $i++) 1105 { 1106 my $objfile = $t[$i]; 1107 my $srcfile = $s[$i]; 1108 1109 if ($perl_asm == 1) 1110 { 1111 my $plasm = $objfile; 1112 $plasm =~ s/${obj}/.pl/; 1113 $ret.="$srcfile: $plasm\n"; 1114 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n"; 1115 } 1116 1117 $ret.="$objfile: $srcfile\n"; 1118 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n"; 1119 } 1120 return($ret); 1121 } 1122 1123sub do_shlib_rule 1124 { 1125 local($n,$def)=@_; 1126 local($ret,$nn); 1127 local($t); 1128 1129 ($nn=$n) =~ tr/a-z/A-Z/; 1130 $ret.="$n.dll: \$(${nn}OBJ)\n"; 1131 if ($vc && $w32) 1132 { 1133 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; 1134 } 1135 $ret.="\n"; 1136 return($ret); 1137 } 1138 1139# do a rule for each file that says 'copy' to new direcory on change 1140sub do_copy_rule 1141 { 1142 local($to,$files,$p)=@_; 1143 local($ret,$_,$n,$pp); 1144 1145 $files =~ s/\//$o/g if $o ne '/'; 1146 foreach (split(/\s+/,$files)) 1147 { 1148 $n=&bname($_); 1149 if ($n =~ /bss_file/) 1150 { $pp=".c"; } 1151 else { $pp=$p; } 1152 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(PERL) \$(SRC_D)${o}util${o}copy-if-different.pl \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; 1153 } 1154 return($ret); 1155 } 1156 1157# Options picked up from the OPTIONS line in the top level Makefile 1158# generated by Configure. 1159 1160sub read_options 1161 { 1162 # Many options are handled in a similar way. In particular 1163 # no-xxx sets zero or more scalars to 1. 1164 # Process these using the %valid_options hash containing the option 1165 # name and reference to the scalars to set. In some cases the option 1166 # needs no special handling and can be ignored: this is done by 1167 # setting the value to 0. 1168 1169 my %valid_options = ( 1170 "no-rc2" => \$no_rc2, 1171 "no-rc4" => \$no_rc4, 1172 "no-rc5" => \$no_rc5, 1173 "no-idea" => \$no_idea, 1174 "no-aes" => \$no_aes, 1175 "no-camellia" => \$no_camellia, 1176 "no-seed" => \$no_seed, 1177 "no-des" => \$no_des, 1178 "no-bf" => \$no_bf, 1179 "no-cast" => \$no_cast, 1180 "no-md2" => \$no_md2, 1181 "no-md4" => \$no_md4, 1182 "no-md5" => \$no_md5, 1183 "no-sha" => \$no_sha, 1184 "no-sha1" => \$no_sha1, 1185 "no-ripemd" => \$no_ripemd, 1186 "no-mdc2" => \$no_mdc2, 1187 "no-whirlpool" => \$no_whirlpool, 1188 "no-patents" => 1189 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], 1190 "no-rsa" => \$no_rsa, 1191 "no-dsa" => \$no_dsa, 1192 "no-dh" => \$no_dh, 1193 "no-hmac" => \$no_hmac, 1194 "no-asm" => \$no_asm, 1195 "nasm" => \$nasm, 1196 "nw-nasm" => \$nw_nasm, 1197 "nw-mwasm" => \$nw_mwasm, 1198 "gaswin" => \$gaswin, 1199 "no-ssl2" => \$no_ssl2, 1200 "no-ssl3" => \$no_ssl3, 1201 "no-ssl3-method" => 0, 1202 "no-tlsext" => \$no_tlsext, 1203 "no-srp" => \$no_srp, 1204 "no-cms" => \$no_cms, 1205 "no-jpake" => \$no_jpake, 1206 "no-ec2m" => \$no_ec2m, 1207 "no-ec_nistp_64_gcc_128" => 0, 1208 "no-err" => \$no_err, 1209 "no-sock" => \$no_sock, 1210 "no-krb5" => \$no_krb5, 1211 "no-ec" => \$no_ec, 1212 "no-ecdsa" => \$no_ecdsa, 1213 "no-ecdh" => \$no_ecdh, 1214 "no-gost" => \$no_gost, 1215 "no-engine" => \$no_engine, 1216 "no-hw" => \$no_hw, 1217 "no-rsax" => 0, 1218 "just-ssl" => 1219 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, 1220 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, 1221 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, 1222 \$no_aes, \$no_camellia, \$no_seed, \$no_srp], 1223 "rsaref" => 0, 1224 "gcc" => \$gcc, 1225 "debug" => \$debug, 1226 "profile" => \$profile, 1227 "shlib" => \$shlib, 1228 "dll" => \$shlib, 1229 "shared" => 0, 1230 "no-sctp" => 0, 1231 "no-srtp" => 0, 1232 "no-gmp" => 0, 1233 "no-rfc3779" => 0, 1234 "no-montasm" => 0, 1235 "no-shared" => 0, 1236 "no-store" => 0, 1237 "no-zlib" => 0, 1238 "no-zlib-dynamic" => 0, 1239 "no-ssl-trace" => 0, 1240 "no-unit-test" => 0, 1241 "no-libunbound" => 0, 1242 "no-multiblock" => 0, 1243 "fips" => \$fips 1244 ); 1245 1246 if (exists $valid_options{$_}) 1247 { 1248 my $r = $valid_options{$_}; 1249 if ( ref $r eq "SCALAR") 1250 { $$r = 1;} 1251 elsif ( ref $r eq "ARRAY") 1252 { 1253 my $r2; 1254 foreach $r2 (@$r) 1255 { 1256 $$r2 = 1; 1257 } 1258 } 1259 } 1260 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } 1261 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } 1262 elsif (/^enable-zlib-dynamic$/) 1263 { 1264 $zlib_opt = 2; 1265 } 1266 elsif (/^no-static-engine/) 1267 { 1268 $no_static_engine = 1; 1269 } 1270 elsif (/^enable-static-engine/) 1271 { 1272 $no_static_engine = 0; 1273 } 1274 # There are also enable-xxx options which correspond to 1275 # the no-xxx. Since the scalars are enabled by default 1276 # these can be ignored. 1277 elsif (/^enable-/) 1278 { 1279 my $t = $_; 1280 $t =~ s/^enable/no/; 1281 if (exists $valid_options{$t}) 1282 {return 1;} 1283 return 0; 1284 } 1285 # experimental-xxx is mostly like enable-xxx, but opensslconf.v 1286 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx. 1287 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.) 1288 elsif (/^experimental-/) 1289 { 1290 my $algo, $ALGO; 1291 ($algo = $_) =~ s/^experimental-//; 1292 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/; 1293 1294 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags"; 1295 1296 } 1297 elsif (/^--with-krb5-flavor=(.*)$/) 1298 { 1299 my $krb5_flavor = $1; 1300 if ($krb5_flavor =~ /^force-[Hh]eimdal$/) 1301 { 1302 $xcflags="-DKRB5_HEIMDAL $xcflags"; 1303 } 1304 elsif ($krb5_flavor =~ /^MIT/i) 1305 { 1306 $xcflags="-DKRB5_MIT $xcflags"; 1307 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) 1308 { 1309 $xcflags="-DKRB5_MIT_OLD11 $xcflags" 1310 } 1311 } 1312 } 1313 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } 1314 elsif (/^-[lL].*$/) { $l_flags.="$_ "; } 1315 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) 1316 { $c_flags.="$_ "; } 1317 else { return(0); } 1318 return(1); 1319 } 1320