mk1mf.pl 30 KB

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