mk1mf.pl 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  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-NT")) {
  540. $rules.= <<"EOF";
  541. \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
  542. \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
  543. \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
  544. \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
  545. EOF
  546. }
  547. $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
  548. foreach (split(/\s+/,$test))
  549. {
  550. $t=&bname($_);
  551. $tt="\$(OBJ_D)${o}$t${obj}";
  552. $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  553. }
  554. $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
  555. foreach (split(/\s+/,$engines))
  556. {
  557. $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
  558. $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
  559. }
  560. $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
  561. $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
  562. $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  563. print $defs;
  564. if ($platform eq "linux-elf") {
  565. print <<"EOF";
  566. # Generate perlasm output files
  567. %.cpp:
  568. (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
  569. EOF
  570. }
  571. print "###################################################################\n";
  572. print $rules;
  573. ###############################################
  574. # strip off any trailing .[och] and append the relative directory
  575. # also remembering to do nothing if we are in one of the dropped
  576. # directories
  577. sub var_add
  578. {
  579. local($dir,$val,$keepext)=@_;
  580. local(@a,$_,$ret);
  581. return("") if $no_engine && $dir =~ /\/engine/;
  582. return("") if $no_hw && $dir =~ /\/hw/;
  583. return("") if $no_idea && $dir =~ /\/idea/;
  584. return("") if $no_aes && $dir =~ /\/aes/;
  585. return("") if $no_camellia && $dir =~ /\/camellia/;
  586. return("") if $no_seed && $dir =~ /\/seed/;
  587. return("") if $no_rc2 && $dir =~ /\/rc2/;
  588. return("") if $no_rc4 && $dir =~ /\/rc4/;
  589. return("") if $no_rc5 && $dir =~ /\/rc5/;
  590. return("") if $no_rsa && $dir =~ /\/rsa/;
  591. return("") if $no_rsa && $dir =~ /^rsaref/;
  592. return("") if $no_dsa && $dir =~ /\/dsa/;
  593. return("") if $no_dh && $dir =~ /\/dh/;
  594. return("") if $no_ec && $dir =~ /\/ec/;
  595. return("") if $no_cms && $dir =~ /\/cms/;
  596. return("") if $no_jpake && $dir =~ /\/jpake/;
  597. if ($no_des && $dir =~ /\/des/)
  598. {
  599. if ($val =~ /read_pwd/)
  600. { return("$dir/read_pwd "); }
  601. else
  602. { return(""); }
  603. }
  604. return("") if $no_mdc2 && $dir =~ /\/mdc2/;
  605. return("") if $no_sock && $dir =~ /\/proxy/;
  606. return("") if $no_bf && $dir =~ /\/bf/;
  607. return("") if $no_cast && $dir =~ /\/cast/;
  608. return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
  609. $val =~ s/^\s*(.*)\s*$/$1/;
  610. @a=split(/\s+/,$val);
  611. grep(s/\.[och]$//,@a) unless $keepext;
  612. @a=grep(!/^e_.*_3d$/,@a) if $no_des;
  613. @a=grep(!/^e_.*_d$/,@a) if $no_des;
  614. @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
  615. @a=grep(!/^e_.*_i$/,@a) if $no_aes;
  616. @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
  617. @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
  618. @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
  619. @a=grep(!/^e_.*_c$/,@a) if $no_cast;
  620. @a=grep(!/^e_rc4$/,@a) if $no_rc4;
  621. @a=grep(!/^e_camellia$/,@a) if $no_camellia;
  622. @a=grep(!/^e_seed$/,@a) if $no_seed;
  623. #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
  624. #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
  625. @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
  626. @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
  627. @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
  628. @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
  629. @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
  630. @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
  631. @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
  632. @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
  633. @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
  634. @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
  635. @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
  636. @a=grep(!/_dhp$/,@a) if $no_dh;
  637. @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
  638. @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
  639. @a=grep(!/_mdc2$/,@a) if $no_mdc2;
  640. @a=grep(!/^engine$/,@a) if $no_engine;
  641. @a=grep(!/^hw$/,@a) if $no_hw;
  642. @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
  643. @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
  644. @a=grep(!/^gendsa$/,@a) if $no_sha1;
  645. @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
  646. @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
  647. grep($_="$dir/$_",@a);
  648. @a=grep(!/(^|\/)s_/,@a) if $no_sock;
  649. @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
  650. $ret=join(' ',@a)." ";
  651. return($ret);
  652. }
  653. # change things so that each 'token' is only separated by one space
  654. sub clean_up_ws
  655. {
  656. local($w)=@_;
  657. $w =~ s/^\s*(.*)\s*$/$1/;
  658. $w =~ s/\s+/ /g;
  659. return($w);
  660. }
  661. sub do_defs
  662. {
  663. local($var,$files,$location,$postfix)=@_;
  664. local($_,$ret,$pf);
  665. local(*OUT,$tmp,$t);
  666. $files =~ s/\//$o/g if $o ne '/';
  667. $ret="$var=";
  668. $n=1;
  669. $Vars{$var}.="";
  670. foreach (split(/ /,$files))
  671. {
  672. $orig=$_;
  673. $_=&bname($_) unless /^\$/;
  674. if ($n++ == 2)
  675. {
  676. $n=0;
  677. $ret.="\\\n\t";
  678. }
  679. if (($_ =~ /bss_file/) && ($postfix eq ".h"))
  680. { $pf=".c"; }
  681. else { $pf=$postfix; }
  682. if ($_ =~ /BN_ASM/) { $t="$_ "; }
  683. elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
  684. elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
  685. elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
  686. elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
  687. elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
  688. elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
  689. elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
  690. elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
  691. elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
  692. elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
  693. elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
  694. elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
  695. else { $t="$location${o}$_$pf "; }
  696. $Vars{$var}.="$t ";
  697. $ret.=$t;
  698. }
  699. # hack to add version info on MSVC
  700. if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT")))
  701. {
  702. if ($var eq "CRYPTOOBJ")
  703. { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
  704. elsif ($var eq "SSLOBJ")
  705. { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
  706. }
  707. chomp($ret);
  708. $ret.="\n\n";
  709. return($ret);
  710. }
  711. # return the name with the leading path removed
  712. sub bname
  713. {
  714. local($ret)=@_;
  715. $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
  716. return($ret);
  717. }
  718. # return the leading path
  719. sub dname
  720. {
  721. my $ret=shift;
  722. $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
  723. return($ret);
  724. }
  725. ##############################################################
  726. # do a rule for each file that says 'compile' to new direcory
  727. # compile the files in '$files' into $to
  728. sub do_compile_rule
  729. {
  730. local($to,$files,$ex)=@_;
  731. local($ret,$_,$n,$d,$s);
  732. $files =~ s/\//$o/g if $o ne '/';
  733. foreach (split(/\s+/,$files))
  734. {
  735. $n=&bname($_);
  736. $d=&dname($_);
  737. if (-f "${_}.c")
  738. {
  739. $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
  740. }
  741. elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
  742. ($s=~s/sha256/sha512/ and -f $s) or
  743. -f ($s="${d}${o}${n}.pl"))
  744. {
  745. $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
  746. }
  747. elsif (-f ($s="${d}${o}asm${o}${n}.S") or
  748. -f ($s="${d}${o}${n}.S"))
  749. {
  750. $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
  751. }
  752. else { die "no rule for $_"; }
  753. }
  754. return($ret);
  755. }
  756. ##############################################################
  757. # do a rule for each file that says 'compile' to new direcory
  758. sub perlasm_compile_target
  759. {
  760. my($target,$source,$bname)=@_;
  761. my($ret);
  762. $bname =~ s/(.*)\.[^\.]$/$1/;
  763. $ret ="\$(TMP_D)$o$bname.asm: $source\n";
  764. $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
  765. $ret.="$target: \$(TMP_D)$o$bname.asm\n";
  766. $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
  767. return($ret);
  768. }
  769. sub Sasm_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\$(CC) -E \$(CFLAG) $source >\$\@\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 cc_compile_target
  781. {
  782. local($target,$source,$ex_flags)=@_;
  783. local($ret);
  784. $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
  785. $target =~ s/\//$o/g if $o ne "/";
  786. $source =~ s/\//$o/g if $o ne "/";
  787. $ret ="$target: \$(SRC_D)$o$source\n\t";
  788. $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
  789. return($ret);
  790. }
  791. ##############################################################
  792. sub do_asm_rule
  793. {
  794. local($target,$src)=@_;
  795. local($ret,@s,@t,$i);
  796. $target =~ s/\//$o/g if $o ne "/";
  797. $src =~ s/\//$o/g if $o ne "/";
  798. @t=split(/\s+/,$target);
  799. @s=split(/\s+/,$src);
  800. for ($i=0; $i<=$#s; $i++)
  801. {
  802. my $objfile = $t[$i];
  803. my $srcfile = $s[$i];
  804. if ($perl_asm == 1)
  805. {
  806. my $plasm = $objfile;
  807. $plasm =~ s/${obj}/.pl/;
  808. $ret.="$srcfile: $plasm\n";
  809. $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
  810. }
  811. $ret.="$objfile: $srcfile\n";
  812. $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
  813. }
  814. return($ret);
  815. }
  816. sub do_shlib_rule
  817. {
  818. local($n,$def)=@_;
  819. local($ret,$nn);
  820. local($t);
  821. ($nn=$n) =~ tr/a-z/A-Z/;
  822. $ret.="$n.dll: \$(${nn}OBJ)\n";
  823. if ($vc && $w32)
  824. {
  825. $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
  826. }
  827. $ret.="\n";
  828. return($ret);
  829. }
  830. # do a rule for each file that says 'copy' to new direcory on change
  831. sub do_copy_rule
  832. {
  833. local($to,$files,$p)=@_;
  834. local($ret,$_,$n,$pp);
  835. $files =~ s/\//$o/g if $o ne '/';
  836. foreach (split(/\s+/,$files))
  837. {
  838. $n=&bname($_);
  839. if ($n =~ /bss_file/)
  840. { $pp=".c"; }
  841. else { $pp=$p; }
  842. $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
  843. }
  844. return($ret);
  845. }
  846. sub read_options
  847. {
  848. # Many options are handled in a similar way. In particular
  849. # no-xxx sets zero or more scalars to 1.
  850. # Process these using a hash containing the option name and
  851. # reference to the scalars to set.
  852. my %valid_options = (
  853. "no-rc2" => \$no_rc2,
  854. "no-rc4" => \$no_rc4,
  855. "no-rc5" => \$no_rc5,
  856. "no-idea" => \$no_idea,
  857. "no-aes" => \$no_aes,
  858. "no-camellia" => \$no_camellia,
  859. "no-seed" => \$no_seed,
  860. "no-des" => \$no_des,
  861. "no-bf" => \$no_bf,
  862. "no-cast" => \$no_cast,
  863. "no-md2" => \$no_md2,
  864. "no-md4" => \$no_md4,
  865. "no-md5" => \$no_md5,
  866. "no-sha" => \$no_sha,
  867. "no-sha1" => \$no_sha1,
  868. "no-ripemd" => \$no_ripemd,
  869. "no-mdc2" => \$no_mdc2,
  870. "no-whirlpool" => \$no_whirlpool,
  871. "no-patents" =>
  872. [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
  873. "no-rsa" => \$no_rsa,
  874. "no-dsa" => \$no_dsa,
  875. "no-dh" => \$no_dh,
  876. "no-hmac" => \$no_hmac,
  877. "no-asm" => \$no_asm,
  878. "nasm" => \$nasm,
  879. "nw-nasm" => \$nw_nasm,
  880. "nw-mwasm" => \$nw_mwasm,
  881. "gaswin" => \$gaswin,
  882. "no-ssl2" => \$no_ssl2,
  883. "no-ssl3" => \$no_ssl3,
  884. "no-tlsext" => \$no_tlsext,
  885. "no-cms" => \$no_cms,
  886. "no-jpake" => \$no_jpake,
  887. "no-err" => \$no_err,
  888. "no-sock" => \$no_sock,
  889. "no-krb5" => \$no_krb5,
  890. "no-ec" => \$no_ec,
  891. "no-ecdsa" => \$no_ecdsa,
  892. "no-ecdh" => \$no_ecdh,
  893. "no-engine" => \$no_engine,
  894. "no-hw" => \$no_hw,
  895. "just-ssl" =>
  896. [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
  897. \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
  898. \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
  899. \$no_aes, \$no_camellia, \$no_seed],
  900. "rsaref" => 0,
  901. "gcc" => \$gcc,
  902. "debug" => \$debug,
  903. "profile" => \$profile,
  904. "shlib" => \$shlib,
  905. "dll" => \$shlib,
  906. "shared" => 0,
  907. "no-gmp" => 0,
  908. "no-rfc3779" => 0,
  909. "no-montasm" => 0,
  910. "no-shared" => 0,
  911. "no-store" => 0,
  912. "no-zlib" => 0,
  913. "no-zlib-dynamic" => 0,
  914. );
  915. if (exists $valid_options{$_})
  916. {
  917. my $r = $valid_options{$_};
  918. if ( ref $r eq "SCALAR")
  919. { $$r = 1;}
  920. elsif ( ref $r eq "ARRAY")
  921. {
  922. my $r2;
  923. foreach $r2 (@$r)
  924. {
  925. $$r2 = 1;
  926. }
  927. }
  928. }
  929. elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
  930. elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
  931. elsif (/^enable-zlib-dynamic$/)
  932. {
  933. $zlib_opt = 2;
  934. }
  935. elsif (/^no-static-engine/)
  936. {
  937. $no_static_engine = 1;
  938. }
  939. elsif (/^enable-static-engine/)
  940. {
  941. $no_static_engine = 0;
  942. }
  943. # There are also enable-xxx options which correspond to
  944. # the no-xxx. Since the scalars are enabled by default
  945. # these can be ignored.
  946. elsif (/^enable-/)
  947. {
  948. my $t = $_;
  949. $t =~ s/^enable/no/;
  950. if (exists $valid_options{$t})
  951. {return 1;}
  952. return 0;
  953. }
  954. # experimental-xxx is mostly like enable-xxx, but opensslconf.v
  955. # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
  956. # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
  957. elsif (/^experimental-/)
  958. {
  959. my $algo, $ALGO;
  960. ($algo = $_) =~ s/^experimental-//;
  961. ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
  962. $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
  963. }
  964. elsif (/^--with-krb5-flavor=(.*)$/)
  965. {
  966. my $krb5_flavor = $1;
  967. if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
  968. {
  969. $xcflags="-DKRB5_HEIMDAL $xcflags";
  970. }
  971. elsif ($krb5_flavor =~ /^MIT/i)
  972. {
  973. $xcflags="-DKRB5_MIT $xcflags";
  974. if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
  975. {
  976. $xcflags="-DKRB5_MIT_OLD11 $xcflags"
  977. }
  978. }
  979. }
  980. elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
  981. elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
  982. elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
  983. { $c_flags.="$_ "; }
  984. else { return(0); }
  985. return(1);
  986. }