PageRenderTime 75ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/crypto/openssl/util/mk1mf.pl

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