mk1mf.pl 29 KB

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